public function get($type) { if ((int) $this->check_access() < 10 || empty($type)) { $this->response(null, null, 401); } if ($type != "now" && $type != "complete") { $this->response(null, null, 400); } if (!is_file("{$this->package_path}/system_upgrade.zip")) { throw new exception("Upgrade file not found."); } if ($type == "complete") { RazorFileTools::delete_directory($this->tmp_path); $this->response("success", "json"); } // lets grab the current system data before we upgrade, after it is too late. $db = new RazorDB(); $db->connect("system"); $search = array("column" => "id", "value" => 1); $system = $db->get_rows($search); $system = $system["result"][0]; // compress the whole system to a single zip backup file $zip = new RazorZip(); $zip->open("{$this->package_path}/system_upgrade.zip"); /* UPGRADE */ $zip->extractTo(RAZOR_BASE_PATH); $zip->close(); // now run any post install script, let this fail if not present as we always provide it, to stop people adding it (as we overwrite it) include "{$this->package_path}/system_upgrade_post_install.php"; // once install script is run, remove it for safety RazorFileTools::delete_file("{$this->package_path}/system_upgrade_post_install.php"); $this->response("success", "json"); }
public function get($type) { // this was moved to allow system to complete after migration to sqlite (and login lost during process) if ($type == "complete") { RazorFileTools::delete_directory($this->tmp_path); $this->response("success", "json"); } if ((int) $this->check_access() < 10 || empty($type)) { $this->response(null, null, 401); } if ($type != "now") { $this->response(null, null, 400); } if (!is_file("{$this->package_path}/system_upgrade.zip")) { throw new exception("Upgrade file not found."); } // lets grab the current system data before we upgrade, after it is too late. $system = $this->razor_db->get_first('system'); // upgrade the system from hte upgrade zip $zip = new RazorZip(); $zip->open("{$this->package_path}/system_upgrade.zip"); /* UPGRADE */ $zip->extractTo(RAZOR_BASE_PATH); $zip->close(); // now run any post install script, let this fail if not present as we always provide it, to stop people adding it (as we overwrite it) include "{$this->package_path}/system_upgrade_post_install.php"; // once install script is run, remove it for safety RazorFileTools::delete_file("{$this->package_path}/system_upgrade_post_install.php"); $this->response("success", "json"); }
public function delete($album_file) { if ((int) $this->check_access() < MANAGER) { $this->response(null, null, 401); } if (empty($album_file)) { $this->response(null, null, 400); } $parts = explode("|", $album_file); if (count($parts) != 2) { $this->response("Invalid album/file format (album|filename.png).", null, 400); } // ensure album and filename is clean $album = preg_replace("/[^a-zA-Z0-9-_]/", "", $parts[0]); $name = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), $parts[1]); // ensure we deleting a image $file_ext = explode(".", strtolower($name)); if (!in_array(end($file_ext), $this->image_ext)) { $this->response("Can only delete image files (jpg, png, gif).", null, 406); } // check exists if (!is_file("{$this->root_path}/{$album}/{$name}")) { $this->response("File does not exist ({$album}/{$name})", null, 406); } RazorFileTools::delete_file("{$this->root_path}/{$album}/{$name}"); $this->response("success", "json"); }
public function delete($name) { if ((int) $this->check_access() < 8) { $this->response(null, null, 401); } if (empty($name)) { $this->response(null, null, 400); } // ensure name is clean $name = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), $name); // ensure we deleting a image $file_ext = explode(".", strtolower($name)); if (!in_array(end($file_ext), $this->image_ext)) { $this->response(null, null, 406); } // check exists if (!is_file(RAZOR_BASE_PATH . "storage/files/images/{$name}")) { $this->response(null, null, 406); } RazorFileTools::delete_file(RAZOR_BASE_PATH . "storage/files/images/{$name}"); $this->response("success", "json"); }