errorInfo() public method

--------------------------------------------------------------------------------
public errorInfo ( $p_full = false )
Exemplo n.º 1
2
function create_zip($themeName)
{
    $exclude_files = array('.', '..', '.svn', 'thumbs.db', '!sources', 'style.less.cache', 'bootstrap.less.cache', '.gitignore', '.git');
    $all_themes_dir = str_replace('\\', '/', get_theme_root());
    $backup_dir = str_replace('\\', '/', WP_CONTENT_DIR) . '/themes_backup';
    $zip_name = $backup_dir . "/" . $themeName . '.zip';
    $backup_date = date("F d Y");
    if (is_dir($all_themes_dir . "/" . $themeName)) {
        $file_string = scan_dir($all_themes_dir . "/" . $themeName, $exclude_files);
    }
    if (function_exists('wp_get_theme')) {
        $backup_version = wp_get_theme($themeName)->Version;
    } else {
        $backup_version = get_current_theme($themeName)->Version;
    }
    if (!is_dir($backup_dir)) {
        if (mkdir($backup_dir, 0700)) {
            $htaccess_file = fopen($backup_dir . '/.htaccess', 'a');
            $htaccess_text = 'deny from all';
            fwrite($htaccess_file, $htaccess_text);
            fclose($htaccess_file);
        }
    }
    $zip = new PclZip($zip_name);
    if ($zip->create($file_string, PCLZIP_OPT_REMOVE_PATH, $all_themes_dir . "/" . $themeName) == 0) {
        die("Error : " . $zip->errorInfo(true));
    }
    update_option($themeName . "_date_backup", $backup_date, '', 'yes');
    update_option($themeName . "_version_backup", $backup_version, '', 'yes');
    echo $backup_date . "," . $backup_version;
}
Exemplo n.º 2
0
 function toSCO()
 {
     $deck_id = $_GET['deck_id'];
     if (isset($_GET['format'])) {
         $format = $_GET['format'];
     } else {
         $format = 'scorm2004_3rd';
     }
     $scorm = new Scorm();
     $scorm->create($deck_id, $format);
     $deck_name = $scorm->root_deck_name;
     $archive = new PclZip($deck_name . '.zip');
     //adding sco universal metadata
     $v_list = $archive->create(ROOT . DS . 'libraries' . DS . 'backend' . DS . $format, PCLZIP_OPT_REMOVE_PATH, ROOT . DS . 'libraries' . DS . 'backend' . DS . $format, PCLZIP_OPT_ADD_TEMP_FILE_ON);
     if ($v_list == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     //adding sco from tmp
     $v_list = $archive->add(ROOT . DS . 'tmp' . DS . $deck_name, PCLZIP_OPT_REMOVE_PATH, ROOT . DS . 'tmp' . DS . $deck_name, PCLZIP_OPT_ADD_TEMP_FILE_ON);
     if ($v_list == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     $archive->force_download();
     chmod(ROOT . DS . $deck_name . '.zip', 0777);
     unlink(ROOT . DS . $deck_name . '.zip');
     $this->RemoveDir(ROOT . DS . 'tmp' . DS . $deck_name);
 }
function rex_a22_extract_archive($file, $destFolder = null)
{
    global $REX;
    if (!$destFolder) {
        $destFolder = '../files/' . $REX['TEMP_PREFIX'] . '/addon_framework';
    }
    $archive = new PclZip($file);
    if ($archive->extract(PCLZIP_OPT_PATH, $destFolder) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    if (($list = $archive->listContent()) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    echo '<div style="height:200px;width:770px;overflow:auto;margin-bottom:10px;text-align:center;">';
    echo '<h3>Archiv wird extrahiert...</h3>';
    echo '<table border="1" style="margin:0 auto 0 auto;">';
    echo '<tr><th>Datei</th><th>Gr&ouml;&szlig;e</th>';
    for ($i = 0; $i < count($list); $i++) {
        echo '<tr>';
        echo '<td>' . $list[$i]['filename'] . '</td><td>' . $list[$i]['size'] . ' bytes</td>';
        echo '</tr>';
    }
    echo '</table>';
    echo '</div>';
}
function rex_a52_extract_archive($file, $msg = '', $path = '../files/tmp_')
{
    $archive = new PclZip($file);
    if ($archive->extract(PCLZIP_OPT_PATH, $path) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    if (($list = $archive->listContent()) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
}
 function unzip($zipfile, $destination_dir = false, $delete_old_dir = false)
 {
     //We check if the previous folder needs to be removed. If so, we do it with deltree() function that recursively deletes all files and then the empty folders from the target folder. if no destination_dir, then ignore this section.
     if ($destination_dir && $delete_old_dir) {
         if (file_exists($destination_dir)) {
             if (!is_writable($destination_dir)) {
                 $this->create_error("Error in deleting the old directory. Missing write permissions in '" . $destination_dir . "'");
             } else {
                 $this->deltree($destination_dir);
             }
         }
     }
     //if destination url, we need to check if it's there and writable, if now, we are going to make it. This script is meant to make the final directory, it will not create the necessary tree up the the folder.
     if (!$this->error() && $destination_dir) {
         if (file_exists($destination_dir)) {
             if (!is_writable($destination_dir)) {
                 $this->create_error("Missing write permissions in '" . $destination_dir . "'");
             }
         } else {
             if (!mkdir($destination_dir, 0775)) {
                 $this->create_error("Unable to create directory '" . $destination_dir . "'. Check writing permissions.");
             }
         }
     }
     //check if the archive file exists and is readable, then depending on destination_dir either just unpack it or unpack it into the destination_dir folder.
     if (!$this->error) {
         if (file_exists($zipfile)) {
             if (is_readable($zipfile)) {
                 $archive = new PclZip($zipfile);
                 if ($destination_dir) {
                     if ($archive->extract(PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_PATH, $destination_dir, PCLZIP_OPT_SET_CHMOD, 0777) == 0) {
                         $this->create_error("Error : " . $archive->errorInfo(true));
                     } else {
                         return true;
                     }
                 } else {
                     if ($archive->extract(PCLZIP_OPT_SET_CHMOD, 0777) == 0) {
                         $this->create_error("Error : " . $archive->errorInfo(true));
                     } else {
                         return true;
                     }
                 }
             } else {
                 $this->create_error("Unable to read ZIP file '" . $zipfile . "'. Check reading permissions.");
             }
         } else {
             $this->create_error("Missing ZIP file '.{$zipfile}.'");
         }
     }
     return $error;
 }
function rex_a52_extract_archive($file, $msg = '', $path = null)
{
    global $REX;
    if (!$path) {
        $path = '../files/' . $REX['TEMP_PREFIX'];
    }
    $archive = new PclZip($file);
    if ($archive->extract(PCLZIP_OPT_PATH, $path) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    if (($list = $archive->listContent()) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
}
function themedrive_unzip($file, $dir)
{
    if (!current_user_can('edit_files')) {
        echo 'Oops, sorry you are not authorized to do this';
        return false;
    }
    if (!class_exists('PclZip')) {
        require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
    }
    $unzipArchive = new PclZip($file);
    $list = $unzipArchive->properties();
    if (!$list['nb']) {
        return false;
    }
    //echo "Number of files in archive : ".$list['nb']."<br>";
    echo "Copying the files<br>";
    $result = $unzipArchive->extract(PCLZIP_OPT_PATH, $dir);
    if ($result == 0) {
        echo 'Could not unarchive the file: ' . $unzipArchive->errorInfo(true) . ' <br />';
        return false;
    } else {
        //print_r($result);
        foreach ($result as $item) {
            if ($item['status'] != 'ok') {
                echo $item['stored_filename'] . ' ... ' . $item['status'] . '<br>';
            }
        }
        return true;
    }
}
Exemplo n.º 8
0
 function guardarArchivo()
 {
     global $db, $t;
     // Copia el archivo del usuario al directorio ../files
     $tipoArchivo = $_FILES['userfile']['type'];
     //if( $tipoArchivo=="application/zip" ){
     if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
         copy($_FILES['userfile']['tmp_name'], "../facturas/facturas.zip");
         $msg[] = "<font color=green>El archivo fue cargado correctamente.</font>";
         // -------------------------------------------
         // Descomprimir los zip
         require_once '../include/pclzip.lib.php';
         $archive = new PclZip('../facturas/facturas.zip');
         //Ejecutamos la funcion extract
         //if ( $archive->extract(PCLZIP_OPT_PATH, ' ../files/facturas/',PCLZIP_OPT_REMOVE_PATH, '../files/facturas/') == 0) {
         if ($archive->extract(PCLZIP_OPT_PATH, '../facturas/', PCLZIP_OPT_REMOVE_PATH, '../facturas/') == 0) {
             die("Error : " . $archive->errorInfo(true));
         }
         // -------------------------------------------
         // Eliminar zip, ya no es necesario.
         unlink("../facturas/facturas.zip");
     } else {
         $msg[] = "<font color=red>ERROR : Possible file upload attack. Filename: " . $_FILES['userfile']['name'];
     }
     //}
     //else{
     //    $archivo = $_FILES['userfile']['name'];
     //    $msg[]= "<font color=red>ERROR : El archivo (<i>$archivo</i>) es incorrecto, debe cargar un formato ZIP, y dentro de él todas las facturas.";
     //}
     return $msg;
 }
function bps_Zip_CC_Master_File()
{
    // Use ZipArchive
    if (class_exists('ZipArchive')) {
        $zip = new ZipArchive();
        $filename = WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.zip';
        if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
            exit("Error: Cannot Open {$filename}\n");
        }
        $zip->addFile(WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.txt', "cc-master.txt");
        $zip->close();
        return true;
    } else {
        // Use PclZip
        define('PCLZIP_TEMPORARY_DIR', WP_PLUGIN_DIR . '/bulletproof-security/admin/core/');
        require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
        if (ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding')) {
            $previous_encoding = mb_internal_encoding();
            mb_internal_encoding('ISO-8859-1');
        }
        $archive = new PclZip(WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.zip');
        $v_list = $archive->create(WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.txt', PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR . '/bulletproof-security/admin/core/');
        return true;
        if ($v_list == 0) {
            die("Error : " . $archive->errorInfo(true));
            return false;
        }
    }
}
Exemplo n.º 10
0
 function decompress($to)
 {
     if (!file_exists($this->zip)) {
         throw new \Fuse_Exception('File :file does not exist', array(':file' => $this->zip));
     }
     $zip = new PclZip($this->zip);
     if (($list = $zip->listContent()) == 0) {
         error_log($zip->errorInfo(true));
         throw new \Fuse_Exception('Invalid zip file');
     }
     $v_list = $zip->extract($to);
     if ($v_list == 0) {
         error_log($zip->errorInfo(true));
         throw new \Fuse_Exception('Zip extraction failed');
     }
     return true;
 }
Exemplo n.º 11
0
function zip_dir($zip_dir, $zip_archive)
{
    $archive = new PclZip("{$zip_archive}");
    $v_list = $archive->create("{$zip_dir}");
    if ($v_list == 0) {
        die("Error: " . $archive->errorInfo(true));
    }
}
Exemplo n.º 12
0
function cherry_unzip_backup($file, $themes_folder)
{
    $zip = new PclZip($file);
    if ($zip->extract(PCLZIP_OPT_PATH, $themes_folder) == 0) {
        die("Error : " . $zip->errorInfo(true));
    }
    echo get_option(PARENT_NAME . "_version_backup");
}
Exemplo n.º 13
0
 /**
  * Extract zip file 
  * @param string $path path to extract files
  * @param string $input input zip file to extract
  * @example  $com->ZipExtract('newlibs', './sample.zip');
  */
 public function ZipExtract($path, $input)
 {
     include_once 'external/pclzip.lib.php';
     $archive = new PclZip($input);
     if ($archive->extract(PCLZIP_OPT_PATH, $path) == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
 }
Exemplo n.º 14
0
function unzip($filename, $path)
{
    $zipfile = new PclZip($filename);
    if ($zipfile->extract(PCLZIP_OPT_PATH, $path) == 0) {
        return 'Error : ' . $zipfile->errorInfo(true);
    } else {
        return TRUE;
    }
}
Exemplo n.º 15
0
 /**
  * Функция делает бекап всех файлов скрипта
  * Для исключения файлов из архива необходимо прописать их в свойство backup::$arrExcept (по умолчанию в нем array('updates', 'updates/backups'))
  * 
  * @return bool
  */
 static function backupSite()
 {
     function except($p_event, &$p_header)
     {
         return backup::skipAddingFilesToArchive($p_event, $p_header);
     }
     $file = CONF_BACKUPS_PATH_TO_FILES . terms::currentDate() . '_site_revision_' . CONF_INFO_SCRIPT_REVISION . '.zip';
     file_exists($file) ? unlink($file) : null;
     $zip = new PclZip($file);
     return !$zip->create(CONF_ROOT_DIR, PCLZIP_OPT_REMOVE_PATH, CONF_ROOT_DIR, PCLZIP_CB_PRE_ADD, 'except') ? $zip->errorInfo(true) : true;
 }
Exemplo n.º 16
0
 function zip_dir($zip_dir, $zip_archive)
 {
     $archive = new PclZip($zip_archive);
     $v_list = $archive->create($zip_dir);
     if ($v_list == 0) {
         if (!defined('SUGAR_PHPUNIT_RUNNER')) {
             die("Error: " . $archive->errorInfo(true));
         }
         return false;
     }
 }
Exemplo n.º 17
0
 /**
  * Function responsible to import label resources from a '.zip' file.
  *
  * @access public
  * @return void
  */
 public function importlabelresources()
 {
     if (!Permission::model()->hasGlobalPermission('labelsets', 'edit')) {
         Yii::app()->session['flashmessage'] = gT('Access denied!');
         $this->getController()->redirect(App()->createUrl("/admin"));
     }
     $lid = returnGlobal('lid');
     if (!empty($lid)) {
         if (Yii::app()->getConfig('demoMode')) {
             $this->getController()->error(gT("Demo mode only: Uploading files is disabled in this system."), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
         }
         // Create temporary directory
         // If dangerous content is unzipped
         // then no one will know the path
         $extractdir = $this->_tempdir(Yii::app()->getConfig('tempdir'));
         $zipfilename = $_FILES['the_file']['tmp_name'];
         $basedestdir = Yii::app()->getConfig('uploaddir') . "/labels";
         $destdir = $basedestdir . "/{$lid}/";
         Yii::app()->loadLibrary('admin.pclzip');
         $zip = new PclZip($zipfilename);
         if (!is_writeable($basedestdir)) {
             $this->getController()->error(sprintf(gT("Incorrect permissions in your %s folder."), $basedestdir), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
         }
         if (!is_dir($destdir)) {
             mkdir($destdir);
         }
         $aImportedFilesInfo = array();
         $aErrorFilesInfo = array();
         if (is_file($zipfilename)) {
             if ($zip->extract($extractdir) <= 0) {
                 $this->getController()->error(gT("This file is not a valid ZIP file archive. Import failed. " . $zip->errorInfo(true)), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
             }
             // now read tempdir and copy authorized files only
             $folders = array('flash', 'files', 'images');
             foreach ($folders as $folder) {
                 list($_aImportedFilesInfo, $_aErrorFilesInfo) = $this->_filterImportedResources($extractdir . "/" . $folder, $destdir . $folder);
                 $aImportedFilesInfo = array_merge($aImportedFilesInfo, $_aImportedFilesInfo);
                 $aErrorFilesInfo = array_merge($aErrorFilesInfo, $_aErrorFilesInfo);
             }
             // Deletes the temp directory
             rmdirr($extractdir);
             // Delete the temporary file
             unlink($zipfilename);
             if (is_null($aErrorFilesInfo) && is_null($aImportedFilesInfo)) {
                 $this->getController()->error(gT("This ZIP archive contains no valid Resources files. Import failed."), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
             }
         } else {
             $this->getController()->error(gT("An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder."), $this->getController()->createUrl("admin/labels/sa/view/lid/{$lid}"));
         }
         $aData = array('aErrorFilesInfo' => $aErrorFilesInfo, 'aImportedFilesInfo' => $aImportedFilesInfo, 'lid' => $lid);
         $this->_renderWrappedTemplate('labels', 'importlabelresources_view', $aData);
     }
 }
 /**
  * 
  * Creates a backup file
  * @param bool $backup_all whether to include customizations to Perch
  * @return a zip file
  */
 public function build($backup_type = 'all', $mysqldump_path = false)
 {
     include 'pclzip.lib.php';
     $zipfolder = 'backup';
     $zipfile = strtolower('website-backup-' . date('d-M-Y') . '.zip');
     $file = $zipfolder . DIRECTORY_SEPARATOR . $zipfile;
     //create zip
     $zip = new PclZip($file);
     $files = array();
     if ($this->can_mysqldump($mysqldump_path)) {
         //generate db dump
         exec($mysqldump_path . ' --opt --host=' . PERCH_DB_SERVER . ' --user='******' --password='******' ' . PERCH_DB_DATABASE . ' > backup/backup.sql');
         //add to zip
         $files[] = 'backup/backup.sql';
     }
     if ($backup_type == 'resources') {
         //get resources folder and add to zip
         $files[] = PERCH_PATH . '/resources';
         //if backupAll
     } elseif ($backup_type == 'custom') {
         //get resources folder and add to zip
         $files[] = PERCH_PATH . '/resources';
         //get templates
         $files[] = PERCH_PATH . '/templates';
         //get addons
         $files = $this->_get_addons($files);
         //get config
         $files[] = PERCH_PATH . '/config';
     } elseif ($backup_type == 'all') {
         $files[] = PERCH_PATH;
     }
     //die('<pre>'.print_r($files, true).'</pre>');
     //return zip
     if ($zip->create($files, PCLZIP_OPT_REMOVE_PATH, PERCH_PATH, PCLZIP_OPT_ADD_PATH, 'perch_backup') == 0) {
         if (file_exists('backup/backup.sql')) {
             unlink('backup/backup.sql');
         }
         echo $zip->errorInfo();
         exit;
     } else {
         header("Content-type:application/x-zip-compressed");
         header("Content-disposition:attachment;filename=" . $zipfile);
         readfile($file);
         //delete zip file
         unlink($file);
         //remove the sql file if it exists
         if (file_exists('backup/backup.sql')) {
             unlink('backup/backup.sql');
         }
         exit;
     }
 }
Exemplo n.º 19
0
 private function oneClick_Unpack()
 {
     require_once PIWIK_INCLUDE_PATH . '/libs/PclZip/pclzip.lib.php';
     $archive = new PclZip($this->pathPiwikZip);
     $pathExtracted = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION;
     if (false == ($archive_files = $archive->extract(PCLZIP_OPT_PATH, $pathExtracted))) {
         throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionArchiveIncompatible', $archive->errorInfo(true)));
     }
     if (0 == count($archive_files)) {
         throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionArchiveEmpty'));
     }
     unlink($this->pathPiwikZip);
     $this->pathRootExtractedPiwik = $pathExtracted . '/piwik';
 }
Exemplo n.º 20
0
function zip_go()
{
    global $list, $options;
    $saveTo = realpath($options['download_dir']) . '/';
    $_POST["archive"] = strlen(trim(urldecode($_POST["archive"]))) > 4 && substr(trim(urldecode($_POST["archive"])), -4) == ".zip" ? trim(urldecode($_POST["archive"])) : "archive.zip";
    $_POST["archive"] = $saveTo . basename($_POST["archive"]);
    for ($i = 0; $i < count($_POST["files"]); $i++) {
        $files[] = $list[$_POST["files"][$i]];
    }
    foreach ($files as $file) {
        $CurrDir = ROOT_DIR;
        $inCurrDir = stristr(dirname($file["name"]), $CurrDir) ? TRUE : FALSE;
        if ($inCurrDir) {
            $add_files[] = substr($file["name"], strlen($CurrDir) + 1);
        }
    }
    require_once CLASS_DIR . "pclzip.php";
    $archive = new PclZip($_POST["archive"]);
    $no_compression = $options['disable_archive_compression'] || isset($_POST["no_compression"]);
    if (file_exists($_POST["archive"])) {
        if ($no_compression) {
            $v_list = $archive->add($add_files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
        } else {
            $v_list = $archive->add($add_files, PCLZIP_OPT_REMOVE_ALL_PATH);
        }
    } else {
        if ($no_compression) {
            $v_list = $archive->create($add_files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
        } else {
            $v_list = $archive->create($add_files, PCLZIP_OPT_REMOVE_ALL_PATH);
        }
    }
    if ($v_list == 0) {
        echo "Error: " . $archive->errorInfo(true) . "<br /><br />";
        return;
    } else {
        echo "Archive <b>" . $_POST["archive"] . "</b> successfully created!<br /><br />";
    }
    if (is_file($_POST['archive'])) {
        $time = filemtime($_POST['archive']);
        while (isset($list[$time])) {
            $time++;
        }
        $list[$time] = array("name" => $_POST['archive'], "size" => bytesToKbOrMbOrGb(filesize($_POST['archive'])), "date" => $time);
        if (!updateListInFile($list)) {
            echo lang(146) . "<br /><br />";
        }
    }
}
Exemplo n.º 21
0
function getWebsiteZip($siteid)
{
    createWebsite($siteid);
    //change so the zip filename contains the website number
    include_once 'pclzip.lib.php';
    $archive = new PclZip('content/' . szName() . '-' . $siteid . '.zip');
    $v_list = $archive->create('content/' . $siteid, PCLZIP_OPT_REMOVE_PATH, 'content/');
    if ($v_list == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    header("Content-type: application/octet-stream");
    header("Content-disposition: attachment; filename=" . szName() . "-" . $siteid . ".zip");
    readfile('content/' . szName() . '-' . $siteid . '.zip');
    unlink('content/' . szName() . '-' . $siteid . '.zip');
}
Exemplo n.º 22
0
/**
 * 压缩文件为zip档案
 * 
 * zip('压缩包文件名全名',array('要压缩的文件'=>'在压缩包中的新路径'));
 * 
 * zip('test.zip',array('jquery-1.11.1.min.js'=>'js/jquery'));
 * 
 * zip('test.zip',array('jquery-1.11.1.min.js','jquery-1.8.3.min.js'));
 * 
 * zip('test.zip','jquery-1.11.1.min.js');
 * @param string $zip 要生成的zip文件名
 * @param array $files 要包含的文件
 * @return bool/string
 */
function zip($zip, $files = null)
{
    $dir = realpath(dirname($zip));
    if (is_file($zip)) {
        //echo "$zip exists,it will be overwritten\r\n<br />";
    } elseif (!is_dir($dir)) {
        if (is_dir(mk_dir($dir))) {
            die("{$dir} cannot create or unwritable");
        }
    }
    $archive = new PclZip($zip);
    $errors = array();
    $v_list = $archive->create('');
    if ($v_list == 0) {
        $errors[0] = $archive->errorInfo(true);
    }
    if ($files) {
        $files = (array) $files;
        foreach ($files as $file_key => $file_value) {
            if (is_string($file_key) && strlen($file_key)) {
                $in_zip_path = $file_value;
                $file = $file_key;
            } else {
                $in_zip_path = null;
                $file = $file_value;
            }
            //var_dump($file);
            if (file_exists($file)) {
                //var_dump($file);
                $file = realpath($file);
                $file_path = dirname($file);
                //var_dump($file_path);
                if ($in_zip_path) {
                    $v_list = $archive->add($file, PCLZIP_OPT_REMOVE_PATH, $file_path, PCLZIP_OPT_ADD_PATH, $in_zip_path);
                } else {
                    $v_list = $archive->add($file, PCLZIP_OPT_REMOVE_PATH, $file_path);
                }
                if ($v_list == 0) {
                    $errors[$file] = $archive->errorInfo(true);
                }
            }
        }
    }
    if ($errors && FUN_DEBUG) {
        echo implode("\r\n<br />", $errors) . "\r\n<br />";
    }
    return is_file($zip) ? $zip : false;
}
Exemplo n.º 23
0
function cherry_plugin_export_content()
{
    $exclude_files = array('xml', 'json');
    /**
     * Filters folders to exclude from export parser
     * @var array
     */
    $exclude_folder = apply_filters('cherry_export_exclude_folders', array('woocommerce_uploads', 'wc-logs'));
    $response = array('what' => 'status', 'action' => 'export_content', 'id' => '1', 'data' => __('Export content done', CHERRY_PLUGIN_DOMAIN));
    $response_file = array('what' => 'file', 'action' => 'export_content', 'id' => '2');
    $zip_name = UPLOAD_BASE_DIR . '/sample_data.zip';
    cherry_plugin_delete_file($zip_name);
    if (is_dir(UPLOAD_BASE_DIR)) {
        $file_string = cherry_plugin_scan_dir(UPLOAD_BASE_DIR, $exclude_folder, $exclude_files);
    }
    $zip = new PclZip($zip_name);
    $result = $zip->create($file_string, PCLZIP_OPT_REMOVE_ALL_PATH);
    //export json
    $json_file = cherry_plugin_export_json();
    if (is_wp_error($json_file)) {
        $response['data'] = "Error : " . $json_file->get_error_message();
    } else {
        $zip->add($json_file, PCLZIP_OPT_REMOVE_ALL_PATH);
        cherry_plugin_delete_file($json_file);
    }
    //export xml
    $xml_file = cherry_plugin_export_xml();
    if (is_wp_error($xml_file)) {
        $response['data'] = "Error : " . $xml_file->get_error_message();
    } else {
        $zip->add($xml_file, PCLZIP_OPT_REMOVE_ALL_PATH);
        cherry_plugin_delete_file($xml_file);
    }
    $nonce = wp_create_nonce('cherry_plugin_download_content');
    $file_url = add_query_arg(array('action' => 'cherry_plugin_get_export_file', 'file' => $zip_name, '_wpnonce' => $nonce), admin_url('admin-ajax.php'));
    if ($result == 0) {
        $response['data'] = "Error : " . $zip->errorInfo(true);
    } else {
        $response_file['data'] = $file_url;
    }
    $xmlResponse = new WP_Ajax_Response($response);
    $xmlResponse->add($response_file);
    $xmlResponse->send();
    exit;
}
 public function execute()
 {
     $v3d0bb1b55e6e399b5a178a7d2ce1e93e = $this->getParam("archive-filepath");
     $v207e5b7e7d2b07f6b19066e8d62f4b1d = $this->getParam("target-directory");
     $v3d0bb1b55e6e399b5a178a7d2ce1e93e = $this->replaceParams($v3d0bb1b55e6e399b5a178a7d2ce1e93e);
     $v3d0bb1b55e6e399b5a178a7d2ce1e93e = $this->replacePlaceHolders($v3d0bb1b55e6e399b5a178a7d2ce1e93e);
     $this->archiveFileName = $v3d0bb1b55e6e399b5a178a7d2ce1e93e;
     if (substr($v207e5b7e7d2b07f6b19066e8d62f4b1d, 1, 1) == ":") {
         $vba237047d6b3d7c06a2bf8b749d226b7 = substr($v207e5b7e7d2b07f6b19066e8d62f4b1d, 2);
     } else {
         $vba237047d6b3d7c06a2bf8b749d226b7 = $v207e5b7e7d2b07f6b19066e8d62f4b1d;
     }
     $vadcdbd79a8d84175c229b192aadc02f2 = new PclZip($v3d0bb1b55e6e399b5a178a7d2ce1e93e);
     $result = $vadcdbd79a8d84175c229b192aadc02f2->extract($v207e5b7e7d2b07f6b19066e8d62f4b1d, $vba237047d6b3d7c06a2bf8b749d226b7);
     if ($result == 0) {
         throw new Exception("Failed to create zip file: \"" . $vadcdbd79a8d84175c229b192aadc02f2->errorInfo(true) . "\"");
     }
 }
 public function execute()
 {
     $v207e5b7e7d2b07f6b19066e8d62f4b1d = $this->getParam("target-directory");
     $vc9db0d9cdbf3dab7ae304d2b8fe6f5d8 = $this->getParam("output-file-name");
     $vc9db0d9cdbf3dab7ae304d2b8fe6f5d8 = $this->replacePlaceHolders($vc9db0d9cdbf3dab7ae304d2b8fe6f5d8);
     $this->outputFileName = $vc9db0d9cdbf3dab7ae304d2b8fe6f5d8;
     if (substr($v207e5b7e7d2b07f6b19066e8d62f4b1d, 1, 1) == ":") {
         $vba237047d6b3d7c06a2bf8b749d226b7 = substr($v207e5b7e7d2b07f6b19066e8d62f4b1d, 2);
     } else {
         $vba237047d6b3d7c06a2bf8b749d226b7 = $v207e5b7e7d2b07f6b19066e8d62f4b1d;
     }
     $vadcdbd79a8d84175c229b192aadc02f2 = new PclZip($vc9db0d9cdbf3dab7ae304d2b8fe6f5d8);
     $result = $vadcdbd79a8d84175c229b192aadc02f2->create($v207e5b7e7d2b07f6b19066e8d62f4b1d, PCLZIP_OPT_REMOVE_PATH, $vba237047d6b3d7c06a2bf8b749d226b7);
     if ($result == 0) {
         throw new Exception("Failed to create zip file: \"" . $vadcdbd79a8d84175c229b192aadc02f2->errorInfo(true) . "\"");
     }
     chmod($vc9db0d9cdbf3dab7ae304d2b8fe6f5d8, 0777);
 }
Exemplo n.º 26
0
function packen($filename, $wordtemplatedownloadpath, $temp_dir, $concontent, $stylecontent)
{
    //global $filename, $wordtemplatedownloadpath;
    //write a new content.xml
    $handle = fopen($wordtemplatedownloadpath . '/' . $temp_dir . '/content.xml', "w");
    fwrite($handle, $concontent);
    fclose($handle);
    //write a new styles.xml
    $handle2 = fopen($wordtemplatedownloadpath . '/' . $temp_dir . '/styles.xml', "w");
    fwrite($handle2, $stylecontent);
    fclose($handle2);
    $archive = new PclZip($wordtemplatedownloadpath . '/' . $filename);
    //make a new archive (or .odt file)
    $v_list = $archive->add($wordtemplatedownloadpath . '/' . $temp_dir, PCLZIP_OPT_REMOVE_PATH, $wordtemplatedownloadpath . '/' . $temp_dir);
    if ($v_list == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
}
Exemplo n.º 27
0
 function execute(&$controller, &$request)
 {
     $root = mamboCore::get('rootPath');
     $live = mamboCore::get('mosConfig_live_site');
     include $root . '/administrator/includes/pcl/pclzip.lib.php';
     chdir($root);
     $lang = mosGetParam($_POST, 'lang', '');
     $language = new mamboLanguage($lang);
     $language->load(true);
     $zipfile = "{$root}/media/MamboLanguage_{$lang}.zip";
     $archive = new PclZip($zipfile);
     foreach ($language->files as $file) {
         $v_list = $archive->add($root . '/' . $file['filename'], PCLZIP_OPT_REMOVE_PATH, $root . 'language/');
         if ($v_list == 0) {
             die("Error : " . $archive->errorInfo(true));
         }
     }
     if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $UserAgent)) {
         $UserBrowser = "Opera";
     } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $UserAgent)) {
         $UserBrowser = "IE";
     } else {
         $UserBrowser = '';
     }
     $mime_type = 'application/x-zip';
     $filename = "MamboLanguage_{$lang}.zip";
     @ob_end_clean();
     ob_start();
     header('Content-Type: ' . $mime_type);
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     if ($UserBrowser == 'IE') {
         header('Content-Disposition: inline; filename="' . $filename . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Pragma: no-cache');
     }
     readfile($zipfile);
     ob_end_flush();
     $fmanager =& mosFileManager::getInstance();
     $fmanager->deleteFile($zipfile);
     exit(0);
 }
 function index()
 {
     import('ORG.Util.Pclzip');
     clearstatcache();
     $url = "http://www.damicms.com/update/dami_update.zip";
     $save_path = './Public/';
     $ext_path = './Public/uptmp/';
     @mk_dir($ext_path);
     $save_file = $save_path . "uptemp.zip";
     if (!file_exists($save_file) || filemtime($save_file) < time() - 6 * 3600) {
         ob_end_flush();
         //清空浏览器缓存
         echo '准备下载升级文件包....<br>';
         ob_flush();
         flush();
         self::get_damipacket($url, $save_file);
     }
     if (file_exists($save_file)) {
         ob_end_flush();
         //清空浏览器缓存
         echo '正在解压升级文件包....<br>';
         ob_flush();
         flush();
         $archive = new PclZip($save_file);
         if ($archive->extract(PCLZIP_OPT_PATH, $ext_path) == 0) {
             die("Error : " . $archive->errorInfo(true));
         } else {
             ob_end_flush();
             //清空浏览器缓存
             echo '解压缩已经完成,准备更新文件....<br>';
             ob_flush();
             flush();
             //遍历文件并更新
             self::up_file($ext_path);
             ob_end_flush();
             //清空浏览器缓存
             echo '恭喜您,所有文件升级完毕!';
             ob_flush();
             flush();
             //删除升级文件
             @deldir($ext_path);
         }
     }
 }
Exemplo n.º 29
0
 /**
  * 上传头像
  */
 public function upload()
 {
     if (isset($_GET['userid']) && isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
         // 根据用户id创建文件夹
         $userid = intval($_GET['userid']);
         $avatardata = $GLOBALS['HTTP_RAW_POST_DATA'];
     } else {
         exit('0');
     }
     $dir1 = ceil($userid / 10000);
     $dir2 = ceil($userid % 10000 / 1000);
     // 创建图片存储文件夹
     $avatarfile = DATA_PATH . 'avatar/';
     $dir = $avatarfile . $dir1 . '/' . $dir2 . '/' . $userid . '/';
     if (!file_exists($dir)) {
         Folder::mk($dir);
     }
     $filename = $dir . $userid . '.zip';
     File::write($filename, $avatardata);
     $archive = new PclZip($filename);
     if ($archive->extract(PCLZIP_OPT_PATH, $dir) == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     // 判断文件安全,删除压缩包和非jpg图片
     $avatararr = array('180x180.jpg', '30x30.jpg', '45x45.jpg', '90x90.jpg');
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if ($file !== '.' && $file !== '..') {
                 if (!in_array($file, $avatararr)) {
                     File::delete($dir . $file);
                 } else {
                     $info = @getimagesize($dir . $file);
                     if (!$info || $info[2] != 2) {
                         File::del($dir . $file);
                     }
                 }
             }
         }
         closedir($handle);
     }
     $this->db->where(array('userid' => $userid))->update(array('avatar' => 1));
     exit('1');
 }
 /**
  * Gets a template and installs it.
  */
 public function getAndInstall()
 {
     $this->setState('DOWNLOADING_TEMPLATE');
     //Get plugin name
     $template = $this->getActiveRequest();
     //Should never occur.
     if (empty($template)) {
         exit("Template Undefined.");
     }
     //Get remote files collector
     include_once "core/lib/RemoteFiles.php";
     //Create new remote file connector.
     $rf = new RemoteFiles();
     //Save this zip
     $rf->downloadRemoteFile("http://styles.lotuscms.org/zips/" . $template . ".zip", "data", $template . ".zip");
     include_once 'modules/Backup/pclzip.lib.php';
     //Setup Archive
     $archive = new PclZip("data/" . $template . ".zip");
     //Extract Archive
     $list = $archive->extract(PCLZIP_OPT_PATH, "style");
     if ($archive->extract() == 0) {
         $this->setState('DOWNLOADING_TEMPLATE_FAILED');
         unlink("data/" . $template . ".zip");
         //Display Error Message
         exit("<p><strong>Error</strong> : " . $archive->errorInfo(true) . "</p><p>It may help to chmod (change write permissions) the 'modules' cms directory to 777.</p>");
     } else {
         $this->setState('DOWNLOADING_TEMPLATE_SUCCESS');
         //If the original template folder is also there remove it
         if (is_dir("comps")) {
             //Destroys the secondary folder before copy.
             $this->destroyDir($template, true);
             //Remove Additional Files
             $this->destroyDir("comps", true);
             //Remove additional FIle
             unlink($template . ".php");
             //Destroys the secondary folder before copy.
             $this->destroyDir("__MACOSX", true);
         }
         //Delete the temporary plugin zip file.
         unlink("data/" . $template . ".zip");
         return $template;
     }
 }