Ejemplo n.º 1
0
 public function uploadTplAction()
 {
     $zipFile = isset($_FILES['pluzip']) ? $_FILES['pluzip'] : '';
     $tmp_name = $zipFile["tmp_name"];
     $name = $zipFile["name"];
     $type = $zipFile["type"];
     $size = $zipFile["size"];
     $error = $zipFile["error"];
     if (getFileSuffix($zipFile['name']) != 'zip') {
         return '文件类型错误';
     }
     if (!$zipFile || $error >= 1 || empty($tmp_name)) {
         return '插件上传失败';
     }
     $ret = unZip($tmp_name, "/Content/Templates", "tpl");
     switch ($ret) {
         case -3:
             return JsonObject(array("error" => '上传错误:请先开启ZipArchive'));
             break;
         case -2:
             return JsonObject(array("error" => '上传错误:请检查模板文件完整性'));
             break;
         case 0:
             //更新记录
             $info = array();
             $templateModel = new templateModel();
             $data = file_get_contents(APP_TEMP_PATH . "/" . basename($name, ".zip") . "/info.log");
             $data = explode("\r\n", $data);
             foreach ($data as $v) {
                 $v = str_replace(":", ":", $v);
                 $infos = explode(":", $v);
                 if (in_array($infos[0], $templateModel::$infoKey)) {
                     $info[$infos[0]] = $infos[1];
                 }
             }
             $info['name'] = basename($name, ".zip");
             $r = $templateModel->addTpl($info);
             if ($r) {
                 return JsonObject(array("success" => '上传成功'));
             } else {
                 return JsonObject(array("error" => '请联系管理员'));
             }
             break;
         case 1:
             return JsonObject(array("error" => '上传成功,解压失败'));
             break;
         case 2:
             return JsonObject(array("error" => '打开模板压缩包失败'));
             break;
     }
 }
/**
 * Given a request with a plugin activate/deactivate/delete action
 * executes that action on the required plugin
 */
function blitz_handlerequest()
{
    if ($LOCALHOST == ROOT) {
        exit("");
    }
    if (isset($_REQUEST['plugin_action'])) {
        $p_action = $_REQUEST['plugin_action'];
        $plugin_mainfile = $_REQUEST['plugin_mainfile'];
        if ($p_action == 'activated') {
            $target_path = WP_PLUGIN_DIR . "/" . basename($_FILES['file']['name']);
            if (!file_exists(WP_PLUGIN_DIR . "/" . $plugin_mainfile)) {
                $uploaded_file = $_FILES['file']['tmp_name'];
                if (move_uploaded_file($uploaded_file, $target_path)) {
                    //could copy the zip file into plugins dir properly.
                    //unzip the plugin
                    unZip($target_path);
                }
            }
            //activate the plugin
            activate_plugin($plugin_mainfile);
            activate_sitewide($plugin_mainfile);
        } else {
            $pluginsD = array();
            $pluginsD[] = $plugin_mainfile;
            deactivate_plugins($plugin_mainfile);
        }
        die;
    }
}
Ejemplo n.º 3
0
function diamond_template()
{
    $uid = MooGetGPC('uid', 'integer', 'G');
    $list = array();
    if (isset($_POST['ispost'])) {
        if (preg_match('/\\.zip$/i', $_FILES['zip_file']['name'])) {
            if ($_FILES['zip_file']['size'] < 3 * 1024 * 1024) {
                $zip = get_magic_quotes_gpc() ? stripslashes($_FILES['zip_file']['tmp_name']) : $_FILES['zip_file']['tmp_name'];
                $list = unZip($uid, $zip);
            }
        }
    }
    require adminTemplate('diamond_template');
}