// $Id: image.php,v 1.5 2006/10/17 10:24:47 janne Exp $
/// This file is used to output image from imagegallery
/// Data base it only takes one argument which is
/// images id.
require_once '../../config.php';
define('IMAGEGALLERY_ERROR_IMAGE', "{$CFG->dirroot}/mod/imagegallery/pix/error.png");
$id = optional_param('id', 0, PARAM_INT);
//required_param('id', PARAM_INT);
$thumb = optional_param('thumb', false, PARAM_BOOL);
if (empty($id)) {
    //header("HTTP/1.0 404 not found");
    //error(get_string("filenotfound", "error"), "$CFG->wwwroot/course/view.php?id=$courseid");
    display_error_image("Image not found!!!");
    exit;
}
$image = __get_one_image_($id, $thumb);
if (!empty($image->requirelogin)) {
    $cm = get_coursemodule_from_instance("imagegallery", $image->galleryid, $image->course);
    $course = new stdClass();
    $course->id = $image->course;
    // strange bug, $course is not good enought for require_course_login()
    // so i "had" to use $COURSE
    require_course_login($COURSE, $CFG->autologinguests, $cm);
}
if (empty($image)) {
    // Create an error image.
    display_error_image();
    exit;
}
// output image
$filesize = filesize($image->path);
<?php

// $Id: image.php,v 1.1 2006/02/01 23:37:43 janne Exp $
/// This file is used to output image from netpublish
/// Data base it only takes one argument which is
/// images id.
require_once '../../config.php';
$id = required_param('id', PARAM_INT);
if (empty($id)) {
    header("HTTP/1.0 404 not found");
    error(get_string("filenotfound", "error"), "{$CFG->wwwroot}/course/view.php?id={$courseid}");
    exit;
}
$image = __get_one_image_($id);
if (empty($image)) {
    header("HTTP/1.0 404 not found");
    error(get_string("filenotfound", "error"), "{$CFG->wwwroot}/course/view.php?id={$courseid}");
}
// output image
$imagesource = $CFG->dataroot . '/' . $image->path;
$filesize = filesize($imagesource);
$filetime = filemtime($imagesource);
$date = gmdate("D, d M Y H:i:s", $filetime) . ' GMT';
$lastmodified = gmdate("D, d M Y H:i:s", $filetime) . ' GMT';
header("Content-Type: {$image->mimetype}\r\n");
header("Content-Length:  {$filesize}\r\n");
header("Date: {$date}\r\n");
header("Last-Modified: {$lastmodified}\r\n");
header("Content-Disposition: inline; filename=\"{$image->name}\"\r\n");
header("Connection: close\r\n");
readfile($imagesource);