This is what I’ve been able to come up with. Much cleaner than what I had but I’m getting an error in VS code that I don’t know how to handle. Here’s the script with the error noted as a comment:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
<title>Foxclone backup, restore, and cloning utility</title>
<meta name="description" content= "FoxClone is a Linux based image backup, restore and clone tool using a simple point and click interface." />
<link rel="stylesheet" type="text/css" media="screen" href="css/update.css">
<!-- Favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
<link rel="mask-icon" href="images/favicon/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<div class="container">
<div class="row" style="text-align:center;" >
<h1>Foxclone Filelist Updating</h1>
</div>
<div class="header"> </div>
<?php
$chk=0;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
function updater () {
$php_scripts = '../php/';
require $php_scripts . 'PDO_Connection_Select.php';
if (!$pdo = PDOConnect("foxclone_data"))
{
$chk=0;
exit;
}
$meg = 1048576 ; // needed to convert filesize bytes to Mb
$stmt = $pdo->prepare("UPDATE `files` SET `filename` = ?, `md5` = ?, `filesize` = ?,`logtime` = now() WHERE `id` = ?") ;
$path = 'download/';
foreach(glob($path.'*.*') as $file) {
$file = new SplFileInfo($path.$file);
$extension = $file->getExtension();
------> if (substr($file, 10,3) = "std") //**Errors with Can't use function return value in write context**
$getdata = (array($file, md5_file($file), filesize($file)/$meg, 1)) ;
$count= $stmt->execute ($getdata) ;
if ($count==0)
exit("Failed to update std iso");
elseif (substr($file, 9,1) = "V")
$getdata = (array($file, md5_file($file), filesize($file)/$meg, 2)) ;
$count= $stmt->execute ($getdata) ;
if ($count==0)
exit("Failed to update pdf");
elseif ($extension = "deb")
$getdata = (array($file, md5_file($file), filesize($file)/$meg,3)) ;
$count= $stmt->execute ($getdata) ;
if ($count==0)
exit("Failed to update deb");
elseif ($extension = "gz")
$getdata = (array($file, md5_file($file), filesize($file)/$meg,4)) ;
$count= $stmt->execute ($getdata) ;
if ($count==0)
exit("Failed to update gz");
elseif (substr($file, 1,4) = "news")
$getdata = (array($file, md5_file($file), filesize($file)/$meg, 5)) ;
$count= $stmt->execute ($getdata) ;
if ($count==0)
exit("Failed to update news");
elseif (substr($file(10,3) = "edg"))
$getdata = (array($file, md5_file($file), filesize($file)/$meg,6)) ;
$count= $stmt->execute ($getdata) ;
if ($count==0)
exit("Failed to update edge iso");
}
}
?>
<div class="row" style="text-align:center;" </div>
<h1>Database Update Successful</h1>