]> source.dussan.org Git - nextcloud-server.git/commitdiff
Optimizations and more aggressive caching.
authorThomas Tanghus <thomas@tanghus.net>
Thu, 19 Jan 2012 17:28:17 +0000 (18:28 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Thu, 19 Jan 2012 17:28:17 +0000 (18:28 +0100)
apps/contacts/thumbnail.php

index 507e1c7b302e8eaa54f6d33c1516bf4b1c67f804..f2b5701478576e51ffef47ef2619ee3bf36f250c 100644 (file)
 
 // 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();