Пример #1
0
 public function authAction()
 {
     $params = $this->_getAllParams();
     if (empty($params['uname']) || empty($params['upwd'])) {
         $this->forward('login');
         return;
     }
     //输入数据需要进行验证
     $loginname = addslashes($params['uname']);
     $password = md5(trim($params['upwd']));
     //生产COOKIE序列号
     $snlogin = md5($loginname . $password);
     $snlogin = substr($snlogin, 2, 9);
     $token = Token::create($snlogin);
     if ($token->is_logined()) {
         setcookie('tsn', $snlogin, -1, '/');
         $this->forward('index', 'company', 'index');
         return;
     }
     $adapter = new Zend_Auth_Adapter_DbTable(GlobalFactory::get_db());
     $adapter->setTableName(DBTables::USER)->setIdentityColumn('username')->setCredentialColumn('passwd')->setIdentity($loginname)->setCredential($password);
     //进行查询验证
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($adapter);
     //没通过验证就跳回到登录页面
     if (!$result->isValid()) {
         $this->forward('login');
         return;
     }
     //通过验证
     $res_obj = $adapter->getResultRowObject();
     //帐号被禁用
     if (0 != $res_obj->status) {
         $this->forward('login');
         return;
     }
     setcookie('tsn', $snlogin, -1, '/');
     $fields = array('sn' => $snlogin, 'uid' => $res_obj->id, 'uname' => $res_obj->username, 'nickname' => $res_obj->nickname);
     $token->register($fields);
     //跳转到默认首页
     $this->forward('index', 'company', 'index');
 }
Пример #2
0
 public function __construct($id = null, $getlists = TRUE)
 {
     //if row is null then get an empty post object
     if ($id != null) {
         $select_sql = "SELECT * from pbpost where id = {$id}";
         if ($result = $GLOBALS['mysqli']->query($select_sql)) {
             $row = $result->fetch_assoc();
             $this->ID = $row['id'];
             $this->Title = $row['title'];
             $this->SubTitle = $row['subtitle'];
             $this->PageName = $row['pagename'];
             $this->Blog = $row['blog'];
             $this->ReadyForPublish = isset($row['readyforpublish']) ? TRUE : FALSE;
             $this->CreateDate = $row['createdate'];
             $this->ModifiedDate = $row['modifieddate'];
             $this->PublishDate = $row['publishdate'];
             $this->UnpublishDate = $row['unpublishdate'];
             $this->Categories = CategoryFactory::GetCategoriesByPost($this->ID);
             $this->Types = TypeFactory::GetTypesByPost($this->ID);
             if ((!empty($this->Title) || !isset($this->Title)) && (!empty($this->Blog) || !isset($this->Blog))) {
                 $this->CanDelete = TRUE;
             }
             //we're going to republish all every single time
             //but why
             //the related post column for previously published will then have refs to newer links
             //but first check if readyforpublish is true
             //first check that a blog has a title and subtitle and or post
             if (!empty($this->Title) && (!empty($this->SubTitle) || !empty($this->Blog))) {
                 //we're not going to use the ready flag to check if it can be published
                 //the ready flag is only used in a batch publish - IMPORTANT
                 $this->CanPublish = TRUE;
             }
             //can delete if it is not published
             //or if the unpublish date is greater than publish date
             if (!isset($this->PublishDate) || $this->UnpublishDate > $this->PublishDate || sizeof($this->Categories) == 0) {
                 $this->CanDelete = TRUE;
             }
             //can unpublish if its been published - that's all nothing about being outdated
             if (isset($this->PublishDate)) {
                 $this->CanUnpublish = TRUE;
             }
         } else {
             //TODO: error in sql execute
         }
     } else {
         $this->Categories = array();
         //TODO: I dont think this is required
     }
     require_once 'pbglobal.php';
     $globalData = GlobalFactory::GetGlobalData();
     $this->TemplateFolder = $globalData->TemplateFolder;
     $this->TemplateName = $globalData->PostTemplateName;
     $this->PostFolder = $globalData->PostFolder;
     $this->PostUrl = $globalData->PostUrl;
 }