| Server IP : 172.67.178.83 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/gotofindhomes.com/components/System/ |
Upload File : |
<?php
/**
* Documentation
* @author norbis, evgeniy
* @category
* @package System
* @subpackage
* @copyright Copyright (c) 2005-2009 ITCrimea Ukraine Inc. (http://www.itcrimea.com)
* @license
*/
abstract class System
{
/**
* Config file name
*/
protected $_filenameConfig = '_config.ini';
/**
* Relative path (from AppFolder) in file system
*/
protected $_folderConfig = '/configs';
/**
* Флаг доступности. Устанавливаеться через _config.ini
*
* @var bool
*/
protected $_enabled = null;
/**
* Базовый URL (baseURL)
*
* @var string
*/
protected $_BaseUrl;
/**
* Инстанс Zend_Config_Ini считанный из файла
*
* @var Zend_Config_Ini
*/
protected $_config = null;
/**
* Конструктор объекта. При создании экземпляра объекта загружаеться конфиг.
*
* @return mixed
*/
public function __construct()
{
$this->loadConfig();
}
/**
* Абстрактная функция "Запуск" для переопределения в потомках.
*
* @return mixed
*/
abstract protected function _run();
/**
* Функция "Инициализация" для переопределения в потомках
* Documentation
*
* @return void
*/
public function init()
{
if ($this->_enabled) {
$this->_init();
}
}
/**
* Функция старта. Проверка доступности.
*
* @return void
*/
public function run()
{
if ($this->_enabled) {
$this->_run();
}
}
/**
* Функция пре-деспечеризации. Проверка доступности.
* @author keeper
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ($this->_enabled) {
$this->_preDispatch($request);
}
}
/**
* Получает имя папки для конфига.
*
* @return string
*/
protected function getConfigDirectory()
{
$ConfigDirectory = Zend_Registry::get('AppFolder') . $this->_folderConfig;
$ConfigDirectory .= '/';
$arrayParts = explode('_', get_class($this));
$ConfigDirectory .= reset($arrayParts);
return $ConfigDirectory;
}
/**
* Возвращает созданный объект конфига (protected)
* @author [email protected]
* @return Zend_Config_Ini
*/
public function getConfig()
{
return $this->_config;
}
/**
* Получает, устаналивает и возвращает BaseUrl
*
* @return string
*/
protected function getBaseUrl()
{
if (!$this->_BaseUrl){
$this->_BaseUrl = Zend_Registry::get('baseUrl');
}
return $this->_BaseUrl;
}
/**
* Загрузка файла конфига для наследков класса System. Для каждого класса используеться подсекция [Class_Name].
* Проверяет на существование след. файлы: HTTP_HOST + Base_Url + Config_Name, HTTP_HOST + Config_Name, Config_Name
* @author [email protected]
* @return mixed
*/
public function loadConfig()
{
$serverHTTPHost = '';
if (isset($_SERVER['HTTP_HOST'])){
$serverHTTPHost = $_SERVER['HTTP_HOST'];
}
$baseUrl = str_replace('/', '_', $this->getBaseUrl());
$filenameConfig = $this->getConfigDirectory() . '/' . $serverHTTPHost . $baseUrl . $this->_filenameConfig;
if (!file_exists($filenameConfig)){
$filenameConfig = $this->getConfigDirectory() . '/' . $serverHTTPHost . $this->_filenameConfig;
if (!file_exists($filenameConfig)){
$filenameConfig = $this->getConfigDirectory() . '/' . $this->_filenameConfig;
if (!file_exists($filenameConfig)){
throw new Zend_Exception('File config with filename ' . $filenameConfig . ' not found in the file system');
}
}
}
$this->_config = new Zend_Config_Ini($filenameConfig, array(get_class($this)));
$this->_enabled = $this->_config->get('enabled', true);
}
}