Exemplo n.º 1
0
 public function createZip()
 {
     $name = q('get.name');
     Zip::PclZip("app.zip");
     //设置压缩文件名
     Zip::create("addons/{$name}");
     //压缩目录
     \Tool::download("app.zip", $name . '.zip');
 }
Exemplo n.º 2
0
        $dumpfile = $backupfile . '.sql';
        @unlink($dumpfile);
        $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base) . 'bin/';
        $_SC['dbcharset'] = empty($_SC['dbcharset']) ? $_SC['charset'] : $_SC['dbcharset'];
        @shell_exec('"' . $mysqlbin . 'mysqldump" --force --quick --default-character-set=' . $_SC['dbcharset'] . ' ' . ($_SGLOBAL['db']->version() > 4.1 ? '--skip-opt --create-options' : '-all') . ' --add-drop-table' . ($extendins == 1 ? '--extended-insert' : '') . '' . ($_SGLOBAL['db']->version() > '4.1' && $sqlcompat == 'MYSQL40' ? '--compatible=mysql40' : '') . ' --host=' . $_SC['dbhost'] . ($_SC['dbport'] ? is_numeric($_SC['dbport']) ? ' --port=' . $_SC['dbport'] : ' --sock=' . $_SC['dbport'] : '') . ' --user='******'dbuser'] . ' --password='******'dbpw'] . ' ' . $_SC['dbname'] . ' ' . $tablesstr . ' > ' . $dumpfile);
        if (file_exists($dumpfile)) {
            if (is_writable($dumpfile)) {
                $fp = fopen($dumpfile, 'rb+');
                fwrite($fp, $idstring . "# <?exit();?>\n " . $setnames . "\n #");
                fclose($fp);
            }
            if ($usezip) {
                include_once S_ROOT . './source/class_zib.php';
                $zipfilename = $backupfile . '.zip';
                $zipfile = new Zip($zipfilename);
                if ($zipfile->create($dumpfile, PCLZIP_OPT_REMOVE_PATH, S_ROOT . './data/' . $backupdir)) {
                    @unlink($dumpfile);
                    fclose(fopen(S_ROOT . './data/' . $backupdir . '/index.htm', 'a'));
                    cpmessage('successful_data_compression_and_backup_server_to', 'admincp.php?ac=backup');
                } else {
                    cpmessage('backup_file_compression_failure', 'admincp.php?ac=backup');
                }
            } else {
                fclose(fopen(S_ROOT . './data/' . $backupdir . '/index.htm', 'a'));
                cpmessage('successful_data_compression_and_backup_server_to', 'admincp.php?ac=backup');
            }
        } else {
            cpmessage('shell_backup_failure', 'admincp.php?ac=backup');
        }
    }
} elseif ($_GET['op'] == 'import') {
Exemplo n.º 3
0
        $dumpfile = $backupfile . '.sql';
        @unlink($dumpfile);
        $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base) . 'bin/';
        $dbcharset = empty($dbcharset) ? $charset : $dbcharset;
        @shell_exec('"' . $mysqlbin . 'mysqldump" --force --quick --default-character-set=' . $dbcharset . ' ' . ($_SGLOBAL['db']->version() > 4.1 ? '--skip-opt --create-options' : '-all') . ' --add-drop-table' . ($extendins == 1 ? '--extended-insert' : '') . '' . ($_SGLOBAL['db']->version() > '4.1' && $sqlcompat == 'MYSQL40' ? '--compatible=mysql40' : '') . ' --host=' . $dbhost . ($dbport ? is_numeric($dbport) ? ' --port=' . $dbport : ' --sock=' . $dbport : '') . ' --user='******' --password='******' ' . $dbname . ' ' . $tablesstr . ' > ' . $dumpfile);
        if (file_exists($dumpfile)) {
            if (is_writable($dumpfile)) {
                $fp = fopen($dumpfile, 'rb+');
                fwrite($fp, $idstring . "# <?exit();?>\n " . $setnames . "\n #");
                fclose($fp);
            }
            if ($usezip) {
                require_once S_ROOT . './include/zip.lib.php';
                $zipfilename = $backupfile . '.zip';
                $zipfile = new Zip($zipfilename);
                if ($zipfile->create($dumpfile, PCLZIP_OPT_REMOVE_PATH, $datadir . '/' . $backupdir)) {
                    @unlink($dumpfile);
                    fclose(fopen($datadir . '/' . $backupdir . '/index.htm', 'a'));
                    showmessage('database_export_zip_succeed');
                } else {
                    showmessage('database_export_zip_error', $theurl);
                }
            } else {
                fclose(fopen($datadir . '/' . $backupdir . '/index.htm', 'a'));
                showmessage('database_export_succeed');
            }
        } else {
            showmessage('database_shell_faile', $theurl);
        }
    }
}
Exemplo n.º 4
0
        fclose($fp);
        deltree($datadir . '/' . $backupdir . '/');
        showmessage('file_write_error');
    } else {
        fclose($fp);
        $zipfilearr[] = $tablesqlfile;
    }
    if (!empty($dberrorarr)) {
        deltree($datadir . '/' . $backupdir . '/');
        showmessage($alang['list_table_not_exists'] . implode('<br />', $dberrorarr));
    }
    //´ò°ü
    require_once S_ROOT . './include/zip.lib.php';
    $zipfile = new Zip($backupfile);
    $zipfilestr = implode(',', $zipfilearr);
    $zipfile->create($zipfilestr, PCLZIP_OPT_REMOVE_PATH, $datadir . '/' . $backupdir);
    if (!empty($zipfilearr)) {
        foreach ($zipfilearr as $tmpvalue) {
            @unlink($tmpvalue);
        }
    }
    showmessage('model_export_suc', CPURL . '?action=models&op=import');
} elseif ($_GET['op'] == 'import') {
    if (!ckfounder($_SGLOBAL['supe_uid'])) {
        showmessage('no_authority_management_operation');
    }
    $backupdir = S_ROOT . '/data/model';
    $exportlog = array();
    $_GET['datafile'] = !empty($_GET['datafile']) ? trim($_GET['datafile']) : '';
    $_GET['do'] = !empty($_GET['do']) ? trim($_GET['do']) : '';
    if (empty($_GET['do']) || $_GET['do'] != 'start') {
Exemplo n.º 5
0
 /**
  *
  * @return Zip
  */
 public static function temp_zip()
 {
     return Zip::create(self::temp_file('zip'));
 }
Exemplo n.º 6
0
         } else {
             AdminServLogs::add('action', 'Insert map: ' . $map);
         }
     }
 } else {
     if (isset($_POST['downloadMap']) && isset($_POST['map']) && count($_POST['map']) > 0) {
         // Si on télécharge plusieurs fichiers, on envoi un zip
         $countMaps = count($_POST['map']);
         if ($countMaps > 1) {
             $struct = array();
             foreach ($_POST['map'] as $map) {
                 $struct[] = $data['mapsDirectoryPath'] . $map;
             }
             $zipError = null;
             $zipFileName = 'maps.zip';
             if (!Zip::create($zipFileName, $struct, $zipError)) {
                 AdminServ::error($zipError);
             } else {
                 File::download($zipFileName);
                 AdminServLogs::add('action', 'Download packmap (' . $countMaps . ' maps)');
                 if ($result = File::delete($zipFileName) !== true) {
                     AdminServ::error($result);
                 }
             }
         } else {
             File::download($data['mapsDirectoryPath'] . $_POST['map'][0]);
             AdminServLogs::add('action', 'Download map: ' . $_POST['map'][0]);
         }
     } else {
         if (isset($_POST['renameMapValid']) && isset($_POST['map']) && count($_POST['map']) > 0 && isset($_POST['renameMapList']) && count($_POST['renameMapList']) > 0) {
             $i = 0;