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


PHP check_dir_exists函数代码示例

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


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

示例1: copy_file_moodle2backup

 /**
  * Copy one file from moodle storage to backup storage
  */
 public static function copy_file_moodle2backup($backupid, $filerecorid)
 {
     global $DB;
     // Normalise param
     if (!is_object($filerecorid)) {
         $filerecorid = $DB->get_record('files', array('id' => $filerecorid));
     }
     // Directory, nothing to do
     if ($filerecorid->filename === '.') {
         return;
     }
     $fs = get_file_storage();
     $file = $fs->get_file_instance($filerecorid);
     // If the file is external file, skip copying.
     if ($file->is_external_file()) {
         return;
     }
     // Calculate source and target paths (use same subdirs strategy for both)
     $targetfilepath = self::get_backup_storage_base_dir($backupid) . '/' . self::get_backup_content_file_location($filerecorid->contenthash);
     // Create target dir if necessary
     if (!file_exists(dirname($targetfilepath))) {
         if (!check_dir_exists(dirname($targetfilepath), true, true)) {
             throw new backup_helper_exception('cannot_create_directory', dirname($targetfilepath));
         }
     }
     // And copy the file (if doesn't exist already)
     if (!file_exists($targetfilepath)) {
         $file->copy_content_to($targetfilepath);
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:33,代码来源:backup_file_manager.class.php

示例2: define_execution

 protected function define_execution() {
     global $CFG;
     $basepath = $this->task->get_taskbasepath();
     if (!check_dir_exists($basepath, true, true)) {
         throw new backup_step_exception('cannot_create_taskbasepath_directory', $basepath);
     }
 }
开发者ID:nuckey,项目名称:moodle,代码行数:7,代码来源:backup_stepslib.php

示例3: xmldb_editor_tinymce_upgrade

function xmldb_editor_tinymce_upgrade($oldversion)
{
    global $CFG, $DB;
    if ($oldversion < 2014062900) {
        // We only want to delete DragMath from the customtoolbar setting if the directory no longer exists. If
        // the directory is present then it means it has been restored, so do not remove any settings.
        if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) {
            // Remove the DragMath plugin from the 'customtoolbar' setting (if it exists) as it has been removed.
            $currentorder = get_config('editor_tinymce', 'customtoolbar');
            $newtoolbarrows = array();
            $currenttoolbarrows = explode("\n", $currentorder);
            foreach ($currenttoolbarrows as $currenttoolbarrow) {
                $currenttoolbarrow = implode(',', array_diff(str_getcsv($currenttoolbarrow), array('dragmath')));
                $newtoolbarrows[] = $currenttoolbarrow;
            }
            $neworder = implode("\n", $newtoolbarrows);
            unset_config('customtoolbar', 'editor_tinymce');
            set_config('customtoolbar', $neworder, 'editor_tinymce');
        }
        upgrade_plugin_savepoint(true, 2014062900, 'editor', 'tinymce');
    }
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:upgrade.php

示例4: setUp

    public function setUp() {
        global $CFG;

        $this->tempdir = convert_helper::generate_id('simpletest');
        check_dir_exists("$CFG->dataroot/temp/backup/$this->tempdir/course_files/sub1");
        check_dir_exists("$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/7");
        copy(
            "$CFG->dirroot/backup/converter/moodle1/simpletest/files/moodle.xml",
            "$CFG->dataroot/temp/backup/$this->tempdir/moodle.xml"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
            "$CFG->dataroot/temp/backup/$this->tempdir/course_files/file1.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
            "$CFG->dataroot/temp/backup/$this->tempdir/course_files/sub1/file2.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
            "$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/file1.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
            "$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/icon.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif",
            "$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/7/icon.gif"
        );
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:31,代码来源:testlib.php

示例5: __construct

 public function __construct()
 {
     global $THEME;
     // make sure cache/compile paths exist
     check_dir_exists(get_config('dataroot') . 'dwoo/compile/' . $THEME->basename);
     check_dir_exists(get_config('dataroot') . 'dwoo/cache/' . $THEME->basename);
     // set paths
     $this->template_dir = $THEME->templatedirs;
     $compileDir = get_config('dataroot') . 'dwoo/compile/' . $THEME->basename;
     $cacheDir = get_config('dataroot') . 'dwoo/cache/' . $THEME->basename;
     parent::__construct($compileDir, $cacheDir);
     // add plugins dir to the loader
     $this->getLoader()->addDirectory(get_config('libroot') . 'dwoo/mahara/plugins/');
     // adds mahara resources and compiler factory
     $this->setDefaultCompilerFactory('file', array($this, 'compilerFactory'));
     $this->addResource('artefact', 'Dwoo_Template_Mahara_Artefact', array($this, 'compilerFactory'));
     $this->addResource('blocktype', 'Dwoo_Template_Mahara_Blocktype', array($this, 'compilerFactory'));
     $this->addResource('export', 'Dwoo_Template_Mahara_Export', array($this, 'compilerFactory'));
     $this->addResource('interaction', 'Dwoo_Template_Mahara_Interaction', array($this, 'compilerFactory'));
     // set base data
     $theme_list = array();
     $themepaths = themepaths();
     foreach ($themepaths['mahara'] as $themepath) {
         $theme_list[$themepath] = $THEME->get_url($themepath);
     }
     $this->_data = array('THEME' => $THEME, 'WWWROOT' => get_config('wwwroot'), 'THEMELIST' => json_encode($theme_list), 'HTTPSWWWROOT' => get_config('httpswwwroot'));
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:27,代码来源:Dwoo_Mahara.php

示例6: check_and_create_backup_dir

 /**
  * Given one backupid, create all the needed dirs to have one backup temp dir available
  */
 public static function check_and_create_backup_dir($backupid)
 {
     global $CFG;
     if (!check_dir_exists($CFG->tempdir . '/backup/' . $backupid, true, true)) {
         throw new backup_helper_exception('cannot_create_backup_temp_dir');
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:10,代码来源:backup_helper.class.php

示例7: __construct

    /**
     * Constructor - creates an instance of the SimplePie class
     * with Moodle defaults.
     *
     * @param string $feedurl optional URL of the feed
     */
    function __construct($feedurl = null) {

        // Use the Moodle class for http requests
        $this->file_class = 'moodle_simplepie_file';

        $cachedir = moodle_simplepie::get_cache_directory();
        check_dir_exists($cachedir);

        parent::__construct();
        // Match moodle encoding
        $this->set_output_encoding('UTF-8');

        // default to a short timeout as most operations will be interactive
        $this->set_timeout(2);

        // 1 hour default cache
        $this->set_cache_location($cachedir);
        $this->set_cache_duration(3600);

        // init the feed url if passed in constructor
        if ($feedurl !== null) {
            $this->set_feed_url($feedurl);
            $this->init();
        }
    }
开发者ID:ncsu-delta,项目名称:moodle,代码行数:31,代码来源:moodle_simplepie.php

示例8: setUp

    protected function setUp() {
        global $CFG;

        $this->tempdir = convert_helper::generate_id('unittest');
        check_dir_exists("$CFG->tempdir/backup/$this->tempdir/course_files/sub1");
        check_dir_exists("$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7");
        copy(
            "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/moodle.xml",
            "$CFG->tempdir/backup/$this->tempdir/moodle.xml"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
            "$CFG->tempdir/backup/$this->tempdir/course_files/file1.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
            "$CFG->tempdir/backup/$this->tempdir/course_files/sub1/file2.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
            "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/file1.gif"
        );
        copy(
            "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
            "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/icon.gif"
        );
        $this->iconhash = sha1_file($CFG->tempdir.'/backup/'.$this->tempdir.'/moddata/unittest/4/icon.gif');
        copy(
            "$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
            "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7/icon.gif"
        );
    }
开发者ID:ncsu-delta,项目名称:moodle,代码行数:32,代码来源:lib_test.php

示例9: __construct

 /**
  * constructor.  overrides the parent class
  * to set up smarty and the attachment directory
  */
 public function __construct(User $user, $views, $artefacts, $progresscallback = null)
 {
     global $THEME;
     parent::__construct($user, $views, $artefacts, $progresscallback);
     $this->rootdir = 'portfolio-for-' . self::text_to_path($user->get('username'));
     $directory = "{$this->exportdir}/{$this->rootdir}/";
     if (!check_dir_exists($directory)) {
         throw new SystemException("Couldn't create the temporary export directory {$directory}");
     }
     $this->pdffile = 'mahara-export-pdf-user' . $this->get('user')->get('id') . '-' . $this->exporttime . '.pdf';
     // Find what base stylesheets need to be included
     $themedirs = $THEME->get_path('', true);
     $stylesheets = array('print.css', 'views.css');
     foreach ($themedirs as $theme => $themedir) {
         foreach ($stylesheets as $stylesheet) {
             if (is_readable($themedir . 'style/' . $stylesheet)) {
                 array_unshift($this->stylesheets[''], $themedir . '/style/' . $stylesheet);
             }
         }
     }
     // Don't export the dashboard
     //        foreach (array_keys($this->views) as $i) {
     //            if ($this->views[$i]->get('type') == 'dashboard') {
     //                unset($this->views[$i]);
     //            }
     //        }
     $this->exportingoneview = $this->viewexportmode == PluginExport::EXPORT_LIST_OF_VIEWS && $this->artefactexportmode == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS && count($this->views) == 1;
     $this->notify_progress_callback(15, get_string('setupcomplete', 'export'));
 }
开发者ID:vohung96,项目名称:mahara,代码行数:33,代码来源:lib.php

示例10: define_local_decimal_separator

 /**
  * Define a local decimal separator.
  *
  * It is not possible to directly change the result of get_string in
  * a unit test. Instead, we create a language pack for language 'xx' in
  * dataroot and make langconfig.php with the string we need to change.
  * The example separator used here is 'X'; on PHP 5.3 and before this
  * must be a single byte character due to PHP bug/limitation in
  * number_format, so you can't use UTF-8 characters.
  */
 protected function define_local_decimal_separator()
 {
     global $SESSION, $CFG;
     $SESSION->lang = 'xx';
     $langconfig = "<?php\n\$string['decsep'] = 'X';";
     $langfolder = $CFG->dataroot . '/lang/xx';
     check_dir_exists($langfolder);
     file_put_contents($langfolder . '/langconfig.php', $langconfig);
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:19,代码来源:moodlelib_test.php

示例11: xmldb_enrol_imsenterprise_upgrade

function xmldb_enrol_imsenterprise_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    //NOTE: this file is not executed during upgrade from 1.9.x!
    if ($oldversion < 2011013000) {
        // this plugin does not use the new file api - lets undo the migration
        $fs = get_file_storage();
        if ($DB->record_exists('course', array('id' => 1))) {
            //course 1 is hardcoded here intentionally!
            if ($context = get_context_instance(CONTEXT_COURSE, 1)) {
                if ($file = $fs->get_file($context->id, 'course', 'legacy', 0, '/', 'imsenterprise-enrol.xml')) {
                    if (!file_exists("{$CFG->dataroot}/1/imsenterprise-enrol.xml")) {
                        check_dir_exists($CFG->dataroot . '/');
                        $file->copy_content_to("{$CFG->dataroot}/1/imsenterprise-enrol.xml");
                    }
                    $file->delete();
                }
            }
        }
        if (!empty($CFG->enrol_imsfilelocation)) {
            if (strpos($CFG->enrol_imsfilelocation, "{$CFG->dataroot}/") === 0) {
                $location = str_replace("{$CFG->dataroot}/", '', $CFG->enrol_imsfilelocation);
                $location = str_replace('\\', '/', $location);
                $parts = explode('/', $location);
                $courseid = array_shift($parts);
                if (is_number($courseid) and $DB->record_exists('course', array('id' => $courseid))) {
                    if ($context = get_context_instance(CONTEXT_COURSE, $courseid)) {
                        $file = array_pop($parts);
                        if ($parts) {
                            $dir = '/' . implode('/', $parts) . '/';
                        } else {
                            $dir = '/';
                        }
                        if ($file = $fs->get_file($context->id, 'course', 'legacy', 0, $dir, $file)) {
                            if (!file_exists($CFG->enrol_imsfilelocation)) {
                                check_dir_exists($CFG->dataroot . '/' . $courseid . $dir);
                                $file->copy_content_to($CFG->enrol_imsfilelocation);
                            }
                            $file->delete();
                        }
                    }
                }
            }
        }
        upgrade_plugin_savepoint(true, 2011013000, 'enrol', 'imsenterprise');
    }
    // Moodle v2.1.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:53,代码来源:upgrade.php

示例12: referentiel_check_and_create_document_files_dir

function referentiel_check_and_create_document_files_dir($referentiel_referentiel_id, $user_creator, $userid)
{
    global $CFG;
    // Moodle 2.0
    // $status = check_dir_exists($CFG->dataroot."/temp/archive/".$referentiel_referentiel_id."/".$user_creator."/document_files/".$userid,true, true);
    // Moodle 22
    $path_temp = cleardoubleslashes(get_string('archivetemp', 'referentiel') . '/' . $referentiel_referentiel_id . '/' . $user_creator);
    // Moodle 2.2
    $temp_dir = make_temp_directory($path_temp);
    $status = check_dir_exists($temp_dir . "/document_files/" . $userid, true, true);
    return $status;
}
开发者ID:jfruitet,项目名称:moodle_referentiel,代码行数:12,代码来源:lib_archive.php

示例13: check_and_create_backup_dir

function check_and_create_backup_dir($backup_unique_code)
{
    global $CFG;
    $status = check_dir_exists($CFG->dataroot . "/temp", true);
    if ($status) {
        $status = check_dir_exists($CFG->dataroot . "/temp/backup", true);
    }
    if ($status) {
        $status = check_dir_exists($CFG->dataroot . "/temp/backup/" . $backup_unique_code, true);
    }
    return $status;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:12,代码来源:lib.php

示例14: get_logger_chain

 public static function get_logger_chain($interactive, $execution, $backupid)
 {
     global $CFG;
     $dfltloglevel = backup::LOG_WARNING;
     // Default logging level
     if (debugging('', DEBUG_DEVELOPER)) {
         // Debug developer raises default logging level
         $dfltloglevel = backup::LOG_DEBUG;
     }
     $enabledloggers = array();
     // Array to store all enabled loggers
     // Create error_log_logger, observing $CFG->backup_error_log_logger_level,
     // defaulting to $dfltloglevel
     $elllevel = isset($CFG->backup_error_log_logger_level) ? $CFG->backup_error_log_logger_level : $dfltloglevel;
     $enabledloggers[] = new error_log_logger($elllevel);
     // Create output_indented_logger, observing $CFG->backup_output_indented_logger_level and $CFG->debugdisplay,
     // defaulting to LOG_ERROR. Only if interactive and inmediate
     if ($CFG->debugdisplay && $interactive == backup::INTERACTIVE_YES && $execution == backup::EXECUTION_INMEDIATE) {
         $oillevel = isset($CFG->backup_output_indented_logger_level) ? $CFG->backup_output_indented_logger_level : backup::LOG_ERROR;
         $enabledloggers[] = new output_indented_logger($oillevel, false, false);
     }
     // Create file_logger, observing $CFG->backup_file_logger_level
     // defaulting to $dfltloglevel
     check_dir_exists($CFG->tempdir . '/backup', true, true);
     // need to ensure that temp/backup already exists
     $fllevel = isset($CFG->backup_file_logger_level) ? $CFG->backup_file_logger_level : $dfltloglevel;
     $enabledloggers[] = new file_logger($fllevel, true, true, $CFG->tempdir . '/backup/' . $backupid . '.log');
     // Create database_logger, observing $CFG->backup_database_logger_level and defaulting to LOG_WARNING
     // and pointing to the backup_logs table
     $dllevel = isset($CFG->backup_database_logger_level) ? $CFG->backup_database_logger_level : backup::LOG_WARNING;
     $columns = array('backupid' => $backupid);
     $enabledloggers[] = new database_logger($dllevel, 'timecreated', 'loglevel', 'message', 'backup_logs', $columns);
     // Create extra file_logger, observing $CFG->backup_file_logger_extra and $CFG->backup_file_logger_extra_level
     // defaulting to $fllevel (normal file logger)
     if (isset($CFG->backup_file_logger_extra)) {
         $flelevel = isset($CFG->backup_file_logger_extra_level) ? $CFG->backup_file_logger_extra_level : $fllevel;
         $enabledloggers[] = new file_logger($flelevel, true, true, $CFG->backup_file_logger_extra);
     }
     // Build the chain
     $loggers = null;
     foreach ($enabledloggers as $currentlogger) {
         if ($loggers == null) {
             $loggers = $currentlogger;
         } else {
             $lastlogger->set_next($currentlogger);
         }
         $lastlogger = $currentlogger;
     }
     return $loggers;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:50,代码来源:backup_factory.class.php

示例15: import_submit

function import_submit(Pieform $form, $values)
{
    global $SESSION;
    $date = time();
    $nicedate = date('Y/m/d h:i:s', $date);
    $uploaddir = get_config('dataroot') . 'import/test-' . $date . '/';
    $filename = $uploaddir . $values['file']['name'];
    check_dir_exists($uploaddir);
    move_uploaded_file($values['file']['tmp_name'], $filename);
    if ($values['file']['type'] == 'application/zip') {
        // Unzip here
        $command = sprintf('%s %s %s %s', escapeshellcmd(get_config('pathtounzip')), escapeshellarg($filename), get_config('unzipdirarg'), escapeshellarg($uploaddir));
        $output = array();
        exec($command, $output, $returnvar);
        if ($returnvar != 0) {
            $SESSION->add_error_msg('Unable to unzip the file');
            redirect('/import/');
        }
        $filename = $uploaddir . 'leap2a.xml';
        if (!is_file($filename)) {
            $SESSION->add_error_msg('No leap2a.xml file detected - please check your export file again');
            redirect('/import/');
        }
    }
    // Create dummy user
    $user = (object) array('username' => 'import_' . $date, 'password' => 'import1', 'firstname' => 'Imported', 'lastname' => 'User (' . $nicedate . ')', 'email' => 'imported@example.org');
    $userid = create_user($user);
    // And we're good to go
    echo '<pre>';
    $filename = substr($filename, strlen(get_config('dataroot')));
    require_once dirname(dirname(__FILE__)) . '/import/lib.php';
    safe_require('import', 'leap');
    db_begin();
    $importer = PluginImport::create_importer(null, (object) array('token' => '', 'usr' => $userid, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('filename' => $filename), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_STDOUT, 'profile' => true));
    $importer->process();
    // Now done, delete the temporary e-mail address if there's a new one
    // A bit sucky, presumes only one email in the import
    $email = artefact_instance_from_id(get_field('artefact', 'id', 'title', 'imported@example.org', 'artefacttype', 'email', 'owner', $userid));
    $email->delete();
    execute_sql('UPDATE {artefact_internal_profile_email} SET principal = 1 WHERE "owner" = ?', array($userid));
    db_commit();
    echo "\n\n";
    echo 'Done. You can <a href="' . get_config('wwwroot') . '/admin/users/changeuser.php?id=' . $userid . '">change to this user</a> to inspect the result, ';
    echo 'or <a href="' . get_config('wwwroot') . 'import/">try importing again</a>';
    echo '</pre>';
    exit;
}
开发者ID:Br3nda,项目名称:mahara,代码行数:47,代码来源:index.php


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