File indexing completed on 2024-12-22 05:33:57

0001 <?php
0002 
0003 /**
0004  *  ocs-webserver
0005  *
0006  *  Copyright 2016 by pling GmbH.
0007  *
0008  *    This file is part of ocs-webserver.
0009  *
0010  *    This program is free software: you can redistribute it and/or modify
0011  *    it under the terms of the GNU Affero General Public License as
0012  *    published by the Free Software Foundation, either version 3 of the
0013  *    License, or (at your option) any later version.
0014  *
0015  *    This program is distributed in the hope that it will be useful,
0016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *    GNU Affero General Public License for more details.
0019  *
0020  *    You should have received a copy of the GNU Affero General Public License
0021  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  **/
0023 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
0024 {
0025 
0026     /**
0027      * @return Zend_Application_Module_Autoloader
0028      * @throws Zend_Loader_Exception
0029      */
0030     protected function _initAutoload()
0031     {
0032         $autoloader = new Zend_Application_Module_Autoloader(array(
0033             'namespace' => 'Default',
0034             'basePath'  => realpath(dirname(__FILE__)),
0035         ));
0036         $autoloader->addResourceType('formelements', 'forms/elements', 'Form_Element');
0037         $autoloader->addResourceType('formvalidators', 'forms/validators', 'Form_Validator');
0038 
0039         return $autoloader;
0040     }
0041 
0042     /**
0043      * @throws Zend_Exception
0044      * @throws Zend_Session_Exception
0045      */
0046     protected function _initSessionManagement()
0047     {
0048         $session = $this->bootstrap('session');
0049         $domain = Local_Tools_ParseDomain::get_domain($_SERVER['HTTP_HOST']);
0050         Zend_Session::setOptions(array('cookie_domain'   => $domain));
0051         Zend_Session::start();
0052         $config = $this->getOption('settings')['session'];
0053         $session_namespace = new Zend_Session_Namespace($config['auth']['name']);
0054         Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session($session_namespace->getNamespace()));
0055     }
0056 
0057     protected function _initConfig()
0058     {
0059         /** $config Zend_Config */
0060         $config = $this->getApplication()->getApplicationConfig();
0061         Zend_Registry::set('config', $config);
0062 
0063         return $config;
0064     }
0065 
0066     /**
0067      * @return mixed|null|Zend_Cache_Core|Zend_Cache_Frontend
0068      * @throws Zend_Cache_Exception
0069      * @throws Zend_Exception
0070      */
0071     protected function _initCache()
0072     {
0073         if (Zend_Registry::isRegistered('cache')) {
0074             return Zend_Registry::get('cache');
0075         }
0076 
0077         $cache = null;
0078         $options = $this->getOption('settings');
0079 
0080         if (true == $options['cache']['enabled']) {
0081             $cache = Zend_Cache::factory($options['cache']['frontend']['type'], $options['cache']['backend']['type'],
0082                 $options['cache']['frontend']['options'], $options['cache']['backend']['options']);
0083         } else {
0084             // Fallback settings for some (maybe development) environments which have no cache management installed.
0085 
0086             if (false === is_writeable(APPLICATION_CACHE)) {
0087                 error_log('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE);
0088                 throw new Zend_Application_Bootstrap_Exception('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE);
0089             }
0090 
0091             $frontendOptions = array(
0092                 'lifetime'                => 600,
0093                 'automatic_serialization' => true,
0094                 'cache_id_prefix'         => $options['cache']['frontend']['options']['cache_id_prefix'],
0095                 'cache'                   => true
0096             );
0097 
0098             $backendOptions = array(
0099                 'cache_dir'              => APPLICATION_CACHE,
0100                 'file_locking'           => true,
0101                 'read_control'           => true,
0102                 'read_control_type'      => 'crc32',
0103                 'hashed_directory_level' => 1,
0104                 'hashed_directory_perm'  => 0700,
0105                 'file_name_prefix'       => $options['cache']['frontend']['options']['cache_id_prefix'],
0106                 'cache_file_perm'        => 0700
0107             );
0108 
0109             $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
0110         }
0111 
0112         Zend_Registry::set('cache', $cache);
0113 
0114         Zend_Locale::setCache($cache);
0115         Zend_Locale_Data::setCache($cache);
0116         Zend_Currency::setCache($cache);
0117         Zend_Translate::setCache($cache);
0118         Zend_Translate_Adapter::setCache($cache);
0119         Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
0120         Zend_Paginator::setCache($cache);
0121 
0122         return $cache;
0123     }
0124 
0125     /**
0126      * @throws Zend_Application_Bootstrap_Exception
0127      */
0128     protected function _initViewConfig()
0129     {
0130         $view = $this->bootstrap('view')->getResource('view');
0131 
0132         $view->addHelperPath(APPLICATION_PATH . '/modules/default/views/helpers', 'Default_View_Helper_');
0133         $view->addHelperPath(APPLICATION_LIB . '/Zend/View/Helper', 'Zend_View_Helper_');
0134 
0135         $options = $this->getOptions();
0136 
0137         $docType = $options['resources']['view']['doctype'] ? $options['resources']['view']['doctype'] : 'XHTML1_TRANSITIONAL';
0138         $view->doctype($docType);
0139     }
0140 
0141     /**
0142      * @throws Zend_Locale_Exception
0143      */
0144     protected function _initLocale()
0145     {
0146         $configResources = $this->getOption('resources');
0147         Zend_Locale::setDefault($configResources['locale']['default']);
0148         Zend_Registry::set($configResources['locale']['registry_key'], $configResources['locale']['default']);
0149     }
0150 
0151     /**
0152      * @return Zend_Translate
0153      * @throws Zend_Application_Resource_Exception
0154      * @throws Zend_Form_Exception
0155      * @throws Zend_Session_Exception
0156      * @throws Zend_Translate_Exception
0157      * @throws Zend_Validate_Exception
0158      */
0159     protected function _initTranslate()
0160     {
0161         $options = $this->getOption('resources');
0162         $options = $options['translate'];
0163         if (!isset($options['data'])) {
0164             throw new Zend_Application_Resource_Exception('not found the file');
0165         }
0166         $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
0167         $session = new Zend_Session_Namespace('aa');
0168         if ($session->locale) {
0169             $locale = $session->locale;
0170         } else {
0171             $locale = isset($options['locale']) ? $options['locale'] : null;
0172         }
0173         $data = '';
0174         if (isset($options['data'][$locale])) {
0175             $data = $options['data'][$locale];
0176         }
0177         $translateOptions = isset($options['options']) ? $options['options'] : array();
0178         $translate = new Zend_Translate($adapter, $data, $locale, $translateOptions);
0179         Zend_Form::setDefaultTranslator($translate);
0180         Zend_Validate_Abstract::setDefaultTranslator($translate);
0181         Zend_Registry::set('Zend_Translate', $translate);
0182 
0183         return $translate;
0184     }
0185 
0186     /**
0187      * @throws Zend_Application_Bootstrap_Exception
0188      */
0189     protected function _initDbAdapter()
0190     {
0191         $db = $this->bootstrap('db')->getResource('db');
0192 
0193         Zend_Registry::set('db', $db);
0194         Zend_Db_Table::setDefaultAdapter($db);
0195         Zend_Db_Table_Abstract::setDefaultAdapter($db);
0196     }
0197 
0198     /**
0199      * @throws Zend_Application_Bootstrap_Exception
0200      */
0201     protected function _initLogger()
0202     {
0203         /** @var Zend_Log $logger */
0204         $logger = $this->getPluginResource('log')->getLog();
0205         $logger->registerErrorHandler();
0206         Zend_Registry::set('logger', $logger);
0207     }
0208 
0209     protected function _initGlobals()
0210     {
0211         Zend_Paginator::setDefaultScrollingStyle('Elastic');
0212         Zend_View_Helper_PaginationControl::setDefaultViewPartial('paginationControl.phtml');
0213 
0214         Zend_Filter::addDefaultNamespaces('Local_Filter');
0215 
0216         $version = $this->getOption('version');
0217         defined('APPLICATION_VERSION') || define('APPLICATION_VERSION', $version);
0218     }
0219 
0220     /**
0221      * @return Default_Plugin_AclRules|false|mixed
0222      * @throws Zend_Cache_Exception
0223      */
0224     protected function _initAclRules()
0225     {
0226         /** @var Zend_Cache_Core $appCache */
0227         $appCache = $this->getResource('cache');
0228 
0229         if (false == ($aclRules = $appCache->load('AclRules'))) {
0230             $aclRules = new Default_Plugin_AclRules();
0231             Zend_Registry::set('acl', $aclRules);
0232             $appCache->save($aclRules, 'AclRules', array('AclRules'), 14400);
0233         }
0234 
0235         return $aclRules;
0236     }
0237 
0238     /**
0239      * @throws Zend_Application_Bootstrap_Exception
0240      * @throws Zend_Loader_PluginLoader_Exception
0241      */
0242     protected function _initPlugins()
0243     {
0244         /** @var $front Zend_Controller_Front */
0245         $front = $this->bootstrap('frontController')->getResource('frontController');
0246         $aclRules = $this->bootstrap('aclRules')->getResource('aclRules');
0247 
0248         $front->unregisterPlugin('Zend_Controller_Plugin_ErrorHandler');
0249         $front->registerPlugin(new Default_Plugin_ErrorHandler());
0250         $front->registerPlugin(new Default_Plugin_Stats());
0251         $front->registerPlugin(new Default_Plugin_RememberMe(Zend_Auth::getInstance()));
0252         $front->registerPlugin(new Default_Plugin_SignOn(Zend_Auth::getInstance()));
0253         $front->registerPlugin(new Default_Plugin_Acl(Zend_Auth::getInstance(), $aclRules));
0254 
0255         $loader = new Zend_Loader_PluginLoader();
0256         $loader->addPrefixPath('Zend_View_Helper', APPLICATION_LIB . '/Zend/View/Helper/')
0257                ->addPrefixPath('Zend_Form_Element', APPLICATION_LIB . '/Zend/Form/Element')
0258                ->addPrefixPath('Default_View_Helper', APPLICATION_PATH . '/modules/default/views/helpers')
0259                ->addPrefixPath('Default_Form_Helper', APPLICATION_PATH . '/modules/default/forms/helpers')
0260                ->addPrefixPath('Default_Form_Element', APPLICATION_PATH . '/modules/default/forms/elements')
0261                ->addPrefixPath('Default_Form_Decorator', APPLICATION_PATH . '/modules/default/forms/decorators')
0262                ->addPrefixPath('Default_Form_Validator', APPLICATION_PATH . '/modules/default/forms/validators');
0263     }
0264 
0265     protected function _initThirdParty()
0266     {
0267         $appConfig = $this->getResource('config');
0268 
0269         $imageConfig = $appConfig->images;
0270         defined('IMAGES_UPLOAD_PATH') || define('IMAGES_UPLOAD_PATH', $imageConfig->upload->path);
0271         defined('IMAGES_MEDIA_SERVER') || define('IMAGES_MEDIA_SERVER', $imageConfig->media->server);
0272         $videoConfig = $appConfig->videos;
0273         defined('VIDEOS_UPLOAD_PATH') || define('VIDEOS_UPLOAD_PATH', $videoConfig->upload->path);
0274         defined('VIDEOS_MEDIA_SERVER') || define('VIDEOS_MEDIA_SERVER', $videoConfig->media->server);
0275         $comicConfig = $appConfig->comics;
0276         defined('COMICS_MEDIA_SERVER') || define('COMICS_MEDIA_SERVER', $comicConfig->media->server);
0277 
0278         // fileserver
0279         $configFileserver = $appConfig->settings->server->files;
0280         defined('PPLOAD_API_URI') || define('PPLOAD_API_URI', $configFileserver->api->uri);
0281         defined('PPLOAD_CLIENT_ID') || define('PPLOAD_CLIENT_ID', $configFileserver->api->client_id);
0282         defined('PPLOAD_SECRET') || define('PPLOAD_SECRET', $configFileserver->api->client_secret);
0283         defined('PPLOAD_HOST') || define('PPLOAD_HOST', $configFileserver->host);
0284         defined('PPLOAD_DOWNLOAD_SECRET') || define('PPLOAD_DOWNLOAD_SECRET', $configFileserver->download_secret);
0285     }
0286 
0287     /**
0288      * @return false|mixed|Zend_Controller_Router_Rewrite
0289      * @throws Zend_Application_Bootstrap_Exception
0290      * @throws Zend_Cache_Exception
0291      * @throws Zend_Controller_Exception
0292      * @throws Zend_Exception
0293      */
0294     protected function _initRouter()
0295     {
0296         $this->bootstrap('frontController');
0297         /** @var $front Zend_Controller_Front */
0298         $front = $this->getResource('frontController');
0299 
0300         /** @var Zend_Cache_Core $cache */
0301         $cache = Zend_Registry::get('cache');
0302 
0303         if (($router = $cache->load('ProjectRouter'))) {
0304             $front->setRouter($router);
0305 
0306             return $router;
0307         }
0308 
0309         /** @var $router Zend_Controller_Router_Rewrite */
0310         $router = $front->getRouter();
0311 
0312         /** RSS Feed */
0313         $router->addRoute('rdf_store', new Zend_Controller_Router_Route('/content.rdf', array(
0314             'module'     => 'default',
0315             'controller' => 'rss',
0316             'action'     => 'rdf'
0317         )));
0318 
0319         $router->addRoute('rdf_events_hive', new Zend_Controller_Router_Route_Regex('.*-events.rss', array(
0320             'module'     => 'default',
0321             'controller' => 'rss',
0322             'action'     => 'rss'
0323         )));
0324 
0325         $router->addRoute('rdf_store_hive', new Zend_Controller_Router_Route_Regex('.*-content.rdf', array(
0326             'module'     => 'default',
0327             'controller' => 'rss',
0328             'action'     => 'rdf'
0329         )));
0330 
0331         $router->addRoute('rdf_store_hive_rss', new Zend_Controller_Router_Route_Regex('rss/.*-content.rdf', array(
0332             'module'     => 'default',
0333             'controller' => 'rss',
0334             'action'     => 'rdf'
0335         )));
0336 
0337         /** new store dependent routing rules */
0338         //$router->addRoute('store_general', new Zend_Controller_Router_Route('/s/:domain_store_id/:controller/:action/*', array(
0339         //    'module'     => 'default',
0340         //    'controller' => 'explore',
0341         //    'action'     => 'index'
0342         //)));
0343 
0344         $router->addRoute('store_home', new Zend_Controller_Router_Route('/s/:domain_store_id/', array(
0345             'module'     => 'default',
0346             'controller' => 'home',
0347             'action'     => 'index'
0348         )));
0349 
0350         $router->addRoute('store_browse', new Zend_Controller_Router_Route('/s/:domain_store_id/browse/*', array(
0351             'module'     => 'default',
0352             'controller' => 'explore',
0353             'action'     => 'index'
0354         )));
0355 
0356         $router->addRoute('store_product_add',
0357             new Zend_Controller_Router_Route('/s/:domain_store_id/product/add', array(
0358                 'module'     => 'default',
0359                 'controller' => 'product',
0360                 'action'     => 'add'
0361             )));
0362 
0363         $router->addRoute('store_settings', new Zend_Controller_Router_Route('/s/:domain_store_id/settings', array(
0364             'module'     => 'default',
0365             'controller' => 'settings',
0366             'action'     => 'index'
0367         )));
0368 
0369         $router->addRoute('store_pling_box_show',
0370             new Zend_Controller_Router_Route('/s/:domain_store_id/supporterbox/:memberid', array(
0371                 'module'     => 'default',
0372                 'controller' => 'plingbox',
0373                 'action'     => 'index'
0374             )));
0375 
0376         $router->addRoute('store_pling_box_show',
0377             new Zend_Controller_Router_Route('/s/:domain_store_id/productcomment/addreply/*', array(
0378                 'module'     => 'default',
0379                 'controller' => 'productcomment',
0380                 'action'     => 'addreply'
0381             )));
0382 
0383         $router->addRoute('store_product',
0384             new Zend_Controller_Router_Route('/s/:domain_store_id/p/:project_id/:action/*', array(
0385                 'module'     => 'default',
0386                 'controller' => 'product',
0387                 'action'     => 'show'
0388             )));
0389 
0390         $router->addRoute('store_collection',
0391             new Zend_Controller_Router_Route('/s/:domain_store_id/c/:project_id/:action/*', array(
0392                 'module'     => 'default',
0393                 'controller' => 'collection',
0394                 'action'     => 'show'
0395             )));
0396 
0397         /*
0398         $router->addRoute('store_product', new Zend_Controller_Router_Route('/s/:domain_store_id/c/:project_id/:action/*', array(
0399                     'module'     => 'default',
0400                     'controller' => 'collection',
0401                     'action'     => 'show'
0402                 )));
0403         */
0404         $router->addRoute('store_user',
0405             new Zend_Controller_Router_Route('/s/:domain_store_id/member/:member_id/:action/*', array(
0406                 'module'     => 'default',
0407                 'controller' => 'user',
0408                 'action'     => 'index'
0409             )));
0410 
0411         $router->addRoute('store_user_name',
0412             new Zend_Controller_Router_Route('/s/:domain_store_id/u/:user_name/:action/*', array(
0413                 'module'     => 'default',
0414                 'controller' => 'user',
0415                 'action'     => 'index'
0416             )));
0417 
0418         $router->addRoute('store_login', new Zend_Controller_Router_Route('/s/:domain_store_id/login/*', array(
0419             'module'     => 'default',
0420             'controller' => 'authorization',
0421             'action'     => 'login'
0422         )));
0423 
0424         $router->addRoute('store_register', new Zend_Controller_Router_Route('/s/:domain_store_id/register', array(
0425             'module'     => 'default',
0426             'controller' => 'authorization',
0427             'action'     => 'register'
0428         )));
0429 
0430 
0431         /** general routing rules */
0432         $router->addRoute('home', new Zend_Controller_Router_Route('/', array(
0433             'module'     => 'default',
0434             'controller' => 'home',
0435             'action'     => 'index'
0436         )));
0437 
0438 
0439         $router->addRoute('home_home', new Zend_Controller_Router_Route('/home', array(
0440             'module'     => 'default',
0441             'controller' => 'home',
0442             'action'     => 'index'
0443         )));
0444 
0445         $router->addRoute('home_start', new Zend_Controller_Router_Route('/start', array(
0446             'module'     => 'default',
0447             'controller' => 'home',
0448             'action'     => 'start'
0449         )));
0450 
0451         $router->addRoute('home_ajax', new Zend_Controller_Router_Route('/showfeatureajax/*', array(
0452             'module'     => 'default',
0453             'controller' => 'home',
0454             'action'     => 'showfeatureajax'
0455         )));
0456 
0457         $router->addRoute('backend', new Zend_Controller_Router_Route('/backend/:controller/:action/*', array(
0458             'module'     => 'backend',
0459             'controller' => 'index',
0460             'action'     => 'index'
0461         )));
0462 
0463         $router->addRoute('backend_statistics', new Zend_Controller_Router_Route('/statistics/:action/*', array(
0464             'module'     => 'backend',
0465             'controller' => 'statistics',
0466             'action'     => 'index'
0467         )));
0468 
0469         $router->addRoute('browse', new Zend_Controller_Router_Route('/browse/*', array(
0470             'module'     => 'default',
0471             'controller' => 'explore',
0472             'action'     => 'index'
0473         )));
0474 
0475         $router->addRoute('browse_favourites', new Zend_Controller_Router_Route('/my-favourites/*', array(
0476             'module'     => 'default',
0477             'controller' => 'explore',
0478             'action'     => 'index',
0479             'fav'        => '1'
0480         )));
0481 
0482         $router->addRoute('button_render', new Zend_Controller_Router_Route('/button/:project_id/:size/', array(
0483             'module'     => 'default',
0484             'controller' => 'button',
0485             'action'     => 'render',
0486             'size'       => 'large'
0487         )));
0488 
0489         $router->addRoute('button_action', new Zend_Controller_Router_Route('/button/a/:action/', array(
0490             'module'     => 'default',
0491             'controller' => 'button',
0492             'action'     => 'index'
0493         )));
0494 
0495         $router->addRoute('pling_box_show', new Zend_Controller_Router_Route('/supporterbox/:memberid/', array(
0496             'module'     => 'default',
0497             'controller' => 'plingbox',
0498             'action'     => 'index'
0499         )));
0500 
0501         $router->addRoute('external_donation_list',
0502             new Zend_Controller_Router_Route('/donationlist/:project_id/', array(
0503                 'module'     => 'default',
0504                 'controller' => 'donationlist',
0505                 'action'     => 'render'
0506             )));
0507 
0508         $router->addRoute('external_widget', new Zend_Controller_Router_Route('/widget/:project_id/', array(
0509             'module'     => 'default',
0510             'controller' => 'widget',
0511             'action'     => 'render'
0512         )));
0513 
0514         $router->addRoute('external_widget_save', new Zend_Controller_Router_Route('/widget/save/*', array(
0515             'module'     => 'default',
0516             'controller' => 'widget',
0517             'action'     => 'save'
0518         )));
0519 
0520         $router->addRoute('external_widget_save', new Zend_Controller_Router_Route('/widget/config/:project_id/', array(
0521             'module'     => 'default',
0522             'controller' => 'widget',
0523             'action'     => 'config'
0524         )));
0525 
0526         $router->addRoute('external_widget_save_default',
0527             new Zend_Controller_Router_Route('/widget/savedefault/*', array(
0528                 'module'     => 'default',
0529                 'controller' => 'widget',
0530                 'action'     => 'savedefault'
0531             )));
0532 
0533         $router->addRoute('support_old', new Zend_Controller_Router_Route('/support-old', array(
0534             'module'     => 'default',
0535             'controller' => 'support',
0536             'action'     => 'index'
0537         )));
0538 
0539         $router->addRoute('support_old_pay', new Zend_Controller_Router_Route('/support-old/pay', array(
0540             'module'     => 'default',
0541             'controller' => 'support',
0542             'action'     => 'pay'
0543         )));
0544 
0545         $router->addRoute('support_old_paymentok', new Zend_Controller_Router_Route('/support-old/paymentok', array(
0546             'module'     => 'default',
0547             'controller' => 'support',
0548             'action'     => 'paymentok'
0549         )));
0550 
0551 
0552         $router->addRoute('support_old_paymentcancel',
0553             new Zend_Controller_Router_Route('/support-old/paymentcancel', array(
0554                 'module'     => 'default',
0555                 'controller' => 'support',
0556                 'action'     => 'paymentcancel'
0557             )));
0558         
0559 
0560         $router->addRoute('watchlist_productmoderation', new Zend_Controller_Router_Route('/watchlist-productmoderation', array(
0561             'module'     => 'default',
0562             'controller' => 'moderation',
0563             'action'     => 'productmoderation'
0564         )));
0565         
0566         $router->addRoute('watchlist_samepaypal', new Zend_Controller_Router_Route('/watchlist-samepaypal', array(
0567             'module'     => 'default',
0568             'controller' => 'spam',
0569             'action'     => 'paypal'
0570         )));
0571 
0572         $router->addRoute('watchlist_products_files', new Zend_Controller_Router_Route('/watchlist-products-10-files', array(
0573             'module'     => 'default',
0574             'controller' => 'spam',
0575             'action'     => 'product'
0576         )));   
0577         $router->addRoute('watchlist_products_deprecated', new Zend_Controller_Router_Route('/watchlist-products-deprecated', array(
0578             'module'     => 'default',
0579             'controller' => 'spam',
0580             'action'     => 'deprecated'
0581         )));
0582         
0583         $router->addRoute('watchlist_md5sum', new Zend_Controller_Router_Route('/watchlist-md5sum-duplicated', array(
0584             'module'     => 'default',
0585             'controller' => 'spam',
0586             'action'     => 'mdsum'
0587         ))); 
0588 
0589         $router->addRoute('watchlist_unpublishedproduct', new Zend_Controller_Router_Route('/watchlist-unpublishedproduct', array(
0590             'module'     => 'default',
0591             'controller' => 'spam',
0592             'action'     => 'unpublishedproduct'
0593         ))); 
0594 
0595         $router->addRoute('watchlist_newproduct_2_month', new Zend_Controller_Router_Route('/watchlist-newproduct-2-month', array(
0596             'module'     => 'default',
0597             'controller' => 'spam',
0598             'action'     => 'newproduct'
0599         ))); 
0600 
0601         $router->addRoute('watchlist_newproducts', new Zend_Controller_Router_Route('/watchlist-newproducts', array(
0602             'module'     => 'default',
0603             'controller' => 'newproducts',
0604             'action'     => 'index'
0605         ))); 
0606 
0607         $router->addRoute('support_new', new Zend_Controller_Router_Route('/supportold2', array(
0608             'module'     => 'default',
0609             'controller' => 'subscription',
0610             'action'     => 'index'
0611         )));
0612         
0613         $router->addRoute('support_predefined', new Zend_Controller_Router_Route('/support-predefined', array(
0614             'module'     => 'default',
0615             'controller' => 'subscription',
0616             'action'     => 'supportpredefinded'
0617         )));
0618         
0619         $router->addRoute('support_pay_predefined', new Zend_Controller_Router_Route('/support/paypredefined', array(
0620             'module'     => 'default',
0621             'controller' => 'subscription',
0622             'action'     => 'paypredefined'
0623         )));
0624         
0625         $router->addRoute('support_new2', new Zend_Controller_Router_Route('/support', array(
0626             'module'     => 'default',
0627             'controller' => 'subscription',
0628             'action'     => 'support2'
0629         )));
0630         
0631         $router->addRoute('support_new_pay2', new Zend_Controller_Router_Route('/support/pay', array(
0632             'module'     => 'default',
0633             'controller' => 'subscription',
0634             'action'     => 'pay2'
0635         )));
0636 
0637 
0638         $router->addRoute('support_new_pay', new Zend_Controller_Router_Route('/support/payold2', array(
0639             'module'     => 'default',
0640             'controller' => 'subscription',
0641             'action'     => 'pay'
0642         )));
0643 
0644         $router->addRoute('support_new_paymentok', new Zend_Controller_Router_Route('/support/paymentok', array(
0645             'module'     => 'default',
0646             'controller' => 'subscription',
0647             'action'     => 'paymentok'
0648         )));
0649 
0650 
0651         $router->addRoute('support_new_paymentcancel', new Zend_Controller_Router_Route('/support/paymentcancel', array(
0652             'module'     => 'default',
0653             'controller' => 'subscription',
0654             'action'     => 'paymentcancel'
0655         )));
0656 
0657         /**
0658          * Project/Product
0659          */
0660         $router->addRoute('product_short_url', new Zend_Controller_Router_Route('/p/:project_id/:action/*', array(
0661             'module'     => 'default',
0662             'controller' => 'product',
0663             'action'     => 'show'
0664         )));
0665 
0666         $router->addRoute('product_referrer_url', new Zend_Controller_Router_Route('/p/:project_id/er/:er/*', array(
0667             'module'     => 'default',
0668             'controller' => 'product',
0669             'action'     => 'show'
0670         )));
0671 
0672         $router->addRoute('product_collectionid_url', new Zend_Controller_Router_Route('/co/:collection_id', array(
0673             'module'     => 'default',
0674             'controller' => 'product',
0675             'action'     => 'show'
0676         )));
0677 
0678         $router->addRoute('product_add', new Zend_Controller_Router_Route('/product/add', array(
0679             'module'     => 'default',
0680             'controller' => 'product',
0681             'action'     => 'add'
0682         )));
0683 
0684         $router->addRoute('product_add_extend', new Zend_Controller_Router_Route('/product/add/:catId', array(
0685             'module'     => 'default',
0686             'controller' => 'product',
0687             'action'     => 'add'
0688         )));
0689 
0690         $router->addRoute('search', new Zend_Controller_Router_Route('/search/*', array(
0691             'module'     => 'default',
0692             'controller' => 'product',
0693             'action'     => 'search'
0694         )));
0695 
0696         $router->addRoute('search_domain', new Zend_Controller_Router_Route('/s/:domain_store_id/search/*',
0697             array(
0698                 'module'     => 'default',
0699                 'controller' => 'product',
0700                 'action'     => 'search'
0701             )));
0702 
0703         $router->addRoute('product_save', new Zend_Controller_Router_Route('/p/save/*', array(
0704             'module'     => 'default',
0705             'controller' => 'product',
0706             'action'     => 'saveproduct'
0707         )));
0708 
0709         
0710 
0711 
0712 
0713         /**
0714          * Collection
0715          */
0716         $router->addRoute('collection_short_url', new Zend_Controller_Router_Route('/c/:project_id/', array(
0717             'module'     => 'default',
0718             'controller' => 'collection',
0719             'action'     => 'index'
0720         )));
0721 
0722         $router->addRoute('collection_short_url', new Zend_Controller_Router_Route('/c/:project_id/:action/*', array(
0723             'module'     => 'default',
0724             'controller' => 'collection',
0725             'action'     => 'index'
0726         )));
0727 
0728         $router->addRoute('collection_referrer_url', new Zend_Controller_Router_Route('/c/:project_id/er/:er/*', array(
0729             'module'     => 'default',
0730             'controller' => 'collection',
0731             'action'     => 'index'
0732         )));
0733 
0734         $router->addRoute('collection_add', new Zend_Controller_Router_Route('/collection/add', array(
0735             'module'     => 'default',
0736             'controller' => 'collection',
0737             'action'     => 'add'
0738         )));
0739 
0740         /**
0741          * $router->addRoute('search', new Zend_Controller_Router_Route('/search/*', array(
0742          * 'module'     => 'default',
0743          * 'controller' => 'collection',
0744          * 'action'     => 'search'
0745          * )));
0746          *
0747          * $router->addRoute('search_domain',new Zend_Controller_Router_Route('/s/:domain_store_id/search/*',
0748          * array(
0749          * 'module'     => 'default',
0750          * 'controller' => 'product',
0751          * 'action'     => 'search'
0752          * )));
0753          */
0754         $router->addRoute('collection_save', new Zend_Controller_Router_Route('/c/save/*', array(
0755             'module'     => 'default',
0756             'controller' => 'collection',
0757             'action'     => 'saveproduct'
0758         )));
0759 
0760 
0761         /**
0762          * Member
0763          */
0764         $router->addRoute('member_settings_old', new Zend_Controller_Router_Route('/settings/:action/*', array(
0765             'module'     => 'default',
0766             'controller' => 'settings',
0767             'action'     => 'index'
0768         )));
0769 
0770         $router->addRoute('user_show', new Zend_Controller_Router_Route('/member/:member_id/:action/*', array(
0771             'module'     => 'default',
0772             'controller' => 'user',
0773             'action'     => 'index'
0774         )));
0775         
0776         
0777         
0778         $router->addRoute('user_avatar', new Zend_Controller_Router_Route('/member/avatar/:emailhash/:size', array(
0779             'module'     => 'default',
0780             'controller' => 'user',
0781             'action'     => 'avatar'
0782         )));
0783 
0784         $router->addRoute('user_show_with_name', new Zend_Controller_Router_Route('/u/:user_name/:action/*', array(
0785             'module'     => 'default',
0786             'controller' => 'user',
0787             'action'     => 'index'
0788         )));
0789         
0790         $router->addRoute('user_recification', new Zend_Controller_Router_Route('/r/:action/*', array(
0791             'module'     => 'default',
0792             'controller' => 'rectification',
0793             'action'     => 'index'
0794         )));
0795 
0796         $router->addRoute('user_show_short', new Zend_Controller_Router_Route('/me/:member_id/:action/*', array(
0797             'module'     => 'default',
0798             'controller' => 'user',
0799             'action'     => 'index'
0800         )));
0801 
0802         $router->addRoute('register', new Zend_Controller_Router_Route_Static('/register', array(
0803             'module'     => 'default',
0804             'controller' => 'authorization',
0805             'action'     => 'register'
0806         )));
0807 
0808         $router->addRoute('register_validate', new Zend_Controller_Router_Route_Static('/register/validate', array(
0809             'module'     => 'default',
0810             'controller' => 'authorization',
0811             'action'     => 'validate'
0812         )));
0813 
0814         $router->addRoute('verification', new Zend_Controller_Router_Route('/verification/:vid', array(
0815             'module'     => 'default',
0816             'controller' => 'authorization',
0817             'action'     => 'verification'
0818         )));
0819 
0820         $router->addRoute('logout', new Zend_Controller_Router_Route_Static('/logout', array(
0821             'module'     => 'default',
0822             'controller' => 'logout',
0823             'action'     => 'logout'
0824         )));
0825 
0826         $router->addRoute('propagatelogout', new Zend_Controller_Router_Route_Static('/logout/propagate', array(
0827             'module'     => 'default',
0828             'controller' => 'authorization',
0829             'action'     => 'propagatelogout'
0830         )));
0831 
0832         $router->addRoute('checkuser', new Zend_Controller_Router_Route_Static('/checkuser', array(
0833             'module'     => 'default',
0834             'controller' => 'authorization',
0835             'action'     => 'checkuser'
0836         )));
0837 
0838         $router->addRoute('login', new Zend_Controller_Router_Route('/login', array(
0839             'module'     => 'default',
0840             'controller' => 'authorization',
0841             'action'     => 'login'
0842         )));
0843 
0844         $router->addRoute('login', new Zend_Controller_Router_Route('/login/:action/*', array(
0845             'module'     => 'default',
0846             'controller' => 'authorization',
0847             'action'     => 'login'
0848         )));
0849 
0850         $router->addRoute('LoginController', new Zend_Controller_Router_Route('/l/:action/*', array(
0851             'module'     => 'default',
0852             'controller' => 'login',
0853             'action'     => 'login'
0854         )));
0855 
0856         $router->addRoute('content', new Zend_Controller_Router_Route('/content/:page', array(
0857             'module'     => 'default',
0858             'controller' => 'content',
0859             'action'     => 'index'
0860         )));
0861 
0862         $router->addRoute('categories_about', new Zend_Controller_Router_Route('/cat/:page/about', array(
0863             'module'     => 'default',
0864             'controller' => 'categories',
0865             'action'     => 'about'
0866         )));
0867 
0868         // **** static routes
0869         $router->addRoute('static_faq_old', new Zend_Controller_Router_Route_Static('/faq-old', array(
0870             'module'     => 'default',
0871             'controller' => 'content',
0872             'action'     => 'index',
0873             'page'       => 'faqold'
0874         )));
0875 
0876         $router->addRoute('static_faq', new Zend_Controller_Router_Route_Static('/faq-pling', array(
0877             'module'     => 'default',
0878             'controller' => 'content',
0879             'action'     => 'index',
0880             'page'       => 'faq'
0881         )));
0882 
0883         $router->addRoute('static_gitfaq', new Zend_Controller_Router_Route_Static('/faq-opencode', array(
0884             'module'     => 'default',
0885             'controller' => 'content',
0886             'action'     => 'index',
0887             'page'       => 'gitfaq'
0888         )));
0889         $router->addRoute('static_ocsapi', new Zend_Controller_Router_Route_Static('/ocs-api', array(
0890             'module'     => 'default',
0891             'controller' => 'content',
0892             'action'     => 'index',
0893             'page'       => 'ocsapi'
0894         )));
0895         $router->addRoute('static_plings', new Zend_Controller_Router_Route_Static('/about', array(
0896             'module'     => 'default',
0897             'controller' => 'content',
0898             'action'     => 'index',
0899             'page'       => 'about'
0900         )));
0901 
0902         $router->addRoute('static_terms', new Zend_Controller_Router_Route_Static('/terms', array(
0903             'module'     => 'default',
0904             'controller' => 'content',
0905             'action'     => 'index',
0906             'page'       => 'terms'
0907         )));
0908 
0909         $router->addRoute('static_terms_general', new Zend_Controller_Router_Route_Static('/terms/general', array(
0910             'module'     => 'default',
0911             'controller' => 'content',
0912             'action'     => 'index',
0913             'page'       => 'terms-general'
0914         )));
0915 
0916         $router->addRoute('static_terms_publish', new Zend_Controller_Router_Route_Static('/terms/publishing', array(
0917             'module'     => 'default',
0918             'controller' => 'content',
0919             'action'     => 'index',
0920             'page'       => 'terms-publishing'
0921         )));
0922 
0923         $router->addRoute('static_terms_dmca', new Zend_Controller_Router_Route_Static('/terms/dmca', array(
0924             'module'     => 'default',
0925             'controller' => 'content',
0926             'action'     => 'index',
0927             'page'       => 'terms-dmca'
0928         )));
0929 
0930         $router->addRoute('static_terms_payout', new Zend_Controller_Router_Route_Static('/terms/payout', array(
0931             'module'     => 'default',
0932             'controller' => 'content',
0933             'action'     => 'index',
0934             'page'       => 'terms-payout'
0935         )));
0936 
0937         $router->addRoute('static_terms_cookies', new Zend_Controller_Router_Route_Static('/terms/cookies', array(
0938             'module'     => 'default',
0939             'controller' => 'content',
0940             'action'     => 'index',
0941             'page'       => 'terms-cookies'
0942         )));
0943 
0944         $router->addRoute('static_privacy', new Zend_Controller_Router_Route_Static('/privacy', array(
0945             'module'     => 'default',
0946             'controller' => 'content',
0947             'action'     => 'index',
0948             'page'       => 'privacy'
0949         )));
0950 
0951         $router->addRoute('static_imprint', new Zend_Controller_Router_Route_Static('/imprint', array(
0952             'module'     => 'default',
0953             'controller' => 'content',
0954             'action'     => 'index',
0955             'page'       => 'imprint'
0956         )));
0957 
0958         $router->addRoute('static_contact', new Zend_Controller_Router_Route_Static('/contact', array(
0959             'module'     => 'default',
0960             'controller' => 'content',
0961             'action'     => 'index',
0962             'page'       => 'contact'
0963         )));
0964 
0965         // **** ppload
0966         $router->addRoute('pploadlogin', new Zend_Controller_Router_Route('/pploadlogin/*', array(
0967             'module'     => 'default',
0968             'controller' => 'authorization',
0969             'action'     => 'pploadlogin'
0970         )));
0971 
0972         // OCS API
0973         //20191120 OCS-API is disabled for webservers, only api.pling.com or api.kde-look.org allowed, see ticket #1494
0974         //20191125 erst mal wieder drin
0975         
0976         $router->addRoute('ocs_providers_xml', new Zend_Controller_Router_Route('/ocs/providers.xml', array(
0977             'module'     => 'default',
0978             'controller' => 'ocsv1',
0979             'action'     => 'providers'
0980         )));
0981         $router->addRoute('ocs_v1_config', new Zend_Controller_Router_Route('/ocs/v1/config', array(
0982             'module'     => 'default',
0983             'controller' => 'ocsv1',
0984             'action'     => 'config'
0985         )));
0986         $router->addRoute('ocs_v1_person_check', new Zend_Controller_Router_Route('/ocs/v1/person/check', array(
0987             'module'     => 'default',
0988             'controller' => 'ocsv1',
0989             'action'     => 'personcheck'
0990         )));
0991         $router->addRoute('ocs_v1_person_data', new Zend_Controller_Router_Route('/ocs/v1/person/data', array(
0992             'module'     => 'default',
0993             'controller' => 'ocsv1',
0994             'action'     => 'persondata'
0995         )));
0996         $router->addRoute('ocs_v1_person_data_personid',
0997             new Zend_Controller_Router_Route('/ocs/v1/person/data/:personid', array(
0998                 'module'     => 'default',
0999                 'controller' => 'ocsv1',
1000                 'action'     => 'persondata'
1001             )));
1002         $router->addRoute('ocs_v1_person_self', new Zend_Controller_Router_Route('/ocs/v1/person/self', array(
1003             'module'     => 'default',
1004             'controller' => 'ocsv1',
1005             'action'     => 'personself'
1006         )));
1007         $router->addRoute('ocs_v1_content_categories',
1008             new Zend_Controller_Router_Route('/ocs/v1/content/categories', array(
1009                 'module'     => 'default',
1010                 'controller' => 'ocsv1',
1011                 'action'     => 'contentcategories'
1012             )));
1013         $router->addRoute('ocs_v1_content_data_contentid',
1014             new Zend_Controller_Router_Route('/ocs/v1/content/data/:contentid', array(
1015                 'module'     => 'default',
1016                 'controller' => 'ocsv1',
1017                 'action'     => 'contentdata',
1018                 'contentid'  => null
1019             )));
1020         $router->addRoute('ocs_v1_content_download_contentid_itemid',
1021             new Zend_Controller_Router_Route('/ocs/v1/content/download/:contentid/:itemid', array(
1022                 'module'     => 'default',
1023                 'controller' => 'ocsv1',
1024                 'action'     => 'contentdownload'
1025             )));
1026         $router->addRoute('ocs_v1_content_previewpic_contentid',
1027             new Zend_Controller_Router_Route('/ocs/v1/content/previewpic/:contentid', array(
1028                 'module'     => 'default',
1029                 'controller' => 'ocsv1',
1030                 'action'     => 'contentpreviewpic'
1031             )));
1032         $router->addRoute('ocs_v1_comments',
1033             new Zend_Controller_Router_Route('/ocs/v1/comments/data/:comment_type/:content_id/:second_id', array(
1034                 'module'       => 'default',
1035                 'controller'   => 'ocsv1',
1036                 'action'       => 'comments',
1037                 'comment_type' => -1,
1038                 'content_id'   => null,
1039                 'second_id'    => null
1040             )));
1041         $router->addRoute('ocs_v1_voting',
1042             new Zend_Controller_Router_Route('/ocs/v1/content/vote/:contentid', array(
1043                 'module'     => 'default',
1044                 'controller' => 'ocsv1',
1045                 'action'     => 'vote'
1046             )));
1047         
1048 
1049         
1050         // embed
1051         $router->addRoute('embed_v1_member_projects',
1052             new Zend_Controller_Router_Route('/embed/v1/member/:memberid', array(
1053                 'module'     => 'default',
1054                 'controller' => 'embedv1',
1055                 'action'     => 'memberprojects'
1056             )));
1057 
1058         $router->addRoute('embed_v1_member_projects_files',
1059             new Zend_Controller_Router_Route('/embed/v1/ppload/:ppload_collection_id', array(
1060                 'module'     => 'default',
1061                 'controller' => 'embedv1',
1062                 'action'     => 'ppload'
1063             )));
1064 
1065         $router->addRoute('embed_v1_member_projectscomments',
1066             new Zend_Controller_Router_Route('/embed/v1/comments/:id', array(
1067                 'module'     => 'default',
1068                 'controller' => 'embedv1',
1069                 'action'     => 'comments'
1070             )));
1071 
1072         $router->addRoute('embed_v1_member_projectdetail',
1073             new Zend_Controller_Router_Route('/embed/v1/project/:projectid', array(
1074                 'module'     => 'default',
1075                 'controller' => 'embedv1',
1076                 'action'     => 'projectdetail'
1077             )));
1078 
1079         $router->addRoute('clones', new Zend_Controller_Router_Route('/clones/*', array(
1080             'module'     => 'default',
1081             'controller' => 'credits',
1082             'action'     => 'index'
1083         )));
1084         $router->addRoute('mods', new Zend_Controller_Router_Route('/mods/*', array(
1085             'module'     => 'default',
1086             'controller' => 'credits',
1087             'action'     => 'mods'
1088         )));
1089 
1090 
1091 
1092         $cache->save($router, 'ProjectRouter', array('router'), 14400);
1093 
1094         return $router;
1095     }
1096 
1097     /**
1098      * @throws Zend_Cache_Exception
1099      * @throws Zend_Exception
1100      * @throws exception
1101      */
1102     protected function _initCss()
1103     {
1104         if (APPLICATION_ENV != "development" && APPLICATION_ENV != "staging") {
1105             return;
1106         }
1107 
1108         $appConfig = $this->getResource('config');
1109         if ((boolean)$appConfig->settings->noLESScompile === true) {
1110             return;
1111         }
1112 
1113         $sLess = realpath(APPLICATION_PATH . '/../httpdocs/theme/flatui/less/stylesheet.less');
1114         $sCss = realpath(APPLICATION_PATH . '/../httpdocs/theme/flatui/css/stylesheet.css');
1115 
1116         /**
1117          * @var Zend_Cache_Core $cache
1118          */
1119         $cache = Zend_Registry::get('cache');
1120         if (md5_file($sLess) !== $cache->load('md5Less')) {
1121             require_once APPLICATION_PATH . "/../library/lessphp/lessc.inc.php";
1122             $oLessc = new lessc($sLess);
1123             $oLessc->setFormatter('compressed');
1124             file_put_contents($sCss, $oLessc->parse());
1125             $cache->save(md5_file($sLess), 'md5Less');
1126         }
1127     }
1128 
1129     protected function _initGlobalApplicationVars()
1130     {
1131         $modelDomainConfig = new Default_Model_DbTable_ConfigStore();
1132         Zend_Registry::set('application_store_category_list', $modelDomainConfig->fetchAllStoresAndCategories());
1133         Zend_Registry::set('application_store_config_list', $modelDomainConfig->fetchAllStoresConfigArray());
1134         Zend_Registry::set('application_store_config_id_list', $modelDomainConfig->fetchAllStoresConfigByIdArray());
1135     }
1136 
1137     /**
1138      * @throws Zend_Application_Bootstrap_Exception
1139      */
1140     protected function _initStoreDependentVars()
1141     {
1142         /** @var $front Zend_Controller_Front */
1143         $front = $this->bootstrap('frontController')->getResource('frontController');
1144         $front->registerPlugin(new Default_Plugin_InitGlobalStoreVars());
1145     }
1146 
1147 }