Exemplo n.º 1
0
 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('密码修改失败');
 }
Exemplo n.º 2
0
 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('密码修改失败');
 }
Exemplo n.º 3
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());
 }
Exemplo n.º 4
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.º 5
0
 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);
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 public function indexAction()
 {
     while (true) {
         $tTime = time();
         $tRunlogdir = APPLICATION_PATH . '/shell/runlog/cli_incognitoreal.run';
         Tool_Fnc::writefile($tRunlogdir, $tTime);
         $this->move();
         sleep(1);
     }
     exit;
 }
Exemplo n.º 9
0
 public function indexAction()
 {
     while (true) {
         $tTime = time();
         $tRunlogdir = APPLICATION_PATH . '/shell/runlog/cli_getuimsg.run';
         Tool_Fnc::writefile($tRunlogdir, $tTime);
         $this->sent();
         sleep(1);
     }
     exit;
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
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.º 12
0
 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);
 }
Exemplo n.º 13
0
 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;
     }
 }
Exemplo n.º 14
0
 public function indexAction()
 {
     #$tRow = Oci_User::isPhone('13677074886');
     #print_r($tRow);
     #$tRow = Oci_User::isPhone2('13677074886');
     #print_r($tRow);
     #exit();
     #header("Content-type: text/html; charset=utf-8");
     #echo '<pre>';
     #print_r(Tool_Fnc::weather('菏泽市'));
     #    echo $this->age('1989-09-12','2016-01-01');
     $data = Tool_Fnc::weather_juhe('北京');
     exit;
 }
Exemplo n.º 15
0
 private function process($pPs)
 {
     $tTime = time();
     $tRunlogfile = APPLICATION_PATH . '/shell/runlog/' . $pPs . '.run';
     $tRuntime = 0;
     if (is_file($tRunlogfile)) {
         $tRuntime = Tool_Fnc::readfile($tRunlogfile);
     }
     $tM = ($tTime - $tRuntime) / 60;
     if ($tM < 1) {
         return;
     }
     system("kill `ps -ef|grep " . $pPs . " | grep -v grep|awk '{print \$2}'`");
     pclose(popen(Yaf_Registry::get("config")->sys->php->bin . ' -f ' . APPLICATION_PATH . '/shell/Cli.php request_uri=/' . $pPs . ' &', 'r'));
 }
Exemplo n.º 16
0
 public function indexAction()
 {
     $tMO = new CenterModel();
     $tList = $tMO->field('cities,provinces')->where('cities <> \'\'')->group('cities')->fList();
     foreach ($tList as $tRow) {
         $tCities = $tRow['cities'];
         $tData = Tool_Fnc::weather_juhe($tCities);
         if (!$tData) {
             $tData = Tool_Fnc::weather_juhe($tRow['provinces']);
         }
         $tSql = 'update ' . $tMO->table . ' set today_weather = \'' . $tData['today_weather'] . '\',tomorrow_weather = \'' . $tData['tomorrow_weather'] . '\' where cities = \'' . $tCities . '\'';
         $tMO->exec($tSql);
     }
     exit;
 }
Exemplo n.º 17
0
 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));
 }
Exemplo n.º 18
0
 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);
 }
Exemplo n.º 19
0
 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;
 }
Exemplo n.º 20
0
 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);
 }
Exemplo n.º 21
0
 /**
  * Decodes a base32 string into a binary string.
  */
 static function base32_decode($b32)
 {
     $b32 = strtoupper($b32);
     if (!preg_match('/^[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]+$/', $b32, $match)) {
         Tool_Fnc::showMsg('非法输入');
     }
     $l = strlen($b32);
     $n = 0;
     $j = 0;
     $binary = "";
     for ($i = 0; $i < $l; $i++) {
         $n = $n << 5;
         // Move buffer left by 5 to make room
         $n = $n + self::$lut[$b32[$i]];
         // Add value into buffer
         $j = $j + 5;
         // Keep track of number of bits in buffer
         if ($j >= 8) {
             $j = $j - 8;
             $binary .= chr(($n & 0xff << $j) >> $j);
         }
     }
     return $binary;
 }
Exemplo n.º 22
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']);
     }
 }
Exemplo n.º 23
0
 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);
 }
Exemplo n.º 24
0
 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);
 }
Exemplo n.º 25
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.º 26
0
 public function foodAction()
 {
     $p = $_REQUEST;
     $pKey = empty($p['term']) ? '' : Tool_Fnc::safe_string($p['term']);
     $tMO = new FoodModel();
     if (!empty($pKey)) {
         $tWhere = 'title like "%' . $pKey . '%"';
     }
     if (!empty($pKey)) {
         $tDatas = $tMO->field('id,title,thumb_img')->where($tWhere)->limit(5)->fList();
     } else {
         $tDatas = $tMO->field('id,title,thumb_img')->limit(5)->fList();
     }
     Yaf_Dispatcher::getInstance()->autoRender(FALSE);
     die(json_encode($tDatas));
 }
Exemplo n.º 27
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.º 28
0
 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);
 }
Exemplo n.º 29
0
 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;
 }
Exemplo n.º 30
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']);
     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);
 }