Example #1
0
 public function doRegister()
 {
     $username = $this->request->post['username'];
     $pwd = $this->request->post['pwd'];
     $_march = '/[^A-Za-z0-9]/';
     //如果发现字母数字意外的字符 报错
     if (preg_match($_march, $username)) {
         St::J(-200, '用户名非法,请重新输入正确的用户名');
     }
     //密码长度
     if (strlen($pwd) < 6) {
         St::J(-200, '密码长度不够,最少6位');
     }
     //判断是否重复
     $row = $this->table->dy_user->where("uname = '{$username}'")->getrow();
     if (!empty($row)) {
         St::J(-200, '用户名已经存在');
     }
     //ok 监测通过
     $res['uname'] = $username;
     $res['pwd'] = $pwd;
     $res['groupid'] = 999;
     $res['regtime'] = T();
     $res['enable'] = 1;
     $this->table->dy_user->insert($res);
     St::J(200, '用户添加完成');
 }
Example #2
0
 public function doLogin()
 {
     $username = $this->request->post['username'];
     $pwd = $this->request->post['pwd'];
     if (empty($username) || empty($pwd)) {
         St::J(-100, '登陆失败');
     }
     //=======================================
     $row = $this->table->dy_user->where("uname = '{$username}'")->getrow();
     //用户不存在
     if (empty($row)) {
         St::J(200, '该用户不存在');
     }
     if ($row['enable'] == 0) {
         St::J(200, '该用户禁止登陆');
     }
     if ($row['user_password'] != $pwd) {
         St::J(200, '密码不对');
     }
     //登陆成功的日志计算
     $mc['f_logintime'] = time();
     $mc['f_loginip'] = Set::GetIP();
     $this->table->dy_user->where("uname = '{$username}'")->update($mc);
     //=======================================
     St::J(200, '登陆成功');
 }
Example #3
0
 /**
  * 构造函数,初始化配置
  * @param array $conf
  */
 private function __construct($conf)
 {
     St::__ini();
     C($conf);
     $conf['CONF_FILE'] = isset($conf['CONF_FILE']) ? $conf['CONF_FILE'] : 'Conf.php';
     $conf = G($conf['APP_PATH'] . $conf['CONF_FILE']);
     if (isset($conf['APP_PATH'])) {
         unset($conf['APP_PATH']);
     }
     //        $conf['modules']['super'] = 'hmvc_s';               //内置 debug
     $conf = array_merge(self::loadAppDefaultConfig(), $conf);
     C($conf);
 }
Example #4
0
 public function doUserimage()
 {
     //-----------------------------------------------------------------
     if (empty($_FILES['tfile']['name'])) {
         St::J(-200, 'error');
     }
     //文件名空
     //接收数据上传文件
     //-----------------------------------------------------------------
     $dirp = './A/upload/v1/' . date("Ym") . '/';
     !is_dir($dirp) && @mkdir($dirp);
     $dirp = './A/upload/v1/' . date("Ym") . '/' . date("d") . '/';
     !is_dir($dirp) && @mkdir($dirp);
     $extname = pathinfo($_FILES['tfile']['name'], PATHINFO_EXTENSION);
     //-----------------------------------------------------------------
     $target_path = $dirp . md5($_FILES['tfile']['name']) . rand(1000000, 9999999) . '.' . $extname;
     //-----------------------------------------------------------------
     if (move_uploaded_file($_FILES['tfile']['tmp_name'], $target_path)) {
         $refile = $target_path;
         $msg = " 上传成功";
         St::jsonres($refile);
         //-----------------------------------------------------------------
         St::J(200, 'succeed');
     } else {
         $refile = "";
         $msg = " error, please try again!" . $_FILES['tfile']['error'];
         //-----------------------------------------------------------------
         St::J(200, $msg);
     }
     //        $this->data($refile);
     //        $this->msg($msg);
     St::jsonres($refile);
     //-----------------------------------------------------------------
     St::J(200, 'succeedu');
     //=======================================
     St::J(200, '登陆成功');
 }
Example #5
0
 public static function jsoncode($code = 0)
 {
     self::$json = ['code' => $code, 'msg' => self::$codelist[$code]];
     return true;
 }
Example #6
0
 public function signin($uname, $pwd)
 {
     $tablename = $this->tablename;
     //用户名密码不能为空
     if ($this->Isempty($uname) || $this->Isempty($pwd)) {
         \St::jsoncode(-200);
         //用户名密码不能为空
         return $this;
     }
     if (!$this->checkname($uname)) {
         \St::jsoncode(-203);
         //用户不存在
         return $this;
     }
     $row = $this->getuserinfo($uname);
     if ($row[$this->filedpwd] != $this->passwordhash($pwd)) {
         \St::jsoncode(-201);
         //密码错误
         return $this;
     } else {
         //禁用的用户
         if ($row[$this->filedenable] != 1) {
             \St::jsoncode(-202);
             //无效用户
             return $this;
         }
         //更改登陆信息
         $ar = array($this->filedlogintm => \GetIP(), $this->filedregtime => \T());
         //更改数据库激励
         $this->S->table->{$tablename}->where($this->fileduname . " = '{$uname}'")->update($ar);
         //日志记录
         //dolog
         //算法验证保证COOKIE安全
         //$filedauthkey  $filedgroupid
         // 604800 = 7*24*60*60
         //路径 //可以通用
         $tm = time();
         $signature = $this->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, '/');
         //签名算法
         \St::jsoncode(200);
         //操作成功
         return $this;
     }
 }
Example #7
0
 public function doIndex()
 {
     //=======================================
     St::J(200, '登陆成功');
 }
Example #8
0
 public function signin($parmas = array())
 {
     //$dc = $this->S->user->signin($this->post['uname'],$this->post['pwd'])->json();            //查看操作json
     $this->S->user->signin($this->post['uname'], $this->post['pwd']);
     St::AjaxReturn();
 }