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


PHP zipfile::send_file方法代码示例

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


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

示例1: zipfile

         $msg .= _AT('subject') . ': ' . $row['subject'] . "\r\n";
         $msg .= _AT('date') . ': ' . $row['date_sent'] . "\r\n";
         $msg .= _AT('body') . ': ' . $row['body'] . "\r\n";
         $msg .= "\r\n=============================================\r\n\r\n";
         $sent_messages .= $msg;
     }
 }
 if ($inbox_messages && $sent_messages) {
     // add the two to a zip file
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     // for zipfile
     $zipfile = new zipfile();
     $zipfile->add_file($inbox_messages, _AT('inbox') . '.txt');
     $zipfile->add_file($sent_messages, _AT('sent_messages') . '.txt');
     $zipfile->close();
     $zipfile->send_file(_AT('inbox') . '-' . date('Ymd'));
     exit;
 } else {
     if ($inbox_messages) {
         header('Content-Type: text/plain');
         header('Content-Disposition: attachment; filename="' . _AT('inbox') . '-' . date('Ymd') . '.txt"');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . strlen($inbox_messages));
         echo $inbox_messages;
         exit;
     } else {
         if ($sent_messages) {
             header('Content-Type: text/plain');
             header('Content-Disposition: attachment; filename="' . _AT('sent_messages') . '-' . date('Ymd') . '.txt"');
开发者ID:vicentborja,项目名称:ATutor,代码行数:31,代码来源:export.php

示例2: trim

    $vcard->setEmail($row['email']);
    $vcard->setNote('Originated from an AContent at ' . TR_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
/* Commented by Cindy Qi Li on Jan 12, 2010
// AContent does not have glossary and forums (discussion tools)
if ($glossary_xml) {
	$zipfile->create_dir('resources/GlossaryItem/');
	$zipfile->add_file($glossary_xml,  'resources/GlossaryItem/glossary.xml');
}
*/
$zipfile->close();
// this is optional, since send_file() closes it anyway
$ims_course_title = str_replace(array(' ', ':'), '_', $ims_course_title);
/**
 * A problem here with the preg_replace below.
 * Originally was designed to remove all werid symbols to avoid file corruptions.
 * In UTF-8, all non-english chars are considered to be 'werid symbols'
 * We can still replace it as is, or add fileid to the filename to avoid these problems
 * Well then again people won't be able to tell what this file is about
 * If we are going to take out the preg_replace, some OS might not be able to understand
 * these characters and will have problems importing.
 */
$ims_course_title = preg_replace("{[^a-zA-Z0-9._-]}", "", trim($ims_course_title));
$zipfile->send_file($ims_course_title . '_imscc');
exit;
开发者ID:harriswong,项目名称:AContent,代码行数:31,代码来源:ims_export.php

示例3: createZIP

 /**
  * Create zip file which contains patch.xml and the files to be added, overwritten, altered; and force to download
  * @access  private
  * @return  true   if successful
  *          false  if errors
  * @author  Cindy Qi Li
  */
 function createZIP()
 {
     require_once AT_INCLUDE_PATH . '/classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file(file_get_contents($this->patch_xml_file), 'patch.xml');
     if (is_array($this->patch_info_array["files"])) {
         foreach ($this->patch_info_array["files"] as $file_info) {
             if ($file_info["upload_tmp_name"] != '') {
                 $file_name = preg_replace('/.php$/', '.new', $file_info['file_name']);
                 $zipfile->add_file(file_get_contents($file_info['upload_tmp_name']), $file_name);
             }
         }
     }
     $zipfile->send_file($this->patch_info_array["atutor_patch_id"]);
 }
开发者ID:genaromendezl,项目名称:ATutor,代码行数:22,代码来源:PatchCreator.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: zipfile

                    $module_folder = $main_module_dir . $_GET['mod_dir'];
                    // check if the module has been un-installed
                    if (!file_exists($module_folder)) {
                        $msg->addError('ITEM_NOT_FOUND');
                    }
                    // only extra modules can be uninstalled
                    if (!$module->isExtra()) {
                        $msg->addError('ONLY_EXPORT_EXTRA_MODULE');
                    }
                    if (!$msg->containsErrors()) {
                        require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
                        /* for zipfile */
                        $zipfile = new zipfile();
                        $zipfile->add_dir($main_module_dir . $_GET['mod_dir'] . '/', $_GET['mod_dir'] . '/');
                        $zipfile->close();
                        $zipfile->send_file($_GET['mod_dir']);
                        exit;
                    }
                } else {
                    if (isset($_GET['disable']) || isset($_GET['enable']) || isset($_GET['details']) || isset($_GET['uninstall']) || isset($_GET['export'])) {
                        $msg->addError('NO_ITEM_SELECTED');
                        header('Location: ' . $_SERVER['PHP_SELF'] . '?' . $args);
                        exit;
                    }
                }
            }
        }
    }
}
$_custom_head .= '    <script src="' . $_base_path . 'mods/_core/modules/js/modules.js"></script>';
require AT_INCLUDE_PATH . 'header.inc.php';
开发者ID:genaromendezl,项目名称:ATutor,代码行数:31,代码来源:index.php

示例6: test_qti_export


//.........这里部分代码省略.........
        $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));
                $test_zipped_files[] = $resource_server_path;
            }
        }
    }
    if ($zipflag) {
        // construct the manifest xml
        $savant->assign('resources', $resources);
        $savant->assign('dependencies', array_keys($dependencies));
        $savant->assign('encoding', $course_language_charset);
        $savant->assign('title', $test_title);
        $savant->assign('xml_filename', $xml_filename);
        $manifest_xml = $savant->fetch('test_questions/manifest_qti_1p2.tmpl.php');
        $zipfile->add_file($manifest_xml, 'imsmanifest.xml');
        $zipfile->close();
        $filename = str_replace(array(' ', ':'), '_', $course_title . '-' . $test_title . '-' . date('Ymd'));
        $zipfile->send_file($filename);
        exit;
    }
    $return_array[$xml_filename] = array_keys($dependencies);
    return $return_array;
    //done
}
开发者ID:vicentborja,项目名称:ATutor,代码行数:101,代码来源:testQuestions.class.php

示例7: export

 function export($filename = '')
 {
     $search = array('"', "'", "", "\n", "\r", "");
     //\x08\\x09, not required
     $replace = array('\\"', "\\'", '\\0', '\\n', '\\r', '\\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->direction}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $sql = "SELECT * FROM %slanguage_text WHERE language_code='%s' ORDER BY variable, term";
     $rows_text = queryDB($sql, array(TABLE_PREFIX, $this->code));
     if (count($rows_text) > 0) {
         foreach ($rows_text as $row) {
             $row['text'] = str_replace($search, $replace, $row['text']);
             $row['context'] = str_replace($search, $replace, $row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an ATutor language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct ATutor table prefix as defined in ./include/config.inc.php . Additional Language Packs can be found on http://atutor.ca .';
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('atutor_' . $version . '_' . $this->code);
     }
 }
开发者ID:genaromendezl,项目名称:ATutor,代码行数:36,代码来源:LanguageEditor.class.php

示例8: zipfile

<?php

define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
//require (AT_INCLUDE_PATH.'header.inc.php');
$forum_id = $_GET['fid'];
$forum_title = $_GET['title'];
require 'forum_post.php';
require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
$zipfile = new zipfile();
$zipfile->add_file(file_get_contents(AT_CONTENT_DIR . '/exported_forum.html'), 'exported_forum.html');
foreach ($filearr as $val) {
    $zipfile->add_file(file_get_contents(AT_CONTENT_DIR . '/' . $val), $val);
    unlink(AT_CONTENT_DIR . '/' . $val);
}
$zipfile->add_file(file_get_contents(AT_CONTENT_DIR . '/styles.css'), 'styles.css');
unlink(AT_CONTENT_DIR . '/styles.css');
// replaces spaces with underscores
if (strpos($forum_title, chr(32)) != false) {
    $forum_title = str_replace(chr(32), chr(95), $forum_title);
}
$zipfile->send_file($forum_title);
exit;
?>

<?php 
//require (AT_INCLUDE_PATH.'footer.inc.php');
开发者ID:genaromendezl,项目名称:ATutor,代码行数:27,代码来源:send_zip_archive.php

示例9: export

 function export($filename = '')
 {
     //		$search  = array('"', "'", "\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
     //		$replace = array('\"', "\'", '\0', '\n', '\r', '\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     global $addslashes;
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $languageTextDAO = new LanguageTextDAO();
     $rows = $languageTextDAO->getAllByLang($this->code);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             //				$row['text']    = str_replace($search, $replace, $row['text']);
             //				$row['context'] = str_replace($search, $replace, $row['context']);
             $row['text'] = $addslashes($row['text']);
             $row['context'] = $addslashes($row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
         return;
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an AChecker language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct AChecker table prefix as defined in ./include/config.inc.php .';
     require AC_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('achecker_' . $version . '_' . $this->code);
     }
 }
开发者ID:giuliaforsythe,项目名称:AChecker,代码行数:39,代码来源:LanguageEditor.class.php


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