當前位置: 首頁>>代碼示例>>PHP>>正文


PHP zotop::cookie方法代碼示例

本文整理匯總了PHP中zotop::cookie方法的典型用法代碼示例。如果您正苦於以下問題:PHP zotop::cookie方法的具體用法?PHP zotop::cookie怎麽用?PHP zotop::cookie使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zotop的用法示例。


在下文中一共展示了zotop::cookie方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: globalid

 public static function globalid()
 {
     $globalid = zotop::cookie('file.globalid');
     if (empty($globalid)) {
         $globalid = TIME . rand(100, 10000);
         $globalid = md5($globalid);
         zotop::cookie('file.globalid', $globalid);
     }
     return $globalid;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:10,代碼來源:form.php

示例2: indexAction

 public function indexAction()
 {
     $user = zotop::model('zotop.user');
     if (form::isPostBack()) {
         $post = array();
         $post['username'] = request::post('username');
         $post['password'] = request::post('password');
         $post['logintime'] = time();
         zotop::cookie('admin.username', $post['username'], 3600);
         if (empty($post['username'])) {
             msg::error(zotop::t('登陸失敗,請輸入登陸賬戶名稱'));
         }
         if (empty($post['password'])) {
             msg::error(zotop::t('登陸失敗,請輸入登陸賬戶密碼'));
         }
         if (!$user->isValidUserName($post['username'])) {
             msg::error(zotop::t('登陸失敗,請輸入有效的賬戶名稱'));
         }
         if (!$user->isValidPassword($post['password'])) {
             msg::error(zotop::t('登陸失敗,請輸入有效的賬戶密碼'));
         }
         //讀取用戶
         $data = $user->read(array('username', '=', $post['username']));
         //驗證
         if ($data == false) {
             msg::error(zotop::t('賬戶名稱`{$username}`不存在,請檢查是否輸入有誤!', array('username' => $post['username'])));
         }
         if ($user->password($post['password']) != $data['password']) {
             msg::error(zotop::t('賬戶密碼`{$password}`錯誤,請檢查是否輸入有誤!', array('password' => $post['password'])));
         }
         //用戶登入
         $user->login();
         //跳轉
         msg::success('登陸成功,係統正在加載中', url::current(), 2);
     }
     if (!empty($this->user)) {
         $this->redirect('zotop/index');
     }
     $data = $user->read(array('username', '=', 'admin'));
     $page = new page();
     $page->title = '係統登陸';
     $page->body = array('class' => 'login');
     $page->addScript('$this/js/login.js');
     $page->display();
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:45,代碼來源:login.php

示例3: onDefault

 public function onDefault()
 {
     if (form::isPostBack()) {
         $post = array();
         $post['username'] = request::post('username');
         $post['password'] = request::post('password');
         $post['logintime'] = time();
         zotop::cookie('admin.username', $post['username'], 3600);
         if (empty($post['username'])) {
             msg::error('登陸失敗', zotop::t('請輸入登陸賬戶名稱'));
         }
         if (empty($post['password'])) {
             msg::error('登陸失敗', zotop::t('請輸入登陸賬戶密碼'));
         }
         $user = zotop::model('zotop.user');
         $data = $user->read(array('username', '=', $post['username']));
         if ($data == false) {
             msg::error('登陸失敗', zotop::t('賬戶名稱`{$username}`不存在,請檢查是否輸入有誤!', array('username' => $post['username'])));
         }
         if ($user->password($post['password']) != $data['password']) {
             msg::error('登陸失敗', zotop::t('賬戶密碼`{$password}`錯誤,請檢查是否輸入有誤!', array('password' => $post['password'])));
         }
         //更新
         $user->refresh();
         //登陸成功
         zotop::user($data);
         msg::success('登陸成功', '登陸成功,係統正在加載中', 'reload', 2);
     }
     if (zotop::user()) {
         zotop::redirect('zotop/index');
     }
     $header['title'] = '用戶登錄';
     $header['js'] = url::module() . '/admin/js/login.js';
     $header['body']['class'] = "login";
     page::header($header);
     block::header(array('id' => 'LoginWindow', 'title' => '用戶登錄'));
     form::header(array('title' => '', 'description' => '請輸入用戶名和密碼', 'class' => 'small'));
     form::field(array('type' => 'text', 'label' => zotop::t('帳 戶(U)'), 'name' => 'username', 'value' => zotop::cookie('admin.username'), 'valid' => 'required:true'));
     form::field(array('type' => 'password', 'label' => zotop::t('密 碼(P)'), 'name' => 'password', 'value' => '', 'valid' => 'required:true'));
     form::buttons(array('type' => 'submit', 'value' => '登 陸'), array('type' => 'button', 'name' => 'options', 'value' => '選 項'));
     form::footer();
     block::footer();
     page::footer();
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:44,代碼來源:login.php

示例4: getPage

 /**
  * 返回limit限製的數據,用於帶分頁的查詢數據
  *
  * @param $page int 頁碼
  * @param $pagesize int 每頁顯示條數
  * @param $num int|bool 總條數|緩存查詢條數,$toal = (false||0) 不緩存查詢
  * @return mixed
  */
 public function getPage($page = 0, $pagesize = 15, $num = false)
 {
     $page = $page <= 0 ? (int) $_GET['page'] : $page;
     $page = $page <= 0 ? 1 : $page;
     //獲取查詢參數
     $sqlBuilder = $this->sqlBuilder($sql);
     if (is_numeric($num) && $num > 0) {
         $total = $num;
     } else {
         $hash = md5(serialize($sqlBuilder['where']));
         if ($page == 1 || $num == true || !is_numeric(zotop::cookie($hash))) {
             //獲取符合條件數據條數
             $total = $this->count($sqlBuilder['where']);
             zotop::cookie($hash, $total);
         } else {
             $total = zotop::cookie($hash);
         }
     }
     //zotop::dump($this->lastsql());
     //計算$offset
     $offset = intval($page) > 0 ? (intval($page) - 1) * intval($pagesize) : 0;
     //設置limit
     $this->sqlBuilder($sqlBuilder);
     $this->limit($pagesize, $offset);
     //獲取指定條件的數據
     $data = $this->getAll();
     return array('data' => (array) $data, 'page' => intval($page), 'pagesize' => intval($pagesize), 'total' => intval($total));
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:36,代碼來源:database.php

示例5: user

 /**
  * 讀取存儲的用戶信息
  *
  */
 public static function user($key = '', $application = '')
 {
     $user = array();
     $application = empty($application) ? APP_NAME : $application;
     $cookieName = 'zotop.user.' . $application;
     if (empty($user)) {
         $user = zotop::cookie($cookieName);
         $user = is_array($user) ? array_change_key_case($user) : array();
     }
     if ($key === null) {
         return zotop::cookie($cookieName, null);
     }
     if (empty($key)) {
         return empty($user) ? false : $user;
     }
     if (is_array($key)) {
         $user = array_merge($user, array_change_key_case($key));
         return zotop::cookie($cookieName, $user);
     }
     $value = $user[strtolower($key)];
     if (isset($value)) {
         return $value;
     }
     return null;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:29,代碼來源:zotop.php

示例6: user

 public static function user($key = '')
 {
     $user = array();
     if (empty($user)) {
         $user = zotop::cookie('zotop.user');
         $user = is_array($user) ? array_change_key_case($user) : array();
     }
     if ($key === null) {
         return zotop::cookie('zotop.user', null);
     }
     if (empty($key)) {
         return empty($user) ? false : $user;
     }
     if (is_array($key)) {
         $user = array_merge($user, array_change_key_case($key));
         return zotop::cookie('zotop.user', $user);
     }
     $value = $user[strtolower($key)];
     if (isset($value)) {
         return $value;
     }
     return null;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:23,代碼來源:zotop.php

示例7: login

 /**
  * 寫入登陸信息
  *
  */
 public function login($data = array())
 {
     $username = $data['username'];
     $password = $data['password'];
     if (empty($username)) {
         $this->error(zotop::t('請輸入登陸賬戶名稱'));
         return false;
     }
     if (empty($password)) {
         $this->error(zotop::t('請輸入登陸賬戶密碼'));
         return false;
     }
     if (!$this->isValidUserName($username)) {
         $this->error(zotop::t('請輸入有效的賬戶名稱'));
         return false;
     }
     if (!$this->isValidPassword($password)) {
         $this->error(zotop::t('請輸入有效的賬戶密碼'));
         return false;
     }
     //檢查賬戶是否存在
     if (!$this->isExist(array('username', '=', $username))) {
         $this->error(zotop::t('賬戶`{$username}`不存在,請檢查是否輸入有誤!', $data));
         return false;
     }
     //加密密碼
     $password = $this->password($password);
     //讀取用戶
     $user = $this->db()->where(array('username', '=', $username))->where(array('password', '=', $password))->getRow();
     //驗證
     if ($user == false) {
         $this->error(zotop::t('賬戶密碼`{$password}`錯誤,請檢查是否輸入有誤!', $data));
         return false;
     }
     //刷新信息
     $this->refresh($user['id']);
     //記錄用戶數據
     zotop::user($user);
     zotop::cookie('username', $username, 3600);
     zotop::log('login', zotop::t('用戶 <b>{$username}</b> 於 {$time} 登陸成功', array('username' => $username, 'time' => TIME)));
     return true;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:46,代碼來源:user.php

示例8: array

		$('button[name=options]').click(function(){
			location.href = "<?php 
echo zotop::url('site://');
?>
";
		});
	});
</script>
<div id="topbar">
	<a href="<?php 
echo zotop::url('site://');
?>
">網站首頁</a>
	<b>|</b>
	<a href="javascript:void(0);" class="addFavorite">加入收藏夾</a>
	<b>|</b>
	<a href="<?php 
echo zotop::url('zotop/login/shortcut', array('title' => url::encode($title), 'url' => url::encode(url::location())));
?>
">設為桌麵圖標</a>		
</div>

<?php 
box::header(array('title' => $title, 'icon' => 'user', 'action' => ''));
form::header(array('title' => '', 'description' => '請輸入您的帳戶和密碼登錄', 'class' => 'small'));
form::field(array('type' => 'text', 'label' => zotop::t('帳 戶'), 'name' => 'username', 'value' => zotop::cookie('username'), 'valid' => 'required:true'));
form::field(array('type' => 'password', 'label' => zotop::t('密 碼'), 'name' => 'password', 'value' => '', 'valid' => 'required:true'));
form::buttons(array('type' => 'submit', 'value' => '登錄'), array('type' => 'button', 'name' => 'options', 'value' => '取消'));
form::footer();
box::footer();
$this->footer();
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:31,代碼來源:index.php


注:本文中的zotop::cookie方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。