From 137c63037704f85ebcba4ce4725750fd68a23c22 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 19 Jan 2012 18:28:17 +0100 Subject: [PATCH] Optimizations and more aggressive caching. --- apps/contacts/thumbnail.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index 507e1c7b302..f2b57014785 100644 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -22,22 +22,16 @@ // Init owncloud require_once('../../lib/base.php'); -OC_JSON::checkLoggedIn(); -//OC_Util::checkLoggedIn(); +//OC_JSON::checkLoggedIn(); +OC_Util::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); -if(!function_exists('imagecreatefromjpeg')) { - OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG); - header('Content-Type: image/png'); - // TODO: Check if it works to read the file and echo the content. - return 'img/person.png'; -} - function getStandardImage(){ $date = new DateTime('now'); $date->add(new DateInterval('P10D')); header('Expires: '.$date->format(DateTime::RFC850)); header('Cache-Control: cache'); + header('Pragma: cache'); header('Location: '.OC_Helper::imagePath('contacts', 'person.png')); exit(); // $src_img = imagecreatefrompng('img/person.png'); @@ -46,6 +40,11 @@ function getStandardImage(){ // imagedestroy($src_img); } +if(!function_exists('imagecreatefromjpeg')) { + OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG); + getStandardImage(); + exit(); +} $id = $_GET['id']; @@ -76,18 +75,14 @@ if( is_null($content)){ $thumbnail_size = 23; -// Finf the photo from VCard. +// Find the photo from VCard. foreach($content->children as $child){ if($child->name == 'PHOTO'){ - foreach($child->parameters as $parameter){ - if( $parameter->name == 'TYPE' ){ - $mime = $parameter->value; - } - } $image = new OC_Image(); if($image->loadFromBase64($child->value)) { if($image->centerCrop()) { if($image->resize($thumbnail_size)) { + header('ETag: '.md5($child->value)); if(!$image()) { OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR); getStandardImage(); -- 2.39.5