public function login($uname, $pwd) { $tablename = $this->tablename; if ($this->Isnotempty($uname) && $this->Isnotempty($pwd)) { $uname = \Sham::saddslashes($uname); $row = $this->S->table->{$tablename}->where($this->fileduname . " = '{$uname}'")->getrow(); if (empty($row)) { $this->S->json = true; $this->S->jsonarr = array('code' => -200, 'msg' => '户名不存在'); return false; } else { if ($row[$this->filedpwd] == $this->S->pwdhash($pwd)) { //禁用的用户 if ($row[$this->filedenable] != 1) { $this->S->json = true; $this->S->jsonarr = array('code' => -200, 'msg' => '无效用户'); return false; } //更改登陆信息 $ar = array($this->fileloginip => \Sham::GetIP(), $this->filelogintm => \Sham::T()); //更改数据库激励 $this->S->table->{$tablename}->where($this->fileduname . " = '{$uname}'")->update($ar); //日志记录 //dolog //算法验证保证COOKIE安全 //$filedauthkey $filedgroupid // 604800 = 7*24*60*60 //路径 //可以通用 $tm = time(); $signature = \Sham::signnature($row[$this->fileduname] . $row[$this->filedtname] . $row[$this->filedauthkey] . $row[$this->filedgroupid] . $tm); setCookie('vuser_uname', $row[$this->fileduname], $tm + 604800, '/'); setCookie('vuser_tname', $row[$this->filedtname], $tm + 604800, '/'); setCookie('vuser_authkey', $row[$this->filedauthkey], $tm + 604800, '/'); setCookie('vuser_groupid', $row[$this->filedgroupid], $tm + 604800, '/'); setCookie('vuser_tm', $tm, $tm + 604800, '/'); //记录时间 setCookie('vuser_signature', $signature, $tm + 604800, '/'); //签名算法 return true; } else { $this->S->json = true; $this->S->jsonarr = array('code' => -200, 'msg' => '密码错'); return false; } } } else { $this->S->json = true; $this->S->jsonarr = array('code' => -200, 'msg' => '用户名密码不能为空'); return false; } }
/* * 调用 入口程序 * */ namespace Seter; define('FAST_PATH', __DIR__); //use Seter\RedBeanPHP; define('SHAM_PATH', __DIR__); include __DIR__ . '/Function/Fun.php'; !empty($_GET) && define('ISGET', TRUE); !empty($_POST) && define('ISPOST', TRUE); !defined('ISGET') && define('ISGET', false); !defined('ISPOST') && define('ISPOST', false); !defined('BTIME') && define('BTIME', \Sham::T()); include 'Core/Base.php'; //基类 include 'Seter.php'; //基类 \Seter\Seter::registerAutoloader(); //PSR-0 /** * 目录设定 * 1 基础类 不能直接使用,需要被继承 * Fast * 2 基础功能类 提供稳定的函数和变量 可以直接使用 * Base * 3 功能类 提供系列功能 * Library * 4 模型 Model