Exemple #1
0
<?php

/**
 * Elgg file thumbnail
 *
 * @package ElggFile
 */
// Get engine
require_once dirname(dirname(__DIR__)) . '/autoloader.php';
$application = new Elgg\Application();
$application->bootCore();
// Get file GUID
$file_guid = (int) get_input('file_guid', 0);
// Get file thumbnail size
$size = get_input('size', 'small');
$file = get_entity($file_guid);
if (!elgg_instanceof($file, 'object', 'file')) {
    exit;
}
$simpletype = $file->simpletype;
if ($simpletype == "image") {
    // Get file thumbnail
    switch ($size) {
        case "small":
            $thumbfile = $file->thumbnail;
            break;
        case "medium":
            $thumbfile = $file->smallthumb;
            break;
        case "large":
        default:
Exemple #2
0
    try {
        $row = $db->getDataRow("\n\t\t\tSELECT `value`\n\t\t\tFROM {$db->getTablePrefix()}datalists\n\t\t\tWHERE `name` = 'dataroot'\n\t\t");
        if (!$row) {
            return "";
        }
    } catch (\DatabaseException $e) {
        // we're going to let the engine figure out what's happening...
        return '';
    }
    return rtrim($row->value, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
});
if ($data_root) {
    $locator = new \Elgg\EntityDirLocator($guid);
    $user_path = $data_root . $locator->getPath();
    $filename = $user_path . "profile/{$guid}{$size}.jpg";
    $filesize = @filesize($filename);
    if ($filesize) {
        header("Content-type: image/jpeg");
        header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")), true);
        header("Pragma: public");
        header("Cache-Control: public");
        header("Content-Length: {$filesize}");
        header("ETag: \"{$etag}\"");
        readfile($filename);
        exit;
    }
}
// something went wrong so load engine and try to forward to default icon
$app->bootCore();
elgg_log("Profile icon direct failed.", "WARNING");
forward("_graphics/icons/user/default{$size}.gif");