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


PHP zipfile::create_dir方法代码示例

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


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

示例1: header

/* for zipfile */
require_once TR_INCLUDE_PATH . 'classes/vcard.php';
/* for vcard */
require_once TR_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
/* for XML_HTMLSax */
require_once TR_INCLUDE_PATH . 'classes/ContentOutputParser.class.php';
/* to retrieve content resources/medias from at_content[text] */
require_once TR_INCLUDE_PATH . '../home/imscc/include/ims_template.inc.php';
/* for ims templates + print_organizations() */
if (isset($_POST['cancel'])) {
    $msg->addFeedback('EXPORT_CANCELLED');
    header('Location: ../index.php');
    exit;
}
$zipfile = new zipfile();
$zipfile->create_dir('resources/');
/* get all the content */
$content = array();
$paths = array();
$top_content_parent_id = 0;
$handler = new ContentOutputParser();
$parser = new XML_HTMLSax();
$parser->set_object($handler);
$parser->set_element_handler('openHandler', 'closeHandler');
$contentDAO = new ContentDAO();
$rows = $contentDAO->getContentByCourseID($course_id);
//if (authenticate(TR_PRIV_CONTENT, TR_PRIV_RETURN)) {
//	$sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
//} else {
//	$sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
//}
开发者ID:harriswong,项目名称:AContent,代码行数:31,代码来源:ims_export.php

示例2: header

/* for vcard */
require AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
/* for XML_HTMLSax */
require AT_INCLUDE_PATH . 'classes/ContentOutputParser.class.php';
/* to retrieve content resources/medias from at_content[text] */
require AT_INCLUDE_PATH . '../mods/_core/imscc/include/ims_template.inc.php';
/* for ims templates + print_organizations() */
require_once AT_INCLUDE_PATH . 'classes/ContentManager.class.php';
/* to retrieve content resources/medias from at_content[text] */
if (isset($_POST['cancel'])) {
    $msg->addFeedback('EXPORT_CANCELLED');
    header('Location: ../index.php');
    exit;
}
$zipfile = new zipfile();
$zipfile->create_dir('resources/');
/* get all the content */
$content = array();
$paths = array();
$top_content_parent_id = 0;
$contentManager = new ContentManager($db, $course_id);
$handler = new ContentOutputParser();
$parser = new XML_HTMLSax();
$parser->set_object($handler);
$parser->set_element_handler('openHandler', 'closeHandler');
if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
    $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM %scontent WHERE course_id=%d ORDER BY content_parent_id, ordering";
    $rows_content = queryDB($sql, array(TABLE_PREFIX, $course_id));
} else {
    $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM %scontent WHERE course_id=%d ORDER BY content_parent_id, ordering";
    $rows_content = queryDB($sql, array(TABLE_PREFIX, $course_id));
开发者ID:genaromendezl,项目名称:ATutor,代码行数:31,代码来源:ims_export.php

示例3: test_qti_export

/** 
 * Export test 
 * @param    int        test id
 * @param    string    the test title
 * @param    ref        [OPTIONAL] zip object reference
 * @param    array    [OPTIONAL] list of already added files.
 */
function test_qti_export($tid, $test_title = '', $zipfile = null)
{
    require_once AT_INCLUDE_PATH . 'classes/zipfile.class.php';
    // for zipfile
    require_once AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
    // for XML_HTMLSax
    require_once AT_INCLUDE_PATH . 'lib/html_resource_parser.inc.php';
    // for get_html_resources()
    global $savant, $db, $system_courses, $languageManager, $test_zipped_files, $test_files, $use_cc;
    global $course_id;
    $course_id = $_SESSION['course_id'];
    $course_title = $_SESSION['course_title'];
    $course_language = $system_courses[$_SESSION['course_id']]['primary_language'];
    if ($course_language == '') {
        // when oauth export into Transformable
        $sql = "SELECT course_id, title, primary_language FROM " . TABLE_PREFIX . "courses\n                 WHERE course_id = (SELECT course_id FROM " . TABLE_PREFIX . "tests\n                                     WHERE test_id=" . $tid . ")";
        $result = mysql_query($sql, $db);
        $course_row = mysql_fetch_assoc($result);
        $course_language = $course_row['primary_language'];
        $course_id = $course_row['course_id'];
        $course_title = $course_row['title'];
    }
    $courseLanguage =& $languageManager->getLanguage($course_language);
    $course_language_charset = $courseLanguage->getCharacterSet();
    $imported_files;
    $zipflag = false;
    if ($zipfile == null) {
        $zipflag = true;
    }
    if ($test_zipped_files == null) {
        $test_zipped_files = array();
    }
    if ($zipflag) {
        $zipfile = new zipfile();
        $zipfile->create_dir('resources/');
        // for all the dependency files
    }
    $resources = array();
    $dependencies = array();
    //    don't want to sort it, i want the same order out.
    //    asort($question_ids);
    //TODO: Merge the following 2 sqls together.
    //Randomized or not, export all the questions that are associated with it.
    $sql = "SELECT TQ.question_id, TQA.weight FROM " . TABLE_PREFIX . "tests_questions TQ INNER JOIN " . TABLE_PREFIX . "tests_questions_assoc TQA USING (question_id) WHERE TQ.course_id={$course_id} AND TQA.test_id={$tid} ORDER BY TQA.ordering, TQA.question_id";
    $result = mysql_query($sql, $db);
    $question_ids = array();
    while (($question_row = mysql_fetch_assoc($result)) != false) {
        $question_ids[] = $question_row['question_id'];
    }
    //No questions in the test
    if (sizeof($question_ids) == 0) {
        return;
    }
    $question_ids_delim = implode(',', $question_ids);
    //$sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions WHERE course_id=$_SESSION[course_id] AND question_id IN($question_ids_delim)";
    $sql = "SELECT TQ.*, TQA.weight, TQA.test_id FROM " . TABLE_PREFIX . "tests_questions TQ INNER JOIN " . TABLE_PREFIX . "tests_questions_assoc TQA USING (question_id) WHERE TQA.test_id={$tid} AND TQ.question_id IN({$question_ids_delim}) ORDER BY TQA.ordering, TQA.question_id";
    $result = mysql_query($sql, $db);
    while ($row = mysql_fetch_assoc($result)) {
        $obj = TestQuestions::getQuestion($row['type']);
        $local_xml = '';
        $local_xml = $obj->exportQTI($row, $course_language_charset, '1.2.1');
        $local_dependencies = array();
        $text_blob = implode(' ', $row);
        $local_dependencies = get_html_resources($text_blob, $course_id);
        $dependencies = array_merge($dependencies, $local_dependencies);
        $xml = $xml . "\n\n" . $local_xml;
    }
    //files that are found inside the test; used by print_organization(), to add all test files into QTI/ folder.
    $test_files = $dependencies;
    $resources[] = array('href' => 'tests_' . $tid . '.xml', 'dependencies' => array_keys($dependencies));
    $xml = trim($xml);
    //get test title
    $sql = "SELECT title, num_takes FROM " . TABLE_PREFIX . "tests WHERE test_id = {$tid}";
    $result = mysql_query($sql, $db);
    $row = mysql_fetch_array($result);
    //TODO: wrap around xml now
    $savant->assign('xml_content', $xml);
    $savant->assign('title', htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8'));
    $savant->assign('num_takes', $row['num_takes']);
    $savant->assign('use_cc', $use_cc);
    $xml = $savant->fetch('test_questions/wrapper.tmpl.php');
    $xml_filename = 'tests_' . $tid . '.xml';
    if (!$use_cc) {
        $zipfile->add_file($xml, $xml_filename);
    } else {
        $zipfile->add_file($xml, 'QTI/' . $xml_filename);
    }
    // add any dependency files:
    if (!$use_cc) {
        foreach ($dependencies as $resource => $resource_server_path) {
            //add this file in if it's not already in the zip package
            if (!in_array($resource_server_path, $test_zipped_files)) {
                $zipfile->add_file(@file_get_contents($resource_server_path), 'resources/' . $resource, filemtime($resource_server_path));
//.........这里部分代码省略.........
开发者ID:vicentborja,项目名称:ATutor,代码行数:101,代码来源:testQuestions.class.php

示例4: export_theme

function export_theme($theme_dir)
{
    require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
    /* for zipfile */
    require AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
    /* for XML_HTMLSax */
    require 'theme_template.inc.php';
    /* for theme XML templates */
    global $db;
    //identify current theme and then searches db for relavent info
    $sql = "SELECT * FROM " . TABLE_PREFIX . "themes WHERE dir_name = '{$theme_dir}'";
    $result = mysql_query($sql, $db);
    $row = mysql_fetch_assoc($result);
    $dir = $row['dir_name'] . '/';
    $title = $row['title'];
    $version = $row['version'];
    $type = $row['type'];
    $last_updated = $row['last_updated'];
    $extra_info = $row['extra_info'];
    //generate 'theme_info.xml' file based on info
    $info_xml = str_replace(array('{TITLE}', '{VERSION}', '{TYPE}', '{LAST_UPDATED}', '{EXTRA_INFO}'), array($title, $version, $type, $last_updated, $extra_info), $theme_template_xml);
    //zip together all the contents of the folder along with the XML file
    $zipfile = new zipfile();
    $zipfile->create_dir($dir);
    //update installation folder
    $dir1 = get_main_theme_dir(intval($row["customized"])) . $dir;
    $zipfile->add_file($info_xml, $dir . 'theme_info.xml');
    /* zip other required files */
    $zipfile->add_dir($dir1, $dir);
    /*close & send*/
    $zipfile->close();
    //Name the Zip file and sends to user for download
    $zipfile->send_file(str_replace(array(' ', ':'), '_', $title));
}
开发者ID:vicentborja,项目名称:ATutor,代码行数:34,代码来源:themes.inc.php

示例5: dashboard_backup

function dashboard_backup()
{
    $name = '';
    require_once SERVDIR . '/core/zip.class.php';
    if (request_type('POST')) {
        cn_dsi_check();
        $name = trim(preg_replace('/[^a-z0_9_]/i', '', REQ('backup_name')));
        $backup_sysonly = REQ('backup_sysonly');
        if (!$name) {
            cn_throw_message('Enter correct backup name', 'e');
        } else {
            // Do compress files
            $zip = new zipfile();
            if (!$backup_sysonly) {
                $zip->create_dir('news/');
                $zip->create_dir('users/');
                // Compress news
                $news = scan_dir(cn_path_construct(SERVDIR, 'cdata', 'news'));
                foreach ($news as $file) {
                    $data = join('', file(cn_path_construct(SERVDIR, 'cdata', 'news') . $file));
                    $zip->create_file($data, 'news' . DIRECTORY_SEPARATOR . $file);
                }
                // Compress users
                $news = scan_dir(cn_path_construct(SERVDIR, 'cdata', 'users'));
                foreach ($news as $file) {
                    $data = join('', file(cn_path_construct(SERVDIR, 'cdata', 'users') . $file));
                    $zip->create_file($data, 'news' . DIRECTORY_SEPARATOR . $file);
                }
                $files = array('conf.php', 'users.txt');
            } else {
                $files = array('conf.php');
            }
            // Append files
            foreach ($files as $file) {
                $data = join('', file(cn_path_construct(SERVDIR, 'cdata') . $file));
                $zip->create_file($data, $file);
            }
            // write compressed data
            $wb = fopen(cn_path_construct(SERVDIR, 'cdata', 'backup') . $name . '.zip', 'w+');
            fwrite($wb, $zip->zipped_file());
            fclose($wb);
            // backup created
            cn_throw_message('Backup sucessfull created');
            unset($zip);
            $name = '';
        }
    } elseif ($unpack_file = REQ('unpack', 'GET')) {
        cn_dsi_check();
        if (file_exists($cf = cn_path_construct(SERVDIR, 'cdata', 'backup') . $unpack_file . 'zip')) {
            $zip = new zipfile();
            $files = $zip->read_zip(cn_path_construct(SERVDIR, 'cdata', 'backup') . $unpack_file . 'zip');
            unset($zip);
            // replace files from zip-archive
            foreach ($files as $fdata) {
                $file = $fdata['dir'] . DIRECTORY_SEPARATOR . $fdata['name'];
                $w = fopen(cn_path_construct(SERVDIR, 'cdata') . $file, 'w+');
                fwrite($w, $fdata['data']);
                fclose($w);
            }
            unlink($cf);
            cn_throw_message('File decompressed, backup removed');
        } else {
            cn_throw_message('File [' . cn_htmlspecialchars($unpack_file) . '] not exists', 'e');
        }
    }
    $archives = array();
    $list = scan_dir(cn_path_construct(SERVDIR, 'cdata', 'backup'), '\\.zip');
    foreach ($list as $d) {
        $file = cn_path_construct(SERVDIR, 'cdata', 'backup') . $d;
        $archives[] = array('name' => str_replace('.zip', '', $d), 'size' => filesize($file), 'date' => date('Y-m-d H:i:s', filemtime($file)));
    }
    cn_assign('archives, name', $archives, $name);
    echoheader('-@dashboard/style.css', 'Backups');
    echo exec_tpl('dashboard/backups');
    echofooter();
}
开发者ID:JulioCF,项目名称:cutenews-2.0,代码行数:76,代码来源:dashboard.php


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