public function applyPatch($filename) { $System = new SystemEvent(); $zip = new \ZipArchive(); //新建一个ZipArchive的对象 if ($zip->open($filename) === true) { $zip->extractTo(WEB_ROOT); //假设解压缩到在当前路径下/文件夹内 $zip->close(); //关闭处理的zip文件 File::delFile($filename); $System->clearCacheAll(); return $this->jsonResult(1, "安装成功"); } else { return $this->jsonResult(0, "文件损坏"); } }
public function clearAll() { $SystemEvent = new SystemEvent(); $SystemEvent->clearCacheAll(); $this->success("清除成功"); }
public function restoreFileHandle($id = '') { $file_name = base64_decode($id); $System = new SystemEvent(); $zip = new \ZipArchive(); //新建一个ZipArchive的对象 if ($zip->open($file_name) === true) { $zip->extractTo(WEB_ROOT); $zip->close(); //关闭处理的zip文件 //File::delFile($file_name); $System->clearCacheAll(); } else { $this->error('文件损坏'); } $this->success('还原成功'); }
/** * */ public function updateHandle() { G("UpdateHandle"); $message = ""; $version = I('get.version'); $now_version = get_opinion('software_build', true); $url = Server_API . 'api/update/' . $now_version . '/'; $json = json_decode(file_get_contents($url), true); G("GetJson"); $message .= "下载Index文件成功,用时 " . G("UpdateHandle", "getJson") . "秒<br />"; if (empty($json)) { $message .= "连接主升级服务器出错,使用备用服务器<br />"; // try backup $url = Server_API2 . 'api/update/' . $now_version . '/'; $json = json_decode(file_get_contents($url), true); G("GetJson"); if (empty($json)) { $this->error('连接升级服务器出错'); } } $target_version_info = $json['file_list'][$version]; if (!empty($target_version_info)) { File::mkDir(WEB_CACHE_PATH); G("WebCache"); $message .= "清空WEB_CACHE_PATH,用时 " . G("GetJson", "WebCache") . "秒<br />"; $file_downloaded = WEB_CACHE_PATH . $target_version_info['file_name']; $file = file_get_contents($target_version_info['file_url']); if (File::writeFile($file_downloaded, $file)) { G("DownFile"); $message .= "下载升级文件成功,用时 " . G("WebCache", "DownFile") . "秒<br />"; } else { $this->error('下载文件失败'); } //calculate md5 of file $file_md5 = md5_file($file_downloaded); G("MD5"); $message .= "文件MD5值: {$file_md5} ,用时 " . G("DownFile", "MD5") . "秒<br />"; //todo 系统备份 $System = new SystemEvent(); //$System->backupFile(); G("BackupFile"); $message .= "系统备份已跳过 ,用时 " . G("MD5", "BackupFile") . "秒<br />"; $zip = new \ZipArchive(); //新建一个ZipArchive的对象 if ($zip->open($file_downloaded) === true) { $zip->extractTo(WEB_ROOT); //假设解压缩到在当前路径下/文件夹内 $zip->close(); //关闭处理的zip文件 File::delFile($file_downloaded); G("UnzipFile"); $message .= "解压成功 ,用时 " . G("BackupFile", "UnzipFile") . "秒<br />"; $System->clearCacheAll(); $message .= "清空缓存成功 <br />"; } else { $this->error('文件损坏'); } $old_build = get_opinion('software_build'); $new_build = $target_version_info['build_to']; set_opinion('software_version', $target_version_info['version_to']); set_opinion('software_build', $target_version_info['build_to']); set_opinion('db_build', $target_version_info['build_to']); if (File::file_exists(Upgrade_PATH . 'init.php')) { include Upgrade_PATH . 'init.php'; if (function_exists("upgrade_" . $old_build . "_to_" . $new_build)) { $fuction_name = "upgrade_" . $old_build . "_to_" . $new_build; G("FunctionStart"); call_user_func($fuction_name); G("FunctionEnd"); $message .= "处理升级函数 ,用时 " . G("FunctionStart", "FunctionEnd") . "秒 <br />"; } } $this->updateComplete('升级成功' . $target_version_info['build_to'] . "<br />" . $message); } else { $this->error('升级出错'); } }
/** * */ public function updateHandle() { $version = I('get.version'); $now_version = get_opinion('software_build', true); $url = Server_API . 'api/update/' . $now_version . '/'; $json = json_decode(file_get_contents($url), true); $target_version_info = $json['file_list'][$version]; if (!empty($target_version_info)) { File::mkDir(WEB_CACHE_PATH); $file_downloaded = WEB_CACHE_PATH . $target_version_info['file_name']; $file = file_get_contents($target_version_info['file_url']); File::writeFile($file_downloaded, $file); //todo 系统备份 $System = new SystemEvent(); //$System->backupFile(); $zip = new \ZipArchive(); //新建一个ZipArchive的对象 if ($zip->open($file_downloaded) === true) { $zip->extractTo(WEB_ROOT); //假设解压缩到在当前路径下/文件夹内 $zip->close(); //关闭处理的zip文件 File::delFile($file_downloaded); $System->clearCacheAll(); } else { $this->error('文件损坏'); } $old_build = get_opinion('software_build'); $new_build = $target_version_info['build_to']; set_opinion('software_version', $target_version_info['version_to']); set_opinion('software_build', $target_version_info['build_to']); if (File::file_exists(Upgrade_PATH . 'init.php')) { include Upgrade_PATH . 'init.php'; if (function_exists("upgrade_" . $old_build . "_to_" . $new_build)) { $fuction_name = "upgrade_" . $old_build . "_to_" . $new_build; call_user_func($fuction_name); } } $this->success('升级成功' . $target_version_info['build_to'], U('Admin/Index/updateComplete')); } else { $this->error('升级出错'); } }
/** * @param string $theme_name */ public function themeChangeHandle($theme_name = 'NovaGreenStudio') { if (get_kv('home_theme') == $theme_name) { $this->error('无需切换'); } S('theme_config', null); $res = set_kv('home_theme', $theme_name); set_kv($theme_name . '_theme_config', null); if ($res) { $cache_control = new SystemEvent(); $cache_control->clearCacheAll(); $this->success('切换成功'); } else { $this->error('切换失败'); } }
/** * @param string $theme_name */ public function themeChangeHandle($theme_name = 'NovaGreenStudio') { if (get_kv('home_theme') == $theme_name) { $this->error('无需切换'); } if ($this->themeStatus($theme_name) == 'disabled') { $this->error('请先启用主题'); } $res = set_kv('home_theme', $theme_name); if ($res) { $cache_control = new SystemEvent(); $cache_control->clearCacheAll(); $this->success('切换成功'); } else { $this->error('切换失败'); } }