• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP zip_files函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: zip_files

 function zip_files($files, $dir = '', $zdir = '', $zip)
 {
     foreach ($files as $file) {
         if ($file == '.' || $file == '..' || $file == 'backup') {
             continue;
         }
         if (is_dir($dir . $file)) {
             $zip->addDir($zdir . $file);
             zip_files(scandir($dir . $file), $dir . $file . '/', $zdir . $file . '/', $zip);
         } else {
             $zip->addFile(file_get_contents($dir . $file), $zdir . $file);
         }
     }
 }
开发者ID:letsdodjango,项目名称:furasta-org,代码行数:14,代码来源:index.php


示例2: zip_files

function zip_files($files, $dir = '')
{
    global $zip;
    foreach ($files as $file) {
        if ($file == '.' || $file == '..' || $file == 'update.zip' || $file == 'backup') {
            continue;
        }
        if (is_dir(HOME . $dir . $file)) {
            $zip->addDir($dir . $file);
            zip_files(scandir(HOME . $dir . $file), $dir . $file . '/');
        } else {
            $zip->addFile(file_get_contents(HOME . '/' . $dir . $file), $dir . $file);
        }
    }
}
开发者ID:letsdodjango,项目名称:furasta-org,代码行数:15,代码来源:backup-files.php


示例3: game_create_zip

function game_create_zip($srcdir, $courseid, $filename)
{
    global $CFG;
    $dir = $CFG->dataroot . '/' . $courseid;
    $filezip = $dir . "/export/{$filename}";
    if (file_exists($filezip)) {
        unlink($filezip);
    }
    if (!file_exists($dir)) {
        mkdir($dir);
    }
    if (!file_exists($dir . '/export')) {
        mkdir($dir . '/export');
    }
    $srcfiles = get_directory_list($srcdir, '', true, true, true);
    $fullsrcfiles = array();
    foreach ($srcfiles as $file) {
        $fullsrcfiles[] = $srcdir . '/' . $file;
    }
    zip_files($fullsrcfiles, $filezip);
    return file_exists($filezip) ? $filezip : '';
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:22,代码来源:locallib.php


示例4: mkdir

             mkdir($destpath, $CFG->directorypermissions, true);
         }
         foreach ($USER->filelist as $fuuid) {
             $file = $repo->get_info($fuuid);
             if (alfresco_get_type($file->uuid) == 'folder') {
                 $dirfiles = $repo->download_dir($destpath, $fuuid);
                 if ($dirfiles !== false) {
                     $filelist[] = $destpath . $file->title;
                 }
             } else {
                 if ($repo->read_file($fuuid, $destpath . $file->title)) {
                     $filelist[] = $destpath . $file->title;
                 }
             }
         }
         if (!zip_files($filelist, $filepath)) {
             print_error('zipfileserror');
         }
         $repo->upload_file('', $filepath, $uuid);
         fulldelete($destpath);
         fulldelete($filepath);
     }
     clearfilelist();
     displaydir($uuid, $wdir, $id);
 } else {
     html_header($course, $wdir, "form.name");
     if (setfilelist($_POST)) {
         echo "<p align=\"center\">" . get_string("youareabouttocreatezip") . ":</p>";
         print_simple_box_start("center");
         printfilelist($USER->filelist);
         print_simple_box_end();
开发者ID:remotelearner,项目名称:elis.alfresco,代码行数:31,代码来源:coursefiles.php


示例5: ewiki_page_wiki_dump_send


//.........这里部分代码省略.........
                        break;
                    case EWIKI_DB_F_BINARY:
                        #print "Binary: $row[id]<br />";
                        if (($row["meta"]["class"] == "image" || $row["meta"]["class"] == "file") && $exportbinaries) {
                            # Copy files to the appropriate directory
                            $fn = moodle_binary_get_path($id, $row["meta"], $course, $wiki, $userid, $groupid);
                            $destfn = clean_filename(substr($id, strlen(EWIKI_IDF_INTERNAL)));
                            $dest = "{$exportdir}/" . $destfn;
                            if (!copy($fn, $dest)) {
                                notify("Cannot copy {$fn} to {$dest}.");
                            }
                            #$fn = urlencode(preg_replace(EWIKI_DUMP_FILENAME_REGEX, "", $id));
                            #$content = &$row["content"];
                            $filestozip[] = $exportdir . "/" . $destfn;
                            continue 2;
                        } else {
                            #-- php considers switch statements as loops so continue 2 is needed to
                            #-- hit the end of the for loop
                            continue 2;
                        }
                        break;
                    default:
                        # don't want it
                        continue 2;
                }
            }
            # Do not translate links when wiki already in pure html - mode
            if ($wiki->htmlmode != 2) {
                $content = preg_replace_callback('/(<a href=")(.*?)(\\.html">)/', create_function('$matches', 'return($matches[1].preg_replace(EWIKI_DUMP_FILENAME_REGEX,"",$matches[2]).$matches[3]);'), $content);
            }
            #-- add file
            // Let's make sure the file exists and is writable first.
            if (!($handle = fopen($exportdir . "/" . $fn, 'w'))) {
                error("Cannot open file ({$exportdir}/{$fn})");
            }
            // Write $content to our opened file.
            if (fwrite($handle, $content) === FALSE) {
                error("Cannot write to file ({$exportdir}/{$fn})");
            }
            fclose($handle);
            $filestozip[] = $exportdir . "/" . $fn;
            #$archive->add($content, $fn, array(
            #  "mtime" => $row["lastmodified"],
            #  "uname" => "ewiki",
            #  "mode" => 0664 | (($row["flags"]&EWIKI_DB_F_WRITEABLE)?0002:0000),
            #  ), $complevel);
        }
        #-- create index page
        /// HTML-Export
        if ($exportformats == 1) {
            $timer = array();
            $level = -1;
            $fordump = 1;
            $str_formatted = "<ul>\n<li><a href=\"" . $wiki_entry->pagename . $html_ext . "\">" . $wiki_entry->pagename . "</a></li>";
            $fin_level = format_sitemap($a_sitemap, $wiki_entry->pagename, $str_formatted, $level, $timer, $fordump);
            $str_formatted .= "</ul>" . str_pad("", $fin_level * 6, "</ul>\n");
            $str_formatted = preg_replace_callback('/(<a href=")(.*?)(\\.html">)/', create_function('$matches', 'return($matches[1].preg_replace(EWIKI_DUMP_FILENAME_REGEX,"",$matches[2]).$matches[3]);'), $str_formatted);
            $str_formatted = str_replace('$content', $str_formatted, str_replace('$title', get_string("index", "wiki"), $HTML_TEMPLATE));
            #-- add file
            // Let's make sure the file exists and is writable first.
            $indexname = "index" . $html_ext;
            if (!($handle = fopen($exportdir . "/" . $indexname, 'w'))) {
                error("Cannot open file ({$exportdir}/{$indexname})");
            }
            // Write $somecontent to our opened file.
            if (fwrite($handle, $str_formatted) === FALSE) {
                error("Cannot write to file ({$exportdir}/{$indexname})");
            }
            fclose($handle);
            $filestozip[] = $exportdir . "/" . $indexname;
            #-- add index page
            #    $archive->add($str_formatted, "Index_$rootid".$html_ext, array(
            #      "mtime" => $row["lastmodified"],
            #      "uname" => "ewiki",
            #      "mode" => 0664 | (($row["flags"]&EWIKI_DB_F_WRITEABLE)?0002:0000),
            #      ), $complevel);
        }
        if (!$exportdestinations) {
            $archivename = $wname . ".zip";
            zip_files($filestozip, "{$exportbasedir}/{$archivename}");
            #-- Headers
            Header("Content-type: application/zip");
            Header("Content-disposition: attachment; filename=\"{$archivename}\"");
            Header("Cache-control: private");
            Header("Original-Filename: {$archivename}");
            Header("X-Content-Type: application/zip");
            Header("Content-Location: {$archivename}");
            if (!@readfile("{$exportbasedir}/{$archivename}")) {
                error("Cannot read {$exportbasedir}/{$archivename}");
            }
            if (!deldir($exportbasedir)) {
                error("Cannot delete {$exportbasedir}");
            }
            #exit();
            return false;
        } else {
            return get_string("exportsuccessful", "wiki") . "<br />";
        }
    }
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:101,代码来源:moodle_wikidump.php


示例6: use_html_editor

         echo "</td></tr></table>\n";
         if ($usehtmleditor) {
             use_html_editor("text");
         }
     }
     html_footer();
     break;
 case "zip":
     if (!empty($name) and confirm_sesskey()) {
         html_header($course, $wdir);
         $name = clean_filename($name);
         $files = array();
         foreach ($USER->filelist as $file) {
             $files[] = "{$basedir}/{$file}";
         }
         if (!zip_files($files, "{$basedir}/{$wdir}/{$name}")) {
             print_error("zipfileserror", "error");
         }
         clearfilelist();
         displaydir($wdir);
     } else {
         html_header($course, $wdir, "form.name");
         if (setfilelist($_POST)) {
             echo "<p align=\"center\">" . get_string("youareabouttocreatezip") . ":</p>";
             print_simple_box_start("center");
             printfilelist($USER->filelist);
             print_simple_box_end();
             echo "<br />";
             echo "<p align=\"center\">" . get_string("whattocallzip");
             echo "<table border=\"0\">\n<tr>\n<td>\n";
             echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:coursefiles.php


示例7: error

    }
    $sourcefiles[] = $exportdir . "imsmanifest.xml";
    // create directory for the zip-file:
    if (!($zipdir = make_upload_directory(export_file_area_name()))) {
        error(get_string("couldntcreatetempdir", "block_exabis_eportfolio"));
        exit;
    }
    // Delete everything inside
    remove_dir($zipdir, true);
    // Put a / on the end
    if (substr($zipdir, -1) != "/") {
        $zipdir .= "/";
    }
    $zipname = clean_param($USER->username, PARAM_ALPHANUM) . strftime("_%Y_%m_%d_%H%M") . ".zip";
    // zip all the files:
    zip_files($sourcefiles, $zipdir . $zipname);
    remove_dir($exportdir);
    echo '<div class="block_eportfolio_center">';
    print_simple_box_start("center", "40%", "#ccffbb");
    echo '<input type="submit" name="export" value="' . get_string("download", "block_exabis_eportfolio") . '"';
    echo ' onclick="window.open(\'' . $CFG->wwwroot . '/blocks/exabis_eportfolio/portfoliofile.php/' . export_file_area_name() . '/' . $zipname . '\');"/>';
    echo '</div>';
    print_simple_box_end();
    print_footer($course);
    exit;
}
echo "<br />";
echo '<div class="block_eportfolio_center">';
$views = get_records('block_exabeporview', 'userid', $USER->id, 'name');
print_simple_box_start("center", "40%", "#ccffbb");
echo '<p>' . get_string("explainexport", "block_exabis_eportfolio") . '</p>';
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:export_scorm.php


示例8: exportprocess

 /**
  * exports the questions in a question category to the given location
  *
  * The parent class method was overridden because the IMS export consists of multiple files
  *
  * @param string $filename the directory name which will hold the exported files
  * @return bool - or errors out
  */
 public function exportprocess()
 {
     global $CFG, $OUTPUT, $USER;
     $courseid = $this->course->id;
     $path = 'temp/qformat_qti_two/' . $USER->id . '/' . $this->filename;
     // create a directory for the exports (if not already existing)
     if (!make_upload_directory($path)) {
         throw new moodle_exception('cannotcreatepath', 'question', '', $path);
     }
     $path = $CFG->dataroot . '/' . $path;
     // get the questions (from database) in this category
     $questions = get_questions_category($this->category);
     // create the imsmanifest file
     $smarty =& $this->init_smarty();
     $this->add_qti_info($questions);
     // copy files used by the main questions to the export directory
     $result = $this->handle_questions_media($questions, $path, $courseid);
     if ($result !== true) {
         throw new coding_exception(implode("<br />", $result));
     }
     $manifestquestions = $this->objects_to_array($questions);
     $manifestid = str_replace(array(':', '/'), array('-', '_'), "question_category_{$this->category->id}---{$CFG->wwwroot}");
     $smarty->assign('externalfiles', 1);
     $smarty->assign('manifestidentifier', $manifestid);
     $smarty->assign('quiztitle', "question_category_{$this->category->id}");
     $smarty->assign('quizinfo', "All questions in category {$this->category->id}");
     $smarty->assign('questions', $manifestquestions);
     $smarty->assign('lang', $this->lang);
     $smarty->error_reporting = 99;
     $expout = $smarty->fetch('imsmanifest.tpl');
     $filepath = $path . '/imsmanifest.xml';
     if (empty($expout)) {
         print_error('emptyxml', 'question');
     }
     if (!($fh = fopen($filepath, "w"))) {
         print_error('cannotopenforwriting', 'question', '', $filepath);
     }
     if (!fwrite($fh, $expout)) {
         print_error('cannotwriteto', 'question', '', $filepath);
     }
     fclose($fh);
     // iterate through questions
     foreach ($questions as $question) {
         // results are first written into string (and then to a file)
         $expout = $this->writequestion($question, null, true, $path) . "\n";
         $expout = $this->presave_process($expout);
         $filepath = $path . '/' . $this->get_assesment_item_id($question) . ".xml";
         if (!($fh = fopen($filepath, "w"))) {
             print_error('cannotopenforwriting', 'question', '', $filepath);
         }
         if (!fwrite($fh, $expout)) {
             print_error('cannotwriteto', 'question', '', $filepath);
         }
         fclose($fh);
     }
     // zip files into single export file
     zip_files(array($path), "{$path}.zip");
     // remove the temporary directory
     remove_dir($path);
     return true;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:69,代码来源:format.php


示例9: apply_incremental

function apply_incremental($courseid, $newfile)
{
    global $CFG;
    //first need to get the "current" version of the backup. - we'll do this based on the incremental passed.
    $newfilename = substr($newfile, strrpos($newfile, '/') + 1);
    $hash = explode('-', $newfilename);
    $oldbackuppath = $CFG->dataroot . '/incrementals_client/' . $courseid . '/';
    if (file_exists($oldbackuppath . $hash[0] . '.zip')) {
        //now unzip original backup into a temp dir.
        $tempdir = $CFG->dataroot . '/temp/' . $hash[0] . '-' . uniqid();
        //add uniqid to the end as for some stupid reason, when unzip_file unzips over the top of an existing dir - it changes the md5 of the moodle.xml file!
        if (!check_dir_exists($tempdir, true, true)) {
            error("failed to create temp dir for original backup");
        }
        if (!unzip_file($oldbackuppath . $hash[0] . '.zip', $tempdir, false)) {
            error('Couldn\'t unzip old backup');
        }
        //now run diff!
        $mydiff = new xdelta();
        $mydiff->apply_diff($tempdir, $newfile);
        if (!empty($mydiff->error)) {
            error("apply diff failed: " . $mydiff->error);
        }
        //now zip up the dir again,
        $listoffiles = get_directory_list($tempdir, '', true, true);
        $files = array();
        foreach ($listoffiles as $file) {
            $files[] = "{$tempdir}/{$file}";
        }
        if (!zip_files($files, $oldbackuppath . $hash[1])) {
            error('failed to zip files after diff');
        }
        return $hash[1];
        //now return path to new backup.
    } else {
        error("Could not find the original backup for this course - you must download a full backup oldpath:" . $oldbackuppath . ' hash:' . $hash[0] . '.zip');
    }
}
开发者ID:r007,项目名称:PMoodle,代码行数:38,代码来源:incremental_backuplib.php


示例10: wiki_export_content

function wiki_export_content(&$WS, $folder = 'exportedfiles')
{
    global $CFG, $contents;
    $export = optional_param('dfformexport', NULL, PARAM_ALPHA);
    $exportall = optional_param('dfformexportall', NULL, PARAM_ALPHA);
    //check if the form was filled in
    if (isset($export) || isset($exportall)) {
        //make sure the file doesn't exist
        $dfformname = optional_param('dfformname', NULL, PARAM_FILE);
        $currentname = clean_filename($dfformname);
        $cleandfwiki = clean_filename($WS->dfwiki->name);
        if (file_exists($CFG->dataroot . "/" . $WS->dfwiki->course . "/" . $folder . "/" . $cleandfwiki . $WS->cm->id . "/" . $currentname)) {
            $err = $currentname . ' already exists!';
            error($err);
        } else {
            //export to xml
            wiki_export_content_XML($WS);
            $prop = null;
            $prop->class = 'textcenter';
            $info = wiki_size_text(get_string("exportcorrectly", 'wiki'), 2, '', true);
            wiki_div($info, $prop);
            //make the zip
            $files = array();
            //copy files inside temp where is the xml
            check_dir_exists("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}", true);
            check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/wiki{$WS->cm->id}", true);
            $flist = list_directories_and_files("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/wiki{$WS->cm->id}");
            if ($flist != null) {
                foreach ($flist as $fil) {
                    $from_file = "{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/wiki{$WS->cm->id}/{$fil}";
                    $to_file = "{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}/{$fil}";
                    copy($from_file, $to_file);
                }
            }
            //continue compressing
            $filelist = list_directories_and_files("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}");
            foreach ($filelist as $file) {
                $files[] = "{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}/{$file}";
            }
            check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/" . $folder, true);
            check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/" . $folder . "/{$cleandfwiki}{$WS->cm->id}", true);
            $destination = "{$CFG->dataroot}/{$WS->dfwiki->course}/" . $folder . "/{$cleandfwiki}{$WS->cm->id}/{$currentname}";
            $status = zip_files($files, $destination);
            //delete folder inside temp that we've created
            $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}");
            foreach ($filelist2 as $file2) {
                unlink("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}/{$file2}");
            }
            rmdir("{$CFG->dataroot}/temp/" . $folder . "/wiki{$WS->cm->id}");
            $prop = null;
            $prop->border = '0';
            $prop->class = 'boxaligncenter';
            $prop->classtd = 'nwikileftnow';
            wiki_table_start($prop);
            $wdir = '/' . $folder . '/' . $cleandfwiki . $WS->cm->id;
            $fileurl = "{$wdir}/{$currentname}";
            $ffurl = "/file.php?file=/{$WS->cm->course}{$fileurl}";
            $icon = mimeinfo("icon", $currentname);
            $prop = null;
            $prop->src = "{$CFG->pixpath}/f/{$icon}";
            $prop->height = '16';
            $prop->width = '16';
            $prop->alt = 'File';
            $im = wiki_img($prop, true);
            link_to_popup_window($ffurl, "display", $im, 480, 640);
            echo '&nbsp;';
            link_to_popup_window($ffurl, "display", htmlspecialchars($currentname), 480, 640);
            $prop = null;
            $prop->class = 'nwikileftnow';
            wiki_change_row($prop);
            wiki_table_end();
            $prop = null;
            $prop->border = '0';
            $prop->class = 'boxaligncenter';
            $prop->classtd = 'nwikileftnow';
            wiki_table_start($prop);
            $prop = null;
            $prop->action = 'index.php?id=' . $WS->dfwiki->course . '&amp;wdir=/"' . $folder;
            $prop->method = 'post';
            $prop->id = 'form';
            wiki_form_start($prop);
            $prop = null;
            $prop->name = 'dfformviewexported';
            $prop->value = get_string('viewexported', 'wiki');
            $input = wiki_input_submit($prop, true);
            wiki_div($input);
            wiki_form_end();
            wiki_change_column();
            print_continue("{$CFG->wwwroot}/mod/wiki/view.php?id={$WS->cm->id}");
            wiki_table_end();
        }
    } else {
        //create the form to export
        //first of all treat the form that we've sended about the pages to export
        if (!($frm = data_submitted())) {
            $contents = null;
            $contentsall = get_records_sql('SELECT DISTINCT pagename,dfwiki
				FROM ' . $CFG->prefix . 'wiki_pages
				WHERE dfwiki=' . $WS->dfwiki->id);
            if ($contentsall != null) {
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:exportxmllib.php


示例11: referentiel_backup_zip

function referentiel_backup_zip($referentiel_referentiel_id, $user_creator, $archive_name)
{
    global $CFG;
    $status = true;
    // DEBUG
    //Base dir where everything happens
    // Moodle 2
    // $basedir = cleardoubleslashes($CFG->dataroot."/temp/archive/".$referentiel_referentiel_id.'/'.$user_creator);
    // Moodle 22
    $path_temp = cleardoubleslashes(get_string('archivetemp', 'referentiel') . '/' . $referentiel_referentiel_id . '/' . $user_creator);
    // Moodle 2.2
    $basedir = make_temp_directory($path_temp);
    $name = $archive_name;
    // DEBUG
    // echo "<br />DEBUG :: lib_archive.php :: 160 :: BASEDIR : '$basedir' NAME : '$name' <br />\n";
    //List of files and directories
    $filelist = referentiel_list_directories_and_files($basedir);
    // print_object($filelist);
    // exit;
    //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:jfruitet,项目名称:moodle_referentiel,代码行数:28,代码来源:lib_archive.php


示例12: get_file_content

 public function get_file_content()
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     do {
         $dir = 'ods/' . time() . '_' . rand(0, 10000);
     } while (file_exists($CFG->tempdir . '/' . $dir));
     make_temp_directory($dir);
     make_temp_directory($dir . '/META-INF');
     $dir = "{$CFG->tempdir}/{$dir}";
     $files = array();
     $handle = fopen("{$dir}/mimetype", 'w');
     fwrite($handle, $this->get_ods_mimetype());
     $files[] = "{$dir}/mimetype";
     $handle = fopen("{$dir}/content.xml", 'w');
     fwrite($handle, $this->get_ods_content($this->worksheets));
     $files[] = "{$dir}/content.xml";
     $handle = fopen("{$dir}/meta.xml", 'w');
     fwrite($handle, $this->get_ods_meta());
     $files[] = "{$dir}/meta.xml";
     $handle = fopen("{$dir}/styles.xml", 'w');
     fwrite($handle, $this->get_ods_styles());
     $files[] = "{$dir}/styles.xml";
     $handle = fopen("{$dir}/settings.xml", 'w');
     fwrite($handle, $this->get_ods_settings());
     $files[] = "{$dir}/settings.xml";
     $handle = fopen("{$dir}/META-INF/manifest.xml", 'w');
     fwrite($handle, $this->get_ods_manifest());
     $files[] = "{$dir}/META-INF";
     $filename = "{$dir}/result.ods";
     zip_files($files, $filename);
     $handle = fopen($filename, 'rb');
     $contents = fread($handle, filesize($filename));
     fclose($handle);
     remove_dir($dir);
     // Cleanup the temp directory.
     return $contents;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:38,代码来源:odslib.class.php


示例13: hiperbook_to_scorm

function hiperbook_to_scorm($id)
{
    if (!($cm = get_record('course_modules', 'id', $id))) {
        error('Course Module ID is incorrect');
    }
    if (!($course = get_record('course', 'id', $cm->course))) {
        error('Course is misconfigured');
    }
    if (!($book = get_record('hiperbook', 'id', $cm->instance))) {
        error('Course module is incorrect');
    }
    $bookid = $book->id;
    set_time_limit(3000);
    global $CFG, $course;
    ob_start();
    ob_implicit_flush();
    echo "<br>Copying files\n";
    ob_flush();
    // cria a pasta de trabalho temporaria
    mkdir($CFG->dataroot . '/' . $course->id . '/temp');
    mkdir($CFG->dataroot . '/' . $course->id . '/temp/assets');
    //copia arquivos do hiperlivro para assets
    mkdir($CFG->dataroot . '/' . $course->id . '/temp/assets/images');
    copy($book->img_hotwords_icon, $CFG->dataroot . '/' . $course->id . '/temp/assets/images/');
    copy($book->img_suggestions_icon, $CFG->dataroot . '/' . $course->id . '/temp/assets/images/');
    copy('images/next.gif', $CFG->dataroot . '/' . $course->id . '/temp/assets/images/next.gif');
    copy('images/back.gif', $CFG->dataroot . '/' . $course->id . '/temp/assets/images/back.gif');
    copy('prototype.js', $CFG->dataroot . '/' . $course->id . '/temp/assets/prototype.js');
    copy('effects.js', $CFG->dataroot . '/' . $course->id . '/temp/assets/effects.js');
    copy('dragdrop.js', $CFG->dataroot . '/' . $course->id . '/temp/assets/dragdrop.js');
    copy('popup.js', $CFG->dataroot . '/' . $course->id . '/temp/assets/popup.js');
    copy('findAPI.js', $CFG->dataroot . '/' . $course->id . '/temp/assets/findAPI.js');
    mkdir($CFG->dataroot . '/' . $course->id . '/temp/scos');
    // transforma o hiperbook em um pacote SCORm dentro da estrutura
    /*
    	/assets : pasta onde sao armazenadas as imgs, swfs e etc
    	/scos : pasta onde sao gravados os capitulos e sub-itens ex /scos/14, /scos/14/dicas 
    	/  
    */
    //inicia pela geração das paginas html dos capityulos (resources)
    echo "<br>Processing chapters:<br>";
    ob_flush();
    hiperbook_parse_chapters($bookid, $cm->id, 'SCORM');
    hiperbook_parse_hotwordspage($bookid, $cm->id);
    hiperbook_parse_suggestionspage($bookid, $cm->id);
    // converte os navpaths e cria os elementos do modelo de navagação
    echo "<br>Creating manifest...<br>";
    ob_flush();
    hiperbook_create_ims_manifest($bookid);
    //compactando
    echo "<br>Zipping files...";
    ob_flush();
    $basedir = $CFG->dataroot . '/' . $course->id . '/temp';
    $fullpath = $CFG->dataroot . '/' . $course->id . '/temp';
    $directory = opendir($fullpath);
    // Find all files
    while (false !== ($file = readdir($directory))) {
        if ($file == "." || $file == "..") {
            continue;
        }
        $filelist[] = $file;
    }
    closedir($directory);
    if (!($book = get_record('hiperbook', 'id', $bookid))) {
        return false;
    }
    $files = array();
    foreach ($filelist as $file) {
        $files[] = "{$basedir}/{$file}";
    }
    if (!zip_files($files, $CFG->dataroot . '/' . $course->id . "/" . $book->name . "_scorm")) {
        error(get_string("zipfileserror", "error"));
    }
    // remove a pasta temporaria
    echo "<br>Deleting temporary data...";
    hiperbook_recursive_remove_directory($CFG->dataroot . '/' . $course->id . '/temp', $empty = FALSE);
    echo "<br>Saved in  <a href=" . $CFG->wwwroot . "/files/index.php?id=" . $course->id . ".zip>" . $book->name . ".zip</a>";
}
开发者ID:ronniebrito,项目名称:moodle_hiperbook,代码行数:78,代码来源:lib.php


示例14: data_presets_export

function data_presets_export($course, $cm, $data)
{
    global $CFG;
    $presetname = clean_filename($data->name) . '-preset-' . gmdate("Ymd_Hi");
    $exportsubdir = "{$course->id}/moddata/data/{$data->id}/{$presetname}";
    make_upload_directory($exportsubdir);
    $exportdir = "{$CFG->dataroot}/{$exportsubdir}";
    // Assemble "preset.xml":
    $presetxmldata = "<preset>\n\n";
    // Raw settings are not preprocessed during saving of presets
    $raw_settings = array('intro', 'comments', 'requiredentries', 'requiredentriestoview', 'maxentries', 'rssarticles', 'approval', 'defaultsortdir');
    $presetxmldata .= "<settings>\n";
    // First, settings that do not require any conversion
    foreach ($raw_settings as $setting) {
        $presetxmldata .= "<{$setting}>" . htmlspecialchars($data->{$setting}) . "</{$setting}>\n";
    }
    // Now specific settings
    if ($data->defaultsort > 0 && ($sortfield = data_get_field_from_id($data->defaultsort, $data))) {
        $presetxmldata .= '<defaultsort>' . htmlspecialchars($sortfield->field->name) . "</defaultsort>\n";
    } else {
        $presetxmldata .= "<defaultsort>0</defaultsort>\n";
    }
    $presetxmldata .= "</settings>\n\n";
    // Now for the fields. Grab all that are non-empty
    $fields = get_records('data_fields', 'dataid', $data->id);
    ksort($fields);
    if (!empty($fields)) {
        foreach ($fields as $field) {
            $presetxmldata .= "<field>\n";
            foreach ($field as $key => $value) {
                if ($value != '' && $key != 'id' && $key != 'dataid') {
                    $presetxmldata .= "<{$key}>" . htmlspecialchars($value) . "</{$key}>\n";
                }
            }
            $presetxmldata .= "</field>\n\n";
        }
    }
    $presetxmldata .= '</preset>';
    // After opening a file in write mode, close it asap
    $presetxmlfile = fopen($exportdir . '/preset.xml', 'w');
    fwrite($presetxmlfile, $presetxmldata);
    fclose($presetxmlfile);
    // Now write the template files
    $singletemplate = fopen($exportdir . '/singletemplate.html', 'w');
    fwrite($singletemplate, $data->singletemplate);
    fclose($singletemplate);
    $listtemplateheader = fopen($exportdir . '/listtemplateheader.html', 'w');
    fwrite($listtemplateheader, $data->listtemplateheader);
    fclose($listtemplateheader);
    $listtemplate = fopen($exportdir . '/listtemplate.html', 'w');
    fwrite($listtemplate, $data->listtemplate);
    fclose($listtemplate);
    $listtemplatefooter = fopen($exportdir . '/listtemplatefooter.html', 'w');
    fwrite($listtemplatefooter, $data->listtemplatefooter);
    fclose($listtemplatefooter);
    $addtemplate = fopen($exportdir . '/addtemplate.html', 'w');
    fwrite($addtemplate, $data->addtemplate);
    fclose($addtemplate);
    $rsstemplate = fopen($exportdir . '/rsstemplate.html', 'w');
    fwrite($rsstemplate, $data->rsstemplate);
    fclose($rsstemplate);
    $rsstitletemplate = fopen($exportdir . '/rsstitletemplate.html', 'w');
    fwrite($rsstitletemplate, $data->rsstitletemplate);
    fclose($rsstitletemplate);
    $csstemplate = fopen($exportdir . '/csstemplate.css', 'w');
    fwrite($csstemplate, $data->csstemplate);
    fclose($csstemplate);
    $jstemplate = fopen($exportdir . '/jstemplate.js', 'w');
    fwrite($jstemplate, $data->jstemplate);
    fclose($jstemplate);
    $asearchtemplate = fopen($exportdir . '/asearchtemplate.html', 'w');
    fwrite($asearchtemplate, $data->asearchtemplate);
    fclose($asearchtemplate);
    // Check if all files have been generated
    if (!is_directory_a_preset($exportdir)) {
        error('Not all files generated!');
        // should be migrated to print_error()
    }
    $filelist = array('preset.xml', 'singletemplate.html', 'listtemplateheader.html', 'listtemplate.html', 'listtemplatefooter.html', 'addtemplate.html', 'rsstemplate.html', 'rsstitletemplate.html', 'csstemplate.css', 'jstemplate.js', 'asearchtemplate.html');
    foreach ($filelist as $key => $file) {
        $filelist[$key] = $exportdir . '/' . $filelist[$key];
    }
    $exportfile = "{$CFG->dataroot}/{$course->id}/moddata/data/{$data->id}/{$presetname}.zip";
    file_exists($exportfile) && unlink($exportfile);
    $status = zip_files($filelist, $exportfile);
    // ToDo: status check
    foreach ($filelist as $file) {
        unlink($file);
    }
    rmdir($exportdir);
    // Return the full path to the exported preset file:
    return $exportfile;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:93,代码来源:preset.php


示例15: export

 function export()
 {
     global $CFG;
     $dir = opendir($this->path);
     $exists = false;
     $file = readdir($dir);
     do {
         if ($file == 'pif' . $this->cm->id . '.zip') {
             $exists = true;
         }
     } while ($exists == false && ($file = readdir($dir)));
     closedir($dir);
     if ($exists == true) {
         unlink($this->path . '/' . 'pif' . $this->cm->id . '.zip');
     }
     // create introduction.html, task.html, ...
     $this->create_webquestscorm('introduction');
     $this->create_webquestscorm('task');
     $this->create_webquestscorm('process');
     $this->create_webquestscorm('evaluation');
     $this->create_webquestscorm('conclusion');
     $this->create_webquestscorm('credits');
     // create pif.zip
     $pif = new PclZip('pif' . $this->cm->id . '.zip');
     $source = $CFG->dirroot . '/mod/webquestscorm/xsd/';
     $dir = opendir($source);
     $route = $this->path . '/pif' . $this->cm->id . '.zip';
     while ($fxsd = readdir($dir)) {
         if ($fxsd != '.' && $fxsd != '..') {
             if (is_dir($source . $fxsd)) {
                 mkdir($this->path . '/' . $fxsd);
                 $dir2 = opendir($source . $fxsd);
                 while ($fxsd2 = readdir($dir2)) {
                     if ($fxsd2 != '.' && $fxsd2 != '..') {
                         copy($source . $fxsd . '/' . $fxsd2, $this->path . '/' . $fxsd . '/' . $fxsd2);
                     }
                 }
             } else {
                 copy($source . $fxsd, $this->path . '/' . $fxsd);
             }
         }
     }
     $dir = opendir($this->path);
     $i = 0;
     while ($fxsd = readdir($dir)) {
         if ($fxsd != '.' && $fxsd != '..') {
             $files[$i++] = $this->path . '/' . $fxsd;
         }
     }
     closedir($dir);
     if (!zip_files($files, "{$route}")) {
         print_error("zipfileserror", "error");
     }
     $dir = opendir($this->path);
     while ($fxsd = readdir($dir)) {
         if ($fxsd != '.' && $fxsd != '..') {
             if (strstr($fxsd, '.xsd') != false || strstr($fxsd, '.dtd') != false) {
                 unlink($this->path . '/' . $fxsd);
             } else {
                 if (is_dir($this->path . '/' . $fxsd)) {
                     $dir2 = opendir($this->path . '/' . $fxsd);
                     while ($fxsd2 = readdir($dir2)) {
                         if ($fxsd2 != '.' && $fxsd2 != '..') {
                             unlink($this->path . '/' . $fxsd . '/' . $fxsd2);
                         }
                     }
                     closedir($dir2);
                     rmdir($this->path . '/' . $fxsd);
                 }
             }
         }
     }
     closedir($dir);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:74,代码来源:webquestscorm.class.php


示例16: data_presets_export

function data_presets_export($course, $cm, $data)
{
    global $CFG;
    /* Info Collected. Now need to make files in moodledata/temp */
    $tempfolder = $CFG->dataroot . '/temp';
    $singletemplate = fopen($tempfolder . '/singletemplate.html', 'w');
    $listtemplate = fopen($tempfolder . '/listtemplate.html', 'w');
    $listtemplateheader = fopen($tempfolder . '/listtemplateheader.html', 'w');
    $listtemplatefooter = fopen($tempfolder . '/listtemplatefooter.html', 'w');
    $addtemplate = fopen($tempfolder . '/addtemplate.html', 'w');
    $rsstemplate = fopen($tempfolder . '/rsstemplate.html', 'w');
    $rsstitletemplate = fopen($tempfolder . '/rsstitletemplate.html', 'w');
    $csstemplate = fopen($tempfolder . '/csstemplate.css', 'w');
    $jstemplate = fopen($tempfolder . '/jstemplate.js', 'w');
    fwrite($singletemplate, $data->singletemplate);
    fwrite($listtemplate, $data->listtemplate);
    fwrite($listtemplateheader, $data->listtemplateheader);
    fwrite($listtemplatefooter, $data->listtemplatefooter);
    fwrite($addtemplate, $data->addtemplate);
    fwrite($rsstemplate, $data->rsstemplate);
    fwrite($rsstitletemplate, $data->rsstitletemplate);
    fwrite($csstemplate, $data->csstemplate);
    fwrite($jstemplate, $data->jstemplate);
    fclose($singletemplate);
    fclose($listtemplate);
    fclose($listtemplateheader);
    fclose($listtemplatefooter);
    fclose($addtemplate);
    fclose($rsstemplate);
    fclose($rsstitletemplate);
    fclose($csstemplate);
    fclose($jstemplate);
    /* All the display data is now done. Now assemble preset.xml */
    $fields = get_records('data_fields', 'dataid', $data->id);
    $presetfile = fopen($tempfolder . '/preset.xml', 'w');
    $presetxml = "<preset>\n\n";
    /* Database settings first. Name not included? */
    $settingssaved = array('intro', 'comments', 'requiredentries', 'requiredentriestoview', 'maxentries', 'rssarticles', 'approval', 'scale', 'assessed', 'defaultsort', 'defaultsortdir', 'editany');
    $presetxml .= "<settings>\n";
    foreach ($settingssaved as $setting) {
        $presetxml .= "<{$setting}>{$data->{$setting}}</{$setting}>\n";
    }
    $presetxml .= "</settings>\n\n";
    /* Now for the fields. Grabs all settings that are non-empty */
    if (!empty($fields)) {
        foreach ($fields as $field) {
            $presetxml .= "<field>\n";
            foreach ($field as $key => $value) {
                if ($value != '' && $key != 'id' && $key != 'dataid') {
                    $presetxml .= "<{$key}>{$value}</{$key}>\n";
                }
            }
            $presetxml .= "</field>\n\n";
        }
    }
    $presetxml .= "</preset>";
    fwrite($presetfile, $presetxml);
    fclose($presetfile);
    /* Check all is well */
    if (!is_directory_a_preset($tempfolder)) {
        error("Not all files generated!");
    }
    $filelist = array('singletemplate.html', 'listtemplate.html', 'listtemplateheader.html', 'listtemplatefooter.html', 'addtemplate.html', 'rsstemplate.html', 'rsstitletemplate.html', 'csstemplate.css', 'jstemplate.js', 'preset.xml');
    foreach ($filelist as $key => $file) {
        $filelist[$key] = $tempfolder . '/' . $filelist[$key];
    }
    @unlink($tempfolder . '/export.zip');
    $status = zip_files($filelist, $tempfolder . '/export.zip');
    /* made the zip... now return the filename for storage.*/
    return $tempfolder . '/export.zip';
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:71,代码来源:lib.php


示例17: zip_dir

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP zip_open函数代码示例发布时间:2022-05-23
下一篇:
PHP zip_entry_read函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap