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, '用户添加完成'); }
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, '登陆成功'); }
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, '登陆成功'); }
public function doIndex() { //======================================= St::J(200, '登陆成功'); }