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


PHP make_cache_directory函数代码示例

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


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

示例1: __construct

 /**
  * Initialises the cache lock instance.
  *
  * @param string $name The name of the cache lock
  * @param array $configuration
  */
 public function __construct($name, array $configuration = array())
 {
     $this->name = $name;
     if (!array_key_exists('dir', $configuration)) {
         $this->cachedir = make_cache_directory(md5($name));
     } else {
         $dir = $configuration['dir'];
         if (strpos($dir, '/') !== false && strpos($dir, '.') !== 0) {
             // This looks like an absolute path.
             if (file_exists($dir) && is_dir($dir) && is_writable($dir)) {
                 $this->cachedir = $dir;
             }
         }
         if (empty($this->cachedir)) {
             $dir = preg_replace('#[^a-zA-Z0-9_]#', '_', $dir);
             $this->cachedir = make_cache_directory($dir);
         }
     }
     if (array_key_exists('maxlife', $configuration) && is_number($configuration['maxlife'])) {
         $maxlife = (int) $configuration['maxlife'];
         // Minimum lock time is 60 seconds.
         $this->maxlife = max($maxlife, 60);
     }
     if (array_key_exists('blockattempts', $configuration) && is_number($configuration['blockattempts'])) {
         $this->blockattempts = (int) $configuration['blockattempts'];
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:lib.php

示例2: test_cache_get_with_prescan_and_purge

 /**
  * Testing cachestore_file::get with prescan enabled and with
  * deleting the cache between the prescan and the call to get.
  *
  * The deleting of cache simulates some other process purging
  * the cache.
  */
 public function test_cache_get_with_prescan_and_purge()
 {
     global $CFG;
     $definition = cache_definition::load_adhoc(cache_store::MODE_REQUEST, 'cachestore_file', 'phpunit_test');
     $name = 'File test';
     $path = make_cache_directory('cachestore_file_test');
     $cache = new cachestore_file($name, array('path' => $path, 'prescan' => true));
     $cache->initialise($definition);
     $cache->set('testing', 'value');
     $path = make_cache_directory('cachestore_file_test');
     $cache = new cachestore_file($name, array('path' => $path, 'prescan' => true));
     $cache->initialise($definition);
     // Let's pretend that some other process purged caches.
     remove_dir($CFG->cachedir . '/cachestore_file_test', true);
     make_cache_directory('cachestore_file_test');
     $cache->get('testing');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:24,代码来源:file_test.php

示例3: blog_rss_save_file

/**
 * This function saves to file the rss feed specified in the parameters
 *
 * @param string $type     The source of the RSS feed (site/course/group/user)
 * @param int    $id       The id of the item defined by $type
 * @param int    $tagid    The id of the row in the tag table that identifies the RSS Feed
 * @param string $contents The contents of the RSS Feed file
 * @return bool whether the save was successful or not
 */
function blog_rss_save_file($type, $id, $tagid = 0, $contents = '')
{
    global $CFG;
    $status = true;
    //blog creates some additional dirs within the rss cache so make sure they all exist
    make_cache_directory('rss/blog');
    make_cache_directory('rss/blog/' . $type);
    $filename = blog_rss_file_name($type, $id, $tagid);
    $expandfilename = false;
    //we're supplying a full file path
    $status = rss_save_file('blog', $filename, $contents, $expandfilename);
    return $status;
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:22,代码来源:rsslib.php

示例4: reset_dataroot

    /**
     * Purge dataroot directory
     * @static
     * @return void
     */
    public static function reset_dataroot() {
        global $CFG;

        $childclassname = self::get_framework() . '_util';

        $handle = opendir($CFG->dataroot);
        while (false !== ($item = readdir($handle))) {
            if (in_array($item, $childclassname::$datarootskiponreset)) {
                continue;
            }
            if (is_dir("$CFG->dataroot/$item")) {
                remove_dir("$CFG->dataroot/$item", false);
            } else {
                unlink("$CFG->dataroot/$item");
            }
        }
        closedir($handle);
        make_temp_directory('');
        make_cache_directory('');
        make_cache_directory('htmlpurifier');
        // Reset the cache API so that it recreates it's required directories as well.
        cache_factory::reset();
        // Purge all data from the caches. This is required for consistency.
        // Any file caches that happened to be within the data root will have already been clearer (because we just deleted cache)
        // and now we will purge any other caches as well.
        cache_helper::purge_all();
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:32,代码来源:util.php

示例5: purge_all_caches

/**
 * Invalidates browser caches and cached data in temp.
 *
 * IMPORTANT - If you are adding anything here to do with the cache directory you should also have a look at
 * {@link phpunit_util::reset_dataroot()}
 *
 * @return void
 */
function purge_all_caches()
{
    global $CFG, $DB;
    reset_text_filters_cache();
    js_reset_all_caches();
    theme_reset_all_caches();
    get_string_manager()->reset_caches();
    core_text::reset_caches();
    if (class_exists('core_plugin_manager')) {
        core_plugin_manager::reset_caches();
    }
    // Bump up cacherev field for all courses.
    try {
        increment_revision_number('course', 'cacherev', '');
    } catch (moodle_exception $e) {
        // Ignore exception since this function is also called before upgrade script when field course.cacherev does not exist yet.
    }
    $DB->reset_caches();
    cache_helper::purge_all();
    // Purge all other caches: rss, simplepie, etc.
    clearstatcache();
    remove_dir($CFG->cachedir . '', true);
    // Make sure cache dir is writable, throws exception if not.
    make_cache_directory('');
    // This is the only place where we purge local caches, we are only adding files there.
    // The $CFG->localcachedirpurged flag forces local directories to be purged on cluster nodes.
    remove_dir($CFG->localcachedir, true);
    set_config('localcachedirpurged', time());
    make_localcache_directory('', true);
    \core\task\manager::clear_static_caches();
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:39,代码来源:moodlelib.php

示例6: rss_save_file

/**
 * This function saves to file the rss feed specified in the parameters
 *
 * @param string $componentname  the module name ie forum. Used to create a cache directory.
 * @param string $filename       the name of the file to be created ie "rss.xml"
 * @param string $contents       the data to be written to the file
 * @param bool   $expandfilename whether or not the fullname of the RSS file should be used
 * @return bool whether the save was successful or not
 */
function rss_save_file($componentname, $filename, $contents, $expandfilename = true)
{
    global $CFG;
    $status = true;
    if (!($basedir = make_cache_directory('rss/' . $componentname))) {
        //Cannot be created, so error
        $status = false;
    }
    if ($status) {
        $fullfilename = $filename;
        if ($expandfilename) {
            $fullfilename = rss_get_file_full_name($componentname, $filename);
        }
        $rss_file = fopen($fullfilename, "w");
        if ($rss_file) {
            $status = fwrite($rss_file, $contents);
            fclose($rss_file);
        } else {
            $status = false;
        }
    }
    return $status;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:32,代码来源:rsslib.php

示例7: install_core

/**
 * Install core moodle tables and initialize
 * @param float $version target version
 * @param bool $verbose
 * @return void, may throw exception
 */
function install_core($version, $verbose) {
    global $CFG, $DB;

    // We can not call purge_all_caches() yet, make sure the temp and cache dirs exist and are empty.
    remove_dir($CFG->cachedir.'', true);
    make_cache_directory('', true);

    remove_dir($CFG->localcachedir.'', true);
    make_localcache_directory('', true);

    remove_dir($CFG->tempdir.'', true);
    make_temp_directory('', true);

    remove_dir($CFG->dataroot.'/muc', true);
    make_writable_directory($CFG->dataroot.'/muc', true);

    try {
        core_php_time_limit::raise(600);
        print_upgrade_part_start('moodle', true, $verbose); // does not store upgrade running flag

        $DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
        upgrade_started();     // we want the flag to be stored in config table ;-)

        // set all core default records and default settings
        require_once("$CFG->libdir/db/install.php");
        xmldb_main_install(); // installs the capabilities too

        // store version
        upgrade_main_savepoint(true, $version, false);

        // Continue with the installation
        log_update_descriptions('moodle');
        external_update_descriptions('moodle');
        events_update_definition('moodle');
        \core\task\manager::reset_scheduled_tasks_for_component('moodle');
        message_update_providers('moodle');
        \core\message\inbound\manager::update_handlers_for_component('moodle');

        // Write default settings unconditionally
        admin_apply_default_settings(NULL, true);

        print_upgrade_part_end(null, true, $verbose);

        // Purge all caches. They're disabled but this ensures that we don't have any persistent data just in case something
        // during installation didn't use APIs.
        cache_helper::purge_all();
    } catch (exception $ex) {
        upgrade_handle_exception($ex);
    }
}
开发者ID:jtibbetts,项目名称:moodle,代码行数:56,代码来源:upgradelib.php

示例8: reset_dataroot

 /**
  * Purge dataroot directory
  * @static
  * @return void
  */
 public static function reset_dataroot()
 {
     global $CFG;
     $childclassname = self::get_framework() . '_util';
     // Do not delete automatically installed files.
     self::skip_original_data_files($childclassname);
     // Clear file status cache, before checking file_exists.
     clearstatcache();
     // Clean up the dataroot folder.
     $handle = opendir(self::get_dataroot());
     while (false !== ($item = readdir($handle))) {
         if (in_array($item, $childclassname::$datarootskiponreset)) {
             continue;
         }
         if (is_dir(self::get_dataroot() . "/{$item}")) {
             remove_dir(self::get_dataroot() . "/{$item}", false);
         } else {
             unlink(self::get_dataroot() . "/{$item}");
         }
     }
     closedir($handle);
     // Clean up the dataroot/filedir folder.
     if (file_exists(self::get_dataroot() . '/filedir')) {
         $handle = opendir(self::get_dataroot() . '/filedir');
         while (false !== ($item = readdir($handle))) {
             if (in_array('filedir/' . $item, $childclassname::$datarootskiponreset)) {
                 continue;
             }
             if (is_dir(self::get_dataroot() . "/filedir/{$item}")) {
                 remove_dir(self::get_dataroot() . "/filedir/{$item}", false);
             } else {
                 unlink(self::get_dataroot() . "/filedir/{$item}");
             }
         }
         closedir($handle);
     }
     make_temp_directory('');
     make_cache_directory('');
     make_localcache_directory('');
     // Reset the cache API so that it recreates it's required directories as well.
     cache_factory::reset();
     // Purge all data from the caches. This is required for consistency.
     // Any file caches that happened to be within the data root will have already been clearer (because we just deleted cache)
     // and now we will purge any other caches as well.
     cache_helper::purge_all();
 }
开发者ID:matiasma,项目名称:moodle,代码行数:51,代码来源:util.php

示例9: purge_all_caches

/**
 * Invalidates browser caches and cached data in temp
 * @return void
 */
function purge_all_caches()
{
    global $CFG;
    reset_text_filters_cache();
    js_reset_all_caches();
    theme_reset_all_caches();
    get_string_manager()->reset_caches();
    textlib::reset_caches();
    // purge all other caches: rss, simplepie, etc.
    remove_dir($CFG->cachedir . '', true);
    // make sure cache dir is writable, throws exception if not
    make_cache_directory('');
    // hack: this script may get called after the purifier was initialised,
    // but we do not want to verify repeatedly this exists in each call
    make_cache_directory('htmlpurifier');
}
开发者ID:nmicha,项目名称:moodle,代码行数:20,代码来源:moodlelib.php

示例10: get_string

    $strsubmit = $PAGE->user_is_editing() ? get_string('blockseditoff') : get_string('blocksediton');
    $url = new moodle_url($CFG->wwwroot . '/mod/certificate/view.php', array('id' => $cm->id, 'edit' => $editvalue));
    $PAGE->set_button($OUTPUT->single_button($url, $strsubmit));
}
// Check if the user can view the certificate
if ($certificate->requiredtime && !has_capability('mod/certificate:manage', $context)) {
    if (certificate_get_course_time($course->id) < $certificate->requiredtime * 60) {
        $a = new stdClass();
        $a->requiredtime = $certificate->requiredtime;
        notice(get_string('requiredtimenotmet', 'certificate', $a), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
        die;
    }
}
// Create new certificate record, or return existing record
$certrecord = certificate_get_issue($course, $USER, $certificate, $cm);
make_cache_directory('tcpdf');
// Load the specific certificate type.
require "{$CFG->dirroot}/mod/certificate/type/{$certificate->certificatetype}/certificate.php";
if (empty($action)) {
    // Not displaying PDF
    echo $OUTPUT->header();
    /// find out current groups mode
    groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/certificate/view.php?id=' . $cm->id);
    $currentgroup = groups_get_activity_group($cm);
    $groupmode = groups_get_activity_groupmode($cm);
    if (has_capability('mod/certificate:manage', $context)) {
        $numusers = count(certificate_get_issues($certificate->id, 'ci.timecreated ASC', $groupmode, $cm));
        $url = html_writer::tag('a', get_string('viewcertificateviews', 'certificate', $numusers), array('href' => $CFG->wwwroot . '/mod/certificate/report.php?id=' . $cm->id));
        echo html_writer::tag('div', $url, array('class' => 'reportlink'));
    }
    if (!empty($certificate->intro)) {
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:view.php

示例11: __construct

 /**
  * Class constructor
  *
  * See the parent class documentation for the parameters info.
  */
 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8')
 {
     make_cache_directory('tcpdf');
     parent::__construct($orientation, $unit, $format, $unicode, $encoding);
     if (is_dir(PDF_CUSTOM_FONT_PATH)) {
         $fontfiles = $this->_getfontfiles(PDF_CUSTOM_FONT_PATH);
         if (count($fontfiles) == 1) {
             $autofontname = substr($fontfiles[0], 0, -4);
             $this->AddFont($autofontname, '', $autofontname . '.php');
             $this->SetFont($autofontname);
         } else {
             if (count($fontfiles == 0)) {
                 $this->SetFont(PDF_DEFAULT_FONT);
             }
         }
     } else {
         $this->SetFont(PDF_DEFAULT_FONT);
     }
     // theses replace the tcpdf's config/lang/ definitions
     $this->l['w_page'] = get_string('page');
     $this->l['a_meta_language'] = current_language();
     $this->l['a_meta_charset'] = 'UTF-8';
     $this->l['a_meta_dir'] = get_string('thisdirection', 'langconfig');
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:29,代码来源:pdflib.php

示例12: downloadfile

 private function downloadfile($url, $filename, $forcedownload = false, $cachefolder = 'skillsoft', $cachetime = 86400)
 {
     global $CFG;
     $basefolder = str_replace('\\', '/', $CFG->cachedir);
     $folder = $cachefolder;
     /// Create cache directory if necesary
     if (!make_cache_directory($folder, false)) {
         //Couldn't create temp folder
         throw new Exception('Could not create WSDL Cache Folder (skillsoft): ' . $basefolder . $folder);
     }
     $fullpath = $basefolder . '/' . $folder . '/' . $filename;
     //Check if we have a cached copy
     if (!file_exists($fullpath) || filemtime($fullpath) < time() - $cachetime || $forcedownload == true) {
         //No copy so download
         if (!extension_loaded('curl') or ($ch = curl_init($url)) === false) {
             //No curl so error
         } else {
             $fp = fopen($fullpath, 'wb');
             $ch = curl_init($url);
             //Ignore SSL errors
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
             curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
             curl_setopt($ch, CURLOPT_FILE, $fp);
             //Force SSLv3 to workaround Openssl 1.0.1 issue
             //See https://bugs.launchpad.net/ubuntu/+source/curl/+bug/595415
             //curl_setopt($ch, CURLOPT_SSLVERSION, 3);
             //Setup Proxy Connection
             if (!empty($CFG->proxyhost)) {
                 // SOCKS supported in PHP5 only
                 if (!empty($CFG->proxytype) and $CFG->proxytype == 'SOCKS5') {
                     if (defined('CURLPROXY_SOCKS5')) {
                         curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
                     } else {
                         curl_close($ch);
                         return false;
                     }
                 }
                 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);
                 if (empty($CFG->proxyport)) {
                     curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost);
                 } else {
                     curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost . ':' . $CFG->proxyport);
                 }
                 if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
                     curl_setopt($ch, CURLOPT_PROXYUSERPWD, $CFG->proxyuser . ':' . $CFG->proxypassword);
                     if (defined('CURLOPT_PROXYAUTH')) {
                         // any proxy authentication if PHP 5.1
                         curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
                     }
                 }
             }
             $data = curl_exec($ch);
             // Check if any error occured
             if (!curl_errno($ch)) {
                 $downloadresult = new object();
                 $downloadresult->status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                 $downloadresult->filename = $filename;
                 $downloadresult->filepath = $basefolder . '/' . $folder . '/' . $filename;
                 $downloadresult->error = '';
                 fclose($fp);
             } else {
                 fclose($fp);
                 $error = curl_error($ch);
                 $downloadresult = new object();
                 $downloadresult->status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                 $downloadresult->filename = '';
                 $downloadresult->filepath = '';
                 $downloadresult->error = $error;
             }
         }
     } else {
         //We do so use it
         $downloadresult = new object();
         $downloadresult->status = '200';
         $downloadresult->filename = $filename;
         $downloadresult->filepath = $fullpath;
         $downloadresult->error = '';
     }
     return $downloadresult;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:81,代码来源:olsalib.php

示例13: initialise_test_instance

 /**
  * Generates an instance of the cache store that can be used for testing.
  *
  * Returns an instance of the cache store, or false if one cannot be created.
  *
  * @param cache_definition $definition
  * @return cachestore_file
  */
 public static function initialise_test_instance(cache_definition $definition)
 {
     $name = 'File test';
     $path = make_cache_directory('cachestore_file_test');
     $cache = new cachestore_file($name, array('path' => $path));
     $cache->initialise($definition);
     return $cache;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:16,代码来源:lib.php

示例14: reset_dataroot

 /**
  * Purge dataroot directory
  * @static
  * @return void
  */
 public static function reset_dataroot()
 {
     global $CFG;
     $handle = opendir($CFG->dataroot);
     $skip = array('.', '..', 'phpunittestdir.txt', 'phpunit', '.htaccess');
     while (false !== ($item = readdir($handle))) {
         if (in_array($item, $skip)) {
             continue;
         }
         if (is_dir("{$CFG->dataroot}/{$item}")) {
             remove_dir("{$CFG->dataroot}/{$item}", false);
         } else {
             unlink("{$CFG->dataroot}/{$item}");
         }
     }
     closedir($handle);
     make_temp_directory('');
     make_cache_directory('');
     make_cache_directory('htmlpurifier');
 }
开发者ID:nigeli,项目名称:moodle,代码行数:25,代码来源:util.php

示例15: __construct

 /**
  * Class constructor
  *
  * See the parent class documentation for the parameters info.
  */
 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8')
 {
     make_cache_directory('tcpdf');
     parent::__construct($orientation, $unit, $format, $unicode, $encoding);
     // theses replace the tcpdf's config/lang/ definitions
     $this->l['w_page'] = get_string('page');
     $this->l['a_meta_language'] = current_language();
     $this->l['a_meta_charset'] = 'UTF-8';
     $this->l['a_meta_dir'] = get_string('thisdirection', 'langconfig');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:pdflib.php


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