当前位置: 首页>>代码示例>>PHP>>正文


PHP PclZip::add方法代码示例

本文整理汇总了PHP中PclZip::add方法的典型用法代码示例。如果您正苦于以下问题:PHP PclZip::add方法的具体用法?PHP PclZip::add怎么用?PHP PclZip::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PclZip的用法示例。


在下文中一共展示了PclZip::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wpd_download

function wpd_download()
{
    if (!class_exists('PclZip')) {
        include ABSPATH . 'wp-admin/includes/class-pclzip.php';
    }
    $what = $_GET['wpd'];
    $object = $_GET['object'];
    switch ($what) {
        case 'plugin':
            if (strpos($object, '/')) {
                $object = dirname($object);
            }
            $root = WP_PLUGIN_DIR;
            break;
        case 'theme':
            $root = get_theme_root($object);
            break;
    }
    $path = $root . '/' . $object;
    $fileName = $object . '.zip';
    $archive = new PclZip($fileName);
    $archive->add($path, PCLZIP_OPT_REMOVE_PATH, $root);
    header('Content-type: application/zip');
    header('Content-Disposition: attachment; filename="' . $fileName . '"');
    readfile($fileName);
    // remove tmp zip file
    unlink($fileName);
    exit;
}
开发者ID:vrkansagara,项目名称:wordpress-plugin-construction,代码行数:29,代码来源:wp-downloader-3.7.php

示例2: add

 public function add($file)
 {
     if (empty($this->remove_path)) {
         $this->archive->add($file);
     } else {
         $this->archive->add($file, PCLZIP_OPT_REMOVE_PATH, $this->remove_path);
     }
     $this->saveMd5($file);
 }
开发者ID:NYC2015,项目名称:team-12,代码行数:9,代码来源:class-wpadm-archive.php

示例3: packed

 public function packed($file)
 {
     ini_set("memory_limit", "256M");
     if (empty($this->remove_path)) {
         $this->archive->add($file);
     } else {
         $this->archive->add($file, PCLZIP_OPT_REMOVE_PATH, $this->remove_path);
     }
     $this->saveMd5($file);
 }
开发者ID:derwegas,项目名称:strubbelkinder,代码行数:10,代码来源:class-wpadm-archive.php

示例4: zip_go

function zip_go()
{
    global $list, $options, $L;
    $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));
        }
    }
    require_once CLASS_DIR . "pclzip.php";
    $archive = new PclZip($_POST["archive"]);
    $no_compression = $options['disable_to']['act_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 $L->say['_error'] . ": " . $archive->errorInfo(true) . "<br /><br />";
        return;
    } else {
        echo $L->say['_arcv'] . " <b>" . $_POST["archive"] . "</b> " . $L->say['success_created'] . "<br /><br />";
    }
    if (is_file($_POST['archive'])) {
        $time = getNowzone(@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 $L->say['couldnt_upd_list'] . "<br /><br />";
        }
    }
}
开发者ID:laiello,项目名称:rapidleech36b,代码行数:49,代码来源:zip.php

示例5: wpmove_create_archive

/**
 * Creates an archive of the given files.
 *
 * @param	array	$files		Array of files to archive
 * @param	string	$ommit_path	Path to ommit
 * @param	integer	$id			To prevent overwriting archives created in the same second
 * @return	string  $filename	Filename of the archive created
 */
function wpmove_create_archive($files, $ommit_path = '', $id = 0)
{
    $filename = trailingslashit(WPMOVE_BACKUP_DIR) . 'Backup-' . time() . $id . '.zip';
    $archive = new PclZip($filename);
    $archive->add($files, PCLZIP_OPT_REMOVE_PATH, $ommit_path);
    return basename($filename);
}
开发者ID:pabloe01,项目名称:Rawsonenmovimiento,代码行数:15,代码来源:functions-file-backup.php

示例6: zipRequest

 /**
  * Creates zip of data directory.
  */
 public function zipRequest($messages = true)
 {
     $data = "";
     date_default_timezone_set("GMT");
     if ($messages) {
         $data = "<p>" . $this->localize("Please wait while the zip is being archived...") . "</p>";
     }
     $name = 'modules/Backup/zips/archive' . date("c") . '-id-' . $this->generateRandStr(20) . '.zip';
     include_once 'modules/Backup/pclzip.lib.php';
     $archive = new PclZip($name);
     $v_list = $archive->add('data/');
     if ($v_list == 0) {
         $data .= "<p><b>" . $this->localize("Error") . " Zipping:</b> " . $archive->errorInfo(true) . "</p>";
     } else {
         if ($messages) {
             $data .= "<p class='success'><strong>" . $this->localize("Success") . ":</strong> " . $this->localize("Your backup has been successfully prepared") . ".</p><p><strong>" . $this->localize("Download Zip of Backup") . ": <a href='" . $name . "'>" . $this->localize("Here") . "</a></strong></p>";
         } else {
             $data .= "<p class='error msg'>" . $this->localize("If an 'PCLZIP_ERR_READ_OPEN_FAIL' error has occured, this indicates that the permissions for the backup folder are sit incorrectly - if so please chmod 'modules/Backup/zips' to 777.") . "</p>";
         }
     }
     if ($messages) {
         $this->setContent($data);
     } else {
         return $data;
     }
 }
开发者ID:andreaspada,项目名称:LotusCMS-Content-Management-System,代码行数:29,代码来源:BackupModuleAdmin.php

示例7: toSCO

 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);
 }
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:27,代码来源:ExportController.php

示例8: cherry_plugin_export_content

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;
}
开发者ID:drupalninja,项目名称:schome_org,代码行数:45,代码来源:export-functions.php

示例9: run

 public function run()
 {
     try {
         main::log(lang::get('Start Backup process...', false));
         $this->init();
         $db_param = $this->getDBParams();
         $mysql = $this->incMysql();
         if (isset($this->params['optimize'])) {
             main::log(lang::get('Optimize Database Tables', false));
             $mysql->optimize();
         }
         $mysql->backup($this->db_file);
         if (filesize($this->db_file) == 0) {
             throw new Exception(lang::get('Error in create dump Database: Chance of a lack of rights for the backup.', fale));
         } else {
             $size_dump = round(filesize($this->db_file) / 1024 / 1024, 2);
             main::log(str_replace('%s', $size_dump, lang::get('Database Dump was successfully created( %s Mb):', false)) . str_replace(ABSPATH, '', $this->db_file));
         }
         $files = $this->createListFiles();
         $files[] = $this->db_file;
         if (($n = count($files)) > 0) {
             include main::getPluginDir() . "/libs/pclzip.lib.php";
             $archive = $this->dir_backup . '/' . $this->getArchive($this->name);
             $zip = new PclZip($archive);
             main::log(lang::get('Add files to Backup', false));
             main::log(lang::get('Create part ', false) . basename($archive));
             for ($i = 0; $i < $n; $i++) {
                 if (file_exists($archive) && filesize($archive) > $this->max_size_archive) {
                     unset($zip);
                     $archive = $this->dir_backup . '/' . $this->getNextArchive($this->name);
                     main::log(lang::get('Create part ', false) . basename($archive));
                     $zip = new PclZip($archive);
                 }
                 $zip->add($files[$i], PCLZIP_OPT_REMOVE_PATH, ABSPATH);
                 $this->saveMd5($files[$i], $archive);
             }
             // delete dump db
             main::log(lang::get('Remove dump Database with folder', false));
             main::remove($this->db_file);
             $dirs = readDirectrory($this->dir_backup, array('.zip', '.md5'));
             $size = 0;
             if (($n = count($dirs)) > 0) {
                 for ($i = 0; $i < $n; $i++) {
                     $size += filesize($dirs[$i]);
                     $dirs[$i] = basename($dirs[$i]);
                 }
             }
             $sizeMb = round($size / 1024 / 1024, 2);
             // MB
             main::log(str_replace('%s', $sizeMb, lang::get('Backup created is finish ( %s Mb)', false)));
             $this->dirs = $dirs;
             $this->size = $size;
         }
     } catch (Exception $e) {
         $this->setError($e->message);
     }
 }
开发者ID:nikitansk,项目名称:devschool,代码行数:57,代码来源:backup.php

示例10: cleanID

 /**
  * Send a zipped theme
  *
  * @author Samuele Tognini <samuele@netsons.org>
  */
 function send_theme($file)
 {
     require_once DOKU_PLUGIN . 'indexmenu/syntax/indexmenu.php';
     $idxm = new syntax_plugin_indexmenu_indexmenu();
     //clean the file name
     $file = cleanID($file);
     //check config
     if (!$idxm->getConf('be_repo') || empty($file)) {
         return false;
     }
     $repodir = INDEXMENU_IMG_ABSDIR . "/repository";
     $zipfile = $repodir . "/{$file}.zip";
     $localtheme = INDEXMENU_IMG_ABSDIR . "/{$file}/";
     //theme does not exists
     if (!file_exists($localtheme)) {
         return false;
     }
     if (!io_mkdir_p($repodir)) {
         return false;
     }
     $lm = @filemtime($zipfile);
     //no cached zip or older than 1 day
     if ($lm < time() - 60 * 60 * 24) {
         //create the zip
         require_once DOKU_PLUGIN . "indexmenu/inc/pclzip.lib.php";
         @unlink($zipfile);
         $zip = new PclZip($zipfile);
         $status = $zip->add($localtheme, PCLZIP_OPT_REMOVE_ALL_PATH);
         //error
         if ($status == 0) {
             return false;
         }
     }
     $len = (int) filesize($zipfile);
     //don't send large zips
     if ($len > 2 * 1024 * 1024) {
         return false;
     }
     //headers
     header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Type: application/zip');
     header('Content-Disposition: attachment; filename="' . basename($zipfile) . '";');
     header("Content-Transfer-Encoding: binary");
     //send zip
     $fp = @fopen($zipfile, 'rb');
     if ($fp) {
         $ct = @fread($fp, $len);
         print $ct;
     }
     @fclose($fp);
     return true;
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:58,代码来源:repo.class.php

示例11: cherry_plugin_export_content

function cherry_plugin_export_content()
{
    $exclude_files = array('xml', 'json');
    $exclude_folder = array('woocommerce_uploads');
    $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);
    }
    if ($result == 0) {
        $response['data'] = "Error : " . $zip->errorInfo(true);
    } else {
        $response_file['data'] = $zip_name;
    }
    $xmlResponse = new WP_Ajax_Response($response);
    $xmlResponse->add($response_file);
    $xmlResponse->send();
    exit;
}
开发者ID:hoangluanlee,项目名称:dlbh,代码行数:39,代码来源:export-functions.php

示例12: _prepareFileDownload

 /**
  * Serve files to browser - one file can be served directly, multiple files must be served as a ZIP file.
  */
 protected function _prepareFileDownload($fileArray)
 {
     if (count($fileArray) > 1) {
         // We need to zip multiple files and return a ZIP file to browser
         if (!@class_exists('ZipArchive') && !function_exists('gzopen')) {
             $this->_getSession()->addError(Mage::helper('xtento_orderexport')->__('PHP ZIP extension not found. Please download files manually from the server, or install the ZIP extension, or export just one file with each profile.'));
             return $this->_redirectReferer();
         }
         // ZIP creation
         $zipFile = false;
         if (@class_exists('ZipArchive')) {
             // Try creating it using the PHP ZIP functions
             $zipArchive = new ZipArchive();
             $zipFile = tempnam(sys_get_temp_dir(), 'zip');
             if ($zipArchive->open($zipFile, ZIPARCHIVE::CREATE) !== TRUE) {
                 $this->_getSession()->addError(Mage::helper('xtento_orderexport')->__('Could not open file ' . $zipFile . '. ZIP creation failed.'));
                 return $this->_redirectReferer();
             }
             foreach ($fileArray as $filename => $content) {
                 $zipArchive->addFromString($filename, $content);
             }
             $zipArchive->close();
         } else {
             if (function_exists('gzopen')) {
                 // Try creating it using the PclZip class
                 require_once Mage::getModuleDir('', 'Xtento_OrderExport') . DS . 'lib' . DS . 'PclZip.php';
                 $zipFile = tempnam(sys_get_temp_dir(), 'zip');
                 $zipArchive = new PclZip($zipFile);
                 if (!$zipArchive) {
                     $this->_getSession()->addError(Mage::helper('xtento_orderexport')->__('Could not open file ' . $zipFile . '. ZIP creation failed.'));
                     return $this->_redirectReferer();
                 }
                 foreach ($fileArray as $filename => $content) {
                     $zipArchive->add(array(array(PCLZIP_ATT_FILE_NAME => $filename, PCLZIP_ATT_FILE_CONTENT => $content)));
                 }
             }
         }
         if (!$zipFile) {
             $this->_getSession()->addError(Mage::helper('xtento_orderexport')->__('ZIP file couldn\'t be created.'));
             return $this->_redirectReferer();
         }
         $this->_prepareDownloadResponse("export_" . time() . ".zip", file_get_contents($zipFile));
         @unlink($zipFile);
         return $this;
     } else {
         // Just one file, output to browser
         foreach ($fileArray as $filename => $content) {
             return $this->_prepareDownloadResponse($filename, $content);
         }
     }
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:54,代码来源:Abstract.php

示例13: doArchive

/**
 * Do the main task of archiving a course.
 * 
 * @param int $course_id
 * @param string $course_code
 * @return boolean $success
 */
function doArchive($course_id, $course_code)
{
    global $webDir, $urlServer, $urlAppend, $siteName;
    if (extension_loaded('zlib')) {
        include 'include/pclzip/pclzip.lib.php';
    }
    $basedir = "{$webDir}/courses/archive/{$course_code}";
    mkpath($basedir);
    // Remove previous back-ups older than 10 minutes
    cleanup("{$webDir}/courses/archive", 600);
    $backup_date = date('Ymd-His');
    $backup_date_short = date('Ymd');
    $archivedir = $basedir . '/' . $backup_date;
    mkpath($archivedir);
    $zipfile = $basedir . "/{$course_code}-{$backup_date_short}.zip";
    // backup subsystems from main db
    $sql_course = "course_id = {$course_id}";
    $archive_conditions = array('course' => "id = {$course_id}", 'user' => "id IN (SELECT user_id FROM course_user\n                                          WHERE course_id = {$course_id})", 'course_user' => "course_id = {$course_id}", 'course_settings' => "course_id = {$course_id}", 'course_department' => "course = {$course_id}", 'course_module' => $sql_course, 'hierarchy' => "id IN (SELECT department FROM course_department\n                                          WHERE course = {$course_id})", 'announcement' => $sql_course, 'group_properties' => $sql_course, 'group' => $sql_course, 'group_members' => "group_id IN (SELECT id FROM `group`\n                                                    WHERE course_id = {$course_id})", 'document' => $sql_course, 'link_category' => $sql_course, 'link' => $sql_course, 'ebook' => $sql_course, 'ebook_section' => "ebook_id IN (SELECT id FROM ebook\n                                                    WHERE course_id = {$course_id})", 'ebook_subsection' => "section_id IN (SELECT ebook_section.id\n                                                         FROM ebook, ebook_section\n                                                         WHERE ebook.id = ebook_id AND\n                                                               course_id = {$course_id})", 'course_units' => $sql_course, 'unit_resources' => "unit_id IN (SELECT id FROM course_units\n                                                    WHERE course_id = {$course_id})", 'forum' => $sql_course, 'forum_category' => $sql_course, 'forum_topic' => "forum_id IN (SELECT id FROM forum\n                                                  WHERE course_id = {$course_id})", 'forum_post' => "topic_id IN (SELECT forum_topic.id\n                                                 FROM forum, forum_topic\n                                                 WHERE forum.id = forum_id AND\n                                                       course_id = {$course_id})", 'forum_notify' => $sql_course, 'forum_user_stats' => $sql_course, 'course_description' => $sql_course, 'glossary' => $sql_course, 'glossary_category' => $sql_course, 'video_category' => $sql_course, 'video' => $sql_course, 'videolink' => $sql_course, 'dropbox_msg' => $sql_course, 'dropbox_attachment' => "msg_id IN (SELECT id from dropbox_msg WHERE course_id = {$course_id})", 'dropbox_index' => "msg_id IN (SELECT id from dropbox_msg WHERE course_id = {$course_id})", 'lp_learnPath' => $sql_course, 'lp_module' => $sql_course, 'lp_asset' => "module_id IN (SELECT module_id FROM lp_module WHERE course_id = {$course_id})", 'lp_rel_learnPath_module' => "learnPath_id IN (SELECT learnPath_id FROM lp_learnPath WHERE course_id = {$course_id})", 'lp_user_module_progress' => "learnPath_id IN (SELECT learnPath_id FROM lp_learnPath WHERE course_id = {$course_id})", 'wiki_properties' => $sql_course, 'wiki_acls' => "wiki_id IN (SELECT id FROM wiki_properties WHERE course_id = {$course_id})", 'wiki_pages' => "wiki_id IN (SELECT id FROM wiki_properties WHERE course_id = {$course_id})", 'wiki_pages_content' => "pid IN (SELECT id FROM wiki_pages\n                                                    WHERE wiki_id IN (SELECT id FROM wiki_properties\n                                                                             WHERE course_id = {$course_id}))", 'poll' => $sql_course, 'poll_question' => "pid IN (SELECT pid FROM poll WHERE course_id = {$course_id})", 'poll_answer_record' => "pid IN (SELECT pid FROM poll WHERE course_id = {$course_id})", 'poll_question_answer' => "pqid IN (SELECT pqid FROM poll_question\n                                                       WHERE pid IN (SELECT pid FROM poll\n                                                                            WHERE course_id = {$course_id}))", 'assignment' => $sql_course, 'assignment_submit' => "assignment_id IN (SELECT id FROM assignment\n                                                             WHERE course_id = {$course_id})", 'gradebook' => $sql_course, 'gradebook_activities' => "gradebook_id IN (SELECT id FROM gradebook\n                                                             WHERE course_id = {$course_id})", 'gradebook_book' => "gradebook_activity_id IN (SELECT gradebook_activities.id FROM gradebook_activities, gradebook\n                                                             WHERE gradebook.course_id = {$course_id} AND gradebook_activities.gradebook_id = gradebook.id)", 'gradebook_users' => "gradebook_id IN (SELECT id FROM gradebook WHERE course_id = {$course_id})", 'attendance' => $sql_course, 'attendance_activities' => "attendance_id IN (SELECT id FROM attendance\n                                                             WHERE course_id = {$course_id})", 'attendance_book' => "attendance_activity_id IN (SELECT attendance_activities.id FROM attendance_activities, attendance\n                                                             WHERE attendance.course_id = {$course_id} AND attendance_activities.attendance_id = attendance.id)", 'attendance_users' => "attendance_id IN (SELECT id FROM attendance WHERE course_id = {$course_id})", 'agenda' => $sql_course, 'exercise' => $sql_course, 'exercise_question' => $sql_course, 'exercise_answer' => "question_id IN (SELECT id FROM exercise_question\n                                                         WHERE course_id = {$course_id})", 'exercise_user_record' => "eid IN (SELECT id FROM exercise WHERE course_id = {$course_id})", 'exercise_with_questions' => "question_id IN (SELECT id FROM exercise_question\n                                                                 WHERE course_id = {$course_id}) OR\n                                          exercise_id IN (SELECT id FROM exercise\n                                                                 WHERE course_id = {$course_id})", 'bbb_session' => "course_id IN (SELECT id FROM bbb_session WHERE course_id = {$course_id})", 'blog_post' => "id IN (SELECT id FROM blog_post WHERE course_id = {$course_id})", 'comments' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'rating' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'rating_cache' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'note' => "(reference_obj_course IS NOT NULL AND reference_obj_course = {$course_id})");
    foreach ($archive_conditions as $table => $condition) {
        backup_table($archivedir, $table, $condition);
    }
    file_put_contents("{$archivedir}/config_vars", serialize(array('urlServer' => $urlServer, 'urlAppend' => $urlAppend, 'siteName' => $siteName, 'version' => get_config('version'))));
    // $htmldir is not needed anywhere
    //$htmldir = $archivedir . '/html';
    // create zip file
    $zipCourse = new PclZip($zipfile);
    $result1 = $zipCourse->create($archivedir, PCLZIP_OPT_REMOVE_PATH, "{$webDir}/courses/archive");
    $result2 = $zipCourse->add("{$webDir}/courses/{$course_code}", PCLZIP_OPT_REMOVE_PATH, "{$webDir}/courses/{$course_code}", PCLZIP_OPT_ADD_PATH, "{$course_code}/{$backup_date}/html");
    $result3 = $zipCourse->add("{$webDir}/video/{$course_code}", PCLZIP_OPT_REMOVE_PATH, "{$webDir}/video/{$course_code}", PCLZIP_OPT_ADD_PATH, "{$course_code}/{$backup_date}/video_files");
    $success = true;
    if ($result1 === 0 || $result2 === 0 || $result3 === 0) {
        $success = false;
    }
    removeDir($archivedir);
    return $success;
}
开发者ID:kostastzo,项目名称:openeclass,代码行数:43,代码来源:archive_functions.php

示例14: export

 public function export()
 {
     // preload current locale
     $this->locale;
     $tempDir = ClassLoader::getRealPath('cache.tmp.' . rand(1, 10000000));
     $locale = Locale::getInstance($this->request->get('id'));
     $fileDir = ClassLoader::getRealPath('application.configuration.language.en');
     $files = $locale->translationManager()->getDefinitionFiles($fileDir);
     // prepare language files
     $translated = array();
     foreach ($files as $file) {
         $relPath = substr($file, strlen($fileDir) + 1);
         // get language default definitions
         $default = $locale->translationManager()->getFileDefs($relPath, true);
         if (!is_array($default)) {
             $default = array();
         }
         // get translated definitions
         $transl = $locale->translationManager()->getCacheDefs($relPath, true);
         $transl = array_merge($default, $transl);
         $values = array();
         foreach ($transl as $key => $value) {
             $values[] = $key . '=' . $value;
         }
         $path = $tempDir . '/' . $locale->getLocaleCode() . '/' . $relPath;
         if ($values) {
             if (!is_dir(dirname($path))) {
                 mkdir(dirname($path), 0777, true);
             }
             file_put_contents($path, implode("\n", $values));
         }
     }
     // put the files in zip archive
     require_once ClassLoader::getRealPath('library.pclzip') . '/pclzip.lib.php';
     if (!is_dir($tempDir)) {
         return new ActionRedirectResponse('backend.language', 'edit', array('id' => $locale->getLocaleCode()));
     }
     chdir($tempDir);
     $zip = dirname($tempDir) . '/temp_' . rand(1, 10000) . '.zip';
     $archive = new PclZip($zip);
     $archive->add($locale->getLocaleCode());
     // remove the temp directory
     $this->application->rmdir_recurse($tempDir);
     $response = new ObjectFileResponse(ObjectFile::getNewInstance('ObjectFile', $zip, 'LiveCart-' . $locale->getLocaleCode() . '.zip'));
     $response->deleteFileOnComplete();
     return $response;
 }
开发者ID:GregerA,项目名称:livecart,代码行数:47,代码来源:LanguageController.php

示例15: packen

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));
    }
}
开发者ID:mslokhat,项目名称:corebos,代码行数:18,代码来源:MergeUtils.php


注:本文中的PclZip::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。