public static function hash($str) { $salt = Configure::read(CMS::SaltConfigureKey); $salt = md5($salt); $result = crypt($str, $salt); return $result; }
protected function autoloadConfig() { $this->config = \Faid\Configure\Configure::read(self::ConfigurePath); $valid = isset($this->config['servers']) && is_array($this->config['servers']); if (!$valid) { throw new Exception('Memcache config not valid'); } $this->prefix = !empty($this->config['prefix']) ? $this->config['prefix'] : ''; }
protected function getTimeLimit() { try { $result = Configure::read(self::TimeoutConfigureKey); } catch (ConfigureException $e) { $result = 1; } return $result; }
public function __construct($data = []) { parent::__construct($data); try { $this->limit = Configure::read(self::ConfigureKey); } catch (\Exception $e) { $this->limit = self::DefaultLimit; } }
protected function autoloadMenuItems() { try { $menuItems = Configure::read(self::AutoloadMenuItemsConfigureKey); } catch (ConfigureException $e) { return; } $menuItems = \EventController::callFilter(self::FilterName, $menuItems); foreach ($menuItems as $item) { $this->items->add($item); } }
public static function getViewPath() { try { $result = Configure::read(self::ConfigureKey); } catch (ConfigureException $e) { $result = ''; } if (empty($result)) { $result = VIEW_PATH; } return $result; }
/** * Check if connection with mysql server was established or not */ public static function checkConnection() { if (!empty(self::$connection)) { // connection established, exit function } else { // no, we have to connect Mysql-server $data = Configure::read('DB'); self::$connection = new \mysqli($data['host'], $data['user'], $data['password'], $data['database'], isset($data['port']) ? $data['port'] : null, isset($data['socket']) ? $data['socket'] : null); if (self::$connection->connect_error) { $msg = sprintf('DB failed to connect mysql server. Mysql respone - %s', self::$connection->connect_error); throw new \Exception($msg); } self::$connection->set_charset('utf8'); } }
/** * @desc Обрабатываем запрос и пересылаем на вывод * @return */ public function post($sql) { $this->szError = ''; $this->aResult = array(); // Замеряем время $timeStart = microtime(true); $connection = Configure::read('DB'); $mysql = new mysqli($connection['host'], $connection['user'], $connection['password'], $connection['database']); $mysql->set_charset('utf8'); $result = $mysql->query($sql); $timeFinish = microtime(true); // Если у запроса есть результаты if ($result !== FALSE) { // Если имеется результат запроса if (!is_bool($result)) { $row = $result->fetch_assoc(); while ($row) { $this->aResult[] = $row; $row = $result->fetch_assoc(); } } } else { $result = array(); $this->szError = $mysql->error; } array_push($this->aSession, $sql); $_SESSION['cms_sql_query_time'] = $timeFinish - $timeStart; // Выводим результат запроса ob_start(); $this->outputResults(); $content = ob_get_clean(); // Получаем последний список запросов ob_start(); $this->outputSessionRequests(); $requests = ob_get_clean(); // Вывод блока ошибки ob_start(); $this->outputError(); $error = ob_get_clean(); // Время запроса $time = $_SESSION['cms_sql_query_time']; // Формируем результат $output = array('request' => $sql, 'time' => $time, 'sql_log' => $requests, 'error' => $error, 'size' => sizeof($result), 'results' => $content); print json_encode($output); die; }
protected function loadConfigurationFile() { try { $sql = sprintf('truncate %s ', Job::TableName); DB::post($sql); $path = \Faid\Configure\Configure::read(self::ConfigureKey); $validator = new ReadableFile($path); if ($validator->isValid()) { include $path; } \CMSLog::addMessage(__CLASS__, 'Schedule restarted'); } catch (\Exception $e) { \CMSLog::addMessage(__CLASS__, $e); return ['error' => 'internal error']; } return; }
/** * */ public function __construct($urlInfo = array()) { parent::__construct($urlInfo); // confirmation page $this->addGet('code', 'confirm'); $this->addPost('code', 'confirm'); $this->addGet('email_confirmation_code', 'confirmEmail'); // after regstration page $this->addGet('success', 'showSuccess'); // submit page $this->AddPost('login,password,email', 'signup'); $register = new SystemRegister('Applications/users'); $captcha_provider = $register->captcha_provider->value; if ('recaptcha' == $captcha_provider) { require_once LIB_PATH . '3rdparty/recaptchalib.php'; $config = \Faid\Configure\Configure::read('Recaptcha'); $this->recaptchaPublicKey = $config['public_key']; $this->recaptchaPrivateKey = $config['private_key']; } }
/** * @param $szContent * @param $aVariables * * @return string * @throws \Exception */ public static function parsePHPCode($szContent, $viewVariables = null) { self::callEvent('UParser::before_parse_code', $szContent, $viewVariables); try { $baseDir = Configure::read('UParser.tmp_dir'); } catch (ConfigureException $e) { throw new \Exception('Directive "UParser.tmp_dir" not defined '); } $szOld = ob_get_contents(); ob_clean(); $__szPath = $baseDir . uniqid(); file_put_contents($__szPath, $szContent); if (!empty($viewVariables)) { extract($viewVariables); } include $__szPath; unlink($__szPath); $szContent = ob_get_contents(); ob_clean(); print $szOld; self::callEvent('UParser::after_parse_code', $szContent, $viewVariables, $szContent); return $szContent; }
protected static function setCookie($value, $time) { $domain = Configure::read(\Extasy\CMS::MainDomainConfigureKey); $domain = '.' . $domain; setcookie(self::cookieName, $value, $time, '/', $domain); }
public static function getFieldsInfo() { return \Faid\Configure\Configure::read(static::ModelConfigureKey); }
/** * @return \Faid\Cache\Engine\CacheEngineInterface */ protected static function factoryInstance() { $engineClass = Configure::read(self::ConfigurePath . '.Engine'); self::$instance = new $engineClass(); }
public function __construct() { $key = self::ConfigurePath . '.BaseDir'; $this->basePath = Configure::read($key); }
public static function getUnitTestCookie() { $string = SITE_NAME . Configure::read('Security.Salt'); return md5($string); }
/** * */ protected function getInitialCookies() { return sprintf(".%s\tTRUE\t/\tFALSE\t%d\t%s\t%s", \Faid\Configure\Configure::read('MainDomain'), time() + 3600, CMS::UnitTestCookieName, CMS::getUnitTestCookie()); }
/** * Setups handlers for errors and exceptions */ protected static function linkErrorHandlers() { $errorHandler = Configure::read('Error.Handler'); $errorLevel = Configure::read('Error.Level'); $exceptionHandler = Configure::read('Exception.Handler'); // enable error handler set_error_handler($errorHandler, $errorLevel); // enable exception handler set_exception_handler($exceptionHandler); }
public function __construct($accessToken = null) { $this->config = \Faid\Configure\Configure::read(self::ConfigureKey); $this->config['redirect_url'] = sprintf('http://%s/oauth/vkontakte/', \Extasy\CMS::getMainDomain()); $this->token = $accessToken; }
protected static function isDebugEnabled() { $debug = Configure::read('Debug'); return $debug; }
public function __construct() { $config = Configure::read(self::ConfigureKey); $this->depth = $config['depth']; $this->title = $config['title']; }
public function __construct($accessToken = null) { $this->config = Configure::read(self::ConfigureKey); FacebookSession::setDefaultApplication($this->config['app_id'], $this->config['app_secret']); $this->token = $accessToken; }
public function testSetAndEditArrays() { $data = array('item1' => 1, 'item2' => 2, 'item3' => 3, 'level2' => array('subitem' => 3, 'sublevel' => array(1, 2, 3))); Configure::write('test', $data); $this->assertEquals($data['level2'], Configure::read('test.level2')); }
protected function getLogoutUrl() { return Configure::read(self::LogoutUrlKey); }