File indexing completed on 2024-04-14 05:53:08

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 // Define if APC extension is loaded
0024 define('APC_EXTENSION_LOADED', extension_loaded('apc') && ini_get('apc.enabled') && (PHP_SAPI !== 'cli' || ini_get('apc.enable_cli')));
0025 
0026 // Define if APC extension is loaded
0027 define('MEMCACHED_EXTENSION_LOADED', extension_loaded('memcached') );
0028 
0029 // Define path to application directory
0030 defined('APPLICATION_PATH')
0031 || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
0032 
0033 // Define path to application library
0034 defined('APPLICATION_LIB')
0035 || define('APPLICATION_LIB', realpath(dirname(__FILE__) . '/../library'));
0036 
0037 // Define application environment
0038 define('APPLICATION_ENV', 'testing');
0039 
0040 defined('TEST_PATH')
0041 || define('TEST_PATH', realpath(dirname(__FILE__) . '/../tests'));
0042 
0043 defined('APPLICATION_DATA')
0044 || define('APPLICATION_DATA', realpath(dirname(__FILE__) . '/../data'));
0045 
0046 // Ensure library/ is on include_path
0047 set_include_path(implode(PATH_SEPARATOR, array(
0048     '.',
0049     APPLICATION_LIB,
0050     get_include_path(),
0051 )));
0052 
0053 
0054 require_once 'Zend/Loader/Autoloader.php';
0055 require_once 'Zend/Loader/Autoloader/Interface.php';
0056 require_once 'Zend/Loader/Autoloader/Resource.php';
0057 require_once 'Zend/Application/Module/Autoloader.php';
0058 $backendAutoloader = new Zend_Application_Module_Autoloader(array(
0059     'namespace' => 'Backend',
0060     'basePath' => APPLICATION_PATH . '/modules/backend',
0061 ));
0062 $backendAutoloader
0063     ->addResourceType('element', 'forms/elements', 'Form_Element')
0064     ->addResourceType('other', 'forms/other', 'Form_Other')
0065     ->addResourceType('commands', 'library/backend/commands', 'Commands')
0066 ;
0067 
0068 $autoloader = Zend_Loader_Autoloader::getInstance();
0069 $autoloader->setAutoloaders(array(
0070     new Zend_Application_Module_Autoloader(array(
0071         'namespace' => 'Default',
0072         'basePath' => APPLICATION_PATH . '/modules/default',
0073     )),
0074     new Zend_Application_Module_Autoloader(array(
0075         'namespace' => 'Backend',
0076         'basePath' => APPLICATION_PATH . '/modules/backend',
0077     ))
0078 ));
0079 
0080 $frontendOptions = array(
0081     'automatic_serialization' => true
0082 );
0083 // Settings for some development environments. If there is no APC installed.
0084 if (APC_EXTENSION_LOADED) {
0085 
0086     $backendOptions = array();
0087 
0088     $cache = Zend_Cache::factory(
0089         'Core',
0090         'Apc',
0091         $frontendOptions,
0092         $backendOptions
0093     );
0094 
0095 } else {
0096     $cacheDir = realpath(APPLICATION_PATH . '/../data/cache/tests');
0097 
0098 //    if (!is_dir($cacheDir)) mkdir($cacheDir, 0755);
0099 //    if (file_exists($cacheDir . '/pluginLoaderCache.php')) unlink($cacheDir . '/pluginLoaderCache.php');
0100 
0101     $backendOptions = array(
0102         'cache_dir' => $cacheDir
0103     );
0104 
0105     $cache = Zend_Cache::factory(
0106         'Core',
0107         'File',
0108         $frontendOptions,
0109         $backendOptions
0110     );
0111 
0112 }
0113 
0114 Zend_Registry::set('cache', $cache);
0115 
0116 
0117 if (file_exists(APPLICATION_PATH . '/configs/application.local.ini')) {
0118     $configuration = array('config' => array(APPLICATION_PATH . '/configs/application.ini',
0119         APPLICATION_PATH . '/configs/application.local.ini'));
0120 } else {
0121     $configuration = APPLICATION_PATH . '/configs/application.ini';
0122 }
0123 
0124 Zend_Registry::set('configuration', $configuration);