function isLogin() { if ($_COOKIE['key']) { if ($_COOKIE['key'] != md5($_COOKIE['admin_id'] . $_COOKIE['admin_name'] . $_COOKIE['lastlogintime'] . base_Constant::COOKIE_KEY)) { $cookie['key'] = ''; $cookie['admin_id'] = ''; $cookie['gid'] = ''; $cookie['admin_name'] = ''; $cookie['lastlogintime'] = ''; base_Utils::ssetcookie($cookie, -1); return false; } } else { return false; } return true; }
function pageaddgoods($inPath) { $url = $this->getUrlParams($inPath); $goods_id = (int) $url['gid'] > 0 ? (int) $url['gid'] : (int) $_POST['goods_id']; $goodsObj = new m_goods($goods_id); if ($_POST) { $post = base_Utils::shtmlspecialchars($_POST); if ($goodsObj->create($post)) { base_Utils::ssetcookie(array('cat_id' => $post['cat_id'])); $this->ShowMsg("操作成功!", $this->createUrl("/goods/addgoods"), 2, 1); } $this->ShowMsg("操作失败" . $goodsObj->getError()); } $categoryObj = new m_category(); $this->params['cat_id'] = (int) $_COOKIE['cat_id']; $this->params['catelist'] = $categoryObj->getOrderCate(' '); $this->params['goods'] = $goodsObj->selectOne("goods_id={$goods_id}"); return $this->render('goods/addgoods.html', $this->params); }
public function checkLogin($username, $pwd, $timeout = 7200) { $pwd = md5($pwd); $rs = $this->selectOne("admin_name = '{$username}' and admin_pwd = '{$pwd}'"); if ($rs) { if ($this->update("admin_id = {$rs['admin_id']}", "lastlogintime = {$this->_time}")) { $cookie['admin_id'] = $rs['admin_id']; $cookie['admin_name'] = $rs['admin_name']; $cookie['gid'] = $rs['gid']; $cookie['lastlogintime'] = $rs['lastlogintime']; $cookie['key'] = md5($rs['admin_id'] . $rs['admin_name'] . $rs['lastlogintime'] . base_Constant::COOKIE_KEY); base_Utils::ssetcookie($cookie, $timeout); return true; } else { return false; } } else { return false; } }
function pagelogout($inPath) { $cookie['key'] = ''; base_Utils::ssetcookie($cookie, -1); return $this->ShowMsg("成功退出!", $this->createUrl('/main/index'), 2, 1); }