diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f444942 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.idea* +.docker* +.docker_init* +docker-compose.yml +Dockerfile* +data/cache/* +data/cache/sessions/* +data/logs/* \ No newline at end of file diff --git a/.gitignore b/.gitignore index de7b51d..2dcd893 100644 --- a/.gitignore +++ b/.gitignore @@ -1,81 +1,190 @@ # ignore local files and directories local/* *.local* .htpasswd* .htaccess* .docker_init Dockerfile.stage -# Created by https://www.gitignore.io/api/phpstorm +.idea* +.vagrant* + +# Created by https://www.gitignore.io/api/linux,macos,windows,netbeans,phpstorm +# Edit at https://www.gitignore.io/?templates=linux,macos,windows,netbeans,phpstorm + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### NetBeans ### +**/nbproject/private/ +**/nbproject/Makefile-*.mk +**/nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ ### PhpStorm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 -# User-specific stuff: +# User-specific stuff .idea/**/workspace.xml .idea/**/tasks.xml -.idea/dictionaries +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf -# Sensitive or high-churn files: +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files .idea/**/dataSources/ .idea/**/dataSources.ids .idea/**/dataSources.xml .idea/**/dataSources.local.xml .idea/**/sqlDataSources.xml .idea/**/dynamic.xml .idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml -# Gradle: +# Gradle .idea/**/gradle.xml .idea/**/libraries +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + # CMake -cmake-build-debug/ +cmake-build-*/ -# Mongo Explorer plugin: +# Mongo Explorer plugin .idea/**/mongoSettings.xml -## File-based project format: +# File-based project format *.iws -## Plugin-specific files: - # IntelliJ -/out/ +out/ # mpeltonen/sbt-idea plugin .idea_modules/ # JIRA plugin atlassian-ide-plugin.xml # Cursive Clojure plugin .idea/replstate.xml # Ruby plugin and RubyMine /.rakeTasks # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties fabric.properties +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + ### PhpStorm Patch ### # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 # *.iml # modules.xml # .idea/misc.xml # *.ipr # Sonarlint plugin -.idea/sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator/ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp +# Windows shortcuts +*.lnk # End of https://www.gitignore.io/api/phpstorm .idea* .vagrant* /nbproject/private/ diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 1745454..958aa49 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,237 +1,252 @@ . * */ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { /** * @var Zend_Controller_Router_Rewrite */ protected $_router = false; + /** + * @throws Zend_Exception + * @throws Zend_Session_Exception + */ + protected function _initSessionManagement() + { + $session = $this->bootstrap('session'); + $domain = Local_Tools_ParseDomain::get_domain(); + Zend_Session::setOptions(array('cookie_domain' => $domain)); + Zend_Session::start(); + Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_NonPersistent()); + } + /** * @return mixed */ protected function _initConfig() { /** $config Zend_Config */ $config = $this->getApplication()->getApplicationConfig(); Zend_Registry::set('config', $config); return $config; } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initLogger() { /** @var Zend_Log $logger */ $logger = $this->getPluginResource('log')->getLog(); $logger->registerErrorHandler(); Zend_Registry::set('logger', $logger); } /** * @return mixed|null|Zend_Cache_Core|Zend_Cache_Frontend * @throws Zend_Cache_Exception * @throws Zend_Exception */ protected function _initCache() { if (Zend_Registry::isRegistered('cache')) { return Zend_Registry::get('cache'); } $cache = null; $options = $this->getOption('settings'); if (true == $options['cache']['enabled']) { $cache = Zend_Cache::factory( $options['cache']['frontend']['type'], $options['cache']['backend']['type'], $options['cache']['frontend']['options'], $options['cache']['backend']['options'] ); } else { // Fallback settings for some (maybe development) environments which have no cache management installed. if (false === is_writeable(APPLICATION_CACHE)) { error_log('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); exit('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); } $frontendOptions = array( 'lifetime' => 600, 'automatic_serialization' => true, 'cache_id_prefix' => 'front_cache', 'cache' => true ); $backendOptions = array( 'cache_dir' => APPLICATION_CACHE, 'file_locking' => true, 'read_control' => true, 'read_control_type' => 'crc32', 'hashed_directory_level' => 1, 'hashed_directory_perm' => 0700, 'file_name_prefix' => 'ocs', 'cache_file_perm' => 0700 ); $cache = Zend_Cache::factory( 'Core', 'File', $frontendOptions, $backendOptions ); } Zend_Registry::set('cache', $cache); Zend_Locale::setCache($cache); Zend_Locale_Data::setCache($cache); Zend_Currency::setCache($cache); Zend_Translate::setCache($cache); Zend_Translate_Adapter::setCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); Zend_Paginator::setCache($cache); return $cache; } /** * @throws Zend_Application_Bootstrap_Exception + * @throws Zend_Exception */ protected function _initDbAdapter() { $db = $this->bootstrap('db')->getResource('db'); if ((APPLICATION_ENV == 'development')) { $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); $profiler->setEnabled(true); // Attach the profiler to your db adapter $db->setProfiler($profiler); } Zend_Registry::set('db', $db); Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultAdapter($db); $config = Zend_Registry::get('config'); //$db2 = $this->bootstrap('db')->getResource('db2'); try { $db2 = Zend_Db::factory($config->settings->db2->adapter, array( 'host' => $config->settings->db2->params->host, 'username' => $config->settings->db2->params->username, 'password' => $config->settings->db2->params->password, 'dbname' => $config->settings->db2->params->dbname, 'charset' => $config->settings->db2->params->charset, 'type' => $config->settings->db2->params->type, 'persistent' => $config->settings->db2->params->persistent, 'isDefaultTableAdapter' => FALSE )); Zend_Registry::set('db2', $db2); $db2->getConnection(); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('logger')->err('Error Init DB2: '. $e->getTraceAsString()); //$e->getMessage(); } catch (Zend_Exception $e) { Zend_Registry::get('logger')->err('Error Init DB2: '. $e->getTraceAsString()); //$e->getMessage(); } } protected function _initRouter() { /** @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); $this->_router = $cache->load('ocs_api_router'); $bootstrap = $this; $bootstrap->bootstrap('FrontController'); if (false === $this->_router) { $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter(); $options = $this->getOptions()['resources']['router']; if (!isset($options['routes'])) { $options['routes'] = array(); } if (isset($options['chainNameSeparator'])) { $this->_router->setChainNameSeparator($options['chainNameSeparator']); } if (isset($options['useRequestParametersAsGlobal'])) { $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']); } $this->_router->addConfig(new Zend_Config($options['routes'])); $cache->save($this->_router, 'ocs_api_router', array(), 7200); } $this->getContainer()->frontcontroller->setRouter($this->_router); return $this->_router; } protected function _initGlobalAppConst() { $appConfig = $this->getResource('config'); $imageConfig = $appConfig->images; defined('IMAGES_UPLOAD_PATH') || define('IMAGES_UPLOAD_PATH', $imageConfig->upload->path); defined('IMAGES_MEDIA_SERVER') || define('IMAGES_MEDIA_SERVER', $imageConfig->media->server); // ppload - $pploadConfig = $appConfig->third_party->ppload; - defined('PPLOAD_API_URI') || define('PPLOAD_API_URI', $pploadConfig->api_uri); - defined('PPLOAD_CLIENT_ID') || define('PPLOAD_CLIENT_ID', $pploadConfig->client_id); - defined('PPLOAD_SECRET') || define('PPLOAD_SECRET', $pploadConfig->secret); - defined('PPLOAD_DOWNLOAD_SECRET') || define('PPLOAD_DOWNLOAD_SECRET', $pploadConfig->download_secret); + $configFileserver = $appConfig->settings->server->files; + defined('PPLOAD_API_URI') || define('PPLOAD_API_URI', $configFileserver->api->uri); + defined('PPLOAD_CLIENT_ID') || define('PPLOAD_CLIENT_ID', $configFileserver->api->client_id); + defined('PPLOAD_SECRET') || define('PPLOAD_SECRET', $configFileserver->api->client_secret); + defined('PPLOAD_HOST') || define('PPLOAD_HOST', $configFileserver->host); + defined('PPLOAD_DOWNLOAD_SECRET') || define('PPLOAD_DOWNLOAD_SECRET', $configFileserver->download_secret); } protected function _initGlobalApplicationVars() { $modelDomainConfig = new Application_Model_DbTable_ConfigStore(); Zend_Registry::set('application_store_category_list', $modelDomainConfig->fetchAllStoresAndCategories()); Zend_Registry::set('application_store_config_list', $modelDomainConfig->fetchAllStoresConfigArray()); Zend_Registry::set('application_store_config_id_list', $modelDomainConfig->fetchAllStoresConfigByIdArray()); } protected function _initStoreDependentVars() { /** @var $front Zend_Controller_Front */ $front = $this->bootstrap('frontController')->getResource('frontController'); $front->registerPlugin(new Application_Plugin_InitGlobalStoreVars()); } } diff --git a/application/configs/application.ini b/application/configs/application.ini index 282d24c..b0cd545 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -1,252 +1,262 @@ [production] +;phpSettings.date.timezone = "UTC" + phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" +autoloaderNamespaces[] = "Local_" +autoloaderNamespaces[] = "Ppload_" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" -autoloaderNamespaces[] = "Local_" -autoloaderNamespaces[] = "Ppload_" - ; FRONTCONTROLLER: resources.frontController.params.displayExceptions = 0 resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" ; resources.frontController.modulecontrollerdirectoryname = ; resources.frontController.moduledirectory = resources.frontController.defaultcontrollername = 'ocsv1' resources.frontController.defaultaction = 'index' ; resources.frontController.defaultmodule = 'default' ; resources.frontController.baseurl = ; resources.frontController.returnresponse = false ; resources.frontController.throwexceptions = false ; resources.frontController.actionhelperpaths. = resources.frontController.noErrorHandler = true resources.frontController.noViewRenderer = true resources.frontController.useDefaultControllerAlways = true ; resources.frontController.disableOutputBuffering = false ; resources.frontController.prefixDefaultModule = false ; DB options: resources.db.adapter = "pdo_mysql" resources.db.isDefaultTableAdapter = true resources.db.params.host = resources.db.params.username = resources.db.params.password = resources.db.params.dbname = ; resources.db.params.port = resources.db.params.charset = "utf8" resources.db.params.type = "pdo_mysql" resources.db.params.driver_options.1002 = "SET NAMES utf8" ; resources.db.params.options.