diff --git a/system/classes/update.php b/system/classes/update.php index e27533bc..98078106 100644 --- a/system/classes/update.php +++ b/system/classes/update.php @@ -9,7 +9,7 @@ * risk of any errors or issues during the update. * * @author Daniel Retzl - * @copyright 2009-2016 Daniel Retzl + * @copyright 2009-2023 Daniel Retzl * @license https://opensource.org/licenses/MIT * @version 1.0.0 * @brief The update class - handles yawk's system update functions. @@ -37,10 +37,11 @@ public function readFilebase($db, $lang) { $this->base_dir = dirname(__FILE__); $this->base_dir = substr($this->base_dir, 0, -15); // remove last 5 characters + // echo "

Base directory: $this->base_dir

"; - echo "

Base directory: $this->base_dir

"; - - $updateFolder = $this->base_dir.'/system/update/'; + // set path and filename of the ini file + $updatePath = '/system/update/'; + $updateFolder = $this->base_dir.$updatePath; $iniFileName = 'filebase.current.ini'; $input_folder = $this->base_dir; $output_file = $updateFolder.$iniFileName; @@ -57,14 +58,14 @@ public function readFilebase($db, $lang) // handle the error (e.g. show an error message or log the error) die("Failed to open file"); } else { - echo "

File opened successfully

"; + // echo "

opened $updateFolder.$iniFileName

"; } // Get the full path of the input folder $input_folder = realpath($input_folder); // Loop through all files in the input folder and its subfolders - echo "

Finding files in $input_folder

"; + echo "

Building filebase of: $input_folder

"; $root_files = array(); $subfolder_files = array(); foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($input_folder)) as $file_path) @@ -129,32 +130,46 @@ public function readFilebase($db, $lang) } // Close the output file - echo '

Scanned '.$totalFiles.' files. Verified '.$totalFilesVerified.' files. Failed '.$totalFilesFailed.' files.

'; - -// if (is_file($output_file)){ -// echo "

".$iniFileName." written successfully

"; -// } -// else -// { -// echo "

".$iniFileName." could not be written

"; -// } -// + echo '

Indexing '.$totalFiles.' files. Verified '.$totalFilesVerified.' files. Failed '.$totalFilesFailed.' files.

'; + + if (!is_file($output_file)) + { // unable to write ini file + $iniFileWritten = "

".$iniFileName." could not be written

"; + } + else + { // ini file written successfully + $iniFileWritten = "

Hash values written to: $updatePath$iniFileName

"; + } + + // check if all files were verified if ($totalFiles == $totalFilesVerified) - { + { // set success icon, message and colors $icon = ''; $done = "

".$totalFiles." ".$lang['UPDATE_VERIFICATION_SUCCESS']."

"; + $iconFalse = ''; + $successColor = ' text-success'; + $failedColor = ''; } else - { $icon = ''; - $done = "

".$totalFilesFailed." ".$lang['UPDATE_VERIFICATION_FAILED']."

"; + { // set failure icon, message and colors + $iconFalse = ''; + $done = "

".$totalFilesFailed." ".$lang['UPDATE_VERIFICATION_FAILED']."

"; + $failedColor = ' text-danger'; + $successColor = ''; } - echo "

Total files: $totalFiles

-

$icon  Verified files: $totalFilesVerified

-

Failed to verify: $totalFilesFailed

-

$iniFileName written to $updateFolder

-

$done

"; + echo " +

$icon  Generated hash values: $totalFilesVerified / $totalFiles

+

$done

+

$iconFalse  Failed to verify: $totalFilesFailed

+$iniFileWritten"; + + // Close the output file + fclose($output_handle); + + // return $output_file; + } }