Exemple #1
0
 /**
  * 把配置存到注册表
  */
 function _initConfig()
 {
     Yaf_Registry::set("config", $config = Yaf_Application::app()->getConfig());
     define('PATH_APP', $config->application->directory);
     define('PATH_TPL', PATH_APP . '/views');
     define('USER_IP', Tool_Fnc::realip());
 }
Exemple #2
0
 static function UserloginAddlog($id)
 {
     $userlogin = new UserLoginModel();
     $user = new UserModel();
     $udata = $user->getById($id);
     $data = array('uid' => $id, 'updated' => time(), 'updateip' => Tool_Fnc::realip(), 'fqy' => 1);
     if ($fqy = Member::LoginToday($id)) {
         if ($fqy['s'] == 1) {
             $data['fqy'] = $fqy['fqy'] + 1;
         } elseif ($fqy['s'] == 0) {
             $data['fqy'] = $fqy['fqy'];
         }
     }
     $userlogin->insert($data);
     //添加登陆日志
     $type = self::$type;
     if ($fqy) {
         if ($fqy['s'] == 1) {
             if ($data['fqy'] <= 10) {
                 $credit = $data['fqy'] * 10;
             } else {
                 $credit = 100;
             }
             self::AddCredit($id, $credit);
             self::AddLevelLog($id, 1, $credit, $data['fqy']);
         } elseif ($fqy['s'] == 0) {
             //同一天
             //$credit = 10;
         }
     } else {
         //第一次
         $credit = 10;
         self::AddCredit($id, $credit);
         self::AddLevelLog($id, 1, $credit, $data['fqy']);
     }
 }
Exemple #3
0
 public function sloginAction()
 {
     $p = $_REQUEST;
     $pPlatform = empty($p['platform']) ? 0 : intval(trim($p['platform']));
     $pIconurl = empty($p['iconurl']) ? '' : trim($p['iconurl']);
     $pUsid = empty($p['usid']) ? '' : trim($p['usid']);
     $pUsername = empty($p['username']) ? '' : Tool_Fnc::safe_string($p['username']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPlatform)) {
         Tool_Fnc::ajaxMsg('请选择第三方平台');
     }
     if (!empty($pIconurl) && !Tool_Validate::url($pIconurl)) {
         Tool_Fnc::ajaxMsg('头像不是有效地址');
     }
     if (empty($pUsid) || !Tool_Validate::safe($pUsid)) {
         Tool_Fnc::app('usid 有问题');
     }
     #if(empty($pUsername) || !Tool_Validate::safe($pUsername)){Tool_Fnc::ajaxMsg('昵称有问题');}
     if (empty($pDid) || !Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did error');
     }
     $tMAMO = new Web_MembersaidModel();
     $tMMO = new Web_MembersModel();
     $tMAMO->begin();
     //判断是否授权过
     $tUid = 0;
     $tMARow = $tMAMO->field('id,username,iconurl,mid')->where('usid = \'' . $pUsid . '\' and platform = ' . $pPlatform)->fRow();
     if (empty($tMARow['id'])) {
         #第一次授权
         $tKey = Tool_Fnc::newrand(4);
         $tData = array('mem_img' => $pIconurl, 'mem_name' => $pUsername, 'mem_key' => $tKey);
         if (!($tUid = $tMMO->insert($tData))) {
             $tMAMO->back();
             Tool_Fnc::ajaxMsg('操作失败:001');
         }
         $tData = array('platform' => $pPlatform, 'iconurl' => $pIconurl, 'usid' => $pUsid, 'created' => $tTime, 'username' => $pUsername, 'mid' => $tUid, 'ip' => Tool_Fnc::realip());
         if (!$tMAMO->insert($tData)) {
             $tMAMO->back();
             Tool_Fnc::ajaxMsg('操作失败:002');
         }
     } else {
         $tUid = $tMARow['mid'];
         $tMRow = $tMMO->field('mem_name,mem_img')->where('id_web_members = ' . $tMARow['mid'])->fRow();
         $tMData = array();
         $tMAData = array();
         if ($tMARow['username'] == $tMRow['mem_name'] && $tMRow['mem_name'] != $pUsername) {
             #如果单独修改昵称 不予第三方同步
             $tMData = array_merge($tMData, array('mem_name' => $pUsername));
             $tMAData = array_merge($tMAData, array('username' => $pUsername));
         }
         if ($tMARow['iconurl'] == $tMRow['mem_img'] && $tMRow['mem_img'] != $pIconurl) {
             #如果单独修改头像 不予第三方同步
             $tMData = array_merge($tMData, array('mem_img' => $pIconurl));
             $tMAData = array_merge($tMAData, array('iconurl' => $pIconurl));
         }
         if (count($tMData)) {
             $tMData = array_merge($tMData, array('id_web_members' => $tMARow['mid']));
             if (!$tMMO->update($tMData)) {
                 $tMAMO->back();
                 Tool_Fnc::ajaxMsg('操作失败:003');
             }
             $tData = array('mid' => $tMARow['mid'], 'updated' => $tTime);
             $tMAData = array_merge($tMAData, $tData);
             if (!$tMAMO->update($tMAData)) {
                 $tMAMO->back();
                 Tool_Fnc::ajaxMsg('操作失败:004');
             }
         }
     }
     //did入库
     $tMDMO = new Web_MembersdidModel();
     $tMDRow = $tMDMO->field('count(0) c')->where('mid = ' . $tUid . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tMDRow['c'])) {
         $tData = array('mid' => $tUid, 'did' => $pDid, 'created' => $tTime);
         $tMDMO->insert($tData);
     }
     $tMAMO->commit();
     $tTokenarr = $this->creattoken($tUid);
     $tISMO = new Web_IncognitosheetsModel();
     $tISMO->incognito_real($pDid, $tUid);
     Tool_Fnc::ajaxMsg("登录成功", 1, $tTokenarr);
     //登录成功返回token
 }
Exemple #4
0
 public function regAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
     #客户端发送的必须是md5的 密码
     $pCode = empty($p['code']) ? '0' : trim($p['code']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPassword)) {
         Tool_Fnc::ajaxMsg('密码不能为空');
     }
     if (empty($pCode)) {
         Tool_Fnc::ajaxMsg('验证码不能为空');
     }
     if (!Tool_Validate::integer($pCode)) {
         Tool_Fnc::ajaxMsg('验证码格式错误');
     }
     if (strlen($pPassword) != 32) {
         Tool_Fnc::ajaxMsg('接口发送的必须是密文密码');
     }
     if (empty($pDid) || !Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did error');
     }
     $tUMO = new UserModel();
     $tRow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入');
     }
     $tUMO = new UserModel();
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pPassword, $tKey);
     $tCodeMO = new PhonecodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, 1, $pCode);
     if ($tCodeCRow['status'] == 0) {
         Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
     }
     $pSex = !isset($p['sex']) ? Tool_Fnc::ajaxMsg('请填写性别') : intval($p['sex']);
     $pDryWeight = !isset($p['dry_weight']) ? Tool_Fnc::ajaxMsg('请填写干体重') : floatval($p['dry_weight']);
     $pDateOfBirth = empty($p['date_of_birth']) ? Tool_Fnc::ajaxMsg('请填写出生日期') : trim($p['date_of_birth']);
     if (!empty($pDateOfBirth) && !Tool_Validate::is_date($pDateOfBirth)) {
         Tool_Fnc::ajaxMsg('日期格式不正确');
     }
     $tData = array('phone' => $pPhone, 'reg_ip' => Tool_Fnc::realip(), "passwd" => $tMd5str, "reg_time" => $tTime, 'private_key' => $tKey, 'reg_did' => $pDid, 'user_type' => 0, 'sex' => $pSex, 'dry_weight' => $pDryWeight, 'date_of_birth' => $pDateOfBirth, 'reg_did' => $pDid);
     if (!($tID = $tUMO->insert($tData))) {
         Tool_Fnc::ajaxMsg('注册失败');
     }
     //did入库
     $tUDMO = new UserdidModel();
     $tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tID . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tUDRow['c'])) {
         $tData = array('uid' => $tID, 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
         $tUDMO->insert($tData);
     }
     $tTokenarr = $this->creattoken($tID);
     //干重记录表数据更新
     $tDWMO = new DryweightlogModel();
     $tDryWeightLog = array('uid' => $tID, 'weight' => $pDryWeight, 'date' => date('Y-m-d'), 'month' => date('Y-m'), 'year' => date('Y'), 'created' => $tTime);
     $tDWMO->insert($tDryWeightLog);
     //匿名转实名
     $tUMO->incognito_real($pDid, $tID);
     $tTokenarr = array_merge($tTokenarr, array('user_type' => 0));
     Tool_Fnc::ajaxMsg('注册成功', 1, $tTokenarr);
 }
Exemple #5
0
 public function bindphoneAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
     #客户端发送的必须是md5的 密码
     $pCode = empty($p['code']) ? '0' : trim($p['code']);
     $tTime = time();
     if (!Tool_Validate::mo($pPhone)) {
         Tool_Fnc::ajaxMsg('手机号不正确');
     }
     if (empty($pPassword)) {
         Tool_Fnc::ajaxMsg('密码不能为空');
     }
     if (empty($pCode)) {
         Tool_Fnc::ajaxMsg('验证码不能为空');
     }
     if (!Tool_Validate::integer($pCode)) {
         Tool_Fnc::ajaxMsg('验证码格式错误');
     }
     if (strlen($pPassword) != 32) {
         Tool_Fnc::ajaxMsg('接口发送的必须是密文密码');
     }
     $tMemberMO = new Web_MembersModel();
     $tRow = $tMemberMO->field('count(0) c')->where('mem_phone = \'' . $pPhone . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入');
     }
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pPassword, $tKey);
     $tCodeMO = new Web_CodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, 1, $pCode);
     if ($tCodeCRow['status'] == 0) {
         Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
     }
     $tData = array('mem_phone' => $pPhone, 'mem_zc_ip' => Tool_Fnc::realip(), "mem_pwd" => $tMd5str, 'mem_key' => $tKey, 'id_web_members' => $this->tUid);
     if ($tMemberMO->update($tData)) {
         $tTokenarr = $this->creattoken($this->tUid);
         Tool_Fnc::ajaxMsg("绑定成功", 1, $tTokenarr);
         //注册成功返回token
     }
     Tool_Fnc::ajaxMsg('绑定失败');
 }