emDirect("./plugin.php?plugin={$plugin}&error=1"); } } //安装插件 if ($action == 'install') { include View::getView('header'); require_once View::getView('plugin_install'); include View::getView('footer'); View::output(); } //删除插件 if ($action == 'del') { $Plugin_Model = new Plugin_Model(); $Plugin_Model->inactivePlugin($plugin); $pludir = preg_replace("/^([^\\/]+)\\/.*/", "\$1", $plugin); if (true === emDeleteFile('../content/plugins/' . $pludir)) { $CACHE->updateCache('options'); emDirect("./plugin.php?activate_del=1"); } else { emDirect("./plugin.php?error_a=1"); } } //上传zip插件 if ($action == 'upload_zip') { $zipfile = isset($_FILES['pluzip']) ? $_FILES['pluzip'] : ''; if ($zipfile['error'] == 4) { emDirect("./plugin.php?action=install&error_d=1"); } if (!$zipfile || $zipfile['error'] >= 1 || empty($zipfile['tmp_name'])) { emMsg('插件上传失败'); }
} //使用模板 if ($action == 'usetpl') { LoginAuth::checkToken(); $tplName = isset($_GET['tpl']) ? addslashes($_GET['tpl']) : ''; $tplSideNum = isset($_GET['side']) ? intval($_GET['side']) : ''; Option::updateOption('nonce_templet', $tplName); Option::updateOption('tpl_sidenum', $tplSideNum); $CACHE->updateCache('options'); emDirect("./template.php?activated=1"); } //删除模板 if ($action == 'del') { LoginAuth::checkToken(); $tplName = isset($_GET['tpl']) ? addslashes($_GET['tpl']) : ''; if (true === emDeleteFile(TPLS_PATH . $tplName)) { emDirect("./template.php?activate_del=1#tpllib"); } else { emDirect("./template.php?error_a=1#tpllib"); } } //自定义顶部图片页面 if ($action == 'custom-top') { $topimg = Option::get('topimg'); $top_image_path = TPLS_PATH . 'default/images/top/'; $handle = @opendir($top_image_path) or die('emlog default template path error!'); $default_topimgs = array(); while ($file = @readdir($handle)) { if (getFileSuffix($file) == 'jpg' && !strstr($file, '_mini.jpg')) { $default_topimgs[] = array('path' => 'content/templates/default/images/top/' . $file); }
/** * 删除文件或目录 */ function emDeleteFile($file) { if (empty($file)) { return false; } if (@is_file($file)) { return @unlink($file); } $ret = true; if ($handle = @opendir($file)) { while ($filename = @readdir($handle)) { if ($filename == '.' || $filename == '..') { continue; } if (!emDeleteFile($file . '/' . $filename)) { $ret = false; } } } else { $ret = false; } @closedir($handle); if (file_exists($file) && !rmdir($file)) { $ret = false; } return $ret; }