File indexing completed on 2024-12-08 05:17:48
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 header("HTTP/1.1 503 Service Unavailable"); 0024 exit(1); 0025 0026 date_default_timezone_set("Europe/Berlin"); 0027 setlocale(LC_ALL, 'de_DE@euro'); 0028 // Define path to application directory 0029 defined('APPLICATION_PATH') 0030 || define('APPLICATION_PATH', realpath(dirname(__FILE__))); 0031 0032 0033 // Define application environment 0034 defined('APPLICATION_ENV') 0035 || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); 0036 0037 defined('IMAGES_UPLOAD_PATH') 0038 || define('IMAGES_UPLOAD_PATH', APPLICATION_PATH . '/img/'); 0039 0040 0041 // Ensure library/ is on include_path 0042 set_include_path(implode("/", array( 0043 APPLICATION_PATH . '/../library', 0044 get_include_path(), 0045 ))); 0046 0047 0048 require_once 'Zend/Loader/Autoloader.php'; 0049 0050 $loader = Zend_Loader_Autoloader::getInstance(); 0051 $loader->setFallbackAutoloader(true); 0052 0053 $upload = new Zend_File_Transfer_Adapter_Http(); 0054 $upload->addValidator('Count', false, 1); 0055 $upload->addValidator('IsImage', false); 0056 $upload->addValidator('Size', false, array('min' => '2kB', 'max' => '2MB')); 0057 $upload->addValidator('ImageSize', false, 0058 array( 0059 'minwidth' => 50, 0060 'maxwidth' => 2000, 0061 'minheight' => 50, 0062 'maxheight' => 2000 0063 ) 0064 ); 0065 //$upload->addFilter('Rename',array('target' => IMAGES_UPLOAD_PATH,'overwrite' => true)); 0066 //$upload->addFilter('Rename',IMAGES_UPLOAD_PATH); 0067 0068 if (true == $upload->receive()) { 0069 0070 $file_source = $upload->getFileName(); 0071 $file_destination = IMAGES_UPLOAD_PATH . basename($upload->getFileName()); 0072 0073 if (rename($file_source, $file_destination)) { 0074 header("HTTP/1.0 200 OK"); 0075 print basename($upload->getFileName()); 0076 exit(0); 0077 } 0078 0079 } 0080 header("HTTP/1.0 500 Server Error"); 0081 print implode("\n<br>", $upload->getMessages());