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

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',
0025     extension_loaded('apc') && ini_get('apc.enabled') && (PHP_SAPI !== 'cli' || ini_get('apc.enable_cli')));
0026 
0027 // Define if APC extension is loaded
0028 define('MEMCACHED_EXTENSION_LOADED', extension_loaded('memcached'));
0029 
0030 // Define if APC extension is loaded
0031 define('MEMCACHE_EXTENSION_LOADED', extension_loaded('memcache'));
0032 
0033 // Define path to application directory
0034 defined('APPLICATION_PATH')
0035 || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
0036 
0037 defined('APPLICATION_DATA')
0038 || define('APPLICATION_DATA', realpath(dirname(__FILE__) . '/../data'));
0039 
0040 // Define path to application cache
0041 defined('APPLICATION_CACHE')
0042 || define('APPLICATION_CACHE', realpath(dirname(__FILE__) . '/../data/cache'));
0043 
0044 // Define path to application library
0045 defined('APPLICATION_LIB')
0046 || define('APPLICATION_LIB', realpath(dirname(__FILE__) . '/../library'));
0047 
0048 defined('APPLICATION_ENV')
0049 || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
0050 
0051 require APPLICATION_LIB . '/Local/CrawlerDetect.php';
0052 if (crawlerDetect($_SERVER['HTTP_USER_AGENT'])) {
0053     define('SEARCHBOT_DETECTED', true);
0054 } else {
0055     define('SEARCHBOT_DETECTED', false);
0056 }
0057 
0058 // Ensure library/ is on include_path
0059 set_include_path(implode(PATH_SEPARATOR, array(
0060     APPLICATION_LIB,
0061     get_include_path(),
0062 )));
0063 
0064 // Initialising Autoloader
0065 require APPLICATION_LIB . '/Zend/Loader/SplAutoloader.php';
0066 require APPLICATION_LIB . '/Zend/Loader/StandardAutoloader.php';
0067 require APPLICATION_LIB . '/Zend/Loader/AutoloaderFactory.php';
0068 Zend_Loader_AutoloaderFactory::factory(array(
0069     'Zend_Loader_StandardAutoloader' => array(
0070         'autoregister_zf' => true,
0071         'namespaces'      => array(
0072             'Application' => APPLICATION_PATH,
0073         )
0074     )
0075 ));
0076 
0077 // Including plugin cache file
0078 if (file_exists(APPLICATION_CACHE . DIRECTORY_SEPARATOR . 'pluginLoaderCache.php')) {
0079     include_once APPLICATION_CACHE . DIRECTORY_SEPARATOR . 'pluginLoaderCache.php';
0080 }
0081 Zend_Loader_PluginLoader::setIncludeFileCache(APPLICATION_CACHE . DIRECTORY_SEPARATOR . 'pluginLoaderCache.php');
0082 
0083 // Set configuration
0084 $configuration = APPLICATION_PATH . '/configs/application.ini';
0085 // Merge an existing local configuration file (application.local.ini) with global config
0086 if (file_exists(APPLICATION_PATH . '/configs/application.local.ini')) {
0087     $configuration = array(
0088         'config' => array(
0089             APPLICATION_PATH . '/configs/application.ini',
0090             APPLICATION_PATH . '/configs/application.local.ini'
0091         )
0092     );
0093 }
0094 
0095 // Init and start Zend_Application
0096 require_once APPLICATION_LIB . '/Local/Application.php';
0097 // Create application, bootstrap, and run
0098 $application = new Local_Application(APPLICATION_ENV, $configuration);
0099 $application->bootstrap()->run();