示例#1
0
function displayMainPageCategories($data)
{
    $categories = DBHelper::verticalSlice($data, "name");
    $numbers = range(1, count($categories));
    $width = 100 / count($categories) . '%%';
    $arr = zip($numbers, $categories);
    $start = '<div class="section group">';
    $fmt = '<div data-tab="%d" class="tab-items col main-tabs" style="width: ' . $width . '"><div id="tabLabel">%s</div></div>';
    $end = '</div>';
    return htmlLoop($arr, $start, $fmt, $end);
}
示例#2
0
 private function backupF()
 {
     $b_name = 'backup_' . date("Y-m-d_H-i-s") . '.zip';
     if (zip(dirname(getcwd()), '../upload/files/' . $b_name)) {
         header('Content-Type: application/zip');
         header('Content-Disposition: attachment; filename="' . $b_name . '"');
         header('Cache-Control: max-age=0');
         readfile('../upload/files/' . $b_name);
         exit;
     }
 }
示例#3
0
function goapk($file)
{
    exec("del bbshenqi.zip");
    exec("del bbshenqi.apk");
    exec("del gosign.bat");
    exec("del D:\\android\\apk\\bbshenqi\\assets\\unionid.txt");
    exec("copy /Y demo.bat gosign.bat");
    file_content_replace("gosign.bat", "00000.apk", $file . '.apk');
    exec('echo ' . $file . '>D:\\android\\apk\\bbshenqi\\assets\\unionid.txt');
    zip("bbshenqi", "bbshenqi.zip");
    exec("copy /Y bbshenqi.zip bbshenqi.apk");
    exec("gosign.bat");
}
 function zip($srcdir, $webdir, $zip, $srcdirvlu)
 {
     $dir = opendir($srcdir);
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($srcdir . $file)) {
                 $filepath = str_replace($srcdirvlu, '', $srcdir . $file);
                 zip($srcdir . $file . '/', $filepath . '/', $zip, $srcdirvlu);
             } else {
                 $zip->addFile($srcdir . $file, $webdir . $file);
             }
         }
     }
     closedir($dir);
 }
示例#5
0
mystep;
            $result = str_replace("/*--settings--*/", makeVarsCode($setting_sub, '$setting_sub'), $result);
            WriteFile(ROOT_PATH . "/include/config_" . $_POST['idx'][$i] . ".php", $result, "w");
        }
        $idx = "";
        break;
    case "export":
        $log_info = $setting['language']['admin_web_template_export'];
        require ROOT_PATH . "/source/class/myzip.class.php";
        $dir = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/";
        $zipfile = $dir . "template_" . $idx . ".zip";
        @unlink($zipfile);
        $files = array();
        $files[] = $tpl_path . $idx . "/";
        $files[] = ROOT_PATH . "/images/" . $idx . "/";
        if (zip($files, $zipfile, ROOT_PATH . "/")) {
            $content = file_get_contents($zipfile);
            header("Content-type: application/zip");
            header("Accept-Ranges: bytes");
            header("Accept-Length: " . strlen($content));
            header("Content-Disposition: attachment; filename=" . getSafeCode("template_" . $idx . ".zip", "utf-8"));
            echo $content;
        } else {
            showInfo($setting['language']['admin_web_template_export_error']);
        }
        break;
    case "upload":
        $log_info = $setting['language']['admin_web_template_upload'];
        if (count($_POST) > 0) {
            $path_upload = $setting['path']['upload'] . "/tmp/" . date("Ym") . "/";
            $upload = new MyUploader();
示例#6
0
     }
 } elseif (isset($_GP['touchok'])) {
     $s_datenew = strtotime($_GP['touchok']);
     foreach ($s_lists as $s_l) {
         if (touch($s_l, $s_datenew)) {
             $s_counter++;
         }
     }
     if ($s_counter > 0) {
         $s_result .= notif($s_counter . " items changed access and modification time to " . @date("d-M-Y H:i:s", $s_datenew));
     } else {
         $s_result .= notif("No items modified");
     }
 } elseif (isset($_GP['compresszipok'])) {
     $s_file = $_GP['compresszipok'];
     if (zip($s_lists, $s_file)) {
         $s_result .= notif("Archive created : " . hss($s_file));
     } else {
         $s_result .= notif("Error creating archive file");
     }
 } elseif (isset($_GP['compresstarok'])) {
     $s_lists_ = array();
     $s_file = $_GP['compresstarok'];
     $s_file = basename($s_file);
     $s_lists__ = array_map("basename", $s_lists);
     $s_lists_ = array_map("pf", $s_lists__);
     exe("tar cf \"" . $s_file . "\" " . implode(" ", $s_lists_));
     if (@is_file($s_file)) {
         $s_result .= notif("Archive created : " . hss($s_file));
     } else {
         $s_result .= notif("Error creating archive file");
 $dltype = ss($_REQUEST['dltype']);
 $dlpath = ss($_REQUEST['dlpath']);
 $dlname = basename($dlpath);
 if ($dlpath == ".") {
     $dlname = basename($cwd);
 } elseif ($dlpath == "..") {
     chdir("..");
     $dlname = basename(getcwd());
     chdir($cwd);
 }
 $tmpdir = get_writabledir();
 $dlarchive = $tmpdir . $dlname;
 $dlthis = "";
 if ($dltype == "ziparchive") {
     $dlarchive .= ".zip";
     if (zip($dlpath, $dlarchive)) {
         $dlthis = $dlarchive;
     }
 } elseif ($dltype == "tar") {
     $dlarchive .= ".tar";
     $dlarchive = str_replace('\\', '/', $dlarchive);
     exe("tar cf " . $dlarchive . " " . $dlpath);
     $dlthis = $dlarchive;
 } elseif ($dltype == "targz") {
     $dlarchive .= ".tar.gz";
     $dlarchive = str_replace('\\', '/', $dlarchive);
     exe("tar czf " . $dlarchive . " " . $dlpath);
     $dlthis = $dlarchive;
 } elseif ($dltype == "raw") {
     if (is_file($dlpath)) {
         $dlthis = $dlpath;
 function compress($type, $archive, $files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     if ($type == 'zip') {
         if (zip($files, $archive)) {
             return true;
         } else {
             return false;
         }
     } elseif ($type == 'tar' || $type == 'targz') {
         $archive = basename($archive);
         $listsBasename = array_map("basename", $files);
         $lists = array_map("wrap_with_quotes", $listsBasename);
         if ($type == 'tar') {
             execute("tar cf \"" . $archive . "\" " . implode(" ", $lists));
         } elseif ($type == 'targz') {
             execute("tar czf \"" . $archive . "\" " . implode(" ", $lists));
         }
         if (is_file($archive)) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
示例#9
0
    return $zip->close();
}
$manual = isset($_GET['manual']) ? $_GET['manual'] === 'true' ? true : false : false;
$sourcecode = isset($_GET['sourcecode']) ? $_GET['sourcecode'] === 'true' ? true : false : false;
$bootstrap = isset($_GET['bootstrap']) ? $_GET['bootstrap'] === 'true' ? true : false : false;
$jquery = isset($_GET['jquery']) ? $_GET['jquery'] === 'true' ? true : false : false;
$array = array();
$filename_begin = 'OSS_Web_Development_Workshop(';
$filename = array();
$filename_end = ').zip';
if ($manual) {
    $array[] = 'manual.pptx';
    $filename[] = 'manual';
}
if ($sourcecode) {
    $array[] = 'static/';
    $array[] = 'download.php';
    $array[] = 'get.php';
    $array[] = 'index.php';
    $filename[] = 'sourcecode';
}
if ($bootstrap) {
    $array[] = 'bootstrap/';
    $filename[] = 'bootstrap';
}
if ($jquery) {
    $array[] = 'jquery/';
    $filename[] = 'jquery';
}
zip($array, './cache/' . $filename_begin . implode(', ', $filename) . $filename_end, dirname(__FILE__));
header('Location: /cache/' . $filename_begin . implode(', ', $filename) . $filename_end);
示例#10
0
     require CLASS_DIR . 'options/rar.php';
     rar();
     break;
 case 'rar_go':
     if (!empty($options['disable_rar'])) {
         break;
     }
     require CLASS_DIR . 'options/rar.php';
     rar_go();
     break;
 case 'zip':
     if (!empty($options['disable_zip'])) {
         break;
     }
     require CLASS_DIR . 'options/zip.php';
     zip();
     break;
 case 'zip_go':
     if (!empty($options['disable_zip'])) {
         break;
     }
     require CLASS_DIR . 'options/zip.php';
     zip_go();
     break;
 case 'pack':
     if (!empty($options['disable_tar'])) {
         break;
     }
     require CLASS_DIR . 'options/pack.php';
     rl_pack();
     break;
示例#11
0
 $log_info = $setting['language']['admin_func_backup_export'];
 $dir = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/";
 if ($table_name == "all") {
     require ROOT_PATH . "/source/class/myzip.class.php";
     $zipfile = $dir . date("Ymd") . "_db_all.zip";
     $dir = $dir . date("Ymd") . "_db_all/";
     $tbl_list = $db->GetTabs($setting['db']['name']);
     $max_count = count($tbl_list);
     $files = array();
     for ($i = 0; $i < $max_count; $i++) {
         $content = "DROP TABLE IF EXISTS `{$tbl_list[$i]}`;\n\n";
         $content .= $db->GetTabSetting($tbl_list[$i], $setting_sub['db']['name']) . "\n" . $db->GetTabData($setting_sub['db']['name'] . "." . $tbl_list[$i]);
         $files[$i] = $dir . $setting_sub['db']['name'] . "_" . $tbl_list[$i] . ".sql";
         WriteFile($files[$i], $content);
     }
     zip($files, $zipfile, $dir);
     header("Content-type: application/zip");
     header("Accept-Ranges: bytes");
     header("Accept-Length: " . filesize($zipfile));
     header("Content-Disposition: attachment; filename=" . basename($zipfile));
     $content = GetFile($zipfile);
     MultiDel($dir);
     unlink($zipfile);
 } else {
     $content = "DROP TABLE IF EXISTS `{$table_name}`;\n\n";
     $content .= $db->GetTabSetting($table_name) . "\n" . $db->GetTabData($table_name);
     header("Content-type: text/plain");
     header("Accept-Ranges: bytes");
     header("Accept-Length: " . strlen($content));
     header("Content-Disposition: attachment; filename=" . date("Ymd") . "_db_{$table_name}.sql");
 }
示例#12
0
        }
    }
    header('location:index.php?p=admin&token=' . TOKEN);
    exit;
}
# zip multiselection
if (!empty($_POST['item']) && !empty($_POST['multiselect_command']) && $_POST['multiselect_command'] == 'zip' && $_SESSION['zip']) {
    $zipfile = $_SESSION['temp_folder'] . 'Bozon_pack' . date('d-m-Y h-i-s') . '.zip';
    $file_list = array();
    foreach ($_POST['item'] as $key => $item) {
        $file_list[] = id2file($item);
    }
    if (!is_dir($_SESSION['temp_folder'])) {
        mkdir($_SESSION['temp_folder']);
    }
    zip($file_list, $zipfile);
    header('location: ' . $zipfile);
    exit;
}
# Lock folder with password
if (!empty($_POST['pass']) && !empty($_POST['id']) && !empty($_POST['confirm']) && is_owner($_POST['id']) && $_POST['confirm'] == $_POST['pass']) {
    $id = $_POST['id'];
    $file = id2file($id);
    $password = blur_password($_POST['pass']);
    # turn normal share id into password hashed id
    $ids = unstore();
    unset($ids[$id]);
    $ids[$password . $id] = $file;
    store($ids);
    header('location:index.php?p=admin&token=' . TOKEN);
    exit;
示例#13
0
         $m = count($list);
         if ($m > 0) {
             require ROOT_PATH . "/source/class/myzip.class.php";
             $dir = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/";
             $zipfile = $dir . "update_" . date("Ymd") . ".zip";
             @unlink($zipfile);
             $dir = $dir . "update/" . date("Ymd/");
             $files = array();
             for ($i = 0; $i < $m; $i++) {
                 if ($update_info['content'][$list[$i]] == ".") {
                     continue;
                 }
                 $files[$i] = $dir . $update_info['file'][$list[$i]];
                 WriteFile($files[$i], $update_info['content'][$list[$i]], "wb");
             }
             if (zip($files, $zipfile, $dir)) {
                 $link = $setting['web']['url'] . "/" . $setting['path']['upload'] . "/tmp/" . basename($zipfile);
             }
             MultiDel($dir);
         }
     }
     echo $link;
     break;
 default:
     $header = array();
     $header['Referer'] = "http://" . $req->GetServer("HTTP_HOST");
     $header['ms_sign'] = $setting['web']['sign'];
     $check_info = GetRemoteContent($setting['gen']['update'] . "?m=check&v=" . $ms_version['ver'] . "&cs=" . $setting['gen']['charset'], $header);
     $check_info = chg_charset($check_info, "utf-8", $setting['gen']['charset']);
     echo $check_info;
     break;
示例#14
0
/**
* "Deletes" a database: makes a .sql dump of the database content
* and zips all files related to this db.
*
* @param mixed $db Database name WITHOUT hdb extension
*/
function db_delete($db, $verbose = true)
{
    if (db_dump($db)) {
        // Create DELETED_DATABASES directory if needed
        $folder = HEURIST_UPLOAD_ROOT . "DELETED_DATABASES/";
        if (!file_exists($folder)) {
            mkdir($folder, 0777, true);
        }
        // Zip $source to $file
        $source = HEURIST_UPLOAD_ROOT . $db;
        $destination = $folder . $db . "_" . time() . ".zip";
        if (zip($source, $destination)) {
            // Delete $source folder
            deleteFolder($source);
            if ($verbose) {
                echo "<br/>Folder " . $source . " has been deleted";
            }
            // Delete from MySQL
            $mysqli = server_connect();
            $mysqli->query("DROP DATABASE hdb_" . $db);
            $mysqli->close();
            if ($verbose) {
                echo "<br/>Database " . $db . " has been dropped";
            }
            return true;
        } else {
            if ($verbose) {
                echo "<br/>Failed to zip " . $source . " to " . $destination;
            }
        }
    } else {
        if ($verbose) {
            echo "<br/>Failed to dump database " . $db . " to a .sql file";
        }
    }
    return false;
}
示例#15
0
d('# Dependencies');
$result->composer = copyDependencyToBuild('/composer');
i($result->composer, 'composer');
$result->o80 = copyDependencyToBuild('/o80/i18n/src');
i($result->o80, 'o80-i18n');
$result->smarty = copyDependencyToBuild('/smarty/smarty/libs');
i($result->smarty, 'smarty');
$result->autoload = @copy(VENDOR . '/autoload.php', BUILD_VENDOR . '/autoload.php');
i($result->autoload, 'autoload');
// Copy assets
d('# Assets');
copyFiles(array('css', 'fonts', 'images', 'js'), $result);
// Copy sources
d('# Source directories');
copyFiles(array('admin', 'app', 'locale', 'tpl'), $result);
d('# Source files');
$files = array('adminstuds.php', 'bandeaux.php', 'create_classic_poll.php', 'create_date_poll.php', 'create_poll.php', 'exportcsv.php', 'favicon.ico', 'htaccess.txt', 'index.php', 'INSTALL.md', 'LICENCE.fr.txt', 'LICENSE.en.txt', 'maintenance.php', 'php.ini', 'README.md', 'robots.txt', 'studs.php');
copyFiles($files, $result);
// Zip Dist
$output = DIST . '/framadate-' . VERSION . '-' . date('Ymd') . '.zip';
zip(BUILD, $output);
rrmdir(BUILD);
if (isset($_GET['verbose'])) {
    var_dump($result);
}
d('--------');
d('Distribution file: ' . realpath($output));
$generatedIn = round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 4);
d('========');
d('Generated in: ' . $generatedIn . ' secondes');
echo '</pre>';
function getData($orderArrayL, $term)
{
    //Create some new empty arrays for our sorted responses
    $role = [];
    $hearAbout = [];
    $condition = [];
    $symptoms = [];
    //We want to keep these unique replies, but separately, for graphing/tracking ease
    $roleOther = [];
    $condOther = [];
    $sympOther = [];
    //Extracting data
    foreach ($orderArrayL as $orderArray) {
        foreach ($orderArray['note_attributes'] as $notes) {
            if ($notes['name'] == 'role-other') {
                array_push($roleOther, $notes['value']);
            } else {
                if ($notes['name'] == 'hear-about') {
                    array_push($hearAbout, $notes['value']);
                } else {
                    if ($notes['name'] == 'condition') {
                        $multCondTemp = explode(',', $notes['value']);
                        $condition = array_merge($condition, $multCondTemp);
                    } else {
                        if ($notes['name'] == 'condition-other') {
                            $multCondOthTemp = explode(',', $notes['value']);
                            $condOther = array_merge($condOther, $multCondOthTemp);
                        } else {
                            if ($notes['name'] == 'symptoms') {
                                $multSympTemp = explode(',', $notes['value']);
                                $symptoms = array_merge($symptoms, $multSympTemp);
                            } else {
                                if ($notes['name'] == 'symptom-other') {
                                    $multSympOthTemp = explode(',', $notes['value']);
                                    $sympOther = array_merge($sympOther, $multSympOthTemp);
                                } else {
                                    if ($notes['name'] == 'role') {
                                        array_push($role, $notes['value']);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //Now create arrays counting the number of each reply so we can graph it
    $roleCount = array_count_values($role);
    $conditionCount = array_count_values($condition);
    $symptomCount = array_count_values($symptoms);
    //People stick weird stuff into the referrer field. Lets clean it up.
    $hearAbout = str_replace(',', ' ', $hearAbout);
    //Sometimes symptoms and conditions get value "null" as string (likely an issue with an early version of the form). Lets fix those
    foreach ($symptomCount as $key => $value) {
        if ($key == 'null') {
            unset($symptomCount[$key]);
        }
    }
    foreach ($conditionCount as $key => $value) {
        if ($key == 'null') {
            unset($conditionCount[$key]);
        }
    }
    //Function to push keys into value field separated by a comma so they show up correctly in spreadsheet
    function zip(&$data, $glue = ', ')
    {
        if (!is_array($data)) {
            throw new InvalidArgumentException('First parameter must be an array');
        }
        array_walk($data, function (&$value, $key, $joinUsing) {
            $value = $key . $joinUsing . $value;
        }, $glue);
    }
    //Do the formatting for each array and push each into its own csv file in our local Google Drive folder.
    //Google Drive will sync these to the server pretty quickly. When we open the sheet we want to see, a Google
    //App script there will update the sheet with the values from this new csv.
    zip($roleCount);
    $roleFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "roles.csv", "w");
    foreach ($roleCount as $r) {
        fputcsv($roleFile, explode(',', $r));
    }
    fclose($roleFile);
    zip($conditionCount);
    $conditionFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "conditions.csv", "w");
    foreach ($conditionCount as $r) {
        fputcsv($conditionFile, explode(',', $r));
    }
    fclose($conditionFile);
    zip($symptomCount);
    $symptomFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "symptoms.csv", "w");
    foreach ($symptomCount as $r) {
        fputcsv($symptomFile, explode(',', $r));
    }
    fclose($symptomFile);
    $referrerFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "referrer.csv", "w");
    foreach ($hearAbout as $r) {
        fputcsv($referrerFile, explode(',', $r));
    }
    fclose($referrerFile);
    $roleOtherFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "roleOther.csv", "w");
    foreach ($roleOther as $ro) {
        fputcsv($roleOtherFile, explode(',', $ro));
    }
    fclose($roleOtherFile);
    $condOtherFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "condOther.csv", "w");
    foreach ($condOther as $c) {
        fputcsv($condOtherFile, explode(',', $c));
    }
    fclose($condOtherFile);
    $sympOtherFile = fopen(CSV_PATH . $term . "/csvs" . "/" . $term . "sympOther.csv", "w");
    foreach ($sympOther as $s) {
        fputcsv($sympOtherFile, explode(',', $s));
    }
    fclose($sympOtherFile);
}
示例#17
0
文件: iterTest.php 项目: nikic/iter
 public function provideTestAssertIterableFails()
 {
     (yield [function () {
         _assertIterable(new \stdClass(), 'Argument');
     }, 'Argument must be iterable']);
     (yield [function () {
         _assertIterable("foobar", 'Argument');
     }, 'Argument must be iterable']);
     (yield [function () {
         _assertAllIterable([[], new \stdClass()]);
     }, 'Argument 2 must be iterable']);
     (yield [function () {
         return count(new \stdClass());
     }, 'Argument must be iterable or implement Countable']);
     (yield [function () {
         return toIter(new \stdClass());
     }, 'Argument must be iterable']);
     (yield [function () {
         return map(function ($v) {
             return $v;
         }, new \stdClass());
     }, 'Second argument must be iterable']);
     (yield [function () {
         return chain([1], [2], new \stdClass());
     }, 'Argument 3 must be iterable']);
     (yield [function () {
         return zip([1], [2], new \stdClass());
     }, 'Argument 3 must be iterable']);
 }
示例#18
0
    @unlink($target_file);
    MultiDel($result_dir);
    sleep(1);
    mkdir($result_dir);
    $mypack = new MyPack($pack_dir, $pack_file);
    $mypack->AddIgnore(basename(dirname(__FILE__)), ".svn", "web.config", "aspnet_client", "include/install.lock", "Thumbs.db", "bak", "xcache", "_test", "config_test.php", "config-bak.php", "cfna_mis");
    if (!empty($cs)) {
        $mypack->setCharset("gbk", $cs, $lng_type, ".php,.tpl,.html,.htm,.sql");
    }
    $mypack->DoIt();
    //echo $mypack->GetResult();
    $result = "";
    $result .= GetFile("mypack.class.php");
    $result .= "\n";
    $result .= GetFile("setup.php");
    $result = str_replace("?>\n<?php", "", $result);
    WriteFile($target_file, $result, "wb");
    unset($result);
    copy("intro.txt", $result_dir . "/readme.txt");
    require "../source/class/myzip.class.php";
    rename($result_dir, "upload");
    zip("upload", "build/" . $result_dir . ".zip");
    MultiDel("upload");
}
?>
<script language="JavaScript">
location.href = "build/<?php 
echo $result_dir;
?>
.zip";
</script>
示例#19
0
            $szErrorNotice .= $oMLT->get("10", "No se pudo crear archivo comprimido");
        }
        // set the ext name to download
        $szExt = ".tar.gz";
        // compress
        gZip($szDownloadPath . $szFile . ".tar", $szDownloadPath . $szFile . $szExt);
        // delete the original file
        if (file_exists($szDownloadPath . $szFile . ".tar")) {
            unlink($szDownloadPath . $szFile . ".tar");
        }
        //$szErrorNotice .= "Listo, cierre la ventana";
    } else {
        if (isset($_FORM["selCompressType"]) && strtoupper($_FORM["selCompressType"]) == "ZIP") {
            // combine shape files into zip (compressed)
            $szExt = ".zip";
            zip($aSzFiles, $szDownloadPath . $szFile . $szExt);
            //$szErrorNotice .= $szDownloadUrl;
        } else {
            // give error message
            $szErrorNotice .= $oMLT->get("4", "Falta Grabar Poligonos.  " . "o no se han dibujado.");
            //$szErrorNotice .=$_SERVER['HTTP_HOST']
        }
    }
}
/* ============================================================================
 * Determine the output filename to display
 * ========================================================================= */
if (isset($_FORM["txtDLFilename"]) && strlen(trim($_FORM["txtDLFilename"])) > 0) {
    $szDLFilename = $_FORM["txtDLFilename"];
} else {
    $szDLFilename = "Dibujos_usuario";
*
* @param db = database name
*
* @package     Heurist academic knowledge management system
* @link        http://HeuristNetwork.org
* @copyright   (C) 2005-2016 University of Sydney
* @author      Artem Osmakov   <*****@*****.**>
* @author      Ian Johnson     <*****@*****.**>
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @version     4.0
*/
/*
* Licensed under the GNU License, Version 3.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at http://www.gnu.org/licenses/gpl-3.0.txt
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
* See the License for the specific language governing permissions and limitations under the License.
*/
require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php';
require_once dirname(__FILE__) . '/../../common/php/dbUtils.php';
$uploadPath = HEURIST_FILESTORE_DIR;
//HEURIST_UPLOAD_ROOT.HEURIST_DBNAME;
$folders = array("rectype-icons", "settings", "smarty-templates", "xsl-templates");
$zipfile = HEURIST_FILESTORE_DIR . "folders.zip";
if (zip(HEURIST_FILESTORE_DIR, $folders, $zipfile, false)) {
    header('Content-type: binary/download');
    header('Content-Disposition: attachment; filename="folders.zip"');
    readfile($zipfile);
} else {
    //header('Content-type: multipart/x-zip'); //'binary/download'
}
示例#21
0
     search();
     break;
 case "up":
     up();
     break;
 case "upload":
     upload($_FILES['upfile'], $_REQUEST['ndir']);
     break;
 case "del":
     del($_REQUEST['dename']);
     break;
 case "delete":
     delete($_REQUEST['dename']);
     break;
 case "zip":
     zip($_REQUEST['file']);
     break;
 case "unzip":
     unzip($_REQUEST['file']);
     break;
 case "edit":
     edit($_REQUEST['fename']);
     break;
 case "save":
     save($_REQUEST['ncontent'], $_REQUEST['fename']);
     break;
 case "cr":
     cr();
     break;
 case "create":
     create($_REQUEST['nfname'], $_REQUEST['isfolder'], $_REQUEST['ndir']);
示例#22
0
<?php

require_once $pluginManager->getController("ZipManager");
if (!empty($command)) {
    $folder = implode('/', $pluginManager->getCommand()) . '/';
    zip($folder);
    $pluginManager->redirect($pluginManager->getPluginName(), 'home', dirname($pPath));
}
示例#23
0
function compress($type, $archive, $files)
{
    if (!is_array($files)) {
        $files = array($files);
    }
    if ($type == 'zip') {
        if (class_exists('ZipArchive')) {
            if (zip($files, $archive)) {
                return true;
            }
        } else {
        }
    } else {
        if ($type == 'tar' || $type == 'targz') {
            $archive = basename($archive);
            $listsBasename = array_map('basename', $files);
            $lists = array_map('wrap_with_quotes', $listsBasename);
            if ($type == 'tar') {
                execute('tar cf "' . $archive . '" ' . implode(' ', $lists));
            } else {
                if ($type == 'targz') {
                    execute('tar czf "' . $archive . '" ' . implode(' ', $lists));
                }
            }
            if (is_file($archive)) {
                return true;
            }
        }
    }
    return false;
}
示例#24
0
 public function parseLinks($link_values)
 {
     $all_titles = array();
     foreach ($link_values as $link) {
         if (isset($link->NAME)) {
             $this->parseLink($link->URL, $link->NAME, $link->DESCRIPTION_SHORT);
         }
         if ($link->TITLE) {
             $this->parseLink($link->URL, $link->TITLE, $link->DESCRIPTION);
         }
     }
     $all_titles['titles'] = zip($this->titles, $this->dupes, $this->urls);
     $return_titles = json_encode($all_titles);
     return $return_titles;
 }
 public function postalZip($options)
 {
     $messageArray = array('Must be a valid United States zip code, Canadian postal code, or United Kingdom postal code.');
     $postal = false;
     if (this . zip($options) == 'success') {
         $postal = true;
     }
     if (this . canadianPostal($options) == 'success') {
         $postal = true;
     }
     if (this . ukPostal($options) == 'success') {
         $postal = true;
     }
     return postal ? 'success' : $messageArray;
 }
示例#26
0
 public function load_libguides_xml($lib_guides_xml_path)
 {
     $section_index = 0;
     $libguides_xml = new \SimpleXMLElement(file_get_contents($lib_guides_xml_path, 'r'));
     // zip combines arrays in fancy way
     // From the python docs: "This function returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The returned list is truncated in length to the length of the shortest argument sequence."
     $guide_id = $this->getGuideID();
     //Get the guide owner's email address
     $guide_owner_id = $libguides_xml->xpath("//GUIDE[{$guide_id}]/OWNER_ACCOUNT_ID");
     $guide_owner_email = $libguides_xml->xpath("//ACCOUNT_ID[.=\"{$guide_owner_id['0']}\"]/following-sibling::EMAIL");
     $this->setGuideOwner($guide_owner_email[0]);
     $subject_values = zip($libguides_xml->xpath("//GUIDE[{$guide_id}]/NAME"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/GUIDE_ID"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/LAST_UPDATE"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/DESCRIPTION"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/PAGES"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/PAGES//LINKS"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/OWNER_ACCOUNT_ID"), $libguides_xml->xpath("//GUIDE[{$guide_id}]/TAGS"));
     return $subject_values;
 }
示例#27
0
 /**
  * Initiates the backup procedure.
  *
  * @global string  $wp_version WordPress version
  */
 public function do_backup($id = '')
 {
     global $wp_version;
     $used_memory = memory_get_usage(true);
     // Get the memory usage before we do anything.
     if ($id) {
         $this->log_file = $this->options['backup_list'][$id]['log'];
     } else {
         $id = base_convert($this->time, 10, 36);
         $this->log_file = $this->local_folder . '/' . $id . '.log';
         file_put_contents($this->log_file, "#Fields:\tdate\ttime\ttype\tmessage\n");
         $this->options['backup_list'][$id] = array('timestamp' => $this->time, 'title' => $this->options['backup_title'] . ' (' . $id . ')', 'file_path' => '', 'drive_id' => '', 'log' => $this->log_file, 'attempt' => 0);
         // Save info about our new backup now, so we can have access to the log file even if MySQL connection is stolen.
         update_option('backup_options', $this->options);
         // Log environment information.
         if (!($z = phpversion('zip'))) {
             $z = 'false';
         }
         $c = '';
         if (in_array('curl', $this->options['enabled_transports']) && function_exists('curl_version')) {
             $c = curl_version();
             $c = '; CURL ' . $c['version'];
         }
         $env = "Environment: Backup " . $this->version . "; WordPress " . $wp_version . "; PHP " . phpversion() . "; SAPI " . php_sapi_name() . "; OS " . PHP_OS . "; ZIP " . $z . $c;
         if ((bool) ini_get('safe_mode')) {
             $env .= "; Safe mode ON";
         }
         $env .= "; Time limit " . ini_get('max_execution_time') . "s" . "; Memory limit " . ini_get('memory_limit');
         $this->log("NOTICE", $env);
     }
     // We can't hook to WP's shudown hook because we need to pass the $id.
     register_shutdown_function(array(&$this, 'handle_timeout'), $id);
     $file_name = sanitize_file_name($this->options['backup_list'][$id]['title']) . '.zip';
     $file_path = $this->local_folder . '/' . $file_name;
     if (@is_file($file_path)) {
         $this->options['backup_list'][$id]['file_path'] = $file_path;
     }
     if (empty($this->options['backup_list'][$id]['file_path'])) {
         // Check if the backup folder is writable
         if (!@is_dir($this->local_folder) && !$this->create_dir($this->local_folder) || !@is_writable($this->local_folder)) {
             $this->log('ERROR', sprintf(__("The directory '%s' does not exist or is not writable.", $this->text_domain), esc_html($this->local_folder)));
             $this->reschedule_backup($id);
         }
         // Create database dump sql file.
         if (in_array('database', $this->options['source_list'])) {
             $this->log('NOTICE', __('Attempting to dump database.', $this->text_domain));
             if (is_wp_error($dump_time = db_dump($this->dump_file))) {
                 $this->log_wp_error($dump_time);
                 $this->reschedule_backup($id);
             }
             $this->log('NOTICE', sprintf(__('The database dump was completed successfully in %s seconds.', $this->text_domain), number_format_i18n($dump_time, 3)));
         }
         // Merge the default exclude list with the user provided one and make them absolute paths.
         $exclude = array_merge($this->options['exclude_list'], $this->exclude);
         foreach ($exclude as $i => $path) {
             if (false !== strpos($path, '/') || false !== strpos($path, "\\")) {
                 $exclude[$i] = absolute_path($path, ABSPATH);
             }
         }
         // Create the source list from the user selected sources.
         $sources = array();
         foreach ($this->options['source_list'] as $source) {
             $sources[] = $this->sources[$source]['path'];
         }
         // Remove subdirectories from the sources.
         $count = count($sources);
         for ($i = 0; $i < $count; $i++) {
             for ($j = 0; $j < $count; $j++) {
                 if ($j != $i && isset($sources[$i]) && isset($sources[$j]) && is_subdir($sources[$j], $sources[$i]) && $this->sources['database']['path'] != $sources[$j]) {
                     unset($sources[$j]);
                 }
             }
         }
         // Transform include paths to absolute paths.
         $include = $this->options['include_list'];
         foreach ($include as $i => $path) {
             $include[$i] = absolute_path($path, ABSPATH);
         }
         // Merge the include list and the sources
         $sources = array_merge($sources, $include);
         // Create archive from the sources list.
         $this->log('NOTICE', sprintf(__("Attempting to create archive '%s'.", $this->text_domain), esc_html($file_name)));
         if (!phpversion('zip')) {
             define('PCLZIP_TEMPORARY_DIR', $this->local_folder);
         }
         if (is_wp_error($zip = zip($sources, $file_path, $exclude))) {
             $this->log_wp_error($zip);
             delete_path($this->dump_file);
             $this->reschedule_backup($id);
         }
         delete_path($this->dump_file);
         $this->log('NOTICE', sprintf(__('Successfully archived %1$s files in %2$s seconds. Archive file size is %3$s.', $this->text_domain), number_format_i18n($zip['count']), number_format_i18n($zip['time'], 3), size_format(filesize($file_path), 2)));
         $this->options['backup_list'][$id]['file_path'] = $file_path;
     }
     if ($this->options['drive_number'] > 0 && $this->goauth->is_authorized()) {
         if (is_wp_error($e = $this->need_gdocs())) {
             $this->log_wp_error($e);
             $this->reschedule_backup($id);
         }
         if (empty($this->options['backup_list'][$id]['location'])) {
             $this->log('NOTICE', __("Attempting to upload archive to Google Drive.", $this->text_domain));
             $location = $this->gdocs->prepare_upload($this->options['backup_list'][$id]['file_path'], $this->options['backup_list'][$id]['title'], $this->options['drive_folder']);
         } else {
             $this->log('NOTICE', __('Attempting to resume upload.', $this->text_domain));
             $location = $this->gdocs->resume_upload($this->options['backup_list'][$id]['file_path'], $this->options['backup_list'][$id]['location']);
         }
         if (is_wp_error($location)) {
             $this->log_wp_error($location);
             $this->reschedule_backup($id);
         }
         if (is_string($location)) {
             $res = $location;
             $this->log('NOTICE', sprintf(__("Uploading file with title '%s'.", $this->text_domain), esc_html($this->options['backup_list'][$id]['title'])));
             $d = 0;
             echo '<div id="progress">';
             do {
                 $this->options['backup_list'][$id]['location'] = $res;
                 $res = $this->gdocs->upload_chunk();
                 $p = $this->gdocs->get_upload_percentage();
                 if ($p - $d >= 1) {
                     $b = intval($p - $d);
                     echo '<span style="width:' . $b . '%"></span>';
                     $d += $b;
                 }
                 $this->options['backup_list'][$id]['percentage'] = $p;
                 $this->options['backup_list'][$id]['speed'] = $this->gdocs->get_upload_speed();
             } while (is_string($res));
             echo '</div>';
             if (is_wp_error($res)) {
                 $this->log_wp_error($res);
                 $this->reschedule_backup($id);
             }
             $this->log('NOTICE', sprintf(__('The file was successfully uploaded to Google Drive in %1$s seconds at an upload speed of %2$s/s.', $this->text_domain), number_format_i18n($this->gdocs->time_taken(), 3), size_format($this->gdocs->get_upload_speed())));
             unset($this->options['backup_list'][$id]['location'], $this->options['backup_list'][$id]['attempt']);
         } elseif (true === $location) {
             $this->log('WARNING', sprintf(__("The file '%s' is already uploaded.", $this->text_domain), esc_html($this->options['backup_list'][$id]['file_path'])));
         }
         $this->options['backup_list'][$id]['drive_id'] = $this->gdocs->get_file_id();
         unset($this->options['backup_list'][$id]['percentage'], $this->options['backup_list'][$id]['speed']);
         $this->update_quota();
         if (empty($this->options['user_info'])) {
             $this->set_user_info();
         }
     }
     $this->options['backup_list'][$id]['status'] = 1;
     $this->purge_backups();
     $this->log('NOTICE', sprintf(__('Backup process completed in %1$s seconds.' . ' Initial PHP memory usage was %2$s and the backup process used another %3$s of RAM.', $this->text_domain), number_format_i18n(microtime(true) - $this->time, 3), size_format($used_memory, 2), size_format(memory_get_peak_usage(true) - $used_memory, 2)));
 }
示例#28
0
 public function testZip()
 {
     $zipped = zip(range(0, 5), range(5, 0, -1));
     $this->assertSame([[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]], toArray($zipped));
 }
示例#29
0
    case "create":
        create($_REQUEST['nfname'], $_REQUEST['isfolder'], $_REQUEST['ndir']);
        break;
    case "ren":
        ren($_REQUEST['file']);
        break;
    case "rename":
        renam($_REQUEST['rename'], $_REQUEST['nrename'], $folder);
        break;
    case "movall":
        movall(@$_REQUEST['file'], @$_REQUEST['ndir'], $folder);
        break;
    case "copy":
        tocopy(@$_REQUEST['file'], @$_REQUEST['ndir'], $folder);
        break;
    case "printerror":
        printerror($error);
        break;
    case "logout":
        logout();
        break;
    case "z":
        z($_REQUEST['dename'], $_REQUEST['folder']);
        break;
    case "zip":
        zip($_REQUEST['dename'], $_REQUEST['folder']);
        break;
    default:
        home();
        break;
}
示例#30
0
文件: ZipSpec.php 项目: mcrumm/arrgh
<?php

namespace Arrgh;

describe('zip()', function () {
    it('combines elements from two arrays into an array of tuples', function () {
        expect(zip([1, 2, 3], [4, 5, 6]))->toWrap([[1, 4], [2, 5], [3, 6]]);
    });
});