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


PHP upload_manager类代码示例

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


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

示例1: gwfontform_validate

function gwfontform_validate(Pieform $form, $values)
{
    global $USER, $SESSION;
    require_once 'file.php';
    require_once 'uploadmanager.php';
    $valid = false;
    if ($values['gwfzipfile'] != null) {
        $filetype = $values['gwfzipfile']['type'];
        // Ensures that the correct file was chosen
        $accepted = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/s-compressed');
        foreach ($accepted as $mimetype) {
            if ($mimetype == $filetype) {
                $valid = true;
                break;
            }
        }
        // Safari and Chrome don't register zip mime types. Something better could be used here.
        // Check if file extension, that is the last 4 characters in file name, equals '.zip'...
        $valid = substr($values['gwfzipfile']['name'], -4) == '.zip' ? true : false;
        if (!$valid) {
            $form->set_error('gwfzipfile', get_string('notvalidzipfile', 'skin'));
        }
        // pass it through the virus checker
        $um = new upload_manager('gwfzipfile');
        if ($error = $um->preprocess_file()) {
            $form->set_error($inputname, $error);
        }
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:29,代码来源:installgwf.php

示例2: moodle_binary_store_file

function moodle_binary_store_file(&$filename, &$id, &$meta, $ext = ".bin")
{
    # READ-Only
    global $_FILES, $CFG, $course, $wiki, $groupid, $userid, $ewiki_title, $cm;
    if (!$wiki->ewikiacceptbinary) {
        print_error('cannotacceptbin', 'wiki');
        return 0;
    }
    $entry = wiki_get_entry($wiki, $course, $userid, $groupid);
    if (!$entry->id) {
        print_error('cannotgetentry', 'wiki');
    }
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager('upload', false, false, $course, false, 0, true, true);
    if ($um->process_file_uploads("{$course->id}/{$CFG->moddata}/wiki/{$wiki->id}/{$entry->id}/{$ewiki_title}")) {
        $filename = '';
        // this to make sure we don't keep processing in the parent function
        if (!$id) {
            $newfilename = $um->get_new_filename();
            $id = EWIKI_IDF_INTERNAL . $newfilename;
        }
        return true;
    }
    print_error('uploaderror', 'wiki', '', $um->print_upload_log(true));
    return false;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:26,代码来源:moodle_binary_store.php

示例3: addvariantform_validate

function addvariantform_validate(Pieform $form, $values)
{
    global $USER, $SESSION;
    require_once 'file.php';
    require_once 'uploadmanager.php';
    // Make sure they didn't hack the hidden variable to have the name of
    // a font that doesn't exist
    if (!record_exists('skin_fonts', 'name', $values['fontname'])) {
        $form->set_error('fontname', get_string('nosuchfont', 'skin'));
    }
    $uploadfiles = array('fontfileEOT' => array('required' => true, 'suffix' => 'eot'), 'fontfileSVG' => array('required' => true, 'suffix' => 'svg'), 'fontfileTTF' => array('required' => true, 'suffix' => 'ttf'), 'fontfileWOFF' => array('required' => true, 'suffix' => 'woff'));
    foreach ($uploadfiles as $inputname => $details) {
        $um = new upload_manager($inputname, false, null, $details['required']);
        if ($error = $um->preprocess_file()) {
            $form->set_error($inputname, $error);
        }
        if ($details['suffix']) {
            $reqext = ".{$details['suffix']}";
            $fileext = substr($values[$inputname]['name'], -1 * strlen($reqext));
            if ($fileext != $reqext) {
                $form->set_error($inputname, get_string('notvalidfontfile', 'skin', strtoupper($details['suffix'])));
            }
        }
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:25,代码来源:add.php

示例4: wiki_upload_deldir

function wiki_upload_deldir(&$WS)
{
    //cheack if the folder exists
    if (file_exists($WS->dfdir->name)) {
        //delete all folder files
        $upd = new upload_manager();
        $upd->delete_other_files($WS->dfdir->name);
        rmdir($WS->dfdir->name);
        return true;
    } else {
        return true;
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:13,代码来源:uploadlib.php

示例5: importskinform_validate

function importskinform_validate(Pieform $form, $values)
{
    global $USER, $SESSION;
    $filetype = $values['file']['type'];
    if (!$filetype || $filetype != 'text/xml') {
        $form->set_error('file', get_string('notvalidxmlfile', 'skin'));
    }
    require_once 'file.php';
    require_once 'uploadmanager.php';
    $um = new upload_manager('file');
    if ($error = $um->preprocess_file()) {
        $form->set_error('file', $error);
    }
}
开发者ID:patkira,项目名称:mahara,代码行数:14,代码来源:import.php

示例6: upload_response

/**
 * Uploads the file submitted (adapted from mod/workshop/submissions.php)
 *
 * @param string $fileid string corresponding to the input file ('resp##_file')
 * @param int $attemptid attempt id
 * @param int $questionid question id
 * @param int $maxbytes maximum upload size in bytes
 * @return string feedback from upload, related to success or failure
 */
function upload_response($fileid, $course, $attemptid, $questionid, $maxbytes)
{
    global $CFG;
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager($fileid, true, false, $course, true, $maxbytes, true);
    if ($um->preprocess_files()) {
        $dir = quiz_file_area_name($attemptid, $questionid);
        if (!quiz_file_area($dir)) {
            return get_string('uploadproblem');
        }
        if ($um->save_files($dir)) {
            return get_string('uploadedfile');
        }
    }
    return get_string('uploaderror', 'qtype_fileresponse');
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:25,代码来源:locallib.php

示例7: require_login

}
require_login($course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lightboxgallery:addimage', $context);
$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id;
$straddimage = get_string('addimage', 'lightboxgallery');
$navigation = build_navigation($straddimage, $cm);
print_header($course->shortname . ': ' . $gallery->name . ': ' . $straddimage, $course->fullname, $navigation, '', '', true, ' ', navmenu($course, $cm));
$mform = new mod_lightboxgallery_imageadd_form(null, $gallery);
if ($mform->is_cancelled()) {
    redirect($galleryurl);
} else {
    if (($formdata = $mform->get_data()) && confirm_sesskey()) {
        require_once $CFG->dirroot . '/lib/uploadlib.php';
        $handlecollisions = !get_config('lightboxgallery', 'overwritefiles');
        $um = new upload_manager('attachment', false, $handlecollisions, $course);
        $uploaddir = $course->id . '/' . $gallery->folder;
        if ($um->process_file_uploads($uploaddir)) {
            $folder = $CFG->dataroot . '/' . $uploaddir;
            $filename = $um->get_new_filename();
            $messages = array();
            if (lightboxgallery_get_file_extension($filename) == 'zip') {
                $thumb = '<img src="' . $CFG->pixpath . '/f/zip.gif" class="icon" alt="zip" />';
                $before = lightboxgallery_directory_images($folder);
                if (unzip_file($folder . '/' . $filename, $folder, false)) {
                    $messages[] = get_string('zipextracted', 'lightboxgallery', $filename);
                    $after = lightboxgallery_directory_images($folder);
                    if ($newfiles = array_diff($after, $before)) {
                        $resizeoption = 0;
                        if (in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH))) {
                            $resizeoption = $gallery->resize;
开发者ID:itziko,项目名称:Moodle-jQuery-Lightbox-Gallery,代码行数:31,代码来源:imageadd.php

示例8: upload_file

 function upload_file()
 {
     global $CFG, $USER;
     $mode = optional_param('mode', '', PARAM_ALPHA);
     $offset = optional_param('offset', 0, PARAM_INT);
     $returnurl = 'view.php?id=' . $this->cm->id;
     $filecount = $this->count_user_files($USER->id);
     $submission = $this->get_submission($USER->id);
     if (!$this->can_upload_file($submission)) {
         $this->view_header(get_string('upload'));
         notify(get_string('uploaderror', 'assignment'));
         print_continue($returnurl);
         $this->view_footer();
         die;
     }
     $dir = $this->file_area_name($USER->id);
     check_dir_exists($CFG->dataroot . '/' . $dir, true, true);
     // better to create now so that student submissions do not block it later
     require_once $CFG->dirroot . '/lib/uploadlib.php';
     $um = new upload_manager('newfile', false, true, $this->course, false, $this->assignment->maxbytes, true);
     if ($um->process_file_uploads($dir)) {
         $submission = $this->get_submission($USER->id, true);
         //create new submission if needed
         $updated = new object();
         $updated->id = $submission->id;
         $updated->timemodified = time();
         if (update_record('assignment_submissions', $updated)) {
             add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
             $submission = $this->get_submission($USER->id);
             $this->update_grade($submission);
             if (!$this->drafts_tracked()) {
                 $this->email_teachers($submission);
             }
         } else {
             $new_filename = $um->get_new_filename();
             $this->view_header(get_string('upload'));
             notify(get_string('uploadnotregistered', 'assignment', $new_filename));
             print_continue($returnurl);
             $this->view_footer();
             die;
         }
         redirect('view.php?id=' . $this->cm->id);
     }
     $this->view_header(get_string('upload'));
     notify(get_string('uploaderror', 'assignment'));
     echo $um->get_errors();
     print_continue($returnurl);
     $this->view_footer();
     die;
 }
开发者ID:NextEinstein,项目名称:riverhills,代码行数:50,代码来源:assignment.class.php

示例9: foreach

        foreach ($submissions as $submission) {
            if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
                // ignore this submission
                redirect("view.php?id={$cm->id}");
                print_footer($course);
                exit;
            }
        }
    }
}
// check existence of title
if ($title == '') {
    notify(get_string("notitlegiven", "exercise"));
} else {
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager('newfile', false, false, $course, false, $exercise->maxbytes);
    if ($um->preprocess_files()) {
        $newsubmission->exerciseid = $exercise->id;
        if (isteacher($course->id)) {
            // it's an exercise submission, flag it as such
            $newsubmission->userid = 0;
            $newsubmission->isexercise = 1;
            // it's a description of an exercise
        } else {
            $newsubmission->userid = $USER->id;
        }
        $newsubmission->title = $title;
        $newsubmission->timecreated = $timenow;
        if ($timenow > $exercise->deadline) {
            $newsubmission->late = 1;
        }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:upload.php

示例10: define

 if (empty($copyright)) {
     $redirect_url = url . $USER->username . "/files/";
     if ($folderid > -1) {
         $redirect_url .= $folderid;
     }
     define('redirect_url', $redirect_url);
     $messages[] = gettext("Upload unsuccessful. You must check the copyright box for a file to be uploaded.");
     break;
 }
 $ul_username = run("users:id_to_name", $page_owner);
 $upload_folder = $textlib->substr($ul_username, 0, 1);
 require_once $CFG->dirroot . 'lib/uploadlib.php';
 $total_quota = get_field_sql('SELECT sum(size) FROM ' . $CFG->prefix . 'files WHERE owner = ?', array($page_owner));
 $max_quota = get_field('users', 'file_quota', 'ident', $page_owner);
 $maxbytes = $max_quota - $tota_quota;
 $um = new upload_manager('new_file', false, true, false, $maxbytes, true);
 $reldir = "files/" . $upload_folder . "/" . $ul_username . "/";
 $dir = $CFG->dataroot . $reldir;
 if ($um->process_file_uploads($dir)) {
     $f = new StdClass();
     $f->owner = $USER->ident;
     $f->files_owner = $page_owner;
     $f->folder = $folderid;
     $f->originalname = $um->get_original_filename();
     if (empty($title)) {
         $title = $um->get_original_filename();
     }
     $f->title = $title;
     $f->description = $description;
     $f->location = $reldir . '/' . $um->get_new_filename();
     $f->access = $access;
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:31,代码来源:files_actions.php

示例11: upload

 function upload()
 {
     global $CFG, $USER;
     $NUM_REVIEWS = 2;
     $POOL_SIZE = 2 * $NUM_REVIEWS + 1;
     // including current submitter
     require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
     $this->view_header(get_string('upload'));
     if ($this->isopen()) {
         if (!record_exists('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $USER->id)) {
             $newsubmission = NULL;
             // Process online text
             if (isset($this->assignment->var3) && $this->assignment->var3 == self::ONLINE_TEXT) {
                 $newsubmission = $this->prepare_new_submission($USER->id);
                 $newsubmission->data1 = addslashes(required_param('text', PARAM_CLEANHTML));
                 $sumbissionName = get_string('yoursubmission', 'assignment_peerreview');
                 // echo '<pre>'.print_r($_POST,true).'</pre>';
             } else {
                 $dir = $this->file_area_name($USER->id);
                 require_once $CFG->dirroot . '/lib/uploadlib.php';
                 $um = new upload_manager('newfile', true, false, $this->course, false, $this->assignment->maxbytes);
                 if ($um->preprocess_files()) {
                     //Check the file extension
                     $submittedFilename = $um->get_original_filename();
                     $extension = $this->assignment->fileextension;
                     if (strtolower(substr($submittedFilename, strlen($submittedFilename) - strlen($extension))) != $extension) {
                         notify(get_string("incorrectfileextension", "assignment_peerreview", $extension));
                     } else {
                         if ($um->save_files($dir)) {
                             $sumbissionName = $um->get_new_filename();
                             $newsubmission = $this->prepare_new_submission($USER->id);
                             $newsubmission->numfiles = 1;
                         }
                     }
                 }
             }
             if ($newsubmission) {
                 // Enter submission into DB and log
                 $newsubmission->timecreated = time();
                 $newsubmission->timemodified = time();
                 if (insert_record('assignment_submissions', $newsubmission)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     // $this->email_teachers($newsubmission);
                     print_heading(get_string('uploadedfile'));
                     $submissionSuccess = true;
                 } else {
                     notify(get_string("uploadnotregistered", "assignment", $sumbissionName));
                 }
                 // Allocate reviews
                 $recentSubmissions = array();
                 $numberOfRecentSubmissions = 0;
                 if ($submissionResult = get_records_sql('SELECT userid FROM ' . $CFG->prefix . 'assignment_submissions WHERE assignment=\'' . $this->assignment->id . '\' ORDER BY timecreated DESC, id DESC', 0, $POOL_SIZE + 1)) {
                     $recentSubmissions = array_values($submissionResult);
                     $numberOfRecentSubmissions = count($recentSubmissions);
                 }
                 if ($numberOfRecentSubmissions >= $POOL_SIZE) {
                     for ($i = 2; $i < 2 * $NUM_REVIEWS + 1; $i += 2) {
                         if (!insert_record('assignment_review', $this->prepare_new_review($USER->id, $recentSubmissions[$i]->userid))) {
                             notify(get_string("reviewsallocationerror", "assignment_peerreview"));
                         }
                     }
                 }
                 // If pool just got large enough, allocated reviews to previous submitters
                 if ($numberOfRecentSubmissions == $POOL_SIZE) {
                     $recentSubmissions = array_reverse($recentSubmissions);
                     for ($i = 0; $i < $POOL_SIZE - 1; $i++) {
                         for ($j = 1; $j <= $NUM_REVIEWS; $j++) {
                             insert_record('assignment_review', $this->prepare_new_review($recentSubmissions[$i]->userid, $recentSubmissions[$i - 2 * $j + ($i - 2 * $j >= 0 ? 0 : $NUM_REVIEWS * 2 + 1)]->userid));
                         }
                         // Send an email to student
                         $subject = get_string('reviewsallocatedsubject', 'assignment_peerreview');
                         $linkToReview = $CFG->wwwroot . '/mod/assignment/view.php?id=' . $this->cm->id;
                         $message = get_string('reviewsallocated', 'assignment_peerreview') . "\n\n" . get_string('assignmentname', 'assignment') . ': ' . $this->assignment->name . "\n" . get_string('course') . ': ' . $this->course->fullname . "\n\n";
                         $messageText = $message . $linkToReview;
                         $messageHTML = nl2br($message) . '<a href="' . $linkToReview . '" target="_blank">' . get_string('reviewsallocatedlinktext', 'assignment_peerreview') . '</a>';
                         $this->email_from_teacher($this->course->id, $recentSubmissions[$i]->userid, $subject, $messageText, $messageHTML);
                     }
                 }
                 if ($numberOfRecentSubmissions >= $POOL_SIZE) {
                     redirect('view.php?id=' . $this->cm->id, get_string("reviewsallocated", "assignment_peerreview"), 2);
                 } else {
                     notify(get_string("poolnotlargeenough", "assignment_peerreview"), 'notifysuccess');
                     print_continue('view.php?id=' . $this->cm->id);
                 }
             }
         } else {
             notify(get_string("resubmit", "assignment_peerreview", $this->course->teacher));
             // re-submitting not allowed
             print_continue('view.php?id=' . $this->cm->id);
         }
     } else {
         notify(get_string("closed", "assignment_peerreview"));
         // assignment closed
         print_continue('view.php?id=' . $this->cm->id);
     }
     $this->view_footer();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:97,代码来源:assignment.class.php

示例12: get_proposal

    //Check proposal owner
    $proposal = get_proposal($proposal_id, $USER->id);
} elseif (Context == 'admin') {
    preg_match('#^admin/proposals/(\\d+)/files#', $q, $matches);
    $proposal_id = !empty($matches) ? (int) $matches[1] : 0;
    $proposal = get_proposal($proposal_id);
}
require $CFG->comdir . 'prop_files_optional_params.php';
//check owner and status, dont delete acepted, scheduled or deleted¿?
// can delete canceled proposal
if (!empty($proposal) && ($proposal->id_status < 5 || ($proposal->id_status = 6))) {
    if (!empty($submit)) {
        if (empty($errmsg)) {
            //upload manager
            require_once $CFG->incdir . 'uploadlib.php';
            $um = new upload_manager('S_filename', false, true);
            $uploaddir = 'proposals/' . $proposal->id;
            if ($um->process_file_uploads($uploaddir)) {
                $f = new StdClass();
                $f->id_propuesta = $proposal->id;
                $f->name = $filename;
                $f->title = $title;
                $f->descr = $descr;
                $f->public = $public;
                $f->size = $um->get_filesize();
                $f->reg_time = time();
                //insert into db
                if ($rs = insert_record('prop_files', $f)) {
                    $errmsg[] = __('Archivo registrado exitosamente.');
                    //reset file
                    $file = new StdClass();
开发者ID:BackupTheBerlios,项目名称:yupana,代码行数:31,代码来源:prop_files.php

示例13: profile_photo_validate_input_field

function profile_photo_validate_input_field($parameter)
{
    global $CFG, $messages, $data, $profile_id;
    $found = false;
    foreach ($data['profile:details'] as $profileitem) {
        if (is_array($profileitem)) {
            $fname = $profileitem[1];
            $ftype = $profileitem[2];
        } else {
            $fname = $profileitem->internal_name;
            $ftype = $profileitem->field_type;
        }
        if ($fname == $parameter->name) {
            $found = true;
            break;
        }
    }
    if ($found && ($ftype = "profile_photo")) {
        require_once $CFG->dirroot . 'lib/uploadlib.php';
        require_once $CFG->dirroot . 'lib/filelib.php';
        $textlib = textlib_get_instance();
        $upload_folder = $textlib->substr(user_info("username", $profile_id), 0, 1);
        $um = new upload_manager('profile_photo_' . $fname, true, true, false, 5000000, true);
        $reldir = "profile_photos/" . $upload_folder . "/" . user_info("username", $profile_id) . "/" . $parameter->name . "/";
        $dir = $CFG->dataroot . $reldir;
        if ($um->process_file_uploads($dir)) {
            $parameter->value = $reldir . $um->get_new_filename();
            update_record('profile_data', $parameter);
        } else {
            $messages[] = $um->get_errors();
        }
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:34,代码来源:lib.php

示例14: optional_param

 $description = optional_param('icondescription');
 $icondefault = optional_param('icondefault');
 // if (!empty($description)) {
 $ok = true;
 if ($ok == true) {
     $numicons = count_records('icons', 'owner', $page_owner);
     if ($numicons >= $_SESSION['icon_quota']) {
         $ok = false;
         $messages[] = gettext("You have already met your icon quota. You must delete some icons before you can upload any new ones.");
     }
 }
 require_once $CFG->dirroot . 'lib/uploadlib.php';
 // TODO passing 0 as maxbytes here as icon_quota is based on number of icons
 // so upload_manager will look at PHP settings instead.
 // not ideal but as good as it can be for the now.
 $um = new upload_manager('iconfile', false, true, false, 0, true);
 $messages[] = gettext("Attempting to upload icon file ...");
 $ul_username = run("users:id_to_name", $page_owner);
 $upload_folder = $textlib->substr($ul_username, 0, 1);
 $dir = $CFG->dataroot . "icons/" . $upload_folder . "/" . $ul_username . "/";
 if ($ok = $um->process_file_uploads($dir)) {
     if (!($imageattr = @getimagesize($um->get_new_filepath()))) {
         $ok = false;
         $messages[] = gettext("The uploaded icon file was invalid. Please ensure you are using JPEG, GIF or PNG files.");
     }
 }
 if ($ok == true) {
     if ($imageattr[0] > 100 || $imageattr[1] > 100) {
         // $ok = false;
         // $messages[] = gettext("The uploaded icon file was too large. Files must have maximum dimensions of 100x100.");
         require_once $CFG->dirroot . 'lib/iconslib.php';
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:31,代码来源:function_actions.php

示例15: dialogue_add_attachment

/**
 * Saves an uploaded Dialogue attachment to the moddata directory
 *  
 * @param   object  $entry
 * @param   string  $inputname
 * @param   string  messages string, passed by reference
 * @return  string  new file name
 */
function dialogue_add_attachment($entry, $inputname, &$message)
{
    global $CFG, $COURSE;
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager($inputname, true, false, $COURSE, false, 0, true, true);
    $dir = dialogue_file_area_name($entry);
    if ($um->process_file_uploads($dir)) {
        $message .= $um->get_errors();
        return $um->get_new_filename();
    }
    $message .= $um->get_errors();
    return null;
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:21,代码来源:lib.php


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