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


PHP list_directories_and_files函数代码示例

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


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

示例1: backup_zip

function backup_zip($preferences)
{
    global $CFG;
    $status = true;
    //Base dir where everything happens
    $basedir = cleardoubleslashes($CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code);
    //Backup zip file name
    $name = $preferences->backup_name;
    //List of files and directories
    $filelist = list_directories_and_files($basedir);
    //Convert them to full paths
    $files = array();
    foreach ($filelist as $file) {
        $files[] = "{$basedir}/{$file}";
    }
    $status = zip_files($files, "{$basedir}/{$name}");
    //echo "<br/>Status: ".$status;                                     //Debug
    return $status;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:19,代码来源:backuplib.php

示例2: wiki_export_html

function wiki_export_html(&$WS)
{
    global $CFG;
    check_dir_exists("{$CFG->dataroot}/temp", true);
    check_dir_exists("{$CFG->dataroot}/temp/html", true);
    check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}", true);
    check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments", true);
    check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true);
    check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata", true);
    check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}", true);
    //export contents
    wiki_export_html_content($WS);
    //export attached files
    $flist = list_directories_and_files("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}");
    if ($flist != null) {
        foreach ($flist as $fil) {
            $from_file = "{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}/{$fil}";
            $to_file = "{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments/{$fil}";
            copy($from_file, $to_file);
        }
    }
    //zip file name
    $times = time();
    $name = $WS->dfwiki->name . '-' . $times . '.zip';
    $cleanzipname = clean_filename($name);
    //List of files and directories
    $filelist = list_directories_and_files("{$CFG->dataroot}/temp/html");
    //Convert them to full paths
    $files = array();
    if ($filelist != null) {
        foreach ($filelist as $file) {
            $files[] = "{$CFG->dataroot}/temp/html/{$file}";
        }
    }
    check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true);
    check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml", true);
    $destination = "{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml/{$cleanzipname}";
    $status = zip_files($files, $destination);
    //delete the folder created in temp
    $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/html");
    if ($filelist2 != null) {
        $del = delete_dir_contents("{$CFG->dataroot}/temp/html");
    }
    //show it all to be albe to download the file
    $prop = null;
    $prop->class = "textcenter";
    wiki_div_start($prop);
    wiki_size_text(get_string("exporthtmlcorrectly", "wiki"), 2);
    wiki_div_end();
    $prop = null;
    $prop->border = "0";
    $prop->class = "boxaligncenter";
    $prop->classtd = "nwikileftnow";
    wiki_table_start($prop);
    $wdir = '/exportedhtml';
    $fileurl = "{$wdir}/{$cleanzipname}";
    $ffurl = "/file.php?file=/{$WS->cm->course}{$fileurl}";
    $icon = mimeinfo("icon", $cleanzipname);
    link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" height=\"16\" width=\"16\" alt=\"File\" />", 480, 640);
    echo "\n" . '&nbsp;';
    link_to_popup_window($ffurl, "display", htmlspecialchars($cleanzipname), 480, 640);
    $prop = null;
    $prop->class = "nwikileftnow";
    wiki_change_row($prop);
    echo '&nbsp;';
    wiki_table_end();
    $prop = null;
    $prop->border = "0";
    $prop->class = "boxaligncenter";
    $prop->classtd = "nwikileftnow";
    wiki_table_start($prop);
    $prop = null;
    $prop->id = "form";
    $prop->method = "post";
    $prop->action = '../xml/index.php?id=' . $WS->dfwiki->course . '&amp;wdir=/exportedhtml';
    wiki_form_start($prop);
    wiki_div_start();
    $prop = null;
    $prop->name = "dfform[viewexported]";
    $prop->value = get_string('viewexported', 'wiki');
    wiki_input_submit($prop);
    wiki_div_end();
    wiki_form_end();
    wiki_change_column();
    print_continue("{$CFG->wwwroot}/mod/wiki/view.php?id={$WS->cm->id}");
    wiki_table_end();
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:87,代码来源:exporthtmllib.php

示例3: fopen

         if ($c > 0) {
             $xmlcontentfnewtext .= "<QUESTION_CATEGORY>" . $xmlcontentfnew_;
         } else {
             $xmlcontentfnewtext .= $xmlcontentfnew_;
         }
         $c++;
     }
 }
 $xml_file = $CFG->dataroot . $dirq . '/moodle.xml';
 $restoreq->file = $CFG->dataroot . $dirq . '/moodle.zip';
 $fp = fopen($xml_file, "w+");
 fwrite($fp, $xmlcontentfnewtext);
 if (!($statusbackup = backup_zip($restoreq))) {
     print_error('Can\'t create backup zip file.');
 }
 $filelist = list_directories_and_files($CFG->dataroot . $dirq);
 $xmlarray = xmlize($xmlcontentfnewtext);
 //---------------Check images ----------------//
 $checkimagesarr = $xmlarray['MOODLE_BACKUP']['#']['COURSE']['0']['#']['QUESTION_CATEGORIES']['0']['#']['QUESTION_CATEGORY'];
 while (list($key, $value) = each($checkimagesarr)) {
     if (@is_array($value['#']['QUESTIONS']['0']['#']['QUESTION'])) {
         $dataquestarr = $value['#']['QUESTIONS']['0']['#']['QUESTION'];
         while (list($key2, $value2) = each($dataquestarr)) {
             if ($value2['#']['IMAGE']['0']['#']) {
                 //Upload Image-------//
                 $imglinks = explode("/", $value2['#']['IMAGE']['0']['#']);
                 end($imglinks);
                 unset($imglinks[key($imglinks)]);
                 $imglinks = implode("/", $imglinks);
                 make_upload_directory('reader/images');
                 $image = file_get_contents($readercfg->reader_serverlink . '/getfile_quiz_image.php?imagelink=' . urlencode($value2['#']['IMAGE']['0']['#']));
开发者ID:e-rasvet,项目名称:reader,代码行数:31,代码来源:dlquizzes_proccess.php

示例4: restore_site_files

function restore_site_files($restore)
{
    global $CFG;
    $status = true;
    $counter = 0;
    //First, we check to "course_id" exists and create is as necessary
    //in CFG->dataroot
    $dest_dir = $CFG->dataroot . "/" . SITEID;
    $status = check_dir_exists($dest_dir, true);
    //Now, we iterate over "site_files" files to check if that file/dir must be
    //copied to the "dest_dir" dir.
    $rootdir = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/site_files";
    //Check if directory exists
    if (is_dir($rootdir)) {
        $list = list_directories_and_files($rootdir);
        if ($list) {
            //Iterate
            $counter = 0;
            foreach ($list as $dir) {
                //Avoid copying maintenance.html. MDL-18594
                if ($dir == 'maintenance.html') {
                    continue;
                }
                //Copy the dir to its new location
                //Only if destination file/dir doesn exists
                if (!file_exists($dest_dir . "/" . $dir)) {
                    $status = backup_copy_file($rootdir . "/" . $dir, $dest_dir . "/" . $dir, true);
                    $counter++;
                }
                //Do some output
                if ($counter % 2 == 0) {
                    if (!defined('RESTORE_SILENTLY')) {
                        echo ".";
                        if ($counter % 40 == 0) {
                            echo "<br />";
                        }
                    }
                    backup_flush(300);
                }
            }
        }
    }
    //If status is ok and whe have dirs created, returns counter to inform
    if ($status and $counter) {
        return $counter;
    } else {
        return $status;
    }
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:49,代码来源:restorelib.php

示例5: backup_wiki_files

function backup_wiki_files($bf, $preferences, $id)
{
    global $CFG;
    $status = true;
    $modul = get_record("modules", "name", 'wiki');
    if (!($cm = get_record("course_modules", "instance", $id, "module", $modul->id))) {
        error("Course Module ID was incorrect");
    }
    check_dir_exists("{$CFG->dataroot}/{$preferences->backup_course}", true);
    check_dir_exists("{$CFG->dataroot}/{$preferences->backup_course}/{$CFG->moddata}", true);
    check_dir_exists("{$CFG->dataroot}/{$preferences->backup_course}/{$CFG->moddata}/wiki{$cm->id}", true);
    $moddata_path = $CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/wiki" . $cm->id;
    check_dir_exists("{$CFG->dataroot}/temp", true);
    check_dir_exists("{$CFG->dataroot}/temp/backup", true);
    check_dir_exists("{$CFG->dataroot}/temp/backup/{$preferences->backup_unique_code}", true);
    check_dir_exists("{$CFG->dataroot}/temp/backup/{$preferences->backup_unique_code}/moddata", true);
    check_dir_exists("{$CFG->dataroot}/temp/backup/{$preferences->backup_unique_code}/moddata/wiki", true);
    check_dir_exists("{$CFG->dataroot}/temp/backup/{$preferences->backup_unique_code}/moddata/wiki/wiki{$id}", true);
    $temp_path = $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/wiki/wiki" . $id;
    //get all attachments
    $list = null;
    $list = list_directories_and_files($moddata_path);
    if ($list != null) {
        foreach ($list as $file) {
            $from_file = "{$moddata_path}/{$file}";
            $to_file = "{$temp_path}/{$file}";
            copy($from_file, $to_file);
        }
    }
    return $status;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:backuplib.php

示例6: wiki_copy_attachments

function wiki_copy_attachments($wikiid, $course, $coursemodule, $oldentryid)
{
    global $CFG;
    //create the dir where attached dfwiki files are stored
    check_dir_exists("{$CFG->dataroot}/{$course}", true);
    check_dir_exists("{$CFG->dataroot}/{$course}/moddata", true);
    check_dir_exists("{$CFG->dataroot}/{$course}/moddata/dfwiki{$coursemodule}", true);
    check_dir_exists("{$CFG->dataroot}/{$course}/moddata", true);
    check_dir_exists("{$CFG->dataroot}/{$course}/moddata/wiki", true);
    check_dir_exists("{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}", true);
    check_dir_exists("{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}/{$oldentryid}", true);
    $files = list_directories_and_files("{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}/{$oldentryid}");
    //get every attached file
    if ($files != null) {
        foreach ($files as $fil) {
            //in case it's not a directory
            if (!is_dir("{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}/{$oldentryid}/{$fil}")) {
                $to_file = "{$CFG->dataroot}/{$course}/moddata/dfwiki{$coursemodule}/{$fil}";
                $from_file = "{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}/{$oldentryid}/{$fil}";
                copy($from_file, $to_file);
            } else {
                //get every single attached file
                $files2 = list_directories_and_files("{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}/{$oldentryid}/{$fil}");
                if ($files2 != null) {
                    foreach ($files2 as $fil2) {
                        $to_file = "{$CFG->dataroot}/{$course}/moddata/dfwiki{$coursemodule}/{$fil2}";
                        $from_file = "{$CFG->dataroot}/{$course}/moddata/wiki/{$wikiid}/{$oldentryid}/{$fil}/{$fil2}";
                        copy($from_file, $to_file);
                    }
                }
            }
        }
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:34,代码来源:wikitodfwiki.php

示例7: get_ewikis

function get_ewikis($zip)
{
    global $CFG;
    $listewikis = null;
    //unpack the .zip
    check_dir_exists("{$CFG->dataroot}/temp", true);
    check_dir_exists("{$CFG->dataroot}/temp/ewikis", true);
    $destination = "{$CFG->dataroot}/temp/ewikis";
    unzip_file($zip, $destination, false);
    //take the .xml
    $filelist = list_directories_and_files("{$CFG->dataroot}/temp/ewikis");
    if ($filelist == null) {
        return $listewikis;
    }
    foreach ($filelist as $file) {
        $extension = explode(".", $file);
        $num = count($extension) - 1;
        if ($extension[$num] == "xml") {
            $goodfile = $file;
        }
    }
    $newfile = "{$CFG->dataroot}/temp/ewikis/{$goodfile}";
    $info = restore_read_xml_bis($newfile);
    if ($info != null) {
        foreach ($info as $mod) {
            if ($mod->modtype == 'wiki' || $mod->modtype == 'dfwiki') {
                $listewikis[] = $mod;
            }
        }
    }
    //delete the folder created in temp
    $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/ewikis");
    if ($filelist2 != null) {
        $del = delete_dir_contents("{$CFG->dataroot}/temp/ewikis");
    }
    return $listewikis;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:37,代码来源:importwiki.php

示例8: xmldb_wiki_upgrade


//.........这里部分代码省略.........
        //        if (!get_records_sql('SHOW COLUMNS FROM '.$CFG->prefix.'wiki WHERE Field=\'editorcols\'')){
        //            execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` ADD `editorcols` integer NOT NULL DEFAULT 60');
        //        }
    }
    if ($result && $oldversion < 2006112502) {
        $table = new XMLDBTable('wiki');
        $field = new XMLDBField('wikicourse');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = add_field($table, $field);
        // OLD SENTENCE
        //      execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` ADD `wikicourse` int(10) unsigned NOT NULL DEFAULT 0');
        if ($wikicourses = get_records('course', 'format', 'wiki')) {
            $wikimod = get_record('modules', 'name', 'wiki');
            foreach ($wikicourses as $wikicourse) {
                $min = get_record_select('course_module', 'course = ' . $wikicourse->id . ' AND module = ' . $wikimod->id, 'min(id) as minim');
                // OLD SENTENCE
                //              $min = get_record_sql('SELECT MIN(`id`) AS minim FROM '.$CFG->prefix.'course_modules WHERE `course`=\''.$wikicourse->id.'\' AND `module`=\''.$wikimod->id.'\'');
                $cm = get_record('course_modules', 'id', $min->minim);
                $result = $result && set_field('wiki', 'wikicourse', $wikicourse->id, 'id', $cm->instance);
            }
        }
    }
    if ($result && $oldversion < 2007022707) {
        // Moving archives to the new directory (from dfwikiX to wikiX)
        require_once $CFG->dirroot . '/lib/uploadlib.php';
        require_once $CFG->dirroot . '/backup/lib.php';
        $wikimod = get_record("modules", "name", "wiki");
        $wikis = get_records("wiki");
        if (!empty($wikis)) {
            foreach ($wikis as $wiki) {
                $cm = get_record("course_modules", "course", $wiki->course, "instance", $wiki->id, "module", $wikimod->id);
                if (check_dir_exists($CFG->dataroot . "/" . $wiki->course . "/moddata/dfwiki" . $cm->id)) {
                    check_dir_exists($CFG->dataroot . "/" . $wiki->course . "/moddata/wiki" . $cm->id, true, true);
                    $flist = list_directories_and_files($CFG->dataroot . "/" . $wiki->course . "/moddata/dfwiki" . $cm->id);
                    foreach ($flist as $file) {
                        $result = $result && copy($CFG->dataroot . "/" . $wiki->course . "/moddata/dfwiki" . $cm->id . "/" . $file, $CFG->dataroot . "/" . $wiki->course . "/moddata/wiki" . $cm->id . "/" . $file);
                    }
                    $result = $result && remove_dir($CFG->dataroot . "/" . $wiki->course . "/moddata/dfwiki" . $cm->id);
                }
            }
        }
    }
    if ($result && $oldversion < 2007030301) {
        // Adding filetemplate file to database
        $table = new XMLDBTable('wiki');
        $field = new XMLDBField('filetemplate');
        $field->setAttributes(XMLDB_TYPE_CHAR, '60', null, null, null, null, null, null, null);
        $result = add_field($table, $field);
        // OLD SENTENCE
        //      execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki` ADD `filetemplate` VARCHAR(60) NULL DEFAULT NULL');
    }
    if ($result && $oldversion < 2007060701) {
        $table = new XMLDBTable('wiki_locks');
        if (!table_exists($table)) {
            // Adding wiki_locks table to admin wiki pages lock system
            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
            $table->addFieldInfo('wikiid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
            $table->addFieldInfo('pagename', XMLDB_TYPE_CHAR, '160', null, XMLDB_NOTNULL, null, null, '', null);
            $table->addFieldInfo('lockedby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 0, null);
            $table->addFieldInfo('lockedsince', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, '0', null);
            $table->addFieldInfo('lockedseen', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, '0', null);
            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
            $table->addKeyInfo('wiki_locks_uk', XMLDB_KEY_UNIQUE, array('wikiid', 'pagename'));
            $table->addIndexInfo('wiki_locks_ix', XMLDB_INDEX_NOTUNIQUE, array('lockedseen'));
            $result = $result && create_table($table);
        }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:upgrade.php

示例9: wiki_restore_files

function wiki_restore_files($olddfwikiid, $restore, $order, $e_wiki)
{
    global $CFG;
    $status = true;
    $moddata_path = "";
    $temp_path = "";
    //get wiki $cm->id we're restoring
    //get the latest wiki $cm->id to restore
    $modul = get_record("modules", "name", 'wiki');
    $newdfwikiid = get_record_sql('SELECT MAX(id) AS maxim
					FROM ' . $CFG->prefix . 'course_modules
					WHERE module=' . $modul->id . ' AND course=' . $restore->course_id);
    //necessary data is available to proceed
    $num = wiki_count_position($newdfwikiid->maxim, $restore->course_id, $order);
    if (isset($e_wiki['oldid'])) {
        $oldcourseid = $e_wiki['oldid'];
    } else {
        $oldcourseid = '';
    }
    if (isset($e_wiki['oldentryid'])) {
        $oldentryid = $e_wiki['oldentryid'];
    } else {
        $oldentryid = '';
    }
    check_dir_exists("{$CFG->dataroot}/{$restore->course_id}", true);
    check_dir_exists("{$CFG->dataroot}/{$restore->course_id}/{$CFG->moddata}", true);
    check_dir_exists("{$CFG->dataroot}/{$restore->course_id}/{$CFG->moddata}/wiki{$num}", true);
    $moddata_path = $CFG->dataroot . "/" . $restore->course_id . "/" . $CFG->moddata . "/wiki" . $num;
    if ($oldcourseid == '' && $oldentryid == '') {
        check_dir_exists("{$CFG->dataroot}/temp", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata/wiki", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata/wiki/wiki{$olddfwikiid}", true);
        $temp_path = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/moddata/wiki/wiki" . $olddfwikiid;
    } else {
        check_dir_exists("{$CFG->dataroot}/temp", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata/wiki", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata/wiki/{$oldcourseid}", true);
        check_dir_exists("{$CFG->dataroot}/temp/backup/{$restore->backup_unique_code}/moddata/wiki/{$oldcourseid}/{$oldentryid}", true);
        $temp_path = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/moddata/wiki/{$oldcourseid}/{$oldentryid}";
    }
    //get the attached files
    $list = null;
    $list = list_directories_and_files($temp_path);
    if ($list != null) {
        foreach ($list as $file) {
            //if isn't a directory
            if (!is_dir("{$temp_path}/{$file}")) {
                $to_file = "{$moddata_path}/{$file}";
                $from_file = "{$temp_path}/{$file}";
                copy($from_file, $to_file);
            } else {
                //one by one
                $temp_path = "{$temp_path}/{$file}";
                $files2 = list_directories_and_files($temp_path);
                if ($files2 != null) {
                    foreach ($files2 as $file2) {
                        $to_file = "{$moddata_path}/{$file2}";
                        $from_file = "{$temp_path}/{$file2}";
                        copy($from_file, $to_file);
                    }
                }
            }
        }
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:71,代码来源:restorelib.php

示例10: get_ewikis_bis

function get_ewikis_bis($zip, $ewiki)
{
    global $CFG;
    $listewikis = null;
    //unpack the .zip
    check_dir_exists("{$CFG->dataroot}/temp", true);
    check_dir_exists("{$CFG->dataroot}/temp/ewikis", true);
    $destination = "{$CFG->dataroot}/temp/ewikis";
    unzip_file($zip, $destination, false);
    //take the .xml
    $filelist = list_directories_and_files("{$CFG->dataroot}/temp/ewikis");
    if ($filelist == null) {
        return $listewikis;
    }
    foreach ($filelist as $file) {
        $extension = explode(".", $file);
        $num = count($extension) - 1;
        if ($extension[$num] == "xml") {
            $goodfile = $file;
        }
    }
    $newfile = "{$CFG->dataroot}/temp/ewikis/{$goodfile}";
    $info = restore_read_xml_bis_bis($newfile, $ewiki);
    return $info;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:25,代码来源:exportxmllib.php

示例11: wiki_search_rest

function wiki_search_rest()
{
    global $CFG;
    $rest = "1/exportedfiles/a0";
    $listmoodledata = list_directories_and_files("{$CFG->dataroot}");
    foreach ($listmoodledata as $filemoodledata) {
        if (check_dir_exists("{$CFG->dataroot}/{$filemoodledata}/exportedfiles", false) && $filemoodledata != temp) {
            $exporteddfwikis = list_directories_and_files("{$CFG->dataroot}/{$filemoodledata}/exportedfiles");
            if ($exporteddfwikis != null) {
                foreach ($exporteddfwikis as $exporteddfwiki) {
                    $xmllist = list_directories_and_files("{$CFG->dataroot}/{$filemoodledata}/exportedfiles/{$exporteddfwiki}");
                    if ($xmllist != null) {
                        foreach ($xmllist as $filexml) {
                            $rest = "{$filemoodledata}/exportedfiles/{$exporteddfwiki}";
                        }
                    }
                }
            }
        }
    }
    return $rest;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:22,代码来源:import.php

示例12: wiki_move_file

/**
 * Private function.
 *
 * This function moves file or directori $from to $to
 *
 * @TODO: Move this function
 *
 * @param string $from. File path to be moved
 * @param string $to. Destination path.
 *
 * @return boolean. true in success or false in error
 */
function wiki_move_file($from, $to)
{
    $result = true;
    if (is_dir($from)) {
        $files = list_directories_and_files($from);
        foreach ($files as $file) {
            $from_file = $from . '/' . $file;
            if (is_dir($from_file)) {
                $to_file = $to;
            } else {
                $to_file = $to . '/' . $file;
            }
            $result = $result && wiki_move_file($from_file, $to_file);
        }
        rmdir($from);
    } else {
        $result = copy($from, $to);
        unlink($from);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:33,代码来源:ewiki_migrate.php

示例13: webwork_codecheck

function webwork_codecheck($data, $wwquestionid, $questioncopy)
{
    //codechecklevel
    $codechecklevel = $data['codecheck'];
    //here we construct a temp question object
    $question = new stdClass();
    $question->code = base64_encode(stripslashes($data['code']));
    $question->seed = $data['seed'];
    $question->trials = $data['trials'];
    //handle the new question from old functionality
    if ($questioncopy) {
        webwork_make_tmp_dir();
        $path = webwork_get_wwquestion_path_full($wwquestionid);
        $filelist = list_directories_and_files($path);
        //copy everthing but derivations folder into tmp folder
        foreach ($filelist as $file) {
            if ($file != 'derivations') {
                webwork_copy_file("{$path}/{$file}", webwork_get_tmp_path_full() . '/' . $file);
            }
        }
    }
    //should we look in tmp or in wwquestion dir to find stuff
    if (!isset($wwquestionid)) {
        $path = webwork_get_tmp_path_full();
        $urlpath = webwork_get_filehandler_path() . '/' . webwork_get_tmp_path() . '/';
    } else {
        $path = webwork_get_wwquestion_path_full($this->question->webworkid);
        $urlpath = webwork_get_filehandler_path() . '/' . webwork_get_wwquestion_path($this->question->webworkid) . '/';
    }
    $filelist = list_directories_and_files($path);
    $filearray = array();
    //files that need to be pushed
    foreach ($filelist as $file) {
        if (!is_dir($path . '/' . $file)) {
            $encode = base64_encode($urlpath . '/' . $file);
            array_push($filearray, $encode);
        }
    }
    $question->files = $filearray;
    //one call to the server will return response for this code and keep it static in the function
    $results = webwork_get_derivations($question);
    //filter errors and warnings
    $errorresults = array();
    $noerrorresults = array();
    $warningresults = array();
    $goodresults = array();
    foreach ($results as $record) {
        if (isset($record['errors']) && $record['errors'] != '' && $record['errors'] != null) {
            array_push($errorresults, $record);
        } else {
            array_push($noerrorresults, $record);
        }
    }
    foreach ($noerrorresults as $record) {
        if (isset($record['warnings']) && $record['warnings'] != '' && $record['warnings'] != null) {
            array_push($warningresults, $record);
        } else {
            array_push($goodresults, $record);
        }
    }
    switch ($codechecklevel) {
        //No code check
        case 0:
            webwork_qtype::_derivations($results);
            return true;
            break;
            //reject seeds with errors
        //reject seeds with errors
        case 1:
            if (count($noerrorresults) > 0) {
                webwork_qtype::_derivations($noerrorresults);
                return true;
            }
            break;
            //reject if errors
        //reject if errors
        case 2:
            if (count($noerrorresults) == count($results)) {
                webwork_qtype::_derivations($results);
                return true;
            }
            break;
            //reject seeds with errors or warnings
        //reject seeds with errors or warnings
        case 3:
            if (count($goodresults) > 0) {
                webwork_qtype::_derivations($goodresults);
                return true;
            }
            break;
            //reject if errors or warnings
        //reject if errors or warnings
        case 4:
            if (count($goodresults) == count($results)) {
                webwork_qtype::_derivations($results);
                return true;
            }
            break;
    }
    $errormsgs = array();
//.........这里部分代码省略.........
开发者ID:bjornbe,项目名称:wwassignment,代码行数:101,代码来源:locallib.php


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