public function indexAction() { if ($this->isUserAny()) { $this->messages->addMessage('debug', 'jestes juz zalogowany'); //$this->messages->addMessage('notice', 'logged'); $this->_redirect('/admin'); } $form = $this->getFormLogin(); if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) { $this->view->assign('form', $form); } else { $values = $form->getValues(); $adapter = new Dfi_Auth_Adapter_Db($values['login'], Dfi_App_Config::getString('cake.salt') . $values['password'], array('table' => 'VAR_authTable', 'loginField' => 'VAR_authLoginField', 'passwordField' => 'VAR_authPasswordField', 'activityField' => 'VAR_authActivityField', 'passwordHash' => 'VAR_authPasswordHash')); $result = Zend_Auth::getInstance()->authenticate($adapter); if (Zend_Auth::getInstance()->hasIdentity()) { $url = $this->_getParam('url', false); if ($url) { $this->_redirect($url); } $this->_redirect($this->view->url(array('controller' => 'index'))); } $this->messages->addMessage('debug', implode(';', $result->getMessages())); $this->messages->addMessage('error', 'login'); $this->view->assign('form', $form); } }
public function preDispatch(Zend_Controller_Request_Abstract $request) { Zend_Auth::getInstance()->setStorage(new Dfi_Auth_Storage_Cookie('user')); /** @var Zend_Controller_Request_Http $request */ $request = $this->getRequest(); $bypass = $this->isBypassRequest($request->getModuleName(), $request->getControllerName(), $request->getActionName()); if (!Zend_Auth::getInstance()->hasIdentity() && !$bypass) { if ($request->isXmlHttpRequest()) { $response = $this->getResponse(); $data = array('auth' => true); $output = json_encode($data); $response->setHeader('Content-Type', 'application/json', true); $this->getResponse()->setBody($output); $this->getResponse()->sendResponse(); exit; } else { if ($request->getControllerName() == 'index' && $request->getActionName() == 'index') { if (!Zend_Layout::getMvcInstance()) { $layoutPath = Dfi_App_Config::get('layout.layoutPath'); Zend_Layout::startMvc($layoutPath); } } $request->setControllerName('login'); $request->setActionName('index'); $request->setModuleName('default'); } } }
public function hash($password) { $salt = Dfi_App_Config::get('main.auth.salt'); $hash = Dfi_App_Config::get('main.auth.hash'); $enc = hash($hash, $salt . $password . $salt, true); $x = strlen($enc); return $enc; }
public function __construct($username, $password) { $this->username = $username; $this->password = $password; if (Dfi_App_Config::get('main.useFakeLogin')) { $this->useFakeLogin = true; } }
private function setup() { $this->cwd = getcwd(); $this->_initPaths($this->cwd . '/application'); $this->_readAppConfig(); $includeConfig = Dfi_App_Config::get('phpSettings.include_path', ''); $this->_initIncludePaths($includeConfig); Zend_Loader_Autoloader::getInstance()->registerNamespace('Dfi_')->suppressNotFoundWarnings(true); }
public function __construct(array $options = array(), $username = null, $password = null) { $options = Dfi_App_Config::getConfig(true, 'main.auth'); $this->setOptions($options); if ($username !== null) { $this->setUsername($username); } if ($password !== null) { $this->setPassword($password); } }
/** * return AMI client and create if not exist * @return Dfi_Asterisk_Client */ private static function getAmiClient() { if (!Dfi_Asterisk_Ami::$amiClient instanceof ClientImpl) { $config = self::getConfig(); $c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/sys/log4php-pami.conf.php'); $config["log4php.properties"] = $c->toArray(); $config["log4php.properties"]['appenders']['appender']['default']['file'] = Dfi_App_Config::get('paths.log') . 'ami.log'; $client = new Dfi_Asterisk_Client($config); if (!Dfi_App_Config::getString('asterisk.fake', true)) { $client->open(); } Dfi_Asterisk_Ami::$amiClient = $client; } return Dfi_Asterisk_Ami::$amiClient; }
<?php define('_BASE_PATH', realpath(APPLICATION_PATH . '/../') . '/'); define('_LIBRARY_PATH', realpath(_BASE_PATH . 'library/') . '/'); define('_LOG_PATH', realpath(_BASE_PATH . 'logs/') . '/'); define('_STATIC_PATH', realpath(_BASE_PATH . 'static/') . '/'); define('_DATA_PATH', realpath(_BASE_PATH . 'data/') . '/'); // --------- logs define('_APP_LOG_FILE', _LOG_PATH . 'app.log'); define('_ERROR_LOG_FILE', _LOG_PATH . 'error.log'); define('_DEBUG_LOG_FILE', _LOG_PATH . 'debug.log'); define('_SHUTDOWN_LOG_FILE', _LOG_PATH . 'shutdown.log'); define('_PROPEL_LOG_FILE', _LOG_PATH . 'propel.log'); define('_AD_LOG_FILE', _LOG_PATH . 'ad.log'); // --------- static define('_CSS', Dfi_App_Config::getString('http.static') . 'css/'); define('_IMG', Dfi_App_Config::getString('http.static') . 'img/'); define('_IMG_LAYOUT', _IMG . 'layout/'); define('_SWF', Dfi_App_Config::getString('http.static') . 'swf/'); define('_XML', Dfi_App_Config::getString('http.static') . 'xml/'); define('_JS', Dfi_App_Config::getString('http.static') . 'js/'); define('_IMG_TMP', _STATIC_PATH . 'tmp/'); define('_CKEDITOR', _JS . 'lib/ckeditor/'); define('_CODEMIRROR', _JS . 'lib/codemirror/');
/** * @param null $mode */ public static function setMode($mode) { self::$mode = $mode; }
protected function _initDatabase() { if (Zend_Loader::isReadable(Dfi_App_Config::get('db.config'))) { try { $logger = Zend_Registry::get('propelLogger'); $adapter = new Dfi_Log_Adapter_Propel2Zend($logger); require_once 'Propel.php'; Propel::setLogger($adapter); Propel::init(Dfi_App_Config::get('db.config')); } catch (Exception $e) { throw new Exception('Can\'t setup database: ' . $e->getMessage()); } } else { throw new Exception('database config read failed'); } }
public static function shutdown() { $isError = false; if ($error = error_get_last()) { switch ($error['type']) { case E_ERROR: // 1 // 1 case E_CORE_ERROR: // 16 // 16 case E_COMPILE_ERROR: // 64 // 64 case E_USER_ERROR: //256 //256 case E_PARSE: //4 $isError = true; break; case E_WARNING: //2 //2 case E_NOTICE: //8 //8 case E_CORE_WARNING: //32 //32 case E_COMPILE_WARNING: //128 //128 case E_USER_WARNING: //512 //512 case E_USER_NOTICE: //1024 //1024 case E_STRICT: //2048 break; } } if ($isError) { http_response_code(500); $guid = false; try { $e = new ErrorException($error['message'], 0, 1, $error['file'], $error['line']); //$guid = Dfi_Error_Report::saveException($e); } catch (Exception $e) { $guid = false; } if (!preg_match('/cli/', php_sapi_name())) { Zend_Registry::get('shutdownLogger')->log($error['message'] . ' : ' . $error['file'] . ' : (' . $error['line'] . ')', Zend_Log::CRIT); if (!Dfi_App_Config::get('main.showDebug')) { $url = "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s://" : "://") . $_SERVER['HTTP_HOST'] . '/'; header("Location: " . $url . "error/error" . ($guid ? '/guid/' . $guid : '')); exit; } else { ob_clean(); echo '<pre>REPORT: ' . ($guid ? $guid : 'brak') . "\n"; echo 'REQUEST: ' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "\n"; echo 'REFERER: ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . "\n"; echo 'ERROR: ' . $e->getMessage() . ' : ' . $e->getFile() . ' : (' . $e->getLine() . ')' . "\n" . $e->getTraceAsString() . '</pre>'; } } } }
public function resetPassword($login) { $options = array('unicodePwd' => $this->encodeUnicodePassword(Dfi_App_Config::get('ad.defaultPassword')), 'pwdLastSet' => 0); $res = $this->updateByLogin($login, $options); return $res; }
private function _init($schemaDir) { defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production'); $configLocation = $schemaDir . '/' . self::CONFIG_FILE_NAME; if (file_exists($configLocation)) { $this->config = new Zend_Config_Ini($configLocation, null, array('skipExtends' => true, 'allowModifications' => true)); } else { $this->config = new Zend_Config(array(), true); } Dfi_App_Config::setConfig($this->config); }
private function _setup() { $this->cwd = getcwd(); $this->_initPaths($this->cwd . '/application'); $this->_readAppConfig(); $includeConfig = Dfi_App_Config::get('phpSettings.include_path', ''); $this->_initIncludePaths($includeConfig); Zend_Loader_Autoloader::getInstance()->registerNamespace('Dfi_')->suppressNotFoundWarnings(true); foreach (Dfi_App_Config::getConfig(true, false, array(), 'scaffold') as $key => $value) { $method = '_' . $key; if (property_exists($this, $method)) { $this->{$method} = $value; } } $propelConfig = Dfi_App_Config::get('db.config', null); if (null === $propelConfig) { $projectProvider = $this->_registry->getProviderRepository()->getProvider('propelorm'); $projectProvider->generate(); } $this->_initPropel($propelConfig); $this->_packageName = $this->_getCamelCase(Propel::getConfiguration()['datasources']['default']); }