Please wait....
Please wait....
Please wait....
open($file); $zip->extractTo(pathFixer('system/cache/')); $zip->close(); if (file_exists($folder)) { $step++; } else { $msg = "Failed to extract update file"; $msgType = "danger"; $continue = false; } // remove downloaded zip if (file_exists($file)) unlink($file); } else if ($step == 3) { deleteFolder('system/autoload/'); deleteFolder('system/vendor/'); deleteFolder('ui/ui/'); copyFolder($folder, pathFixer('./')); deleteFolder('install/'); deleteFolder($folder); if (!file_exists($folder . pathFixer('/system/'))) { $step++; } else { $msg = "Failed to install update file."; $msgType = "danger"; $continue = false; } } else if ($step == 4) { if (file_exists("system/updates.json")) { require 'config.php'; $db = new pdo( "mysql:host=$db_host;dbname=$db_name", $db_user, $db_password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) ); $updates = json_decode(file_get_contents("system/updates.json"), true); $dones = []; if (file_exists("system/cache/updates.done.json")) { $dones = json_decode(file_get_contents("system/cache/updates.done.json"), true); } foreach ($updates as $version => $queries) { if (!in_array($version, $dones)) { foreach ($queries as $q) { try { $db->exec($q); } catch (PDOException $e) { //ignore, it exists already } } $dones[] = $version; } } file_put_contents("system/cache/updates.done.json", json_encode($dones)); } $step++; } else { $path = 'ui/compiled/'; $files = scandir($path); foreach ($files as $file) { if (is_file($path . $file)) { unlink($path . $file); } } $version = json_decode(file_get_contents('version.json'), true)['version']; $continue = false; } function pathFixer($path) { return str_replace("/", DIRECTORY_SEPARATOR, $path); } function r2($to, $ntype = 'e', $msg = '') { if ($msg == '') { header("location: $to"); die(); } $_SESSION['ntype'] = $ntype; $_SESSION['notify'] = $msg; header("location: $to"); die(); } function copyFolder($from, $to, $exclude = []) { $files = scandir($from); foreach ($files as $file) { if (is_file($from . $file) && !in_array($file, $exclude)) { if (file_exists($to . $file)) unlink($to . $file); rename($from . $file, $to . $file); } else if (is_dir($from . $file) && !in_array($file, ['.', '..'])) { if (!file_exists($to . $file)) { mkdir($to . $file); } copyFolder($from . $file . DIRECTORY_SEPARATOR, $to . $file . DIRECTORY_SEPARATOR); } } } function deleteFolder($path) { $files = scandir($path); foreach ($files as $file) { if (is_file($path . $file)) { unlink($path . $file); } else if (is_dir($path . $file) && !in_array($file, ['.', '..'])) { deleteFolder($path . $file . DIRECTORY_SEPARATOR); rmdir($path . $file); } } rmdir($path); } ?>