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); } }
/** * 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/');
private function _deploy($schemaDir, $configs, $currentWorkingDirectory) { if (false !== strpos($currentWorkingDirectory, 'tools')) { $pos = strpos($currentWorkingDirectory, 'tools'); $currentWorkingDirectory = substr($currentWorkingDirectory, 0, $pos - 1); chdir($currentWorkingDirectory); } $_targetDir = Dfi_App_Config::getString('generator.targetDir', $currentWorkingDirectory . '/application/models'); $question = "Target DirProject name ({$_targetDir}): "; $targetDir = $this->_readInput($question); if ('' === $targetDir) { $targetDir = $_targetDir; } unset($_targetDir, $question); Dfi_App_Config::set('generator.targetDir', $targetDir); $propelCnf = array(); $classmap = array(); $sourceDir = ''; foreach ($configs as $key => $config) { $package = Dfi_App_Config::getString('generator.targetPackage.' . $key); $sourceDir = $schemaDir . '/' . $config . '/build'; $map = $targetDir . '/' . $config . '/map'; if (!file_exists($map)) { mkdir($map, 0777, true); } $om = $targetDir . '/' . $config . '/om'; if (!file_exists($om)) { mkdir($om, 0777, true); } $copy = array(); $copy[] = 'cp -n ' . $sourceDir . '/classes/' . $package . '/*.php ' . $targetDir . '/' . $config; $copy[] = 'cp -f ' . $sourceDir . '/classes/' . $package . '/map/*.php ' . $targetDir . '/' . $config . '/map'; $copy[] = 'cp -f ' . $sourceDir . '/classes/' . $package . '/om/*.php ' . $targetDir . '/' . $config . '/om'; $file = $sourceDir . '/conf/classmap-' . $config . '-conf.php'; $arr = (include $file); $classmap = array_merge($classmap, $arr); $propelCnf[$config] = $sourceDir . '/conf/' . $config . '-conf.php'; foreach ($copy as $command) { $out = array(); $val = 0; exec($command, $out, $val); if ($val) { foreach ($out as $line) { ZFscaffold_ZfTool_Helpers_Messages::printOut($line, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } } } } $default = Dfi_App_Config::getString('generator.default'); $dst = realpath($targetDir . '/..') . '/configs/' . $default . '-conf.php'; $src = $propelCnf[$default]; rename($src, $dst); $dst = realpath($targetDir . '/..') . '/configs/classmap-' . $default . '-conf.php'; $map = '<? return ' . var_export($classmap, true) . ';'; $res = file_put_contents($dst, $map); if (!$res) { ZFscaffold_ZfTool_Helpers_Messages::printOut('error writing classmap:' . $dst, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } //$currentWorkingDirectory = getcwd(); $configDir = str_replace('/', DIRECTORY_SEPARATOR, $currentWorkingDirectory . '/application/configs/'); $configFilePath = $configDir . 'application.ini'; $rawConfig = parse_ini_file($configFilePath, true, INI_SCANNER_RAW); $rawConfig['production']['db.config'] = 'APPLICATION_PATH' . ' "/configs/' . $default . '-conf.php"'; $res = array(); foreach ($rawConfig as $key => $val) { if (is_array($val)) { $res[] = '[' . $key . ']'; foreach ($val as $skey => $sval) { $res[] = $skey . ' = ' . $this->_parseIniValue($sval); } } else { $res[] = $key . ' = ' . $this->_parseIniValue($val); } } $res = file_put_contents($configFilePath, implode("\r\n", $res)); if (!$res) { ZFscaffold_ZfTool_Helpers_Messages::printOut('error writing app config :' . $configFilePath, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } foreach ($configs as $config) { $sourceDir = $schemaDir . '/' . $config . '/build'; $command = 'rm -rf ' . $sourceDir; $out = array(); $val = 0; exec($command, $out, $val); if ($val) { foreach ($out as $line) { ZFscaffold_ZfTool_Helpers_Messages::printOut($line, ZFscaffold_ZfTool_Helpers_Messages::MSG_ERROR); } } } }