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


PHP make_request_directory函数代码示例

本文整理汇总了PHP中make_request_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP make_request_directory函数的具体用法?PHP make_request_directory怎么用?PHP make_request_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: setUp

 protected function setUp()
 {
     $this->resetAfterTest();
     // Create tempfile.
     $tempfolder = make_request_directory(false);
     $this->tempfile = $tempfolder . '/' . rand();
     touch($this->tempfile);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:scanner_test.php

示例2: setUp

 protected function setUp()
 {
     global $CFG;
     // Use our special testable fixture plugin.
     $CFG->antiviruses = 'testable';
     $this->resetAfterTest();
     // Create tempfile.
     $tempfolder = make_request_directory(false);
     $this->tempfile = $tempfolder . '/' . rand();
     touch($this->tempfile);
 }
开发者ID:dg711,项目名称:moodle,代码行数:11,代码来源:antivirus_test.php

示例3: test_rewrite_step_backup_file_for_legacy_freeze

 /**
  * @dataProvider rewrite_step_backup_file_for_legacy_freeze_provider
  * @param   string  $source     The source file to test
  * @param   string  $expected   The expected result of the transformation
  */
 public function test_rewrite_step_backup_file_for_legacy_freeze($source, $expected)
 {
     $restore = $this->getMockBuilder('\\restore_gradebook_structure_step')->setMethods(null)->disableOriginalConstructor()->getMock();
     // Copy the file somewhere as the rewrite_step_backup_file_for_legacy_freeze will write the file.
     $dir = make_request_directory(true);
     $filepath = $dir . DIRECTORY_SEPARATOR . 'file.xml';
     copy($source, $filepath);
     $rc = new \ReflectionClass('\\restore_gradebook_structure_step');
     $rcm = $rc->getMethod('rewrite_step_backup_file_for_legacy_freeze');
     $rcm->setAccessible(true);
     $rcm->invoke($restore, $filepath);
     // Check the result.
     $this->assertFileEquals($expected, $filepath);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:restore_gradebook_structure_step_test.php

示例4: test_extract_to_pathname_returnvalue_failure

 /**
  * Tests extracting files returning only a boolean state with failure.
  */
 public function test_extract_to_pathname_returnvalue_failure()
 {
     $packer = get_file_packer('application/x-gzip');
     // Create sample files.
     $archivefile = make_request_directory() . DIRECTORY_SEPARATOR . 'test.tgz';
     file_put_contents($archivefile, '');
     // Extract same files.
     $outdir = make_request_directory();
     $result = $packer->extract_to_pathname($archivefile, $outdir, null, null, true);
     $this->assertFalse($result);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:tgz_packer_test.php

示例5: test_make_request_directory

 public function test_make_request_directory()
 {
     // Every request directory should be unique.
     $firstdir = make_request_directory();
     $seconddir = make_request_directory();
     $thirddir = make_request_directory();
     $fourthdir = make_request_directory();
     $this->assertNotEquals($firstdir, $seconddir);
     $this->assertNotEquals($firstdir, $thirddir);
     $this->assertNotEquals($firstdir, $fourthdir);
     $this->assertNotEquals($seconddir, $thirddir);
     $this->assertNotEquals($seconddir, $fourthdir);
     $this->assertNotEquals($thirddir, $fourthdir);
     // They should also all be within the request storage directory.
     $requestdir = get_request_storage_directory();
     $this->assertEquals(0, strpos($firstdir, $requestdir));
     $this->assertEquals(0, strpos($seconddir, $requestdir));
     $this->assertEquals(0, strpos($thirddir, $requestdir));
     $this->assertEquals(0, strpos($fourthdir, $requestdir));
     // Removing the requestdir should mean that new request directories are still created successfully.
     remove_dir($requestdir);
     $this->assertFalse(file_exists($requestdir));
     $this->assertFalse(is_dir($requestdir));
     $fifthdir = make_request_directory();
     $this->assertNotEquals($firstdir, $fifthdir);
     $this->assertNotEquals($seconddir, $fifthdir);
     $this->assertNotEquals($thirddir, $fifthdir);
     $this->assertNotEquals($fourthdir, $fifthdir);
     $this->assertTrue(is_dir($fifthdir));
     $this->assertFalse(strpos($fifthdir, $requestdir));
     // And it should be within the new request directory.
     $newrequestdir = get_request_storage_directory();
     $this->assertEquals(0, strpos($fifthdir, $newrequestdir));
 }
开发者ID:educakanchay,项目名称:campus,代码行数:34,代码来源:setuplib_test.php

示例6: test_extract_to_pathname_returnvalue_failure

 /**
  * @dataProvider usezipbackups_provider
  */
 public function test_extract_to_pathname_returnvalue_failure($usezipbackups)
 {
     global $CFG;
     $this->resetAfterTest();
     $packer = get_file_packer('application/vnd.moodle.backup');
     // Create 2 archives (each with one file in) in zip mode.
     $CFG->usezipbackups = $usezipbackups;
     $mbzfile = make_request_directory() . '/file.mbz';
     file_put_contents($mbzfile, 'Content');
     $target = make_request_directory();
     $result = $packer->extract_to_pathname($mbzfile, $target, null, null, true);
     $this->assertDebuggingCalledCount(1);
     $this->assertFalse($result);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:17,代码来源:mbz_packer_test.php

示例7: archive_plugin_version

 /**
  * Archive the current plugin on-disk version.
  *
  * @param string $folderpath full path to the plugin folder
  * @param string $component
  * @param int $version
  * @param bool $overwrite overwrite existing archive if found
  * @return bool
  */
 public function archive_plugin_version($folderpath, $component, $version, $overwrite = false)
 {
     if ($component !== clean_param($component, PARAM_SAFEDIR)) {
         // This should never happen, but just in case.
         throw new moodle_exception('unexpected_plugin_component_format', 'core_plugin', '', null, $component);
     }
     if ((string) $version !== clean_param((string) $version, PARAM_FILE)) {
         // Prevent some nasty injections via $plugin->version tricks.
         throw new moodle_exception('unexpected_plugin_version_format', 'core_plugin', '', null, $version);
     }
     if (empty($component) or empty($version)) {
         return false;
     }
     if (!is_dir($folderpath)) {
         return false;
     }
     $archzip = $this->temproot . '/archive/' . $component . '/' . $version . '.zip';
     if (file_exists($archzip) and !$overwrite) {
         return true;
     }
     $tmpzip = make_request_directory() . '/' . $version . '.zip';
     $zipped = $this->zip_plugin_folder($folderpath, $tmpzip);
     if (!$zipped) {
         return false;
     }
     // Assert that the file looks like a valid one.
     list($expectedtype, $expectedname) = core_component::normalize_component($component);
     $actualname = $this->get_plugin_zip_root_dir($tmpzip);
     if ($actualname !== $expectedname) {
         // This should not happen.
         throw new moodle_exception('unexpected_archive_structure', 'core_plugin');
     }
     make_writable_directory(dirname($archzip));
     return rename($tmpzip, $archzip);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:44,代码来源:code_manager.php

示例8: get_file_content

 /**
  * Fetch the file ocntnet for the ODS.
  *
  * @return string
  */
 public function get_file_content()
 {
     $dir = make_request_directory();
     $filename = $dir . '/result.ods';
     $files = ['mimetype' => [$this->get_ods_mimetype()], 'content.xml' => [$this->get_ods_content($this->worksheets)], 'meta.xml' => [$this->get_ods_meta()], 'styles.xml' => [$this->get_ods_styles()], 'settings.xml' => [$this->get_ods_settings()], 'META-INF/manifest.xml' => [$this->get_ods_manifest()]];
     $packer = get_file_packer('application/zip');
     $packer->archive_to_pathname($files, $filename);
     $contents = file_get_contents($filename);
     remove_dir($dir);
     return $contents;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:odslib.class.php

示例9: required_param

 * @package   mod_folder
 * @copyright 2015 Andrew Hancox <andrewdchancox@googlemail.com>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once __DIR__ . "/../../config.php";
$id = required_param('id', PARAM_INT);
// Course module ID.
$cm = get_coursemodule_from_id('folder', $id, 0, true, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/folder:view', $context);
$folder = $DB->get_record('folder', array('id' => $cm->instance), '*', MUST_EXIST);
$downloadable = folder_archive_available($folder, $cm);
if (!$downloadable) {
    print_error('cannotdownloaddir', 'repository');
}
folder_downloaded($folder, $course, $cm, $context);
$fs = get_file_storage();
$file = $fs->get_file($context->id, 'mod_folder', 'content', 0, '/', '.');
if (!$file) {
    print_error('cannotdownloaddir', 'repository');
}
$zipper = get_file_packer('application/zip');
$filename = clean_filename($folder->name . "-" . date("Ymd")) . ".zip";
$temppath = make_request_directory() . $filename;
if ($zipper->archive_to_pathname(array('/' => $file), $temppath)) {
    send_temp_file($temppath, $filename);
} else {
    print_error('cannotdownloaddir', 'repository');
}
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:download_folder.php

示例10: prepare_file

 /**
  * Get a unique file path in which to save the file.
  *
  * The filename returned will be removed at the end of the request and
  * should not be relied upon to exist in subsequent requests.
  *
  * @param string $filename file name
  * @return file path
  */
 public function prepare_file($filename)
 {
     if (empty($filename)) {
         $filename = 'file';
     }
     return sprintf('%s/%s', make_request_directory(), $filename);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:lib.php

示例11: test_extract_to_pathname_returnvalue_failure

 /**
  * @depends test_archive_to_storage
  */
 public function test_extract_to_pathname_returnvalue_failure()
 {
     global $CFG;
     $this->resetAfterTest(false);
     $packer = get_file_packer('application/zip');
     $target = make_request_directory();
     $archive = "{$CFG->tempdir}/noarchive.zip";
     $result = $packer->extract_to_pathname($archive, $target, null, null, true);
     $this->assertFalse($result);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:zip_packer_test.php

示例12: rewrite_step_backup_file_for_legacy_freeze

 /**
  * Rewrite step definition to handle the legacy freeze attribute.
  *
  * In previous backups the calculations_freeze property was stored as an attribute of the
  * top level node <gradebook>. The backup API, however, do not process grandparent nodes.
  * It only processes definitive children, and their parent attributes.
  *
  * We had:
  *
  * <gradebook calculations_freeze="20160511">
  *   <grade_categories>
  *     <grade_category id="10">
  *       <depth>1</depth>
  *       ...
  *     </grade_category>
  *   </grade_categories>
  *   ...
  * </gradebook>
  *
  * And this method will convert it to:
  *
  * <gradebook >
  *   <attributes>
  *     <calculations_freeze>20160511</calculations_freeze>
  *   </attributes>
  *   <grade_categories>
  *     <grade_category id="10">
  *       <depth>1</depth>
  *       ...
  *     </grade_category>
  *   </grade_categories>
  *   ...
  * </gradebook>
  *
  * Note that we cannot just load the XML file in memory as it could potentially be huge.
  * We can also completely ignore if the node <attributes> is already in the backup
  * file as it never existed before.
  *
  * @param string $filepath The absolute path to the XML file.
  * @return void
  */
 protected function rewrite_step_backup_file_for_legacy_freeze($filepath)
 {
     $foundnode = false;
     $newfile = make_request_directory(true) . DIRECTORY_SEPARATOR . 'file.xml';
     $fr = fopen($filepath, 'r');
     $fw = fopen($newfile, 'w');
     if ($fr && $fw) {
         while (($line = fgets($fr, 4096)) !== false) {
             if (!$foundnode && strpos($line, '<gradebook ') === 0) {
                 $foundnode = true;
                 $matches = array();
                 $pattern = '@calculations_freeze=.([0-9]+).@';
                 if (preg_match($pattern, $line, $matches)) {
                     $freeze = $matches[1];
                     $line = preg_replace($pattern, '', $line);
                     $line .= "  <attributes>\n    <calculations_freeze>{$freeze}</calculations_freeze>\n  </attributes>\n";
                 }
             }
             fputs($fw, $line);
         }
         if (!feof($fr)) {
             throw new restore_step_exception('Error while attempting to rewrite the gradebook step file.');
         }
         fclose($fr);
         fclose($fw);
         if (!rename($newfile, $filepath)) {
             throw new restore_step_exception('Error while attempting to rename the gradebook step file.');
         }
     } else {
         if ($fr) {
             fclose($fr);
         }
         if ($fw) {
             fclose($fw);
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:78,代码来源:restore_stepslib.php

示例13: test_zip_plugin_folder

 public function test_zip_plugin_folder()
 {
     $fixtures = __DIR__ . '/fixtures/update_validator/plugindir';
     $storage = make_request_directory();
     $codeman = new \core\update\testable_code_manager();
     $codeman->zip_plugin_folder($fixtures . '/foobar', $storage . '/foobar.zip');
     $this->assertTrue(file_exists($storage . '/foobar.zip'));
     $fp = get_file_packer('application/zip');
     $zipfiles = $fp->list_files($storage . '/foobar.zip');
     $this->assertNotEmpty($zipfiles);
     foreach ($zipfiles as $zipfile) {
         if ($zipfile->is_directory) {
             $this->assertTrue(is_dir($fixtures . '/' . $zipfile->pathname));
         } else {
             $this->assertTrue(file_exists($fixtures . '/' . $zipfile->pathname));
         }
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:18,代码来源:update_code_manager_test.php

示例14: prepare_file

 /**
  * Get a unique file path in which to save the file.
  *
  * The filename returned will be removed at the end of the request and
  * should not be relied upon to exist in subsequent requests.
  *
  * @param string $filename file name
  * @return file path
  */
 public function prepare_file($filename)
 {
     return sprintf('%s/%s', make_request_directory(), $filename);
 }
开发者ID:isuruAb,项目名称:moodle,代码行数:13,代码来源:lib.php

示例15: detect_plugin_component

 /**
  * Detect the given plugin's component name
  *
  * Only plugins that declare valid $plugin->component value in the version.php
  * are supported.
  *
  * @param string $zipfilepath full path to the saved ZIP file
  * @return string|bool declared component name or false if unable to detect
  */
 public function detect_plugin_component($zipfilepath)
 {
     $workdir = make_request_directory();
     $versionphp = $this->extract_versionphp_file($zipfilepath, $workdir);
     if (empty($versionphp)) {
         return false;
     }
     return $this->detect_plugin_component_from_versionphp(file_get_contents($workdir . '/' . $versionphp));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:installer.php


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