File indexing completed on 2025-05-04 05:29:31
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 0023 $file_out = $this->avatar; // The image to return 0024 $size = $this->size; 0025 $request = Zend_Controller_Front::getInstance()->getRequest(); 0026 $debugMe = 0; 0027 if(null != $request->getParam('debug')) { 0028 $debugMe = $request->getParam('debug', 0); 0029 0030 if($debugMe == 1) { 0031 print_r('ImgUrl1: ' . $file_out); 0032 } 0033 } 0034 0035 //$hash = md5("rvs75@email.de"); 0036 //var_dump($hash); 0037 //sdie; 0038 0039 $helperImage = new Default_View_Helper_Image(); 0040 0041 $imgUrl = $helperImage->Image($file_out,array('width' => $size, 'height' => $size)); 0042 0043 if($debugMe == 1) { 0044 print_r('ImgUrl2: ' . $imgUrl); 0045 } 0046 0047 0048 $sizeString = '/'.$size.'x'.$size.'-2/'; 0049 0050 if (!strpos($imgUrl, $sizeString)) { 0051 $imgUrl = str_replace('/200x200-2/', $sizeString, $imgUrl); 0052 } 0053 0054 if($debugMe == 1) { 0055 print_r('ImgUrl3: ' . $imgUrl); 0056 } 0057 0058 $ext = substr($imgUrl, -3); 0059 switch ($ext) { 0060 case 'jpg': 0061 $mime = 'image/jpeg'; 0062 break; 0063 case 'peg': 0064 $mime = 'image/jpeg'; 0065 break; 0066 case 'gif': 0067 $mime = 'image/gif'; 0068 break; 0069 case 'png': 0070 $mime = 'image/png'; 0071 break; 0072 default: 0073 $mime = 'image/png'; 0074 } 0075 0076 if($debugMe == 1) { 0077 print_r('Mime: ' . $mime); 0078 die; 0079 } 0080 0081 if ($mime) { 0082 header('Content-type: '.$mime); 0083 //header('Content-length: '.filesize($file_out)); 0084 0085 try { 0086 $file = file_get_contents($imgUrl); 0087 } catch (Exception $exc) { 0088 echo $exc->getTraceAsString(); 0089 } 0090 0091 echo $file; 0092 } 0093