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


PHP FileManager::my_delete方法代码示例

本文整理汇总了PHP中FileManager::my_delete方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::my_delete方法的具体用法?PHP FileManager::my_delete怎么用?PHP FileManager::my_delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileManager的用法示例。


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

示例1: HotPotGCt

/**
 * Garbage collector
 */
function HotPotGCt($folder, $flag, $userID)
{
    // Garbage Collector
    $filelist = array();
    if ($dir = @opendir($folder)) {
        while (($file = readdir($dir)) !== false) {
            if ($file != ".") {
                if ($file != "..") {
                    $full_name = $folder . "/" . $file;
                    if (is_dir($full_name)) {
                        HotPotGCt($folder . "/" . $file, $flag);
                    } else {
                        $filelist[] = $file;
                    }
                }
            }
        }
        closedir($dir);
    }
    while (list($key, $val) = each($filelist)) {
        if (stristr($val, $userID . ".t.html")) {
            if ($flag == 1) {
                FileManager::my_delete($folder . "/" . $val);
            } else {
                echo $folder . "/" . $val . "<br />";
            }
        }
    }
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:32,代码来源:GC.php

示例2: export_zip

 /**
  * Exports the current SCORM object's files as a zip. Excerpts taken from learnpath_functions.inc.php::exportpath()
  * @param    integer    Learnpath ID (optional, taken from object context if not defined)
  */
 function export_zip($lp_id = null)
 {
     if ($this->debug > 0) {
         error_log('In scorm::export_zip method(' . $lp_id . ')', 0);
     }
     if (empty($lp_id)) {
         if (!is_object($this)) {
             return false;
         } else {
             $id = $this->get_id();
             if (empty($id)) {
                 return false;
             } else {
                 $lp_id = $this->get_id();
             }
         }
     }
     //error_log('New LP - in export_zip()',0);
     //zip everything that is in the corresponding scorm dir
     //write the zip file somewhere (might be too big to return)
     require_once 'learnpath_functions.inc.php';
     $course_id = api_get_course_int_id();
     $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
     $_course = api_get_course_info(api_get_course_id());
     $sql = "SELECT * FROM {$tbl_lp} WHERE c_id = " . $course_id . " AND id=" . $lp_id;
     $result = Database::query($sql);
     $row = Database::fetch_array($result);
     $LPname = $row['path'];
     $list = split('/', $LPname);
     $LPnamesafe = $list[0];
     //$zipfoldername = '/tmp';
     //$zipfoldername = '../../courses/'.$_course['directory'].'/temp/'.$LPnamesafe;
     $zipfoldername = api_get_path(SYS_COURSE_PATH) . $_course['directory'] . '/temp/' . $LPnamesafe;
     $scormfoldername = api_get_path(SYS_COURSE_PATH) . $_course['directory'] . '/scorm/' . $LPnamesafe;
     $zipfilename = $zipfoldername . '/' . $LPnamesafe . '.zip';
     // Get a temporary dir for creating the zip file.
     //error_log('New LP - cleaning dir '.$zipfoldername, 0);
     deldir($zipfoldername);
     // Make sure the temp dir is cleared.
     $res = mkdir($zipfoldername, api_get_permissions_for_new_directories());
     //error_log('New LP - made dir '.$zipfoldername, 0);
     // Create zipfile of given directory.
     $zip_folder = new PclZip($zipfilename);
     $zip_folder->create($scormfoldername . '/', PCLZIP_OPT_REMOVE_PATH, $scormfoldername . '/');
     //$zipfilename = '/var/www/chamilo/courses/TEST2/scorm/example_document.html';
     //This file sending implies removing the default mime-type from php.ini
     //DocumentManager :: file_send_for_download($zipfilename, true, $LPnamesafe.'.zip');
     DocumentManager::file_send_for_download($zipfilename, true);
     // Delete the temporary zip file and directory in fileManager.lib.php
     FileManager::my_delete($zipfilename);
     FileManager::my_delete($zipfoldername);
     return true;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:57,代码来源:scorm.class.php

示例3: unset_document_as_template

 /**
  * Unset a document as template
  *
  * @param int $document_id
  * @param string $couse_code
  * @param int $user_id
  */
 public static function unset_document_as_template($document_id, $course_code, $user_id)
 {
     $table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
     $course_code = Database::escape_string($course_code);
     $user_id = Database::escape_string($user_id);
     $document_id = Database::escape_string($document_id);
     $sql = 'SELECT id FROM ' . $table_template . ' WHERE course_code="' . $course_code . '" AND user_id="' . $user_id . '" AND ref_doc="' . $document_id . '"';
     $result = Database::query($sql);
     $template_id = Database::result($result, 0, 0);
     FileManager::my_delete(api_get_path(SYS_CODE_PATH) . 'upload/template_thumbnails/' . $template_id . '.jpg');
     $sql = 'DELETE FROM ' . $table_template . ' WHERE course_code="' . $course_code . '" AND user_id="' . $user_id . '" AND ref_doc="' . $document_id . '"';
     Database::query($sql);
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:20,代码来源:document.lib.php

示例4: exportSCORM

/**
 * Export SCORM content into a zip file
 *
 * Basically, all this function does is put the scorm directory back into a zip file (like the one
 * that was most probably used to import the course at first)
 * @deprecated this function is only called in the newscorm/scorm_admin.php which is deprecated
 *
 * @param    string    Name of the SCORM path (or the directory under which it resides)
 * @param    array        Not used right now. Should replace the use of global $_course
 * @return    void
 * @author    imandak80
 */
function exportSCORM($scormname, $course)
{
    $_course = api_get_course_info();
    // Initialize.
    $tmpname = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/scorm';
    $zipfoldername = $tmpname . $scormname;
    $zipfilename = $zipfoldername . '.zip';
    // Create zipfile of given directory.
    include_once api_get_path(LIBRARY_PATH) . 'pclzip/pclzip.lib.php';
    $zip_folder = new PclZip($zipfilename);
    $list = 1;
    //$list = $zip_folder->create($zipfoldername.'/',PCLZIP_OPT_REMOVE_PATH,$tmpname.$scormname."/"); // whitout folder
    $list = $zip_folder->create($zipfoldername . '/', PCLZIP_OPT_REMOVE_PATH, $tmpname);
    if ($list == 0) {
        //echo "Error  : ".$zip_folder->errorInfo(true);
    }
    // Send to client.
    DocumentManager::file_send_for_download($zipfilename, false, basename($scormname . '.zip'));
    FileManager::my_delete($zipfilename);
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:32,代码来源:learnpath_functions.inc.php

示例5: array

 case 'delete':
     // deletes an exercise
     $imgparams = array();
     $imgcount = 0;
     GetImgParams($file, $documentPath, $imgparams, $imgcount);
     $fld = GetFolderName($file);
     for ($i = 0; $i < $imgcount; $i++) {
         FileManager::my_delete($documentPath . $uploadPath . "/" . $fld . "/" . $imgparams[$i]);
         FileManager::update_db_info("delete", $uploadPath . "/" . $fld . "/" . $imgparams[$i]);
     }
     if (FileManager::my_delete($documentPath . $file)) {
         FileManager::update_db_info("delete", $file);
     }
     // hotpotatoes folder may contains several tests so don't delete folder if not empty : #2165
     if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !FileManager::folder_is_empty($documentPath . $uploadPath . "/" . $fld . "/"))) {
         FileManager::my_delete($documentPath . $uploadPath . "/" . $fld . "/");
     }
     break;
 case 'enable':
     // enables an exercise
     $newVisibilityStatus = "1";
     //"visible"
     $query = "SELECT id FROM {$TBL_DOCUMENT} WHERE c_id = {$course_id} AND path='" . Database::escape_string($file) . "'";
     $res = Database::query($query);
     $row = Database::fetch_array($res, 'ASSOC');
     api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'visible', $_user['user_id']);
     break;
 case 'disable':
     // disables an exercise
     $newVisibilityStatus = "0";
     //"invisible"
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:exercice.php

示例6: api_get_path

 * Included libraries
 */
//require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/hotpotatoes.lib.php';
$time = time();
$doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
$cid = api_get_course_id();
$document_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
$document_web_path = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/document';
$origin = $_REQUEST['origin'];
$learnpath_id = $_REQUEST['learnpath_id'];
$learnpath_item_id = $_REQUEST['learnpath_item_id'];
$time = isset($_REQUEST['time']) ? $_REQUEST['time'] : null;
$user_id = api_get_user_id();
$full_file_path = $document_path . $doc_url;
FileManager::my_delete($full_file_path . $user_id . '.t.html');
$content = ReadFileCont($full_file_path . $user_id . '.t.html');
if ($content == '') {
    $url = api_get_path(WEB_CODE_PATH) . "exercice/savescores.php?origin={$origin}&learnpath_id={$learnpath_id}&learnpath_item_id={$learnpath_item_id}&time=" . Security::remove_XSS($time) . "&test=" . $doc_url . "&uid=" . $user_id . "&cid=" . $cid . "&score='+Score";
    $content = ReadFileCont($full_file_path);
    $mit = "function Finish(){";
    $js_content = "\n        //Code added - start\n\n        var SaveScoreVariable = 0;\n        function mySaveScore() {\n            if (SaveScoreVariable==0) {\n                SaveScoreVariable = 1;\n                if (C.ie) {\n                    document.location.href = '" . $url . ";\n                    //window.alert(Score);\n                } else {\n                    window.location.href = '" . $url . ";\n                }\n            }\n        }\n        function Finish() {\n            mySaveScore();\n\n        //Code added - end\n    ";
    $newcontent = str_replace($mit, $js_content, $content);
    $prehref = "<!-- BeginTopNavButtons -->";
    $posthref = "<!-- BeginTopNavButtons -->";
    $newcontent = str_replace($prehref, $posthref, $newcontent);
    if (CheckSubFolder($full_file_path . $user_id . '.t.html') == 0) {
        $newcontent = ReplaceImgTag($newcontent);
    }
} else {
    $newcontent = $content;
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:showinframes.php

示例7: api_item_property_update

     $doc_id = FileManager::add_document($_course, '/HotPotatoes_files/' . $fld, 'folder', 0, $fld);
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id());
 } else {
     // It is not the first step... get the filename directly from the system params.
     $filename = $_FILES['userFile']['name'];
 }
 $allow_output_on_success = false;
 if (FileManager::handle_uploaded_document($_course, $_FILES['userFile'], $document_sys_path, $uploadPath . '/' . $fld, api_get_user_id(), null, null, $unzip, '', $allow_output_on_success)) {
     if ($finish == 2) {
         $imgparams = $_POST['imgparams'];
         $checked = CheckImageName($imgparams, $filename);
         if ($checked) {
             $imgcount = $imgcount - 1;
         } else {
             $dialogBox .= $filename . ' ' . get_lang('NameNotEqual');
             FileManager::my_delete($document_sys_path . $uploadPath . '/' . $fld . '/' . $filename);
             FileManager::update_db_info('delete', $uploadPath . '/' . $fld . '/' . $filename);
         }
         if ($imgcount == 0) {
             // all image uploaded
             $finish = 1;
         }
     } else {
         // If we are (still) on the first step of the upload process.
         if ($finish == 0) {
             $finish = 2;
             // Get number and name of images from the files contents.
             GetImgParams('/' . $filename, $document_sys_path . $uploadPath . '/' . $fld, $imgparams, $imgcount);
             if ($imgcount == 0) {
                 $finish = 1;
             } else {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:hotpotatoes.php

示例8: api_get_course_id

    require_once '../newscorm/learnpath.class.php';
    require_once '../newscorm/learnpathItem.class.php';
    require_once '../newscorm/scorm.class.php';
    require_once '../newscorm/scormItem.class.php';
    require_once '../newscorm/aicc.class.php';
    require_once '../newscorm/aiccItem.class.php';
}
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$_cid = api_get_course_id();
$test = $_REQUEST['test'];
$score = $_REQUEST['score'];
$origin = $_REQUEST['origin'];
$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document";
$full_file_path = $documentPath . $test;
FileManager::my_delete($full_file_path . $_user['user_id'] . ".t.html");
$TABLETRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$tbl_learnpath_user = Database::get_course_table(TABLE_LEARNPATH_USER);
$TABLE_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$jscript2run = '';
/**
 * Save the score for a HP quiz. Can be used by the learnpath tool as well
 * for HotPotatoes quizzes. When coming from the learning path, we
 * use the session variables telling us which item of the learning path has to
 * be updated (score-wise)
 * @param    string    File is the exercise name (the file name for a HP)
 * @param    integer    Score to save inside the tracking tables (HP and learnpath)
 * @return    void
 */
function save_scores($file, $score)
{
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:savescores.php

示例9: import_exercise


//.........这里部分代码省略.........
    }
    $uploadPath = '/';
    // set some default values for the new exercise
    $exercise_info = array();
    $exercise_info['name'] = preg_replace('/.zip$/i', '', $file);
    $exercise_info['question'] = array();
    $element_pile = array();
    // create parser and array to retrieve info from manifest
    $element_pile = array();
    //pile to known the depth in which we are
    //$module_info = array (); //array to store the info we need
    // if file is not a .zip, then we cancel all
    if (!preg_match('/.zip$/i', $file)) {
        Display::display_error_message(get_lang('You must upload a zip file'));
        return false;
    }
    // unzip the uploaded file in a tmp directory
    if (!get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath)) {
        Display::display_error_message(get_lang('You must upload a zip file'));
        return false;
    }
    // find the different manifests for each question and parse them.
    $exerciseHandle = opendir($baseWorkDir);
    //$question_number = 0;
    $file_found = false;
    $operation = false;
    $result = false;
    // parse every subdirectory to search xml question files
    while (false !== ($file = readdir($exerciseHandle))) {
        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
            //find each manifest for each question repository found
            $questionHandle = opendir($baseWorkDir . '/' . $file);
            while (false !== ($questionFile = readdir($questionHandle))) {
                if (preg_match('/.xml$/i', $questionFile)) {
                    $result = parse_file($baseWorkDir, $file, $questionFile);
                    $file_found = true;
                }
            }
        } elseif (preg_match('/.xml$/i', $file)) {
            $result = parse_file($baseWorkDir, '', $file);
            $file_found = true;
        }
        // else ignore file
    }
    if (!$file_found) {
        Display::display_error_message(get_lang('No XML file found in the zip'));
        return false;
    }
    if ($result == false) {
        return false;
    }
    //add exercise in tool
    //1.create exercise
    $exercise = new Exercise();
    $exercise->exercise = $exercise_info['name'];
    $exercise->save();
    $last_exercise_id = $exercise->selectId();
    if (!empty($last_exercise_id)) {
        //For each question found...
        foreach ($exercise_info['question'] as $key => $question_array) {
            //2.create question
            $question = new Ims2Question();
            $question->type = $question_array['type'];
            $question->setAnswer();
            $question->updateTitle($question_array['title']);
            // question ...
            $type = $question->selectType();
            $question->type = constant($type);
            // type ...
            $question->save($last_exercise_id);
            // save computed grade
            $last_question_id = $question->selectId();
            //3.create answer
            $answer = new Answer($last_question_id);
            $answer->new_nbrAnswers = count($question_array['answer']);
            foreach ($question_array['answer'] as $key => $answers) {
                $split = explode('_', $key);
                $i = $split[1];
                $answer->new_answer[$i] = $answers['value'];
                // answer ...
                $answer->new_comment[$i] = $answers['feedback'];
                // comment ...
                $answer->new_position[$i] = $i;
                // position ...
                // correct answers ...
                if (in_array($key, $question_array['correct_answers'])) {
                    $answer->new_correct[$i] = 1;
                } else {
                    $answer->new_correct[$i] = 0;
                }
                $answer->new_weighting[$i] = $question_array['weighting'][$key];
            }
            $answer->save();
        }
        // delete the temp dir where the exercise was unzipped
        FileManager::my_delete($baseWorkDir . $uploadPath);
        $operation = true;
    }
    return $operation;
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:exercise_import.inc.php

示例10: HotPotGCt

/**
 * Hotpotato Garbage Collector
 * @param    string     Path
 * @param    integer    Flag
 * @param    integer    User id
 * @return   void       No return value, but echoes results
 */
function HotPotGCt($folder, $flag, $user_id)
{
    // Garbage Collector
    $filelist = array();
    if ($dir = @opendir($folder)) {
        while (($file = readdir($dir)) !== false) {
            if ($file != '.') {
                if ($file != '..') {
                    $full_name = $folder . '/' . $file;
                    if (is_dir($full_name)) {
                        HotPotGCt($folder . '/' . $file, $flag, $user_id);
                    } else {
                        $filelist[] = $file;
                    }
                }
            }
        }
        closedir($dir);
    }
    while (list($key, $val) = each($filelist)) {
        if (stristr($val, $user_id . '.t.html')) {
            if ($flag == 1) {
                FileManager::my_delete($folder . '/' . $val);
            } else {
                echo $folder . '/' . $val . '<br />';
            }
        }
    }
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:36,代码来源:hotpotatoes.lib.php


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