diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-07-25 02:01:36 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-07-25 02:01:36 +0000 |
commit | 73403645808a81425381f43c25e0ea2c92705312 (patch) | |
tree | 83fb73e9a122054f6f4c2e1c44e399572ee13e28 /pages/thumbnail.php | |
parent | 791ec4925346cb38ecca9a2f2574b012ab64a88a (diff) | |
download | elgg-73403645808a81425381f43c25e0ea2c92705312.tar.gz elgg-73403645808a81425381f43c25e0ea2c92705312.tar.bz2 |
first go at brining tidypics up to code standards
Diffstat (limited to 'pages/thumbnail.php')
-rw-r--r-- | pages/thumbnail.php | 146 |
1 files changed, 74 insertions, 72 deletions
diff --git a/pages/thumbnail.php b/pages/thumbnail.php index 3aad5969d..9daa2f9c0 100644 --- a/pages/thumbnail.php +++ b/pages/thumbnail.php @@ -1,76 +1,78 @@ <?php - /** - * Tidypics Thumbnail - * - */ - - // Get file GUID - $file_guid = (int) get_input('file_guid'); - - // Get file thumbnail size - $size = get_input('size'); - // only 3 possibilities - if ($size != 'small' && $size != 'thumb') { - $size = 'large'; - } - - $error_image = ''; - switch ($size) { - case 'thumb': - $error_image = "image_error_thumb.png"; - break; - case 'small': - $error_image = "image_error_small.png"; - break; - case 'large': - $error_image = "image_error_large.png"; - break; - } - - // Get file entity - $file = get_entity($file_guid); - if (!$file) - forward('mod/tidypics/graphics/' . $error_image); - - if ($file->getSubtype() != "image") - forward('mod/tidypics/graphics/' . $error_image); - - // Get filename - if ($size == "thumb") { - $thumbfile = $file->thumbnail; - } else if ($size == "small") { - $thumbfile = $file->smallthumb; - } else { - $thumbfile = $file->largethumb; - } - - if (!$thumbfile) - forward('mod/tidypics/graphics/' . $error_image); - - // create Elgg File object - $readfile = new ElggFile(); - $readfile->owner_guid = $file->owner_guid; - $readfile->setFilename($thumbfile); - $contents = $readfile->grabFile(); +/** + * Tidypics Thumbnail + * + */ - // send error image if file could not be read - if (!$contents) { - forward('mod/tidypics/graphics/' . $error_image); - } - - // expires every 14 days - $expires = 14 * 60*60*24; +// Get file GUID +$file_guid = (int) get_input('file_guid'); - // overwrite header caused by php session code so images can be cached - $mime = $file->getMimeType(); - header("Content-Type: $mime"); - header("Content-Length: " . strlen($contents)); - header("Cache-Control: public", true); - header("Pragma: public", true); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); - - // Return the thumbnail and exit - echo $contents; - exit; -
\ No newline at end of file +// Get file thumbnail size +$size = get_input('size'); +// only 3 possibilities +if ($size != 'small' && $size != 'thumb') { + $size = 'large'; +} + +$error_image = ''; +switch ($size) { + case 'thumb': + $error_image = "image_error_thumb.png"; + break; + case 'small': + $error_image = "image_error_small.png"; + break; + case 'large': + $error_image = "image_error_large.png"; + break; +} + +// Get file entity +$file = get_entity($file_guid); +if (!$file) { + forward('mod/tidypics/graphics/' . $error_image); +} + +if ($file->getSubtype() != "image") { + forward('mod/tidypics/graphics/' . $error_image); +} + +// Get filename +if ($size == "thumb") { + $thumbfile = $file->thumbnail; +} else if ($size == "small") { + $thumbfile = $file->smallthumb; +} else { + $thumbfile = $file->largethumb; +} + +if (!$thumbfile) { + forward('mod/tidypics/graphics/' . $error_image); +} + +// create Elgg File object +$readfile = new ElggFile(); +$readfile->owner_guid = $file->owner_guid; +$readfile->setFilename($thumbfile); +$contents = $readfile->grabFile(); + +// send error image if file could not be read +if (!$contents) { + forward('mod/tidypics/graphics/' . $error_image); +} + +// expires every 14 days +$expires = 14 * 60*60*24; + +// overwrite header caused by php session code so images can be cached +$mime = $file->getMimeType(); +header("Content-Type: $mime"); +header("Content-Length: " . strlen($contents)); +header("Cache-Control: public", true); +header("Pragma: public", true); +header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); + +// Return the thumbnail and exit +echo $contents; +exit; |