Exemplo n.º 1
0
 public function updateptkAction()
 {
     $p = $_REQUEST;
     $pCid = empty($p['cid']) ? '' : trim($p['cid']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $pDevicetoken = empty($p['devicetoken']) ? '' : trim($p['devicetoken']);
     $tTime = time();
     if (!Tool_Validate::az09($pCid)) {
         Tool_Fnc::ajaxMsg('cid 错误');
     }
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('Did 错误');
     }
     if (!empty($pDevicetoken) && !Tool_Validate::az09($pDevicetoken)) {
         Tool_Fnc::ajaxMsg('devicetoken 错误');
     }
     $tGMO = new GetuiModel();
     $tGMORow = $tGMO->field('count(0) c')->where('did = \'' . $pDid . '\' and cid = \'' . $pCid . '\' and devicetoken = \'' . $pDevicetoken . '\'')->fRow();
     if (!empty($tGMORow['c'])) {
         Tool_Fnc::ajaxMsg('did 关联存在', 1);
     }
     $tData = array('devicetoken' => $pDevicetoken, 'cid' => $pCid, 'did' => $pDid, 'created' => $tTime);
     if (!$tGMO->insert($tData)) {
         Tool_Fnc::ajaxMsg('更新 push token失败');
     }
     Tool_Fnc::ajaxMsg('操作成功', 1);
 }
Exemplo n.º 2
0
 public function init()
 {
     $p = $_REQUEST;
     $pAtk = empty($p['atk']) ? '' : trim($p['atk']);
     if (!Tool_Validate::az09($pAtk)) {
         Tool_Fnc::ajaxMsg('token 格式不正确');
     }
     if (!($tUid = $this->checktoken($pAtk))) {
         Tool_Fnc::ajaxMsg('token 认证失败', -1);
     }
     $this->tUid = $tUid;
 }
Exemplo n.º 3
0
 public function addAction()
 {
     $p = $_REQUEST;
     $pName = empty($p['name']) ? '' : Tool_Fnc::safe_string($p['name']);
     $pIdcard = empty($p['idcard']) ? '' : trim($p['idcard']);
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pCode = empty($p['code']) ? '' : trim($p['code']);
     $tTime = time();
     if (!Tool_Validate::name($pName)) {
         Tool_Fnc::ajaxMsg('姓名格式错误');
     }
     if (!Tool_Validate::identify($pIdcard)) {
         Tool_Fnc::ajaxMsg('身份证错误');
     }
     if (!Tool_Validate::az09($pCode)) {
         Tool_Fnc::ajaxMsg('验证码格式错误');
     }
     $tMO = new MemberModel();
     $tRow = $tMO->field('count(0) c')->where('uid = ' . $this->tUid . ' and name = \'' . $pName . '\' and idcard = \'' . $pIdcard . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('家人已经存在');
     }
     /*
     *  
     name = sys.argv[1]
     sex = sys.argv[2]
     sfz = sys.argv[3]
     phone = sys.argv[4]
     dxcode = sys.argv[5]
     */
     $tSex = substr($pIdcard, strlen($pIdcard) == 15 ? -1 : -2, 1) % 2 ? '男' : '女';
     exec('cd ' . Yaf_Registry::get("config")->guahao->shell->dir . ' reg.py ' . $pName . ' ' . $tSex . ' ' . $pIdcard . ' ' . $pPhone . ' ' . $pCode, $tOut);
     if (!isset($tOut[0])) {
         Tool_Fnc::ajaxMsg('异常错误 002');
     }
     $tRes = json_decode($tOut[0], true);
     $tRes['msg'] = trim($tRes['msg']);
     if ($tRes['status'] == 0 && $tRes['msg'] != '此证件号码已注册过!  重新注册。') {
         Tool_Fnc::ajaxMsg($tRes['msg'], $tRes['status']);
     }
     $tData = array('name' => $pName, 'idcard' => $pIdcard, 'phone' => $pPhone, 'uid' => $this->tUid, 'created' => $tTime);
     if (!$tMO->insert($tData)) {
         Tool_Fnc::ajaxMsg('异常错误 001');
     }
     Tool_Fnc::ajaxMsg('添加成功', 1);
 }
Exemplo n.º 4
0
 public function addAction()
 {
     $p = $_REQUEST;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('用户名不能为空') : Tool_Fnc::safe_string($p['name']);
         Tool_Validate::az09($pName) ? '' : Tool_Fnc::ajaxMsg('用户名格式为a-zA-Z_-组成');
         $pPasswd = empty($p['passwd']) ? Tool_Fnc::ajaxMsg('密码不能为空') : trim($p['passwd']);
         $pRepasswd = empty($p['repasswd']) ? Tool_Fnc::ajaxMsg('重复密码不能为空') : trim($p['repasswd']);
         strlen($pPasswd) < 6 || strlen($pRepasswd) < 6 ? Tool_Fnc::ajaxMsg('密码长度至少为6位') : '';
         if ($pPasswd !== $pRepasswd) {
             Tool_Fnc::ajaxMsg('两次密码不一置');
         }
         $pPrivateKey = Tool_Fnc::newrand();
         $pPasswd = Tool_Fnc::markmd5($pPasswd, $pPrivateKey);
         $tDatas = array('name' => $pName, 'passwd' => $pPasswd, 'private_key' => $pPrivateKey);
         $tAM = new AdminModel();
         if (!$tAM->insert($tDatas)) {
             Tool_Fnc::ajaxMsg('新增管理员失败');
         }
         Tool_Fnc::ajaxMsg('添加成功', 1);
     }
 }
Exemplo n.º 5
0
 public function listAction()
 {
     $p = $_REQUEST;
     $pDid = empty($p['did']) ? Tool_Fnc::ajaxMsg('DID不能为空') : trim($p['did']);
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did格式不正确');
     }
     $tMO = new I_WeightModel();
     $tDatas = $tMO->field('number,type,date')->where('did = \'' . $pDid . '\'')->order('date desc')->limit('2')->fList();
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
 }
Exemplo n.º 6
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
 }
Exemplo n.º 7
0
 public function delAction()
 {
     $p = $_REQUEST;
     $pType = empty($p['type']) ? Tool_Fnc::ajaxMsg('删除类型不能为空') : intval($p['type']);
     $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']);
     $pDid = empty($p['did']) ? Tool_Fnc::ajaxMsg('DID不能为空') : trim($p['did']);
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did格式不正确');
     }
     if (!Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tMO = new I_BloodpressureModel();
     $tSql = 'delete from ' . $tMO->table . ' where type = ' . $pType . ' and date = \'' . $pDate . '\' and did = \'' . $pDid . '\'';
     if (!$tMO->exec($tSql)) {
         Tool_Fnc::ajaxMsg('删除失败');
     }
     Tool_Fnc::ajaxMsg('删除成功', 1);
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
0
 public function diethomeAction()
 {
     $p = $_REQUEST;
     $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']);
     $pDid = empty($p['did']) ? Tool_Fnc::ajaxMsg('DID不能为空') : trim($p['did']);
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did格式不正确');
     }
     if (!Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tFAMO = new I_FoodaddModel();
     $tFMO = new FoodModel();
     $tDatas = array();
     $tSql = 'select * from (select fid,unit,amount,weight from ' . $tFAMO->table . ' where did = \'' . $pDid . '\' and created >=' . strtotime($pDate) . ' and created <=' . strtotime($pDate . ' 23:59:59') . ') fa, ' . $tFMO->table . ' f where fa.fid = f.id';
     $tList = $tFMO->query($tSql);
     $tDatas['protein'] = array('total' => 90, 'surplus' => 0, 'number' => 0);
     if (!count($tList)) {
         Tool_Fnc::ajaxMsg('', 1, $tDatas);
     }
     #已经摄取
     foreach ($tList as $tRow) {
         $tDatas['protein']['number'] += $tRow['protein'] / 100 * $tRow['weight'];
         #蛋白质
     }
     unset($tList);
     $tDatas['protein']['total'] = 90;
     $tDatas['protein']['surplus'] = 90 - $tDatas['protein']['number'];
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
     exit;
 }