コード例 #1
0
ファイル: icon.php プロジェクト: pzingg/saugus_elgg
// Icon script
// Run includes
require_once dirname(dirname(__FILE__)) . "/includes.php";
// Initialise functions for user details, icon management and profile management
run("userdetails:init");
run("profile:init");
run("files:init");
// If an ID number for the file has been specified ...
$id = optional_param('id', 0, PARAM_INT);
if (!empty($id)) {
    // ... and the file exists ...
    if ($file = get_record('files', 'ident', $id)) {
        if (run("users:access_level_check", $file->access) == true) {
            require_once $CFG->dirroot . 'lib/filelib.php';
            require_once $CFG->dirroot . 'lib/iconslib.php';
            // "Cache-Control: private" to allow a user's browser to cache the file, but not a shared proxy
            // Also to override PHP's default "DON'T EVER CACHE THIS EVER" header
            header("Cache-Control: private");
            // Then output some appropriate headers and send the file data!
            $mimetype = mimeinfo('type', $file->originalname);
            if ($mimetype == "image/jpeg" || $mimetype == "image/png") {
                // file is an image
                $phpthumbconfig['w'] = 90;
                spit_phpthumb_image($CFG->dataroot . $file->location, $phpthumbconfig);
            } else {
                // file is a file
                spitfile_with_mtime_check($CFG->dirroot . "_files/file.png", "image/png");
            }
        }
    }
}
コード例 #2
0
ファイル: img.php プロジェクト: BackupTheBerlios/tulipan-svn
    $phpthumb = true;
    $phpthumbconfig[$constraint2] = $size2;
}
// images most likely don't want compressing, and this will kill the Vary header
if (function_exists('apache_setenv')) {
    // apparently @ isn't enough to make php ignore this failing
    @apache_setenv('no-gzip', '1');
}
// user icons are public
header("Pragma: public");
header("Cache-Control: public");
if (!$default && !$phpthumb && ($constraint1 == 'h' || $constraint1 == 'w') && (!$constraint2 || $constraint2 == 'h' || $constraint2 == 'w')) {
    // 100 pixels requested, redirect to attributeless icon url for cacheability fun
    header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
    header("Location: " . $CFG->wwwroot . '_icon/user/' . $id);
    die;
}
if ($phpthumb) {
    // let phpthumb manipulate the image
    spit_phpthumb_image($filepath, $phpthumbconfig);
} elseif ($default) {
    // no manipulation and default icon
    if ($id == -1) {
        header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
    }
    header("Location: " . $CFG->wwwroot . '_icons/data/default.png');
    die;
} else {
    // output the image directly
    spitfile_with_mtime_check($filepath, $mimetype);
}
コード例 #3
0
ファイル: icon.php プロジェクト: BackupTheBerlios/tulipan-svn
            // images most likely don't want compressing, and this will kill the Vary header
            if (function_exists('apache_setenv')) {
                // apparently @ isn't enough to make php ignore this failing
                @apache_setenv('no-gzip', '1');
            }
            if ($file->access == 'PUBLIC') {
                header("Pragma: public");
                header("Cache-Control: public");
            } else {
                // "Cache-Control: private" to allow a user's browser to cache the file, but not a shared proxy
                // Also to override PHP's default "DON'T EVER CACHE THIS EVER" header
                header("Cache-Control: private");
            }
            $mimetype = mimeinfo('type', $file->originalname);
            if ($mimetype == "image/jpeg" || $mimetype == "image/png" || $mimetype == "image/gif") {
                // file is an image
                $phpthumbconfig = array();
                $phpthumbconfig['w'] = $w;
                $phpthumbconfig['h'] = $h;
                $filelocation = file_cache($file);
                spit_phpthumb_image($filelocation, $phpthumbconfig);
            } else {
                // file is a file
                header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently");
                //permanent because the user's file can't change and keep the same id
                header("Location: " . $CFG->wwwroot . 'mod/file/file.png');
                die;
            }
        }
    }
}