Exemplo n.º 1
0
 protected function _compile()
 {
     $moConvert = new Ht_Utils_MoConverter();
     $langAvalid = $this->getSysSetting(Ht_Model_SystemSetting::KEY_LANGUAGES_AVAILABLE, array());
     $language = count($langAvalid) > 0 ? explode(",", $langAvalid) : array();
     if (is_array($language)) {
         foreach ($language as $lang) {
             $local_dir = APPLICATION_PATH . '/languages/' . $lang . '/';
             if (!realpath($local_dir)) {
                 mkdir($local_dir, true);
             }
             $po_creater = new Ht_Utils_PoCreator(array(Ht_Utils_PoCreator::LANGUAGE_KEY => $lang, Ht_Utils_PoCreator::LOCAL_DIR_KEY => APPLICATION_PATH . '/languages/' . $lang . '/', Ht_Utils_PoCreator::ADAPTER_KEY => new Zend_Db_Table(array('name' => 'sys_languages'))));
             $po_creater->setProperties(array(Ht_Utils_PoCreator::PROPERTY_CREATE_DATE => date("Y-m-d H:i:s"), Ht_Utils_PoCreator::PROPERTY_REVISION_DATE => date("Y-m-d H:i:s"), Ht_Utils_PoCreator::PROPERTY_PROJECT_ID => Ht_Utils_SystemSetting::getSetting(Ht_Model_SystemSetting::KEY_SOFTWARE_VERSION)));
             $pofile = $po_creater->create();
             $moConvert->convert($pofile);
         }
     }
 }
Exemplo n.º 2
0
 public function logoutAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     /* clear cookie language */
     $dfLang = Ht_Utils_SystemSetting::getSetting(Ht_Model_SystemSetting::KEY_DEFAULT_LANGUAGE, self::DEFAULT_LANG);
     setcookie("_lang", $dfLang, time() + 2592000, "/");
     try {
         $sysaccess = new Default_Model_DbTable_SysAccess();
         $sysaccess->update(array("logout_time" => new Zend_Db_Expr("NOW()")), $sysaccess->getAdapter()->quoteInto("access_id=?", $identity->access_id));
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` logout success.', trim($identity->u_name . ' ' . $identity->u_lastname))), 'priority' => Zend_Log::INFO)));
         $auth->clearIdentity();
     } catch (Exception $e) {
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` logout error.', trim($identity->u_name . ' ' . $identity->u_lastname)), $e->getMessage()), 'priority' => Zend_Log::ERR)));
     }
     $this->_redirect($this->_baseUrl);
 }
Exemplo n.º 3
0
 protected function _processAuthWithDb($username, $password)
 {
     $defaultHomepage = Ht_Utils_SystemSetting::getSetting(Ht_Model_SystemSetting::KEY_DEFAULT_ADMIN_PAGE, $this->_firstPage);
     $db = Zend_Db_Table::getDefaultAdapter();
     // setup Zend_Auth adapter for a database table;
     //Zend_Loader :: loadClass("Ht_Auth_Adapter_DbTable");
     $adapter = new Zend_Auth_Adapter_DbTable($db, 'ht_user', 'use_login', 'use_password_hash', 'MD5(CONCAT(?, salt))');
     //     	$adapter = new Zend_Auth_Adapter_DbTable($db);
     //     	$adapter->setTableName('ht_user');
     //     	$adapter->setIdentityColumn('use_login');
     //     	$adapter->setCredentialColumn('use_password');
     //     	$adapter->setCredentialTreatment('CONCAT(SUBSTRING(use_password, 1, 40), SHA1(CONCAT(SUBSTRING(use_password, 1, 40), ?)))');
     // Set the input credential values to authenticate against
     $adapter->setIdentity($username);
     $adapter->setCredential($password);
     // do the authentication
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session());
     if ($auth->hasIdentity()) {
         $auth->clearIdentity();
     }
     $result = $auth->authenticate($adapter);
     if ($result->isValid()) {
         $storage = $auth->getStorage();
         // store the identity as an object where the password column has
         // been omitted
         $resultRow = $adapter->getResultRowObject(null, array('use_password_hash', 'salt'));
         if ($resultRow->use_status == 'N') {
             $this->redirecWithErrorCode(self::ERR_CODE_INACTIVE_USER);
             return;
         }
         // Set access log.
         $this->setSystemAccessLog($resultRow);
         $storage->write($resultRow);
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` login success.', trim($resultRow->use_name . ' ' . $resultRow->use_lastname))), 'priority' => 6)));
         $this->_redirect($defaultHomepage);
     } else {
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('User name `%s` login fail.', trim($username)), implode(", ", (array) $result->getMessages())), 'priority' => Zend_Log::WARN)));
         $this->redirecWithErrorCode(self::ERR_CODE_USER_PASS_INVALID);
     }
     return;
 }