예제 #1
0
파일: pubdata.php 프로젝트: vyouzhis/phpdbi
 private function tol()
 {
     $format = 'select count(*) as count from analysis where cid=%d  LIMIT 1';
     $sql = sprintf($format, $this->switch);
     $res = parent::FetchOne($sql);
     return $res['count'];
 }
예제 #2
0
 /**
  * @name IsUser
  * @package 发送验证码之前,验证手机号码是否存在
  * @return array
  */
 public function IsUser($phone)
 {
     /*查询是否存在此账户*/
     $where = "where login_md5='" . md5($phone) . "'";
     $format = "select user_id from " . DB_PRE . "user_main %s limit 1 ";
     $sql = sprintf($format, $where);
     $res = parent::FetchOne($sql);
     if (is_array($res)) {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 /**
  *
  * @name u_Login
  * @param $login  email or phone num
  * @param $passwd
  * @param int $type=0  0 email, 1, phone
  * @param $sess_salt
  * @package user login action 使用 密码登录
  * @return  0 ok,  -1 login error, -2 salt error , -3 empty error
  */
 function u_Login($login, $passwd, $type = 0)
 {
     if (empty($login)) {
         return -1;
     }
     if (empty($passwd)) {
         return -2;
     }
     if ($type != 0 && $type != 1) {
         return -4;
     }
     /*查询是否存在此账户,且密码相等*/
     if ($type == 0) {
         $where = "where (email='" . $login . "' or login_md5='" . md5($login) . "') and password='******'";
     } else {
         if ($type == 1) {
             /*并验证验证码*/
             if ($this->u_checkVerify($login, $passwd)) {
                 $where = "where (email='" . $login . "' or login_md5='" . md5($login) . "')";
             } else {
                 return -3;
             }
         } else {
             /*其他全部抛弃*/
             return -4;
         }
     }
     /*查询是否存在此账户*/
     $format = "select user_id,  password, real_name, sex, email, mobile, login_md5 from " . DB_PRE . "user_main %s limit 1 ";
     $sql = sprintf($format, $where);
     $res = parent::FetchOne($sql);
     if (is_array($res)) {
         $ses["uid"] = $res['user_id'];
         $ses['name'] = $res['real_name'];
         $ses['sex'] = $res['sex'];
         $this->SetSessionInfo($ses);
         /**
          * 设置  BaseTheme 的全域名  cookie
          */
         setcookie(WEB_COOKIE_UID, $res['user_id'], time() + 31557600, "/", DOMAIN);
         setcookie(WEB_COOKIE_NAME, $res['real_name'], time() + 31557600, "/", DOMAIN);
         setcookie(WEB_COOKIE_SEX, $res['sex'], time() + 31557600, "/", DOMAIN);
         return 0;
     } else {
         return -1;
     }
 }