本文整理汇总了PHP中send_file_not_found函数的典型用法代码示例。如果您正苦于以下问题:PHP send_file_not_found函数的具体用法?PHP send_file_not_found怎么用?PHP send_file_not_found使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_file_not_found函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: block_html_pluginfile
/**
* Form for editing HTML block instances.
*
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package block_html
* @category files
* @param stdClass $course course object
* @param stdClass $birecord_or_cm block instance record
* @param stdClass $context context object
* @param string $filearea file area
* @param array $args extra arguments
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
* @return bool
*/
function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
global $SCRIPT;
if ($context->contextlevel != CONTEXT_BLOCK) {
send_file_not_found();
}
require_course_login($course);
if ($filearea !== 'content') {
send_file_not_found();
}
$fs = get_file_storage();
$filename = array_pop($args);
$filepath = $args ? '/' . implode('/', $args) . '/' : '/';
if (!($file = $fs->get_file($context->id, 'block_html', 'content', 0, $filepath, $filename)) or $file->is_directory()) {
send_file_not_found();
}
if ($parentcontext = get_context_instance_by_id($birecord_or_cm->parentcontextid)) {
if ($parentcontext->contextlevel == CONTEXT_USER) {
// force download on all personal pages including /my/
//because we do not have reliable way to find out from where this is used
$forcedownload = true;
}
} else {
// weird, there should be parent context, better force dowload then
$forcedownload = true;
}
session_get_instance()->write_close();
send_stored_file($file, 60 * 60, 0, $forcedownload, $options);
}
示例2: block_jmail_pluginfile
/**
* Serves the message attachments. Implements needed access control ;-)
*
* @param object $course
* @param object $cm
* @param object $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @return bool false if file not found, does not return if found - justsend the file
*/
function block_jmail_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload)
{
global $SCRIPT;
if ($context->contextlevel != CONTEXT_BLOCK) {
//send_file_not_found();
}
require_course_login($course);
$coursecontext = block_jmail_get_context(CONTEXT_COURSE, $course->id, MUST_EXIST);
// The mailbox constructor does the permission validation
if (!($mailbox = new block_jmail_mailbox($course, $coursecontext, $context))) {
return;
}
$messageid = (int) array_shift($args);
$message = block_jmail_message::get_from_id($messageid);
// We check if we are the senders or the receivers
if (!$message) {
send_file_not_found();
}
$pendingaprobal = !$message->approved and has_capability('block/jmail:approvemessages', $context);
if (!$message->is_mine() and !$pendingaprobal) {
send_file_not_found();
}
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$context->id}/block_jmail/{$filearea}/{$messageid}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
send_file_not_found();
}
$forcedownload = true;
send_stored_file($file, 60 * 60, 0, $forcedownload);
}
示例3: workshopform_numerrors_pluginfile
function workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
global $DB;
if ($context->contextlevel != CONTEXT_MODULE) {
return false;
}
require_login($course, true, $cm);
if ($filearea !== 'description') {
return false;
}
$itemid = (int)array_shift($args); // the id of the assessment form dimension
if (!$workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
send_file_not_found();
}
if (!$dimension = $DB->get_record('workshopform_numerrors', array('id' => $itemid ,'workshopid' => $workshop->id))) {
send_file_not_found();
}
// TODO now make sure the user is allowed to see the file
// (media embedded into the dimension description)
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/$context->id/workshopform_numerrors/$filearea/$itemid/$relativepath";
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
return false;
}
// finally send the file
send_stored_file($file);
}
示例4: teamworkform_rubric_pluginfile
/**
* Server teamwork files
*
* @category files
* @param stdClass $course course object
* @param stdClass $cm course module object
* @param stdClass $context context object
* @param string $filearea file area
* @param array $args extra arguments
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
* @return bool
*/
function teamworkform_rubric_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options = array())
{
global $DB;
if ($context->contextlevel != CONTEXT_MODULE) {
return false;
}
require_login($course, true, $cm);
if ($filearea !== 'description') {
return false;
}
$itemid = (int) array_shift($args);
// the id of the assessment form dimension
if (!($teamwork = $DB->get_record('teamwork', array('id' => $cm->instance)))) {
send_file_not_found();
}
if (!($dimension = $DB->get_record('teamworkform_rubric', array('id' => $itemid, 'teamworkid' => $teamwork->id)))) {
send_file_not_found();
}
// TODO now make sure the user is allowed to see the file
// (media embedded into the dimension description)
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$context->id}/teamworkform_rubric/{$filearea}/{$itemid}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
return false;
}
// finally send the file
send_stored_file($file, 0, 0, $forcedownload, $options);
}
示例5: theme_clean_pluginfile
function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') {
$theme = theme_config::load('clean');
return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
} else {
send_file_not_found();
}
}
示例6: block_informationspot_pluginfile
/**
* Form for editing Information Spot block instances.
*
* @copyright 2014 Roberto Pinna
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package block_informationspot
* @category files
* @param stdClass $course course object
* @param stdClass $birecord_or_cm block instance record
* @param stdClass $context context object
* @param string $filearea file area
* @param array $args extra arguments
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
* @return bool
*/
function block_informationspot_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
global $DB, $CFG, $USER;
if ($context->contextlevel != CONTEXT_BLOCK) {
send_file_not_found();
}
// If block is in course context, then check if user has capability to access course.
if ($context->get_course_context(false)) {
require_course_login($course);
} else {
if ($CFG->forcelogin) {
require_login();
} else {
// Get parent context and see if user have proper permission.
$parentcontext = $context->get_parent_context();
if ($parentcontext->contextlevel === CONTEXT_COURSECAT) {
// Check if category is visible and user can view this category.
$category = $DB->get_record('course_categories', array('id' => $parentcontext->instanceid), '*', MUST_EXIST);
if (!$category->visible) {
require_capability('moodle/category:viewhiddencategories', $parentcontext);
}
} else {
if ($parentcontext->contextlevel === CONTEXT_USER && $parentcontext->instanceid != $USER->id) {
// The block is in the context of a user, it is only visible to the user who it belongs to.
send_file_not_found();
}
}
// At this point there is no way to check SYSTEM context, so ignoring it.
}
}
if ($filearea != 'image') {
send_file_not_found();
}
$fs = get_file_storage();
$imageid = array_shift($args);
$filename = array_pop($args);
$filepath = $args ? '/' . implode('/', $args) . '/' : '/';
if (!($file = $fs->get_file($context->id, 'block_informationspot', $filearea, $imageid, $filepath, $filename)) or $file->is_directory()) {
send_file_not_found();
}
if ($parentcontext = context::instance_by_id($birecord_or_cm->parentcontextid, IGNORE_MISSING)) {
if ($parentcontext->contextlevel == CONTEXT_USER) {
// force download on all personal pages including /my/
//because we do not have reliable way to find out from where this is used
$forcedownload = true;
}
} else {
// weird, there should be parent context, better force dowload then
$forcedownload = true;
}
// NOTE: it woudl be nice to have file revisions here, for now rely on standard file lifetime,
// do not lower it because the files are dispalyed very often.
\core\session\manager::write_close();
send_stored_file($file, null, 0, $forcedownload, $options);
}
示例7: local_email_pluginfile
function local_email_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
$fs = get_file_storage();
$relativepath = implode('/', $args);
$filename = $args[1];
$itemid = $args[0];
if (!($file = $fs->get_file($context->id, 'local_email', $filearea, $itemid, '/', $filename)) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0);
}
示例8: block_nurs_navigation_pluginfile
/**
* This is method serves up files to the user. The files used in this course are just images,
* but they are sent largely the same way.
*
*/
function block_nurs_navigation_pluginfile($course, $birecord, $context, $filearea, $args, $forcedownload)
{
require_once 'lib/filelib.php';
$fs = get_file_storage();
$entryid = clean_param(array_shift($args), PARAM_INT);
$file = array_shift($args);
if (!($file = $fs->get_file($context->id, 'block_nurs_navigation', $filearea, $entryid, '/', $file))) {
send_file_not_found();
return;
}
send_stored_file($file, 10 * 60, 0, true);
}
示例9: question_preview_question_pluginfile_joomdle
function question_preview_question_pluginfile_joomdle($course, $context, $component, $filearea, $qubaid, $slot, $filename, $forcedownload)
{
global $USER, $DB, $CFG;
$query = "SELECT *\n FROM {$CFG->prefix}files\n WHERE component = 'question'\n AND filearea = ?\n AND itemid = ?\n AND filename = ?\n ORDER by id\n LIMIT 1";
$params = array($filearea, $qubaid, $filename);
$record = $DB->get_record_sql($query, $params);
$fs = get_file_storage();
if (!($file = $fs->get_file_by_hash($record->pathnamehash))) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload);
}
示例10: qformat_xhtml_question_preview_pluginfile
/**
* Serve question files when they are displayed in this export format.
*
* @param context $previewcontext the quiz context
* @param int $questionid the question id.
* @param context $filecontext the file (question) context
* @param string $filecomponent the component the file belongs to.
* @param string $filearea the file area.
* @param array $args remaining file args.
* @param bool $forcedownload.
* @param array $options additional options affecting the file serving.
*/
function qformat_xhtml_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
global $CFG;
list($context, $course, $cm) = get_context_info_array($previewcontext->id);
require_login($course, false, $cm);
question_require_capability_on($questionid, 'view');
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $options);
}
示例11: theme_bootstrap_pluginfile
/**
* Serves any files associated with the theme settings.
*
* @param stdClass $course
* @param stdClass $cm
* @param context $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @param array $options
* @return bool
*/
function theme_bootstrap_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
$fs = get_file_storage();
$relativepath = implode('/', $args);
$filename = $args[1];
$itemid = $args[0];
if ($filearea == 'logo') {
$itemid = 0;
}
if (!($file = $fs->get_file($context->id, 'theme_bootstrap', $filearea, $itemid, '/', $filename)) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload);
}
示例12: block_course_message_pluginfile
function block_course_message_pluginfile($course, $birecord, $context, $filearea, $args, $forcedownload)
{
require_once 'lib/filelib.php';
$fs = get_file_storage();
$context = context_course::instance($course->id);
$entryid = clean_param(array_shift($args), PARAM_INT);
$file = array_shift($args);
if (!($file = $fs->get_file($context->id, 'block_course_message', $filearea, $entryid, '/', $file))) {
send_file_not_found();
return;
}
// Fourth parameter forces the user to download the file.
send_stored_file($file, BLOCK_CM_LIFETIME, 0, $forcedownload);
}
示例13: tool_generator_pluginfile
/**
* Files support.
*
* Exits if the required permissions are not satisfied.
*
* @param stdClass $course course object
* @param stdClass $cm
* @param stdClass $context context object
* @param string $filearea file area
* @param array $args extra arguments
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
* @return void The file is sent along with it's headers
*/
function tool_generator_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
// Only for admins or CLI.
if (!defined('CLI_SCRIPT') && !is_siteadmin()) {
die;
}
if ($context->contextlevel != CONTEXT_SYSTEM) {
send_file_not_found();
}
$fs = get_file_storage();
$file = $fs->get_file($context->id, 'tool_generator', $filearea, $args[0], '/', $args[1]);
// Send the file, always forcing download, we don't want options.
session_get_instance()->write_close();
send_stored_file($file, 0, 0, true);
}
示例14: block_html_pluginfile
/**
* Form for editing HTML block instances.
*
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package block_html
* @category files
* @param stdClass $course course object
* @param stdClass $birecord_or_cm block instance record
* @param stdClass $context context object
* @param string $filearea file area
* @param array $args extra arguments
* @param bool $forcedownload whether or not force download
* @param array $options additional options affecting the file serving
* @return bool
* @todo MDL-36050 improve capability check on stick blocks, so we can check user capability before sending images.
*/
function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
global $DB, $CFG;
if ($context->contextlevel != CONTEXT_BLOCK) {
send_file_not_found();
}
// If block is in course context, then check if user has capability to access course.
if ($context->get_course_context(false)) {
require_course_login($course);
} else {
if ($CFG->forcelogin) {
require_login();
} else {
// Get parent context and see if user have proper permission.
$parentcontext = $context->get_parent_context();
if ($parentcontext->contextlevel === CONTEXT_COURSECAT) {
// Check if category is visible and user can view this category.
$category = $DB->get_record('course_categories', array('id' => $parentcontext->instanceid), '*', MUST_EXIST);
if (!$category->visible) {
require_capability('moodle/category:viewhiddencategories', $parentcontext);
}
}
// At this point there is no way to check SYSTEM or USER context, so ignoring it.
}
}
if ($filearea !== 'content') {
send_file_not_found();
}
$fs = get_file_storage();
$filename = array_pop($args);
$filepath = $args ? '/' . implode('/', $args) . '/' : '/';
if (!($file = $fs->get_file($context->id, 'block_html', 'content', 0, $filepath, $filename)) or $file->is_directory()) {
send_file_not_found();
}
if ($parentcontext = get_context_instance_by_id($birecord_or_cm->parentcontextid)) {
if ($parentcontext->contextlevel == CONTEXT_USER) {
// force download on all personal pages including /my/
//because we do not have reliable way to find out from where this is used
$forcedownload = true;
}
} else {
// weird, there should be parent context, better force dowload then
$forcedownload = true;
}
session_get_instance()->write_close();
send_stored_file($file, 60 * 60, 0, $forcedownload, $options);
}
示例15: quiz_statistics_question_preview_pluginfile
/**
* Serve questiontext files in the question text when they are displayed in this report.
*
* @package quiz_statistics
* @category files
* @param context $previewcontext the quiz context
* @param int $questionid the question id.
* @param context $filecontext the file (question) context
* @param string $filecomponent the component the file belongs to.
* @param string $filearea the file area.
* @param array $args remaining file args.
* @param bool $forcedownload.
* @param array $options additional options affecting the file serving.
*/
function quiz_statistics_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
global $CFG;
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
list($context, $course, $cm) = get_context_info_array($previewcontext->id);
require_login($course, false, $cm);
// Assume only trusted people can see this report. There is no real way to
// validate questionid, becuase of the complexity of random quetsions.
require_capability('quiz/statistics:view', $context);
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $options);
}