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); }
public function indexAction() { $p = $_REQUEST; $pPhone = empty($p['phone']) ? '' : trim($p['phone']); $pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']); $pCode = empty($p['code']) ? '' : intval(trim($p['code'])); $tTime = time(); if (empty($pPhone)) { Tool_Fnc::ajaxMsg('请输入手机号码'); } if (empty($pNewptxt)) { Tool_Fnc::ajaxMsg('请输入新密码'); } if (!Tool_Validate::mo($pPhone)) { Tool_Fnc::ajaxMsg('手机号不正确'); } $tMO = new UserModel(); $tRow = $tMO->field('*')->where('phone = \'' . $pPhone . '\'')->fRow(); if (empty($tRow['id'])) { Tool_Fnc::ajaxMsg('用户不存在'); } $tCodeMO = new PhonecodeModel(); $tCodeCRow = $tCodeMO->check($pPhone, 2, $pCode); if ($tCodeCRow['status'] == 0) { Tool_Fnc::ajaxMsg($tCodeCRow['msg']); } $tKey = Tool_Fnc::newrand(4); $tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey); $tData = array('passwd' => $tMd5str, 'id' => $tRow['id'], 'private_key' => $tKey); if ($tMO->update($tData)) { Tool_Fnc::ajaxMsg('密码修改成功', 1); } Tool_Fnc::ajaxMsg('密码修改失败'); }
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; }
public function codeAction() { $p = $_REQUEST; header("Content-type: text/html; charset=utf-8"); $pPhone = empty($p['phone']) ? 0 : intval($p['phone']); if (!Tool_Validate::mo($pPhone)) { Tool_Fnc::ajaxMsg('手机号不正确'); } exec('cd ' . Yaf_Registry::get("config")->guahao->shell->dir . ' regcode.py ' . $pPhone, $tOut); if (!isset($tOut[0])) { Tool_Fnc::ajaxMsg('发送验证码异常 001'); } $tRes = json_decode($tOut[0], true); $tRes['msg'] = $tRes['msg'] == "false" ? '当前手机号每天只能发送4条短信,您已经超过限制' : $tRes['msg']; Tool_Fnc::ajaxMsg($tRes['msg'], $tRes['status'], array('webcode' => $tRes['webcode'])); exit; }
public function ckauthcodeAction() { $p = $_REQUEST; $pPhone = empty($p['phone']) ? '' : trim($p['phone']); $pReqmode = empty($p['reqmode']) ? '' : intval(trim($p['reqmode'])); #1: 注册请求;2: 忘记/找回密码请求; 3:第三方 $pCode = empty($p['code']) ? '' : intval(trim($p['code'])); $tTime = time(); if (!Tool_Validate::mo($pPhone)) { Tool_Fnc::ajaxMsg('手机号不正确'); } $tCodeMO = new PhonecodeModel(); $tCodeCRow = $tCodeMO->check($pPhone, $pReqmode, $pCode); $tUMO = new UserModel(); $tURow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow(); $tIsregphone = 0; if (!empty($tURow['c'])) { $tIsregphone = 1; } Tool_Fnc::ajaxMsg($tCodeCRow['msg'], $tCodeCRow['status'], array('isregphone' => $tIsregphone)); }
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); } }
public function diethomeAction() { $p = $_REQUEST; $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']); if (!Tool_Validate::is_date($pDate)) { Tool_Fnc::ajaxMsg('日期不正确'); } $tFAMO = new R_FoodaddModel(); $tFMO = new FoodModel(); $tDWLMO = new DryweightlogModel(); $tDatas = array(); $tDWLRow['weight'] = $tDWLMO->is_dryweight($this->tUid, $pDate); $tArr = $tFMO->diet('protein', $tDWLRow['weight']); $tDatas['protein']['total'] = $tArr['start']; $tSql = 'select * from (select fid,unit,amount,weight from ' . $tFAMO->table . ' where uid = ' . $this->tUid . ' 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']['surplus'] = 0; $tDatas['protein']['number'] = 0; if (!count($tList)) { Tool_Fnc::ajaxMsg('', 1, $tDatas); } #已经摄取 foreach ($tList as $tRow) { $tDatas['protein']['number'] += $tRow['protein'] / 100 * $tRow['weight']; #蛋白质 } unset($tList); #应摄取 #蛋白质 $tSurplus = $tArr['end'] - $tDatas['protein']['number']; $tDatas['protein']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus; Tool_Fnc::ajaxMsg('', 1, $tDatas); exit; }
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); }
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 }
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']); if (!Tool_Validate::is_date($pDate)) { Tool_Fnc::ajaxMsg('日期不正确'); } $tMO = new R_BloodpressureModel(); $tSql = 'delete from ' . $tMO->table . ' where type = ' . $pType . ' and date = \'' . $pDate . '\' and uid = ' . $this->tUid; if (!$tMO->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } Tool_Fnc::ajaxMsg('删除成功', 1); }
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); }
public function yearAction() { $p = $_REQUEST; $pDate = empty($p['date']) ? '' : trim($p['date']); $pOpt = empty($p['opt']) ? 'left' : Tool_Fnc::safe_string($p['opt']); if (!empty($pDate) && !Tool_Validate::is_date($pDate)) { Tool_Fnc::ajaxMsg('日期不正确'); } $tWhere = ''; $tTime = strtotime($pDate); if ($pOpt == 'left') { if (!empty($pDate)) { $tEnd = date('Y-m-d', $tTime - 86400); } else { $tTime = time(); $tEnd = date('Y-m-d'); } $tStart = date('Y-m-d', $tTime - 86400 * 364); } else { if (!empty($pDate)) { $tStart = date('Y-m-d', $tTime + 86400); } else { $tTime = time(); $tStart = date('Y-m-d'); } $tEnd = date('Y-m-d', $tTime + 86400 * 364); } $tTRMO = new BqetreatmentrecordModel(); $tTRDatas = $tTRMO->field('bodyweight_bef,bodyweight_after,treate_date')->where('uid = ' . $this->tUid . ' and treate_date between \'' . $tStart . '\' and \'' . $tEnd . '\'')->order('treate_date asc')->fList(); $tDWLMO = new DryweightlogModel(); $tDWLDatas = $tDWLMO->field('weight,date')->where('uid = ' . $this->tUid . ' and date between \'' . $tStart . '\' and \'' . $tEnd . '\'')->fList(); //最开始日期 $tSql = 'select treate_date from ' . $tTRMO->table . ' where uid = ' . $this->tUid . ' order by treate_date asc limit 1'; $tTRMOList = $tTRMO->query($tSql); #用户最新干体重 $tUMO = new UserModel(); $tURow = $tUMO->field('dry_weight')->where('id = ' . $this->tUid)->fRow(); //如果没有干体重 初始化 $tDatearr = array(); for ($i = 0; $i < 364; $i++) { $tDatearr[] = date('Y-m-d', strtotime($tStart) + 86400 * $i); } $tDWLDate = array(); foreach ($tDWLDatas as $tRow) { $tDWLDate[] = $tRow['date']; } $tDatediff = array_diff($tDatearr, $tDWLDate); $tDiffarr = array(); foreach ($tDatediff as $tDate) { break; #判断该日期之前的干体重 $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $this->tUid . ' and date < ' . $tDate)->order('date desc')->limit('1')->fRow(); if (count($tDWLRow)) { $tDWLDatas[] = $tDiffarr[] = array('date' => $tDate, 'weight' => $tDWLRow['weight']); continue; } #判断该日期之后临近的干体重 $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $this->tUid . ' and date > ' . $tDate)->order('date desc')->limit('1')->fRow(); if (count($tDWLRow)) { $tDWLDatas[] = $tDiffarr[] = array('date' => $tDate, 'weight' => $tDWLRow['weight']); continue; } #当前用户干体重 $tDWLDatas[] = $tDiffarr[] = array('date' => $tDate, 'weight' => $tURow['dry_weight']); } #将没有干体重的天入库 foreach ($tDiffarr as $tRow) { break; if ($tDWLMO->in_weight($this->tUid, $tRow['date'])) { continue; } $tData = array('weight' => $tRow['weight'], 'uid' => $this->tUid, 'created' => $tTime, 'date' => $tRow['date'], 'month' => date('Y-m', strtotime($tRow['date'])), 'year' => date('Y-m', strtotime($tRow['date']))); $tDWLMO->insert($tData); } #排除 只要有体重的 干体重╮(╯▽╰)╭ $tTRDate = array(); foreach ($tTRDatas as $tRow) { $tTRDate[] = $tRow['treate_date']; } foreach ($tDWLDatas as $tKey => $tRow) { if (!in_array($tRow['date'], $tTRDate)) { unset($tDWLDatas[$tKey]); } } $tDWLDatas = Tool_Fnc::arraySort($tDWLDatas, 'date', 'asc'); Tool_Fnc::ajaxMsg('', 1, array('dry_weight' => $tDWLDatas, 'weight' => $tTRDatas, 'start_treate_date' => $tTRMOList[0]['treate_date'])); }
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; }
public function infoAction() { $tMO = new UserModel(); $tRow = $tMO->field('headimg,phone,sex,dry_weight,date_of_birth')->where('id = ' . $this->tUid)->fRow(); if (!count($tRow)) { Tool_Fnc::ajaxMsg('获取信息失败'); } $tUAMO = new UserassessmentModel(); $tARow = $tUAMO->field('name,medical_id')->where(' uid = ' . $this->tUid)->fRow(); $tCMO = new CenterModel(); $tCRow = $tCMO->field('name')->where(' id = ' . $tARow['medical_id'])->fRow(); $tODTMO = new OrdinarydialysistimeModel(); $tODTRow = $tODTMO->field('time,week,time_code')->where(' uid = ' . $this->tUid)->fRow(); unset($tARow['medical_id']); $tRow = array_merge($tRow, $tARow); if (!empty($tRow['headimg']) && !Tool_Validate::url($tRow['headimg'])) { $tRow['headimg'] = Yaf_Registry::get("config")->web->url->img . $tRow['headimg']; } Tool_Fnc::ajaxMsg('', 1, array_merge($tRow, array('medical_addr' => $tCRow['name'], 'assess_time' => $tODTRow))); }