* @package    mahara
 * @subpackage artefact-file
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('PUBLIC', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'file');
require_once 'file.php';
$fileid = param_integer('file');
$viewid = param_integer('view', null);
$postid = param_integer('post', null);
$size = get_imagesize_parameters();
$forcedl = param_boolean('download');
$options = array();
if ($forcedl) {
    $options['forcedownload'] = true;
} else {
    $options['downloadurl'] = get_config('wwwroot') . substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], 'artefact/file/download.php')) . '&download=1';
}
if ($viewid && $fileid) {
    $file = artefact_instance_from_id($fileid);
    $ancestors = $file->get_item_ancestors();
    $artefactok = false;
    if (artefact_in_view($file, $viewid)) {
        $artefactok = true;
    }
    // Check to see if the artefact has a parent that is allowed to be in this view.
Example #2
0
         // Move the file into the correct place.
         $directory = get_config('dataroot') . 'artefact/file/profileicons/no_userphoto/' . $THEME->basename . '/originals/0/';
         check_dir_exists($directory);
         copy($nouserphotopic, $directory . '0');
         // Now we can try and get the image in the correct size
         if ($path = get_dataroot_image_path('artefact/file/profileicons/no_userphoto/' . $THEME->basename, 0, $size)) {
             header('Content-type: ' . 'image/png');
             readfile_exit($path);
         }
     }
     // Emergency fallback
     header('Content-type: ' . 'image/png');
     readfile_exit($THEME->get_path('images/no_userphoto.png'));
 case 'logobyid':
     $filedata = get_record('artefact_file_files', 'artefact', param_integer('id'));
     if ($path = get_dataroot_image_path('artefact/file/profileicons', $filedata->fileid, get_imagesize_parameters())) {
         if ($filedata->filetype) {
             header('Content-type: ' . $filedata->filetype);
             if (!get_config('nocache')) {
                 $maxage = 604800;
                 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $maxage) . ' GMT');
                 header('Cache-Control: max-age=' . $maxage);
                 header('Pragma: public');
             }
             readfile_exit($path);
         }
     }
     // Nothing found, use the site logo.
     header('Content-type: ' . 'image/png');
     readfile_exit($THEME->get_path('images/site-logo.png'));
 case 'blocktype':