public function fix_user_reg() { $model = new \Common\Model\UserModel(); $users = M()->query("select uid,created from zj_user where created BETWEEN UNIX_TIMESTAMP('2015-04-01') and UNIX_TIMESTAMP('2015-04-02') and last_login_ip=0"); foreach ($users as $user) { $time = '2015-03-' . rand(10, 31) . ' ' . rand(10, 23) . ':' . rand(10, 59) . ':' . rand(10, 59); $model->where('uid=' . $user['uid'])->setField('created', strtotime($time)); $model->updateStat($user['uid']); } M('user_reg')->where(['reg_year' => '2015', 'reg_month' => 3])->delete(); M('user_reg')->where(['reg_year' => '2015', 'reg_month' => 4, 'reg_day' => 1])->delete(); die('done'); }
public function login() { if (isset($_POST['dosubmit'])) { $account = I('post.account'); $password = I('post.password'); $identifying = I('post.identifying'); if (empty($account)) { $this->error("请输入用户名"); } if (empty($password)) { $this->error("请输入密码"); } if (empty($identifying)) { $this->error("请输入验证码"); } if (!check_verify($identifying)) { $this->error("亲,验证码输错了哦"); exit; } $user = new \Common\Model\UserModel(); $data = $user->where(array("account" => $account))->find(); if (is_null($data) || empty($data)) { $this->error("用户名或者密码错误"); exit; } //判断是否是站长 /*if ($data['mn']!=1) {//是否是小区(对应user表中的ccode字段)站长 0否 1是 $this->error("您不是小区站长");exit(); }*/ $password = md5($password); if ($data['mn'] != 1) { $this->error("您不是小区站长"); exit; } if ($password == $data['pwd']) { session("home_userid", $data['id']); cookie('userid', $data['id'], array('expire' => 86400 * 30, 'prefix' => 'home_')); $ccode = $data['ccode']; //小区代码 $CommunityModel = new \Common\Model\CommunityModel(); $CommunityName = $CommunityModel->getNameByCcode($ccode); cookie('nickname', $data['nickname'], array('expire' => 86400 * 30, 'prefix' => 'home_')); cookie('CommunityName', $CommunityName, array('expire' => 86400 * 30, 'prefix' => 'home_')); cookie('account', $data['account'], array('expire' => 86400 * 30, 'prefix' => 'home_')); cookie('score', $data['score'], array('expire' => 86400 * 30, 'prefix' => 'home_')); //查询用户的当前佣金 $curcash = M('agent')->where(array('uid' => $data['id']))->getField('curcash'); if (empty($curcash) || is_null($curcash)) { $curcash = 0; } cookie('curcash', $curcash, array('expire' => 86400 * 30, 'prefix' => 'home_')); //登陆成功 //查询用户的邀请码 $UsericodeModel = new \Common\Model\UsericodeModel(); $UserCode = $UsericodeModel->getCode($data['id']); cookie('UserCode', $UserCode, array('expire' => 86400 * 30, 'prefix' => 'home_')); $this->success("登陆成功", "/Home/Index/index"); } else { $this->error("用户名或者密码错误"); exit; } } else { $this->display(); } }