Пример #1
0
 function extract_zip()
 {
     $zip_file = UPGRADE_PATH . $this->package['release_code'] . '.zip';
     require HDWIKI_ROOT . '/lib/zip.class.php';
     $zip = new zip();
     $swap_dir = UPGRADE_PATH . $this->package['release_code'];
     if (!is_dir($swap_dir)) {
         file::forcemkdir($swap_dir);
     }
     if (file::iswriteable($swap_dir)) {
         $zip->extract($zip_file, $swap_dir);
     }
     unset($zip);
     return count(@scandir($swap_dir)) > 0;
 }
Пример #2
0
     default:
         $c = new wcurl(UPDATE_SERVER_GITHUB);
         $floderName = UPDATE_FNAME_GITHUB;
         break;
 }
 $file = $c->exec();
 $c->close();
 $zipPath = UPDATE_CACHE . 'update_' . time() . '.zip';
 if (file_put_contents($zipPath, $file) === false) {
     DeleteFile(UPDATE_CACHE);
     msg('错误 - 更新失败:<br/><br/>无法从更新服务器下载更新包');
 }
 //解压缩
 $z = new zip();
 $z->open($zipPath);
 $z->extract(UPDATE_CACHE);
 $z->close();
 //检查更新文件
 $floderName = UPDATE_CACHE . $floderName;
 if (!is_dir($floderName)) {
     DeleteFile(UPDATE_CACHE);
     msg('错误 - 更新失败:<br/><br/>无法解压缩更新包');
 }
 //删除配置文件
 if (file_exists($floderName . '/config.php')) {
     unlink($floderName . '/config.php');
 }
 if (file_exists($floderName . '/app.conf')) {
     unlink($floderName . '/app.conf');
 }
 if (file_exists($floderName . '/config.yaml')) {
require_once 'panel_admin.inc.php';
$types = array('lang', 'module', 'design');
$dirs = array('lang', 'modules', 'designs');
$fhs = $formulaires = array();
foreach ($types as $k => $val) {
    $formulaires[$val] = new Form(translate('file_upload'), 'post', '', true);
    $formulaires[$val]->add_fieldset();
    $formulaires[$val]->add_input('file_' . $val, 'file_' . $val, translate('file_form'), 'file', 'file');
    $formulaires[$val]->add_button();
    $fhs[$val] = new FormHandle($formulaires[$val]);
    $fhs[$val]->handle();
    if ($fhs[$val]->okay()) {
        $file = $fhs[$val]->get('file_' . $val);
        load('core/zip');
        $zip = new zip($file);
        if ($zip->extract(ROOT . 'cache/tmp/' . $dirs[$k] . '/')) {
            $nameZip = $_FILES['file_' . $val]['name'];
            if (is_dir(ROOT . $dirs[$k] . '/' . $nameZip)) {
                $error = new Error();
                $error->add_error(translate('file_already_exists'), ERROR_PAGE, __FILE__, __LINE__);
            } else {
                if (($dirDbFile = ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip . 'db/db.sql') && is_file($dirDbFile)) {
                    $bdd->extract_files($dirDbFile);
                }
                #rm( ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip . 'db/' );
                rename(ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip, ROOT . $dirs[$k] . '/' . $nameZip);
                rm(ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip);
                $error = new Error();
                $error->add_error(translate('file_success'), ERROR_PAGE, __FILE__, __LINE__);
            }
        } else {
Пример #4
0
 function install_skin()
 {
     if (!isset($this->post['submit']) && !isset($this->get['temp'])) {
         $skin_box = '';
         $dp = opendir('../');
         while (($file = readdir($dp)) !== false) {
             $ext = strtolower(substr($file, -4));
             if ($ext == '.mbs') {
                 $skin_box .= "<option value='../{$file}'>" . substr($file, 0, -4) . "</option>\n";
             }
         }
         closedir($dp);
         return $this->message('Install a Skin', "\r\n\t\t\t<form action='{$this->self}?a=templates&amp;s=load' method='post'>\r\n\t\t\t\tThe following skins were found in the MercuryBoard directory:<br /><br />\r\n\t\t\t\t<select name='install'>\r\n\t\t\t\t\t{$skin_box}\r\n\t\t\t\t</select>\r\n\t\t\t\t<input type='submit' name='submit' value='Install Skin'>\r\n\t\t\t</form>");
     } else {
         if (!isset($this->get['temp'])) {
             include '../lib/zip.php';
             $dir = md5(microtime());
             $zip = new zip();
             $zip->extract($this->post['install'], "../skins/{$dir}");
             include "../skins/{$dir}/info.php";
             if (is_dir("../skins/{$skin['dir']}")) {
                 return $this->message('Install a Skin', "It appears that the skin <b>{$skin['name']}</b> is already installed.", 'Overwrite', "{$this->self}?a=templates&amp;s=load&amp;s=load&amp;temp={$dir}");
             }
             $this->get['temp'] = $dir;
         }
         $dir = $this->get['temp'];
         include "../skins/{$dir}/info.php";
         if (is_dir("../skins/{$skin['dir']}")) {
             $this->remove_dir("../skins/{$skin['dir']}");
         }
         rename("../skins/{$dir}", "../skins/{$skin['dir']}");
         $dir = $skin['dir'];
         $queries = array();
         $pre = $this->pre;
         include "../skins/{$dir}/templates.php";
         $this->db->query("DELETE FROM {$this->pre}skins WHERE skin_dir='{$dir}'");
         $this->db->query("INSERT INTO {$this->pre}skins (skin_name, skin_dir) VALUES ('{$skin['name']}', '{$dir}')");
         $this->db->query("DELETE FROM {$this->pre}templates WHERE template_skin='{$dir}'");
         $this->execute_queries($queries);
         return $this->message('Install a Skin', 'The skin has been installed successfully.');
     }
 }
Пример #5
0
 function install_skin()
 {
     if (!isset($this->post['submit']) && !isset($this->get['temp'])) {
         $skin_box = '';
         $dp = opendir('../skins');
         while (($file = readdir($dp)) !== false) {
             $ext = strtolower(substr($file, -4));
             if ($ext == '.mbs') {
                 $skin_box .= "<option value='../skins/{$file}'>" . substr($file, 0, -4) . "</option>\n";
             }
         }
         closedir($dp);
         return $this->message($this->lang->install_skin, "\n\t\t\t<form action='{$this->self}?a=templates&amp;s=load' method='post'><div>\n\t\t\t\t{$this->lang->skins_found}:<br /><br />\n\t\t\t\t<select name='install'>\n\t\t\t\t\t{$skin_box}\n\t\t\t\t</select>\n\t\t\t\t<input type='submit' name='submit' value='{$this->lang->install_skin}' /></div>\n\t\t\t</form>");
     } else {
         if (!isset($this->get['temp']) && !isset($this->get['install'])) {
             if (!isset($this->post['install'])) {
                 return $this->message($this->lang->install_skin, $this->lang->skin_none);
             }
             include '../lib/zip.php';
             $dir = md5(microtime());
             $zip = new zip();
             $zip->extract($this->post['install'], "../skins/{$dir}");
             $this->chmod("../skins/{$dir}", 0777, true);
             include "../skins/{$dir}/info.php";
             if (is_dir("../skins/{$skin['dir']}")) {
                 return $this->message($this->lang->install_skin, "{$this->lang->install_exists1} <b>{$skin['name']}</b> {$this->lang->install_exists2}", $this->lang->install_overwrite, "{$this->self}?a=templates&amp;s=load&amp;temp={$dir}");
             }
             $this->get['temp'] = $dir;
         }
         $dir = $this->get['temp'];
         include "../skins/{$dir}/info.php";
         if (is_dir("../skins/{$skin['dir']}")) {
             $this->remove_dir("../skins/{$skin['dir']}");
         }
         rename("../skins/{$dir}", "../skins/{$skin['dir']}");
         $this->chmod("../skins/{$skin['dir']}", 0777, true);
         $dir = $skin['dir'];
         $queries = array();
         $pre = $this->pre;
         include "../skins/{$dir}/templates.php";
         $this->db->query("DELETE FROM {$this->pre}skins WHERE skin_dir='{$dir}'");
         $this->db->query("INSERT INTO {$this->pre}skins (skin_name, skin_dir) VALUES ('{$skin['name']}', '{$dir}')");
         $this->db->query("DELETE FROM {$this->pre}templates WHERE template_skin='{$dir}'");
         $this->execute_queries($queries);
         return $this->message($this->lang->install_skin, $this->lang->install_done);
     }
 }
Пример #6
0
 function install_skin()
 {
     if (!isset($this->post['submit']) && !isset($this->get['newskin']) && !isset($this->get['skindetails'])) {
         // Build drop down list for the OLD method
         $skin_box = '';
         $dp = opendir('../skins');
         while (($file = readdir($dp)) !== false) {
             $ext = strtolower(substr($file, -4));
             if ($ext == '.mbs') {
                 $skin_box .= "<option value='../skins/{$file}'>" . substr($file, 0, -4) . "</option>\n";
             }
         }
         closedir($dp);
         // Now check for skins using the NEW method
         // build a list of all the xml skin files
         $tarTool = new archive_tar();
         $xmlInfo = new xmlparser();
         $new_skin_box = '';
         $dp = opendir('../packages');
         while (($file = readdir($dp)) !== false) {
             if (strtolower(substr($file, -4)) == '.tar' || strtolower(substr($file, -7)) == '.tar.gz' && $tarTool->can_gunzip()) {
                 if ($tarTool->open_file_reader('../packages/' . $file)) {
                     // Okay. Look at packages.txt to find our xml file
                     $xmlFilename = $tarTool->extract_file('package.txt');
                     if ($xmlFilename === false) {
                         continue;
                     }
                     $xmlData = $tarTool->extract_file($xmlFilename);
                     $xmlInfo->parseTar($tarTool, $xmlFilename);
                 } else {
                     continue;
                 }
             } else {
                 if (strtolower(substr($file, -4)) == '.xml') {
                     $xmlInfo->parse('../packages/' . $file);
                 } else {
                     $xmlInfo->reset();
                     continue;
                     // skip file
                 }
             }
             $node = $xmlInfo->GetNodeByPath('QSFMOD/TYPE');
             if ($node['content'] != 'skin') {
                 continue;
             }
             // skip other mods
             $new_skin_box .= "  <li><a href=\"{$this->self}?a=templates&amp;s=load&amp;newskin=";
             if (strtolower(substr($file, -7)) == '.tar.gz') {
                 $new_skin_box .= urlencode(substr($file, 0, -7)) . "\" ";
             } else {
                 $new_skin_box .= urlencode(substr($file, 0, -4)) . "\" ";
             }
             $node = $xmlInfo->GetNodeByPath('QSFMOD/DESCRIPTION');
             if (isset($node['content']) && $node['content']) {
                 $new_skin_box .= "title=\"" . htmlspecialchars($node['content']) . "\"";
             }
             $new_skin_box .= ">";
             $node = $xmlInfo->GetNodeByPath('QSFMOD/TITLE');
             $new_skin_box .= "<strong>" . htmlspecialchars($node['content']) . "</strong></a>";
             $node = $xmlInfo->GetNodeByPath('QSFMOD/VERSION');
             $new_skin_box .= " " . htmlspecialchars($node['content']);
             $node = $xmlInfo->GetNodeByPath('QSFMOD/AUTHORNAME');
             $new_skin_box .= " (" . htmlspecialchars($node['content']) . ")";
             $new_skin_box .= "</li>\n";
             $xmlInfo->reset();
         }
         closedir($dp);
         return $this->message($this->lang->install_skin, eval($this->template('ADMIN_INSTALL_SKIN')));
     } else {
         if (isset($this->get['skindetails'])) {
             // Display some preview information on the skin
         } else {
             if (isset($this->get['newskin'])) {
                 // Use new method of install
                 $tarTool = new archive_tar();
                 // Open and parse the XML file
                 $xmlInfo = new xmlparser();
                 if (file_exists('../packages/' . $this->get['newskin'] . '.xml')) {
                     $xmlInfo->parse('../packages/' . $this->get['newskin'] . '.xml');
                 } else {
                     if (file_exists('../packages/' . $this->get['newskin'] . '.tar')) {
                         $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar');
                         $xmlFilename = $tarTool->extract_file('package.txt');
                         $xmlInfo->parseTar($tarTool, $xmlFilename);
                     } else {
                         if (file_exists('../packages/' . $this->get['newskin'] . '.tar.gz') && $tarTool->can_gunzip()) {
                             $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar.gz');
                             $xmlFilename = $tarTool->extract_file('package.txt');
                             $xmlInfo->parseTar($tarTool, $xmlFilename);
                         } else {
                             return $this->message($this->lang->install_skin, $this->lang->skin_none);
                         }
                     }
                 }
                 // Get the folder name
                 $node = $xmlInfo->GetNodeByPath('QSFMOD/TYPE');
                 $skin_dir = $node['attrs']['FOLDER'];
                 // Run the uninstall queries
                 packageutil::run_queries($this->db, $xmlInfo->GetNodeByPath('QSFMOD/UNINSTALL'));
                 // Run the install queries
                 packageutil::run_queries($this->db, $xmlInfo->GetNodeByPath('QSFMOD/INSTALL'));
                 // Add the templates
                 packageutil::insert_templates($skin_dir, $this->db, $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'));
                 // Extract the files
                 if (file_exists('../packages/' . $this->get['newskin'] . '.tar')) {
                     $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar');
                 } else {
                     $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar.gz');
                 }
                 $nodes = $xmlInfo->GetNodeByPath('QSFMOD/FILES');
                 foreach ($nodes['child'] as $node) {
                     if ($node['name'] == 'FILE') {
                         $filename = $node['content'];
                         $data = $tarTool->extract_file($filename);
                         if ($data !== false) {
                             $this->_make_dir('../' . $filename);
                             $fh = fopen('../' . $filename, 'wb');
                             fwrite($fh, $data);
                             fclose($fh);
                         }
                     }
                 }
                 $tarTool->close_file();
                 $this->chmod('../skins/' . $skin_dir, 0777, true);
                 return $this->message($this->lang->install_skin, $this->lang->install_done);
             } else {
                 // Use old method of install
                 if (!isset($this->get['temp']) && !isset($this->get['install'])) {
                     if (!isset($this->post['install'])) {
                         return $this->message($this->lang->install_skin, $this->lang->skin_none);
                     }
                     $dir = md5(microtime());
                     $zip = new zip();
                     $zip->extract($this->post['install'], "../skins/{$dir}");
                     $this->chmod("../skins/{$dir}", 0777, true);
                     include "../skins/{$dir}/info.php";
                     if (is_dir("../skins/{$skin['dir']}")) {
                         return $this->message($this->lang->install_skin, "{$this->lang->install_exists1} <b>{$skin['name']}</b> {$this->lang->install_exists2}", $this->lang->install_overwrite, "{$this->self}?a=templates&amp;s=load&amp;temp={$dir}");
                     }
                     $this->get['temp'] = $dir;
                 }
                 $dir = $this->get['temp'];
                 include "../skins/{$dir}/info.php";
                 if (is_dir("../skins/{$skin['dir']}")) {
                     $this->remove_dir("../skins/{$skin['dir']}");
                 }
                 rename("../skins/{$dir}", "../skins/{$skin['dir']}");
                 $this->chmod("../skins/{$skin['dir']}", 0777, true);
                 $dir = $skin['dir'];
                 $queries = array();
                 $pre = $this->db->prefix;
                 include "../skins/{$dir}/templates.php";
                 $this->db->query("DELETE FROM %pskins WHERE skin_dir='%s'", $dir);
                 $this->db->query("INSERT INTO %pskins (skin_name, skin_dir) VALUES ('%s', '%s')", $skin['name'], $dir);
                 $this->db->query("DELETE FROM %ptemplates WHERE template_skin='%s'", $dir);
                 $this->execute_queries($queries);
                 return $this->message($this->lang->install_skin, $this->lang->install_done);
             }
         }
     }
 }
Пример #7
0
        if (file_exists(ROOT . $filePath)) {
            $existingFiles[] = $filePath;
        } elseif ($filePath == '_files_to_delete.txt') {
            $toDeleteFiles = explode("\n", $zip->extract_file('_files_to_delete.txt'));
        } elseif ($filePath == '_maj_infos.txt') {
            $nameFileToMove = $zip->extract_file('_maj_infos.txt');
        } else {
            $newFiles[] = $filePath;
        }
    }
    move_uploaded_file($file, ROOT . 'uploads/' . url_transform($nameFileToMove) . '.zip');
}
if (isset($_GET['confirmMAJ'])) {
    $file = ROOT . 'uploads/' . $_GET['confirmMAJ'] . '.zip';
    $zip = new zip($file);
    if ($zip->extract(ROOT)) {
        if (file_exists(ROOT . '_files_to_delete.txt')) {
            $toDeleteFiles = file(ROOT . '_files_to_delete.txt');
            foreach ($toDeleteFiles as $filePathDel) {
                rm(ROOT . ltrim(trim($filePathDel), '/'), true);
            }
        }
        @unlink(ROOT . '_files_to_delete.txt');
        @unlink(ROOT . '_maj_infos.txt');
        $error = new Error();
        $error->add_error(translate('maj_success'), ERROR_PAGE, __FILE__, __LINE__);
    } else {
        $error = new Error();
        $error->add_error(translate('maj_fail'), ERROR_PAGE, __FILE__, __LINE__);
    }
}