Ejemplo n.º 1
0
 function doinstall()
 {
     $appid = $this->get[2];
     if (is_numeric($appid)) {
         $pluginurl = $this->setting['app_url'] . '/hdapp.php?action=download&type=plugin&install=1&id=' . $appid . '&url=' . urlencode(WIKI_URL);
         $zipcontent = @util::hfopen($pluginurl);
         if (empty($zipcontent)) {
             $this->message($this->view->lang['msgConnectFailed']);
         }
         $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
         file::writetofile($tmpname, $zipcontent);
         if (function_exists('gzopen')) {
             require HDWIKI_ROOT . "/lib/zip.class.php";
             $zip = new zip();
             if (!$zip->chk_zip) {
                 $this->message($this->view->lang['pluginInstallNoZlib'], '');
             }
             $ziplist = @$zip->get_List($tmpname);
             if (!(bool) $ziplist) {
                 unlink($tmpname);
                 $this->message($this->view->lang['pluginAddr'] . $pluginurl . $this->view->lang['pluginAddrFail']);
             }
             $lastpos = strpos($ziplist[0]['filename'], '/');
             $identifier = substr($ziplist[0]['filename'], 0, $lastpos);
             @$zip->Extract($tmpname, HDWIKI_ROOT . '/plugins');
         } else {
             $this->message($this->view->lang['pluginInstallNoZlib']);
         }
         unlink($tmpname);
     } else {
         $identifier = $this->get[2];
     }
     $plugin = $this->db->fetch_by_field('plugin', 'identifier', $identifier);
     if ($plugin) {
         $this->message($this->view->lang['pluginAddrName'] . $identifier . $this->view->lang['pluginHasInstall'], 'index.php?admin_plugin-list');
     }
     $this->loadplugin($identifier);
     $plugin = $_ENV["{$identifier}"]->install();
     $_ENV['plugin']->add_plugin($plugin);
     $this->cache->removecache('plugin');
     $this->message($this->view->lang['pluginInstallSuccess'], 'index.php?admin_plugin-list');
 }
Ejemplo n.º 2
0
if (empty($action)) {
    $action = '';
}
$mdir = DEDEDATA . '/module';
if ($action == 'upload') {
    if (!is_uploaded_file($upfile)) {
        ShowMsg("貌似你什么都没有上传哦!", "javascript:;");
        exit;
    } else {
        include_once dirname(__FILE__) . "/../include/zip.class.php";
        $tmpfilename = $mdir . '/' . ExecTime() . mt_rand(10000, 50000) . '.tmp';
        move_uploaded_file($upfile, $tmpfilename) or die("把上传的文件移动到{$tmpfilename}时失败,请检查{$mdir}目录是否有写入权限!");
        //ZIP格式的文件
        if ($filetype == 1) {
            $z = new zip();
            $files = $z->get_List($tmpfilename);
            $dedefileindex = -1;
            //为了节省资源,系统仅以.xml作为扩展名识别ZIP包里了dede模块格式文件
            if (is_array($files)) {
                for ($i = 0; $i < count($files); $i++) {
                    if (preg_match("#\\.xml#i", $files[$i]['filename'])) {
                        $dedefile = $files[$i]['filename'];
                        $dedefileindex = $i;
                        break;
                    }
                }
            }
            if ($dedefileindex == -1) {
                unlink($tmpfilename);
                ShowMsg("对不起,你上传的压缩包中不存在dede模块文件!<br /><br /><a href='javascript:history.go(-1);'>&gt;&gt;返回重新上传&gt;&gt;</a>", "javascript:;");
                exit;
Ejemplo n.º 3
0
 function doinstall()
 {
     if (isset($this->get[2]) && is_numeric($this->get[2])) {
         $style_download_url = $this->setting['app_url'] . "/hdapp.php?action=download&type=template&install=1&id=" . $this->get[2] . "&url=" . WIKI_URL;
         $zipcontent = @util::hfopen($style_download_url);
         $tmpdir = HDWIKI_ROOT . '/data/tmp/';
         file::forcemkdir($tmpdir);
         $tmpname = $tmpdir . util::random(6) . '.zip';
         file::writetofile($tmpname, $zipcontent);
         require HDWIKI_ROOT . "/lib/zip.class.php";
         require HDWIKI_ROOT . "/lib/xmlparser.class.php";
         $zip = new zip();
         if (!$zip->chk_zip) {
             $this->message($this->view->lang['styleInstallNoZlib'], '');
         }
         $ziplist = @$zip->get_List($tmpname);
         if (!(bool) $ziplist) {
             @unlink($tmpname);
             $this->message($this->view->lang['styleZipFail'], 'BACK');
         }
         $theme_name = $_ENV['theme']->get_theme_name($ziplist);
         @$zip->Extract($tmpname, $tmpdir);
         @unlink($tmpname);
         //move file
         $syle_path = $tmpdir . 'hdwiki';
         if (is_dir(HDWIKI_ROOT . '/style/' . $theme_name)) {
             @file::removedir($syle_path);
             $this->message($this->view->lang['stylePathRepeat'], 'BACK');
         }
         @file::copydir($syle_path, HDWIKI_ROOT);
         @file::removedir($syle_path);
         //save db
         $style_xml = HDWIKI_ROOT . '/style/' . $theme_name . '/desc.xml';
         if (!is_file($style_xml)) {
             $this->message($this->view->lang['styleXmlNotExist'], 'BACK');
         }
         $xmlnav = $_ENV['theme']->read_xml($theme_name);
         $style['name'] = $xmlnav['name'];
         $style['copyright'] = $xmlnav['copyright'];
         $style['path'] = $theme_name;
         $stylecon = $_ENV['theme']->add_check_style($style['path']);
         if ($stylecon == null) {
             $_ENV['theme']->add_style($style);
             $this->cache->removecache('style');
             $this->message($this->view->lang['styleInstallSuccess'], 'BACK');
         } else {
             $this->message($this->view->lang['styleDbPathRepeat'], 'index.php?admin_theme');
         }
     } else {
         $this->message($this->view->lang['commonParametersInvalidTip'], 'index.php?admin_theme');
     }
 }
Ejemplo n.º 4
0
 function extract_all()
 {
     require HDWIKI_ROOT . '/lib/zip.class.php';
     $zip = new zip();
     if (!$zip->chk_zip) {
         $this->base->message($this->view->lang['chkziperror'], '');
     }
     $plugindir = dir(HDWIKI_ROOT . '/plugins');
     while ($entry = $plugindir->read()) {
         $filename = HDWIKI_ROOT . '/plugins/' . $entry;
         if (is_file($filename)) {
             $ziplist = @$zip->get_List($filename);
             if ($ziplist) {
                 $lastpos = strpos($ziplist[0]['filename'], '/');
                 $identifier = substr($ziplist[0]['filename'], 0, $lastpos);
                 if (!$identifier) {
                     continue;
                 }
                 $plugin = $_ENV['plugin']->get_plugin_by_identifier($identifier);
                 if (!$plugin && !file_exists(HDWIKI_ROOT . '/plugins/' . $identifier)) {
                     $zip->Extract($filename, HDWIKI_ROOT . '/plugins');
                 }
             }
         }
     }
     $plugindir->close();
 }