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 listAction() { $p = $_REQUEST; $pCateid = empty($p['cateid']) ? 0 : intval($p['cateid']); $pAid = empty($p['aid']) ? 0 : intval($p['aid']); $pOpt = empty($p['opt']) ? '' : trim($p['opt']); $tOptarr = array('up', 'down'); $pSize = empty($p['size']) ? 5 : intval(trim($p['size'])); $tTime = time(); if (!in_array($pOpt, $tOptarr)) { Tool_Fnc::appMsg('操作类型错误'); } if (empty($pCateid)) { Tool_Fnc::ajaxMsg('分类id不正确'); } $tWhere = ''; $tOrder = ''; if ($pOpt == 'up') { $tWhere = ' and id < ' . $pAid; $tOrder = 'id desc'; } else { $tWhere = ' and id > ' . $pAid; $tOrder = 'id asc'; } if (empty($pAid)) { $tWhere = ''; $tOrder = 'id desc'; } #特殊情况 $tMO = new ArticleModel(); $tImgUrl = Yaf_Registry::get("config")->web->url->img; $tDatas = $tMO->field('id aid, concat(\'' . $tImgUrl . '\', head_img) head_img,(view+initview) viewtotal,title,description,created')->where('cate_id = ' . $pCateid . $tWhere)->order($tOrder)->limit('0,' . $pSize)->fList(); Tool_Fnc::ajaxMsg('', 1, $tDatas); }
public function editAction() { $p = $_REQUEST; $pWeight = empty($p['weight']) ? Tool_Fnc::ajaxMsg('干体重不能为空') : floatval($p['weight']); $tTime = time(); $tDWLMO = new DryweightlogModel(); $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . date('Y-m-d', $tTime) . '\'')->fRow(); $tUMO = new UserModel(); $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow(); if ($tURow['user_type'] == 1) { Tool_Fnc::ajaxMsg('操作异常'); } $tData = array('weight' => $pWeight); if (empty($tDWLRow['id'])) { $tData = array_merge($tData, array('created' => $tTime, 'uid' => $this->tUid, 'date' => date('Y-m-d', $tTime), 'year' => date('Y', $tTime), 'month' => date('Y-m', $tTime))); } else { $tData = array_merge($tData, array('updated' => $tTime, 'id' => $tDWLRow['id'])); } $tUMO->begin(); if (!$tDWLMO->save($tData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 001'); } $tUData = array('id' => $this->tUid, 'dry_weight' => $pWeight, 'updated' => $tTime); if (!$tUMO->update($tUData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 002'); } $tUMO->commit(); Tool_Fnc::ajaxMsg('操作成功', 1); }
public function loginAction() { if (!$this->valiCaptcha()) { return; } $p = $_REQUEST; $pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('用户名不能为空') : Tool_Fnc::safe_string($p['name']); $pPasswd = empty($p['passwd']) ? Tool_Fnc::ajaxMsg('密码不能为空') : trim($p['passwd']); $pCaptcha = empty($p['captcha']) ? Tool_Fnc::ajaxMsg('验证码为空') : trim($p['captcha']); $tMO = new AdminModel(); $tRow = $tMO->field('*')->where("name = '{$pName}'")->fRow(); if (!count($tRow)) { Tool_Fnc::ajaxMsg('用户不存在'); } if (Tool_Fnc::markmd5($pPasswd, $tRow['private_key']) != $tRow['passwd']) { Tool_Fnc::ajaxMsg('密码不正确'); } $_SESSION['admin'] = array('id' => $tRow['id'], 'name' => $tRow['name']); if (isset($p['remember']) && $p['remember'] == 'remember') { setcookie('admin[id]', $tRow['id'], time() + 60 * 60 * 24 * 365, '/'); setcookie('admin[name]', $tRow['name'], time() + 60 * 60 * 24 * 365, '/'); } $this->showMsg('', '/admin_user'); Tool_Fnc::ajaxMsg('', 1); }
public function indexAction() { $p = $_REQUEST; $pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']); $pOldptxt = empty($p['oldptxt']) ? '' : trim($p['oldptxt']); $tTime = time(); if (empty($pOldptxt)) { Tool_Fnc::ajaxMsg('请输入旧密码'); } if (empty($pNewptxt)) { Tool_Fnc::ajaxMsg('请输入新密码'); } $tUMO = new UserModel(); $tRow = $tUMO->field('id,passwd,private_key')->where('id = ' . $this->tUid)->fRow(); if (!count($tRow)) { Tool_Fnc::ajaxMsg('读取信息失败'); } $tOldptxt = Tool_Fnc::markmd5($pOldptxt, $tRow['private_key']); if ($tRow['passwd'] != $tOldptxt) { Tool_Fnc::ajaxMsg('旧密码不正确'); } $tKey = Tool_Fnc::newrand(4); $tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey); $tData = array('id' => $tRow['id'], 'passwd' => $tMd5str, 'private_key' => $tKey, 'updated' => $tTime); if ($tUMO->update($tData)) { Tool_Fnc::ajaxMsg('密码修改成功', 1); } Tool_Fnc::ajaxMsg('密码修改失败'); }
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 infoAction() { $p = $_REQUEST; $pUid = empty($p['id']) ? Tool_Fnc::ajaxMsg("异常错误 001") : intval($p['id']); $tUMO = new UserModel(); $tURow = $tUMO->field('headimg,nickname,phone,sex,dry_weight,date_of_birth,medical_addr')->where('id = ' . $pUid)->fRow(); $tUAMO = new UserassessmentModel(); $tUARow = $tUAMO->field('*')->where(' uid = ' . $pUid)->fRow(); $this->assign('tURow', $tURow); $this->assign('tUARow', $tUARow); }
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 indexAction() { /* $tBMO = new BannerModel; $tImgUrl = Yaf_Registry::get("config")->web->url->img; $tDatas = $tBMO->field('aid,concat(\''.$tImgUrl.'\',img) img')->order(' id asc ')->fList(); Tool_Fnc::ajaxMsg('',1,$tDatas); */ $tAMO = new ArticleModel(); $tImgUrl = Yaf_Registry::get("config")->web->url->img; $tDatas = $tAMO->field('id aid,concat(\'' . $tImgUrl . '\',head_img) img')->where(' cate_id = 18')->order('id asc')->fList(); Tool_Fnc::ajaxMsg('', 1, $tDatas); }
public function __construct() { if ($this->db == NULL) { header("Content-type: text/html; charset=utf-8"); $this->db = oci_connect('bqe', 'bqe', '123.57.47.91:1521/bqedb', 'AL32UTF8'); } if (!$this->db) { $e = oci_error(); Tool_Fnc::ajaxMsg(htmlentities($e['message'], ENT_QUOTES)); } else { return $this->db; } }
public function indexAction() { $tWeek = date('w', time()); $tODTMO = new OrdinarydialysistimeModel(); $tODTRow = $tODTMO->field('week,time,time_code')->where('uid = ' . $this->tUid)->fRow(); $tODTRow['week'] = empty($tODTRow['week']) ? -1 : $tODTRow['week']; $tODTRow['time'] = empty($tODTRow['time']) ? '' : $tODTRow['time']; $tODTRow['time_code'] = empty($tODTRow['time_code']) ? '' : $tODTRow['time_code']; $tArr = explode('|', $tODTRow['week']); foreach ($tArr as $k => &$v) { if ($v == "" || $v == null) { unset($tArr[$k]); } } $tUMO = new UserModel(); $tURow = $tUMO->field('center_id')->where(' id = ' . $this->tUid . ' and user_type = 0')->fRow(); $tCMO = new CenterModel(); $tCRow = $tCMO->field('name,today_weather')->where('id =' . $tURow['center_id'])->fRow(); $tCRow['name'] = empty($tCRow['name']) ? '' : $tCRow['name']; $tCRow['today_weather'] = empty($tCRow['today_weather']) ? '' : $tCRow['today_weather']; $tArray = array(); $tArray['time'] = $tODTRow['time']; $tArray['time_code'] = $tODTRow['time_code']; $tArray['medical_addr'] = $tCRow['name']; $tArray['today_weather'] = $tCRow['today_weather']; if (in_array($tWeek, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', time())), $tArray)); } if (in_array(($tWeek + 1) % 7, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+1day'))), $tArray)); } if (in_array(($tWeek + 2) % 7, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+2day'))), $tArray)); } if (in_array(($tWeek + 3) % 7, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+3day'))), $tArray)); } if (in_array(($tWeek + 4) % 7, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+4day'))), $tArray)); } if (in_array(($tWeek + 5) % 7, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+5day'))), $tArray)); } if (in_array(($tWeek + 6) % 7, $tArr)) { Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+6day'))), $tArray)); } Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => ''), $tArray)); }
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 indexAction() { $p = $_REQUEST; # $pType = empty($p['type'])?Tool_Fnc::ajaxMsg('类型错误'):intval($p['type']); $pTremble = empty($p['tremble']) ? Tool_Fnc::ajaxMsg('震颤未选择') : intval($p['tremble']); $pWeaken = empty($p['weaken']) ? Tool_Fnc::ajaxMsg('减弱未选择') : intval($p['weaken']); $pNoise = empty($p['noise']) ? Tool_Fnc::ajaxMsg('杂音未选择') : intval($p['noise']); $pPain = empty($p['pain']) ? Tool_Fnc::ajaxMsg('疼痛未选择') : intval($p['pain']); $pResult = empty($p['result']) ? Tool_Fnc::ajaxMsg('结果值未返回') : intval($p['result']); $tTime = time(); $tVPTMO = new VascularpermeabilitytestModel(); $tDatas = array('uid' => $this->tUid, 'tremble' => $pTremble, 'weaken' => $pWeaken, 'noise' => $pNoise, 'pain' => $pPain, 'result' => $pResult, 'created' => $tTime); if (!$tVPTMO->insert($tDatas)) { Tool_Fnc::ajaxMsg('插入失败'); } Tool_Fnc::ajaxMsg('插入成功', 1); }
public function daily_recipesAction() { $tDate = date('Y-m-d'); $tMO = new DailyrecipesModel(); $tRow = $tMO->field('day_date')->group('day_date')->order('day_date desc')->limit('1')->fRow(); if (!empty($tRow['day_date'])) { $tDate = $tRow['day_date']; } $tFUMO = new FoodunitsModel(); $tImgUrl = Yaf_Registry::get("config")->web->url->img; $tDatas = $tMO->field('mt_name,mt_id,title,unit,amount,weight,fid,tag, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img,protein')->where('day_date = \'' . $tDate . '\'')->order('mt_id asc')->fList(); $tDatasnew = array(); foreach ($tDatas as $tRow) { $tUnits = $tFUMO->field('amount,unit,weight')->where('fid = ' . $tRow['fid'])->fList(); $tDatasnew[$tRow['mt_id']][] = array_merge($tRow, array('units' => $tUnits)); } Tool_Fnc::ajaxMsg('', 1, $tDatasnew); }
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 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 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 delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? die('error') : intval($p['id']); $tMO = new ArticleModel(); $tRow = $tMO->field('head_img')->where('id = ' . $pId)->fRow(); if (!empty($tRow['head_img'])) { unlink(APPLICATION_PATH . '/public' . $tRow['head_img']); } $tSql = 'delete from ' . $tMO->table . ' where id = ' . $pId; if (!$tMO->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } Tool_Fnc::ajaxMsg('删除成功', 1); }
public function normalAction() { $p = $_REQUEST; $tFMO = new FoodModel(); $tImgUrl = Yaf_Registry::get("config")->web->url->img; $tSql = 'select id fid,title,c_id cateid,c_title cate_title, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img ,tag,protein from ' . $tFMO->table . ' where suggest = 1 order by count desc,protein desc'; $tDRDatas = $tFMO->query($tSql); $tFUMO = new FoodunitsModel(); foreach ($tDRDatas as &$v) { $v['units'] = $tFUMO->field('unit,amount,weight')->where(' fid = ' . $v['fid'])->fList(); } Tool_Fnc::ajaxMsg('', 1, $tDRDatas); }
public function delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? die('ID不能为空') : intval($p['id']); $tMO = new CategoryModel(); $tRow = $tMO->field('count(0) c')->where('id = ' . $pId)->fRow(); if (empty($tRow['c'])) { Tool_Fnc::ajaxMsg('分类不存在'); } $tSql = 'delete from ' . $tMO->table . ' where id=' . $pId; if (!$tMO->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } Tool_Fnc::ajaxMsg('删除成功', 1); }
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 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 delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? die('ID不能为空') : floatval($p['id']); $tMO = new FoodModel(); $tRow = $tMO->field('large_img,thumb_img')->where('id = ' . $pId)->fRow(); $tSql = 'delete from ' . $tMO->table . ' where id=' . $pId; if (!$tMO->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } if (!empty($tRow['large_img'])) { unlink(APPLICATION_PATH . '/public' . $tRow['large_img']); } if (!empty($tRow['thumb_img'])) { unlink(APPLICATION_PATH . '/public' . $tRow['thumb_img']); } $tFT = new FoodtagModel(); $tSql = "delete from " . $tFT->table . " where fid =" . $pId; $tFT->exec($tSql); Tool_Fnc::ajaxMsg('删除成功', 1); }
public function addfoodAction() { $p = $_REQUEST; $pFid = empty($p['id']) ? Tool_Fnc::ajaxMsg('错误异常 001') : intval($p['id']); $tFMO = new FoodModel(); $tRow = $tFMO->field('id,title,tag,protein,thumb_img')->where('id =' . $pFid)->fRow(); $tRow['protein'] = floatval($tRow['protein']) / 100; $tFUMO = new FoodunitsModel(); $tUnit = $tFUMO->field('id,amount,unit,weight,calory')->where(' fid = ' . $pFid)->fList(); $tMTMO = new MealtypeModel(); $pType = $tMTMO->field('id,name')->fList(); $this->assign('tRow', $tRow); $this->assign('pUnit', $tUnit); $this->assign('pType', $pType); }
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 listAction() { $p = $_REQUEST; $tUAMO = new UserassessmentModel(); $tRow = $tUAMO->field('*')->where(' uid = ' . $this->tUid)->fRow(); $tRow['medical_date_01'] = empty($tRow['medical_date_01']) ? '0000-00' : substr($tRow['medical_date_01'], 0, strlen($tRow['medical_date_01']) - 3); $tRow['medical_date_02'] = empty($tRow['medical_date_02']) ? '0000-00' : substr($tRow['medical_date_02'], 0, strlen($tRow['medical_date_02']) - 3); $tRow['medical_date_03'] = empty($tRow['medical_date_03']) ? '0000-00' : substr($tRow['medical_date_03'], 0, strlen($tRow['medical_date_03']) - 3); $tRow['medical_date_04'] = empty($tRow['medical_date_04']) ? '0000-00' : substr($tRow['medical_date_04'], 0, strlen($tRow['medical_date_04']) - 3); $tCDMO = new CenterModel(); $tCRow = $tCDMO->field('provinces,cities,name')->where(' id = ' . $tRow['medical_id'])->fRow(); $tRow['provinces'] = empty($tCRow['provinces']) ? '' : $tCRow['provinces']; $tRow['cities'] = empty($tCRow['cities']) ? '' : $tCRow['cities']; $tRow['medical_addr'] = empty($tCRow['name']) ? '' : $tCRow['name']; $tODTMO = new OrdinarydialysistimeModel(); $tODTRow = $tODTMO->field('time,week')->where(' uid =' . $this->tUid)->fRow(); $tRow['time'] = empty($tODTRow['time']) ? '' : $tODTRow['time']; $tRow['week'] = empty($tODTRow['week']) ? '' : $tODTRow['week']; Tool_Fnc::ajaxMsg('', 1, $tRow); }
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 delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? die('ID不能为空') : intval($p['id']); $tAM = new AdminModel(); if (!$tAM->del($pId)) { Tool_Fnc::ajaxMsg('删除失败'); } Tool_Fnc::ajaxMsg('删除成功', 1); }
protected function valiCaptcha() { if (!isset($_POST['captcha'], $_SESSION['captcha']) || strtolower($_SESSION['captcha']) != strtolower($_POST['captcha'])) { #$this->assign('captchamsg', '验证码错误'); Tool_Fnc::ajaxMsg('验证码错误'); return false; } unset($_SESSION['captcha']); return true; }
public function delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? Tool_Fnc::ajaxMsg('ID不能为空') : intval($p['id']); $tDR = new FoodunitsModel(); $tSql = 'delete from ' . $tDR->table . ' where id = ' . $pId; if (!$tDR->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } Tool_Fnc::ajaxMsg('删除成功', 1); }