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'); }
function doimport() { set_time_limit(0); if (substr(trim(ini_get('memory_limit')), 0, -1) < 32 && substr(trim(ini_get('memory_limit')), 0, -1) > 0) { @ini_set('memory_limit', '32M'); } $filename = str_replace('*', '.', $this->get[2]); $filenum = $this->get[3] ? $this->get[3] : 1; $filedir = "./data/db_backup/"; $filetype = $this->get[4] ? $this->get[4] : substr($filename, -3); if ($filetype != 'zip' && $filetype != 'sql') { $this->message($this->view->lang['dbBackupFormatError'], 'BACK'); } else { if ($filenum == 1) { if ($filetype == 'zip') { require_once HDWIKI_ROOT . '/lib/zip.class.php'; $zip = new zip(); if (!$zip->chk_zip) { $this->message($this->view->lang['chkziperror'], ''); } $zip->Extract($filedir . $filename, $filedir); $filename = substr($filename, 0, -4) . "_1.sql"; } else { $num = strrpos($filename, "_"); $filename = substr($filename, 0, $num) . "_1.sql"; } } if (file_exists($filedir . $filename)) { $sqldump = file::readfromfile($filedir . $filename); preg_match('/#\\sVersion:\\shdwiki\\s([^\\n]+)\\n/i', $sqldump, $hdversion); if ($hdversion[1] != HDWIKI_VERSION) { $this->message($this->view->lang['dbSqlVersionError'], 'index.php?admin_db-backup'); } $sqlquery = $_ENV['db']->splitsql($sqldump); unset($sqldump); foreach ($sqlquery as $sql) { $sql = $_ENV['db']->syntablestruct(trim($sql), $this->db->version() > '4.1', DB_CHARSET); if ($sql != '') { $this->db->query($sql, 'SILENT'); if (($sqlerror = $this->db->error()) && $this->db->errno() != 1062) { $this->db->halt('MySQL Query Error', $sql); } } } if ($filetype == 'zip') { @unlink($filedir . $filename); } $filenum++; $num = strrpos($filename, "_"); $filename = str_replace('.', '*', substr($filename, 0, $num) . "_" . $filenum . ".sql"); $url = "index.php?admin_db-import-{$filename}-{$filenum}-{$filetype}"; $this->message("<image src='style/default/loading.gif'><br />" . $this->view->lang['dbBackupNext1'] . ($filenum - 1) . $this->view->lang['dbBackupNext2'] . "<script type=\"text/JavaScript\">setTimeout(\"window.location.replace('{$url}');\", 2000);</script>", ''); } else { $this->cache->removecache('import_files'); $this->message($this->view->lang['dbSqlImportSuccess'], 'index.php?admin_db-backup'); } } }
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);'>>>返回重新上传>></a>", "javascript:;"); exit; } $ziptmp = $mdir . '/ziptmp'; $z->Extract($tmpfilename, $ziptmp, $dedefileindex); unlink($tmpfilename); $tmpfilename = $mdir . "/ziptmp/" . $dedefile; } $dm = new DedeModule($mdir); $infos = $dm->GetModuleInfo($tmpfilename, 'file'); if (empty($infos['hash'])) { unlink($tmpfilename); $dm->Clear(); ShowMsg("对不起,你上传的文件可能不是织梦模块的标准格式文件!<br /><br /><a href='javascript:history.go(-1);'>>>返回重新上传>></a>", "javascript:;"); exit; } $okfile = $mdir . '/' . $infos['hash'] . '.xml'; if ($dm->HasModule($infos['hash']) && empty($delhas)) { unlink($tmpfilename); $dm->Clear();
function InportDict($targetfile) { if (!ini_set('memory_limit', '128M')) { exit('设置内存错误,请到dede官网下载解压版的base_dic_full.dic!'); } require_once DEDEINC . '/zip.class.php'; $zip = new zip(); //echo $targetfile; $unpackagefile = array_keys($zip->Extract($targetfile, DEDEINC . '/data/')); //exit(); $this->MakeDict(DEDEINC . '/data/' . $unpackagefile[0]); unlink(DEDEINC . '/data/' . $unpackagefile[0]); return true; }
function onimport() { set_time_limit(0); if (substr(trim(ini_get('memory_limit')), 0, -1) < 32 && substr(trim(ini_get('memory_limit')), 0, -1) > 0) { @ini_set('memory_limit', '32M'); } $filename = str_replace('*', '.', $this->get[2]); $filenum = $this->get[3] ? $this->get[3] : 1; $filedir = "./data/db_backup/"; $filetype = $this->get[4] ? $this->get[4] : substr($filename, -3); if ($filetype != 'zip' && $filetype != 'sql') { $this->message('文件格式不正确', 'BACK'); } else { if ($filenum == 1) { if ($filetype == 'zip') { require_once TIPASK_ROOT . '/lib/zip.class.php'; $zip = new zip(); if (!$zip->chk_zip) { $this->message('chkziperror', ''); } $zip->Extract($filedir . $filename, $filedir); $filename = substr($filename, 0, -4) . "_1.sql"; } else { $num = strrpos($filename, "_"); $filename = substr($filename, 0, $num) . "_1.sql"; } } if (file_exists($filedir . $filename)) { $sqldump = readfromfile($filedir . $filename); preg_match('/#\\sVersion:\\sTipask\\s([^\\n]+)\\n/i', $sqldump, $tversion); if ($tversion[1] != TIPASK_VERSION) { $this->message('导入的备份数据文件版本不正确', 'admin_db/backup'); } $sqlquery = $_ENV['db']->splitsql($sqldump); unset($sqldump); foreach ($sqlquery as $sql) { $sql = $_ENV['db']->syntablestruct(trim($sql), $this->db->version() > '4.1', DB_CHARSET); if ($sql != '') { $this->db->query($sql, 'SILENT'); if (($sqlerror = $this->db->error()) && $this->db->errno() != 1062) { $this->db->halt('MySQL Query Error', $sql); } } } if ($filetype == 'zip') { @unlink($filedir . $filename); } $filenum++; $num = strrpos($filename, "_"); $filename = str_replace('.', '*', substr($filename, 0, $num) . "_" . $filenum . ".sql"); $this->message("<image src='css/default/loading.gif'><br />" . '第 ' . ($filenum - 1) . ' 个文件已经完成!正在进入下一个备份!', "admin_db/import/{$filename}/{$filenum}/{$filetype}"); } else { $this->cache->remove('import_files'); $this->message('导入数据成功!', 'admin_db/backup'); } } }
function InportDict($targetfile) { if (!ini_set('memory_limit', '128M')) { exit('设置内存错误,请稍后在试!'); } require_once ROOT_PATH . 'includes/zip.class.php'; $zip = new zip(); //echo $targetfile; $unpackagefile = array_keys($zip->Extract($targetfile, ROOT_PATH . 'includes/codetable/')); //exit(); $this->MakeDict(ROOT_PATH . 'includes/codetable/' . $unpackagefile[0]); unlink(ROOT_PATH . 'includes/codetable/' . $unpackagefile[0]); return true; }
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'); } }
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(); }