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 updateUser($inputData) { //TODO::datacheck $data = ['name' => $inputData['name'], 'email' => $inputData['email']]; $where = ['id' => $inputData['id']]; return $this->userDao->update($data, $where); }
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 editAction() { if (!isset($_POST['name']) && !isset($_POST['firstname']) && !isset($_POST['pseudo']) && !isset($_POST['mdp']) && !isset($_POST['email']) && !isset($_SESSION['id_user'])) { return json_encode(["error" => "something is missing"]); } //$id_user = $_POST['id_user']; // A mettre quand connexion $id_user = 1; // A enlever quand connexion good $name_user = strip_tags($_POST['name']); $name_user = htmlentities($name_user); $name_user = trim($name_user); $firstname_user = strip_tags($_POST['firstname']); $firstname_user = htmlentities($firstname_user); $firstname_user = trim($firstname_user); $pseudo_user = strip_tags($_POST['pseudo']); $pseudo_user = htmlentities($pseudo_user); $pseudo_user = trim($pseudo_user); $mdp_user = strip_tags($_POST['password_user']); $mdp_user = htmlentities($mdp_user); $mdp_user = trim($mdp_user); $email_user = strip_tags($_POST['email']); $email_user = htmlentities($email_user); $email_user = trim($email_user); $id_article = UserModel::update($this->pdo, $name_user, $firstname_user, $pseudo_user, $mdp_user, $email_user, $id_user); return json_encode(["message" => "Connecté !", "id_user" => $id_user, "name_user" => $name_user, "password_user" => $mdp_user]); }
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); }
function onsetting() { $email = $_POST['eamil']; $user = new UserModel(); if ($user->update(array("email" => $email), array("uid" => $_SESSION['uid']))) { cpmsg("更新成功"); } }
static function modify($id, $data) { if (!$id || !$data) { return false; } $model = new UserModel(); $result = $model->update($id, $data); return $result; }
public static function LoginByPass($login, $pass) { $user = UserModel::Login($login, $pass); if ($user->id > 0) { self::$id = $user->id; self::$login = $user->login; self::$company_id = $user->companyid; $hash = self::NewHash($arr['id']); setcookie('userid', $hash, time() + 360000, '/'); UserModel::update(['hash' => $hash])->id($user->id); } }
public function review() { if ($this->isLogged()) { $this->load->model('UserModel'); $user = new UserModel(); $data = $user->search($this->session->userdata('userid')); $data['help'] = true; if ($user->update($data)) { redirect(base_url('help')); } } }
public function updateMissingData($user, array $me) { $updateData = array(); if (empty($user['name'])) { $updateData['name'] = $me['first_name']; } if (empty($user['fbuid'])) { $updateData['fbuid'] = $me['id']; } if (!empty($updateData)) { UserModel::update($user['id'], $updateData); } }
public function indexAction() { echo '<pre>'; $tTime = time(); $tH = date('H', $tTime); $tWhere = ' and PUNCTURE_NURSE is not NULL'; if ($tH >= 22 && $tH <= 23) { $tWhere = ''; } $tTRMO = new BqetreatmentrecordModel(); $tUAMO = new UserassessmentModel(); $tDWLMO = new DryweightlogModel(); $tUMO = new UserModel(); $tOci = new Orm_Oci(); $tHSql = 'select patient_id,treatment_times,fluid_volume,dialyzer,dialysis_mach,volume_na,volume_ca,volume_hc,volume_quantity,vascular_access,body_weight,bodyweight_bef,bodyweight_increase,ultrafilt_quantity,ufr,treat_time,blood_quantity,first_agent,maitain,additional,total_quantity,t,p,r,bp1,bp2,actual_treat_time,bodyweight_after,actual_ultrafilt_quantity,t_after,p_after,bp1_after,bp2_after,treate_summary,puncture_nurse,treate_nurse,doctor_user,to_char(treate_date,\'YYYY-mm-dd\') treate_date,treate_mode,dfz,vein_puncture,artery_puncture,kidney_solidification,dialyze_allergy,takeoff_needle from treatment_record where to_char(TREATE_DATE,\'YYYY-mm-dd\') = \'' . date('Y-m-d', $tTime) . '\' ' . $tWhere; #$tHSql = 'select patient_id,treatment_times,fluid_volume,dialyzer,dialysis_mach,volume_na,volume_ca,volume_hc,volume_quantity,vascular_access,body_weight,bodyweight_bef,bodyweight_increase,ultrafilt_quantity,ufr,treat_time,blood_quantity,first_agent,maitain,additional,total_quantity,t,p,r,bp1,bp2,actual_treat_time,bodyweight_after,actual_ultrafilt_quantity,t_after,p_after,bp1_after,bp2_after,treate_summary,puncture_nurse,treate_nurse,doctor_user,to_char(treate_date,\'YYYY-mm-dd\') treate_date,treate_mode,dfz,vein_puncture,artery_puncture,kidney_solidification,dialyze_allergy,takeoff_needle from treatment_record where to_char(TREATE_DATE,\'YYYY-mm-dd\') between \'2015-10-08\' and \'2015-12-08\''; $tDatas = $tOci->getAll($tHSql); foreach ($tDatas as $tRow) { $tTRRow = $tTRMO->field('count(0) c')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\' and treate_date = \'' . $tRow['TREATE_DATE'] . '\'')->fRow(); if (!empty($tTRRow['c'])) { continue; } foreach ($tRow as $k => $v) { $k = strtolower($k); $tData[$k] = $v; } $tUARow = $tUAMO->field('uid')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\'')->fRow(); $tData['uid'] = empty($tUARow['uid']) ? 0 : $tUARow['uid']; echo $tTRMO->insert($tData); echo "\r\n"; if (empty($tRow['BODY_WEIGHT'])) { continue; } if (!empty($tUid) && date('Y-m-d', $tTime) == $tRow['TREATE_DATE']) { #用户存在 并且干体重记录日期是今日 的话更新用户信息表 $tData = array('id' => $tUid, 'dry_weight' => $tRow['BODY_WEIGHT']); $tUMO->update($tData); } $tDWLRow = $tDWLMO->field('id')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\' and date = \'' . $tRow['TREATE_DATE'] . '\'')->fRow(); if (!empty($tDWLRow['id'])) { $tData = array('id' => $tDWLRow['id'], 'weight' => $tRow['BODY_WEIGHT'], 'updated' => $tTime); $tDWLMO->update($tData); } else { #干体重log $tData = array('weight' => $tRow['BODY_WEIGHT'], 'created' => $tTime, 'date' => $tRow['TREATE_DATE'], 'month' => date('Y-m', strtotime($tRow['TREATE_DATE'])), 'year' => date('Y', strtotime($tRow['TREATE_DATE'])), 'patient_id' => $tRow['PATIENT_ID']); $tDWLMO->insert($tData); } } exit; }
public function updateMissingData($user, array $google_user) { $updateData = array(); if (empty($user['name'])) { $updateData['name'] = $google_user['name']; } if (empty($user['surname']) or $user['surname'] == '') { $updateData['surname'] = $google_user['family_name']; } if (empty($user['google_id'])) { $updateData['google_id'] = $google_user['id']; } if (!empty($updateData)) { UserModel::update($user['id'], $updateData); } }
/** * Updates the user data * * @global type $STRINGS * @param type $params */ public function profile_update($params) { global $STRINGS; $userid = array_shift($params); //remove url params $params = array_slice($params, 1); //check if the password is set if (empty($params['password'])) { //no password is provided -> remove key unset($params['password']); } else { //compute new password and store $params['password'] = sha1($params['password']); } $success = UserModel::update($userid, $params); $success == true ? $alert = BootstrapHelper::alert('success', $STRINGS['event:success'], $STRINGS['user:update:success']) : ($alert = BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:update:failed'])); //refresh the user data $this->_data->user = UserModel::find($userid); new UserProfileView($this->_data, $alert); }
/** * Performs an authentication * * @param array * @return void * @throws AuthenticationException */ public function authenticate(array $credentials) { $username = $credentials[self::USERNAME]; $password = $credentials[self::PASSWORD]; $sql = dibi::query(' SELECT *, ' . TABLE_USERS . '.id AS id FROM [' . TABLE_USERS . '] LEFT JOIN [' . TABLE_USERS_INFO . '] ON (' . TABLE_USERS . '.id = ' . TABLE_USERS_INFO . '.user_id) WHERE login=%s;', $username); $sql->setType('permission', Dibi::BOOL); $row = $sql->fetch(); /*if (count($sql)==0) { throw new AuthenticationException('Unknown user', self::IDENTITY_NOT_FOUND); }*/ /*if ($row->password !== md5($password)) { throw new AuthenticationException('Password not match', self::INVALID_CREDENTIAL); }*/ /* ak to bolo stratene heslo */ if (count($sql) == 1 and $row->new_password == self::getHash($password)) { UserModel::update($row->id, array('password' => self::getHash($password), 'new_password' => NULL)); $row->password = $row->new_password; } if (count($sql) == 0 or $row->password !== self::getHash($password)) { throw new NAuthenticationException('Nespráne heslo alebo meno.', self::INVALID_CREDENTIAL); } // get roles $sql = dibi::query('SELECT r.key_name FROM [' . TABLE_ROLES . '] AS r RIGHT JOIN [' . TABLE_USERS_ROLES . '] AS us ON r.id=us.role_id WHERE us.user_id=%i;', $row->id); $roles = $sql->fetchPairs(); unset($row->password); return new NIdentity($username, $roles, $row); }
public function editAction() { $p = $_REQUEST; $tUMO = new UserModel(); $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow(); if ($tURow['user_type'] == 1) { Tool_Fnc::ajaxMsg('操作异常'); } $tData = array(); if (isset($p['name'])) { $tData = array_merge($tData, array('nickname' => Tool_Fnc::safe_string($p['name']))); } if (isset($p['date_of_birth'])) { $tData = array_merge($tData, array('date_of_birth' => date('Y-m-d', strtotime($p['date_of_birth'])))); } if (isset($p['sex'])) { $tData = array_merge($tData, array('sex' => intval($p['sex']))); } $tTime = time(); //存在干体重修改,则更新干体重记录 $pDryWeight = !isset($p['dry_weight']) ? '' : floatval($p['dry_weight']); $tUMO->begin(); if (!empty($pDryWeight)) { $tData = array_merge($tData, array('dry_weight' => $pDryWeight)); $tDWLMO = new DryweightlogModel(); $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . date('Y-m-d', $tTime) . '\'')->fRow(); if (empty($tDWLRow['id'])) { $tDWLData = array('weight' => $pDryWeight, 'uid' => $this->tUid, 'created' => $tTime, 'date' => date('Y-m-d', $tTime), 'month' => date('Y-m', $tTime), 'year' => date('Y', $tTime)); } else { $tDWLData = array('weight' => $pDryWeight, 'updated' => $tTime, 'id' => $tDWLRow['id']); } if (!$tDWLMO->save($tDWLData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 001'); } } //存在名字修改,则更新健康档案中的名字字段 if (isset($p['name']) && !empty($p['name'])) { $tUAMO = new UserassessmentModel(); $tUARow = $tUAMO->field('id,name')->where('uid = ' . $this->tUid)->fRow(); if (!empty($tUARow['id'])) { $tUADatas = array('id' => $tUARow['id'], 'name' => Tool_Fnc::safe_string($p['name']), 'updated' => $tTime); if (!$tUAMO->update($tUADatas)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 002'); } } else { $tUADatas = array('uid' => $this->tUid, 'name' => Tool_Fnc::safe_string($p['name']), 'created' => $tTime); if (!$tUAMO->insert($tUADatas)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 002'); } } } $tData = array_merge($tData, array('id' => $this->tUid, 'updated' => $tTime)); if (!$tUMO->update($tData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 003'); } $tUMO->commit(); Tool_Fnc::ajaxMsg('操作成功', 1); }
function saveUser(NForm $form) { $values = $form->getValues(); // print_r($values); // exit; unset($values['passwordCheck']); $id_user = $values['id']; unset($values['id']); //ak nevyplni heslo, zostava stare if ($values['password'] == '') { unset($values['password']); } UserModel::update($id_user, $values); $this->redirect('this'); }
public function update() { if ($this->isLogged()) { $page = $this->getPage(); $this->load->model('UserModel'); $user = new UserModel(); $data['id'] = $this->input->get('id'); $data['name'] = mb_strtoupper($this->input->get('name')); $data['username'] = $this->input->get('username'); $data['phone'] = $this->input->get('phone'); $pass = $this->input->get('changepass'); $confirmpass = $this->input->get('confirmpass'); if (empty($pass)) { $pass = $this->input->get('password'); $confirmpass = $pass; $data['password'] = $pass; } else { $data['password'] = md5($this->input->get('changepass')); } $data['role'] = $this->input->get('role'); $data['status'] = $this->input->get('status'); if ($pass === $confirmpass) { if (!$user->verifyusn($this->input->get('username'))) { if ($user->update($data)) { redirect(base_url('user/index/2')); } } else { $aux = $user->search($data['id']); if ($aux['username'] === $data['username']) { if ($user->update($data)) { redirect(base_url('user/index/2')); } } else { $savefail = array("class" => "danger", "message" => "Nome de usuário já existente no banco"); $data = $user->search($data['id']); $msg = array("savefail" => $savefail, "user" => $data); $this->load->view('template/super/header', $page); $this->load->view('super/edituser', $msg); $this->load->view('template/public/footer'); } } } else { $savefail = array("class" => "danger", "message" => "As senhas inseridas não são iguais"); $data = $user->search($data['id']); $msg = array("savefail" => $savefail, "user" => $data); $this->load->view('template/super/header', $page); $this->load->view('super/edituser', $msg); $this->load->view('template/public/footer'); } } }
public function edit($id = '') { if (!$id) { $id = request('id'); } if (isset($_POST['id'])) { $uname = request('uname'); $user = UserModel::get('', $uname); if ($user && $user['id'] != $id) { $this->error('用户名重复'); } $passwd = request('passwd'); if ($passwd) { if ($passwd != request('passwd2')) { $this->error('两次输入的密码不一致'); } $data['passwd'] = mymd5($passwd); } if ($GLOBALS['method'] != 'my') { $data['group_id'] = request('group_id'); $data['department_id'] = request('department_id'); } $data['alias'] = request('alias'); $data['uname'] = request('uname'); $data['phone'] = request('phone'); if (UserModel::update($id, $data)) { $this->success(request('reffer')); } else { $this->error('更新失败'); } } else { $user = UserModel::get($id); if (!$user) { $this->error('用户不存在'); } $this->assign('user', $user); $this->display('user_edit'); } }
/** * API:用户登陆 * * @access public * @param 无 * @return JsonView 响应json */ public function exeUserLogin() { $requestParam = $this->getAllParameters(); Logger::debug('requestParam:' . print_r($requestParam, true)); $requestJsonParam = $this->getDecodedJsonRequest(); Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true)); // 获取用户id $user_id = AuthModel::getUserID($requestJsonParam['account'], $requestJsonParam['password'], $pdo); if (!$user_id) { $view = new JsonView(); $messageArr['error'] = "密码不正确,请重新输入"; return $this->getViewByJson($view, $messageArr, 0, "auth/user_login"); } // 初始化缓存 $userInfo = UserAction::iniUserInfo($user_id); $loginInfo = UserAction::getUserLoginInfo($userInfo['s_login_info']); if ($loginInfo != false) { $taskInfo = TaskAndAchieveAction::randTask($user_id); $updateArr['s_login_info'] = serialize($loginInfo); $updateArr['s_task_info'] = serialize($taskInfo); UserCache::setByKey($user_id, 's_login_info', $loginInfo); UserCache::setByKey($user_id, 's_task_info', $taskInfo); $userInfo['s_login_info'] = $loginInfo; $userInfo['s_task_info'] = $taskInfo; UserModel::update($updateArr, $user = array('n_id' => $user_id), $pdo); //清零合体次数 FriendModel::clearFitNum($user_id); // // 成就 // $statisticArr['login_day'] = 1; // TaskAndAchieveAction::achieveStatistic( $user_id, $statisticArr ); } //$user_id = $requestParam['user_id']; //$userInfo = AuthModel::getUserInfo( $user_id, $pdo ); // 生成缓存 $newSessionKey = Util::generateSessionKey($user_id); $oldSessionKey = $requestParam['session_key']; Logger::debug('SessionKey1:' . $oldSessionKey); Logger::debug('SessionKey2:' . $newSessionKey); UserCache::setByKey($user_id, Constants::PREVIOUS_SESSION_KEY, $oldSessionKey); UserCache::setByKey($user_id, Constants::CURRENT_SESSION_KEY, $newSessionKey); //UserCache::setByKey($user_id, 'userInfo', $userInfo); //$messageArr['user'] = $userInfo; $messageArr['n_id'] = $user_id; $messageArr['total_day'] = $userInfo['s_login_info']['total_day']; $messageArr['session_key'] = $newSessionKey; $view = new JsonView(); return $this->getViewByJson($view, $messageArr, 1, "auth/user_login"); }
public function reiniPass() { $login = new AuthentificationModel(); $userModel = new UserModel(); $errors = array(); $mail = new PHPMailer(); $params = array(); // Les paramètres qu'on envoi a la vue, on utilisera les clés du tableau précédé par un $ pour les utiliser dans la vue if (!empty($_POST)) { // Faire vérification des champs ICI if (empty($_POST['email'])) { $errors[] = 'l\'email est vide'; } if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) !== false) { $errors[] = 'L\'email est invalide'; } // si pas d'erreurs, if (count($errors) == 0) { // on va vérifier qu'il existe un utilisateur avec cet email dans la base if ($idUser = $userModel->emailExists($_POST['email'])) { $token = password_hash($_POST['pass'], PASSWORD_DEFAULT); // on génère un 'token', identifiant unique $idUser = $userModel->getUserByUsernameOrEmail($_POST['email'])['id']; //chercher id $userModel->update(["confirmedToken" => $token, "dateConfirmedToken" => date('Y-m-d', strtotime('+1 week'))], $idUser); // on stocke le token dans la bdd pour cet utilisateur $successUrl = $this->generateUrl('reiniPassTok') . '?email=' . $_POST['email'] . '&token=' . $token; // on crée le lien permettant à l'utilisateur de resaisir un $successLink = "http://localhost" . $successUrl; // nouveau mot de passe // on envoie le mail avec le lien: $app = getApp(); //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->setLanguage('fr', '../../vendor/phpmailer/phpmailer/language/'); $mail->isSMTP(); // Set mailer to use SMTP $mail->send(); $mail->Host = $app->getConfig("phpmailer_server"); // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $app->getConfig("phpmailer_user"); // SMTP username $mail->Password = $app->getConfig("phpmailer_pass"); // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = $app->getConfig('phpmailer_port'); // TCP port to connect to $mail->setFrom($_POST['email'], 'vous même'); // Add a recipient $mail->addAddress($_POST['email']); //$mail->addAddress($_POST['email']); // Name is optional $mail->addReplyTo('*****@*****.**', 'Information'); /*$mail->addCC('*****@*****.**'); $mail->addBCC('*****@*****.**'); $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name */ $mail->isHTML(true); $mail->Body = '<a href="' . $successLink . '">Reinitialisez votre mot de passe en cliquant sur cette phrase ce liens est valable une semaine après merci de refaire une demande.</a>'; // Set email format to HTML } else { // si non: // message d'erreur: cette adresse mail ne correspond pas à un membre du site $errors[] = 'L\'email n\'existe pas'; } // si oui: // on génère un 'token', identifiant unique // on stocke le token dans la bdd pour cet utilisateur // on crée le lien permettant à l'utilisateur de resaisir un nouveau mot de passe // ce lien doit contenir le token, c'est ce qui nous permettra de vérifier que l'utilisateur qui saisit le nouveau mot de passe est bien le propriétaire de l'adresse email (qui a cliqué sur le lien) if (!$mail->send()) { $errors[] = 'L\'email n\'a pas pu être envoyé'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { $params['success'] = 'Youhou, c\'est envoyé!'; } } } if (count($errors) > 0) { $params['errors'] = $errors; } $this->show('admin/reiniPass', $params); }
public function indexAction() { $p = $_REQUEST; //判断用户是否为白求恩用户 $tUMO = new UserModel(); $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow(); if (empty($tURow) || $tURow['user_type'] == 1) { Tool_Fnc::ajaxMsg('操作错误'); } $tData = array(); $pPatientId = !isset($p['patient_id']) ? '' : ($tData['patient_id'] = Tool_Fnc::safe_string($p['patient_id'])); $pInpNo = !isset($p['inp_no']) ? '' : ($tData['inp_no'] = Tool_Fnc::safe_string($p['inp_no'])); $pMedicalDate01 = !isset($p['medical_date_01']) ? '' : ($tData['medical_date_01'] = Tool_Fnc::safe_string($p['medical_date_01'] . '-01')); $pMedicalDate02 = !isset($p['medical_date_02']) ? '' : ($tData['medical_date_02'] = Tool_Fnc::safe_string($p['medical_date_02'] . '-01')); $pMedicalDate03 = !isset($p['medical_date_03']) ? '' : ($tData['medical_date_03'] = Tool_Fnc::safe_string($p['medical_date_03'] . '-01')); $pMedicalDate04 = !isset($p['medical_date_04']) ? '' : ($tData['medical_date_04'] = Tool_Fnc::safe_string($p['medical_date_04'] . '-01')); $pPresent01 = !isset($p['present_01']) ? '' : ($tData['present_01'] = Tool_Fnc::safe_string($p['present_01'])); $pPresent02 = !isset($p['present_02']) ? '' : ($tData['present_02'] = Tool_Fnc::safe_string($p['present_02'])); $pPresent03 = !isset($p['present_03']) ? '' : ($tData['present_03'] = Tool_Fnc::safe_string($p['present_03'])); $pPresent04 = !isset($p['present_04']) ? '' : ($tData['present_04'] = Tool_Fnc::safe_string($p['present_04'])); $pPresent05 = !isset($p['present_05']) ? '' : ($tData['present_05'] = Tool_Fnc::safe_string($p['present_05'])); $pPresent06 = !isset($p['present_06']) ? '' : ($tData['present_06'] = Tool_Fnc::safe_string($p['present_06'])); $pPresent07 = !isset($p['present_07']) ? '' : ($tData['present_07'] = Tool_Fnc::safe_string($p['present_07'])); $pPresent08 = !isset($p['present_08']) ? '' : ($tData['present_08'] = Tool_Fnc::safe_string($p['present_08'])); $pPresent09 = !isset($p['present_09']) ? '' : ($tData['present_09'] = Tool_Fnc::safe_string($p['present_09'])); $pPresent10 = !isset($p['present_10']) ? '' : ($tData['present_10'] = Tool_Fnc::safe_string($p['present_10'])); $pPresent11 = !isset($p['present_11']) ? '' : ($tData['present_11'] = Tool_Fnc::safe_string($p['present_11'])); $pPresent12 = !isset($p['present_12']) ? '' : ($tData['present_12'] = Tool_Fnc::safe_string($p['present_12'])); $pPresent13 = !isset($p['present_13']) ? '' : ($tData['present_13'] = Tool_Fnc::safe_string($p['present_13'])); $pPresent14 = !isset($p['present_14']) ? '' : ($tData['present_14'] = Tool_Fnc::safe_string($p['present_14'])); $pPresent15 = !isset($p['present_15']) ? '' : ($tData['present_15'] = Tool_Fnc::safe_string($p['present_15'])); $pPresent16 = !isset($p['present_16']) ? '' : ($tData['present_16'] = Tool_Fnc::safe_string($p['present_16'])); $pPresent17 = !isset($p['present_17']) ? '' : ($tData['present_17'] = Tool_Fnc::safe_string($p['present_17'])); $pPresent18 = !isset($p['present_18']) ? '' : ($tData['present_18'] = Tool_Fnc::safe_string($p['present_18'])); $pPresent19 = !isset($p['present_19']) ? '' : ($tData['present_19'] = Tool_Fnc::safe_string($p['present_19'])); $pPresent20 = !isset($p['present_20']) ? '' : ($tData['present_20'] = Tool_Fnc::safe_string($p['present_20'])); $pPresent21 = !isset($p['present_21']) ? '' : ($tData['present_21'] = Tool_Fnc::safe_string($p['present_21'])); $pPresent22 = !isset($p['present_22']) ? '' : ($tData['present_22'] = Tool_Fnc::safe_string($p['present_22'])); $pPresent23 = !isset($p['present_23']) ? '' : ($tData['present_23'] = Tool_Fnc::safe_string($p['present_23'])); $pPresent24 = !isset($p['present_24']) ? '' : ($tData['present_24'] = Tool_Fnc::safe_string($p['present_24'])); $pComplication01 = !isset($p['complication_01']) ? '' : ($tData['complication_01'] = Tool_Fnc::safe_string($p['complication_01'])); $pComplication02 = !isset($p['complication_02']) ? '' : ($tData['complication_02'] = Tool_Fnc::safe_string($p['complication_02'])); $pComplication03 = !isset($p['complication_03']) ? '' : ($tData['complication_03'] = Tool_Fnc::safe_string($p['complication_03'])); $pComplication04 = !isset($p['complication_04']) ? '' : ($tData['complication_04'] = Tool_Fnc::safe_string($p['complication_04'])); $pComplication05 = !isset($p['complication_05']) ? '' : ($tData['complication_05'] = Tool_Fnc::safe_string($p['complication_05'])); $pComplication06 = !isset($p['complication_06']) ? '' : ($tData['complication_06'] = Tool_Fnc::safe_string($p['complication_06'])); $pMedPast011 = !isset($p['med_past_011']) ? '' : ($tData['med_past_011'] = Tool_Fnc::safe_string($p['med_past_011'])); $pMedPast012 = !isset($p['med_past_012']) ? '' : ($tData['med_past_012'] = Tool_Fnc::safe_string($p['med_past_012'])); $pMedPast013 = !isset($p['med_past_013']) ? '' : ($tData['med_past_013'] = Tool_Fnc::safe_string($p['med_past_013'])); $pMedPast021 = !isset($p['med_past_021']) ? '' : ($tData['med_past_021'] = Tool_Fnc::safe_string($p['med_past_021'])); $pMedPast022 = !isset($p['med_past_022']) ? '' : ($tData['med_past_022'] = Tool_Fnc::safe_string($p['med_past_022'])); $pMedPast031 = !isset($p['med_past_031']) ? '' : ($tData['med_past_031'] = Tool_Fnc::safe_string($p['med_past_031'])); $pMedPast032 = !isset($p['med_past_032']) ? '' : ($tData['med_past_032'] = Tool_Fnc::safe_string($p['med_past_032'])); $pMedPast033 = !isset($p['med_past_033']) ? '' : ($tData['med_past_033'] = Tool_Fnc::safe_string($p['med_past_033'])); $pMedPast034 = !isset($p['med_past_034']) ? '' : ($tData['med_past_034'] = Tool_Fnc::safe_string($p['med_past_034'])); $pMedPast035 = !isset($p['med_past_035']) ? '' : ($tData['med_past_035'] = Tool_Fnc::safe_string($p['med_past_035'])); $pMedPast036 = !isset($p['med_past_036']) ? '' : ($tData['med_past_036'] = Tool_Fnc::safe_string($p['med_past_036'])); $pMedPast037 = !isset($p['med_past_037']) ? '' : ($tData['med_past_037'] = Tool_Fnc::safe_string($p['med_past_037'])); $pMedPast041 = !isset($p['med_past_041']) ? '' : ($tData['med_past_041'] = Tool_Fnc::safe_string($p['med_past_041'])); $pMedPast042 = !isset($p['med_past_042']) ? '' : ($tData['med_past_042'] = Tool_Fnc::safe_string($p['med_past_042'])); $pMedPast043 = !isset($p['med_past_043']) ? '' : ($tData['med_past_043'] = Tool_Fnc::safe_string($p['med_past_043'])); $pMedPast044 = !isset($p['med_past_044']) ? '' : ($tData['med_past_044'] = Tool_Fnc::safe_string($p['med_past_044'])); $pMedPast045 = !isset($p['med_past_045']) ? '' : ($tData['med_past_045'] = Tool_Fnc::safe_string($p['med_past_045'])); $pMedPast046 = !isset($p['med_past_046']) ? '' : ($tData['med_past_046'] = Tool_Fnc::safe_string($p['med_past_046'])); $pMedPast05 = !isset($p['med_past_05']) ? '' : ($tData['med_past_05'] = Tool_Fnc::safe_string($p['med_past_05'])); $pMedPast06 = !isset($p['med_past_06']) ? '' : ($tData['med_past_06'] = Tool_Fnc::safe_string($p['med_past_06'])); $pMedPast07 = !isset($p['med_past_07']) ? '' : ($tData['med_past_07'] = Tool_Fnc::safe_string($p['med_past_07'])); $pMedPast08 = !isset($p['med_past_08']) ? '' : ($tData['med_past_08'] = Tool_Fnc::safe_string($p['med_past_08'])); $pMedPast09 = !isset($p['med_past_09']) ? '' : ($tData['med_past_09'] = Tool_Fnc::safe_string($p['med_past_09'])); $pMedPast10 = !isset($p['med_past_10']) ? '' : ($tData['med_past_10'] = Tool_Fnc::safe_string($p['med_past_10'])); $pMedPast11 = !isset($p['med_past_11']) ? '' : ($tData['med_past_11'] = Tool_Fnc::safe_string($p['med_past_11'])); $pMedPast12 = !isset($p['med_past_12']) ? '' : ($tData['med_past_12'] = Tool_Fnc::safe_string($p['med_past_12'])); $pMedPast13 = !isset($p['med_past_13']) ? '' : ($tData['med_past_13'] = Tool_Fnc::safe_string($p['med_past_13'])); $pBodyHeight = !isset($p['body_height']) ? '' : ($tData['body_height'] = floatval($p['body_height'])); $pDialysisNo = !isset($p['dialysis_no']) ? '' : ($tData['dialysis_no'] = floatval($p['dialysis_no'])); $pAnticoagulation = !isset($p['anticoagulation']) ? '' : ($tData['anticoagulation'] = Tool_Fnc::safe_string($p['anticoagulation'])); $pIfIn = !isset($p['if_in']) ? '' : ($tData['if_in'] = Tool_Fnc::safe_string($p['if_in'])); $pWeeks = !isset($p['weeks']) ? '' : ($tData['weeks'] = floatval($p['weeks'])); $pPresent101 = !isset($p['present_10_1']) ? '' : ($tData['present_10_1'] = Tool_Fnc::safe_string($p['present_10_1'])); $pPresent041 = !isset($p['present_04_1']) ? '' : ($tData['present_04_1'] = Tool_Fnc::safe_string($p['present_04_1'])); $pPresent201 = !isset($p['present_20_1']) ? '' : ($tData['present_20_1'] = Tool_Fnc::safe_string($p['present_20_1'])); $pPresent241 = !isset($p['present_24_1']) ? '' : ($tData['present_24_1'] = Tool_Fnc::safe_string($p['present_24_1'])); $pMedPast051 = !isset($p['med_past_05_1']) ? '' : ($tData['med_past_05_1'] = Tool_Fnc::safe_string($p['med_past_05_1'])); $pMedPast061 = !isset($p['med_past_06_1']) ? '' : ($tData['med_past_06_1'] = Tool_Fnc::safe_string($p['med_past_06_1'])); $pMedPast071 = !isset($p['med_past_07_1']) ? '' : ($tData['med_past_07_1'] = Tool_Fnc::safe_string($p['med_past_07_1'])); $pMedPast081 = !isset($p['med_past_08_1']) ? '' : ($tData['med_past_08_1'] = Tool_Fnc::safe_string($p['med_past_08_1'])); $pMedPast091 = !isset($p['med_past_09_1']) ? '' : ($tData['med_past_09_1'] = Tool_Fnc::safe_string($p['med_past_09_1'])); $pMedPast101 = !isset($p['med_past_10_1']) ? '' : ($tData['med_past_10_1'] = Tool_Fnc::safe_string($p['med_past_10_1'])); $pMedPast111 = !isset($p['med_past_11_1']) ? '' : ($tData['med_past_11_1'] = Tool_Fnc::safe_string($p['med_past_11_1'])); $pMedPast121 = !isset($p['med_past_12_1']) ? '' : ($tData['med_past_12_1'] = Tool_Fnc::safe_string($p['med_past_12_1'])); $pMedPast131 = !isset($p['med_past_13_1']) ? '' : ($tData['med_past_13_1'] = Tool_Fnc::safe_string($p['med_past_13_1'])); $pMedPast102 = !isset($p['med_past_10_2']) ? '' : ($tData['med_past_10_2'] = Tool_Fnc::safe_string($p['med_past_10_2'])); $pMethod = !isset($p['method']) ? '' : ($tData['method'] = intval($p['method'])); $pMedicalType = !isset($p['medical_type']) ? '' : ($tData['medical_type'] = Tool_Fnc::safe_string($p['medical_type'])); $pProvinces = !isset($p['provinces']) ? '' : ($tData['provinces'] = Tool_Fnc::safe_string($p['provinces'])); $pCities = !isset($p['cities']) ? '' : ($tData['cities'] = Tool_Fnc::safe_string($p['cities'])); $pMedicalAddr = !isset($p['medical_addr']) ? '' : ($tData['medical_addr'] = Tool_Fnc::safe_string($p['medical_addr'])); $pName = !isset($p['name']) ? '' : ($tData['name'] = Tool_Fnc::safe_string($p['name'])); $tTime = time(); $pAssessTime = !isset($p['assess_time']) ? '' : ($tData['assess_time'] = Tool_Fnc::safe_string($p['assess_time'])); $pAssessWeek = !isset($p['assess_week']) ? '' : ($tData['assess_week'] = Tool_Fnc::safe_string($p['assess_week'])); $pAssesstimecode = !isset($p['assess_time_code']) ? '' : ($tData['assess_time_code'] = intval($p['assess_time_code'])); //判断是否有数据 if (!count($tData)) { Tool_Fnc::ajaxMsg('数据异常'); } //更新用户表字段用户名 if (isset($tData['name']) && !empty($tData['name'])) { $tUMO = new UserModel(); $tUData = array('id' => $this->tUid, 'nickname' => $tData['name'], 'updated' => $tTime); if (!$tUMO->update($tUData)) { Tool_Fnc::ajaxMsg('更新失败'); } } //先更新透析中心 $tCMO = new CenterModel(); $tCData = array(); if (isset($tData['medical_addr']) && !empty($tData['medical_addr'])) { $tCData = array_merge($tCData, array('name' => $tData['medical_addr'])); } if (isset($tData['provinces']) && !empty($tData['provinces'])) { $tCData = array_merge($tCData, array('provinces' => $tData['provinces'])); } if (isset($tData['cities']) && !empty($tData['cities'])) { $tCData = array_merge($tCData, array('cities' => $tData['cities'])); } if (!empty($tCData)) { $sql = "select id from {$tCMO->table} where name = '{$tData['medical_addr']}' and provinces = '{$tData['provinces']}' and cities ='{$tData['cities']}' and type = 0"; $tCMOList = $tCMO->query($sql); if (empty($tCMOList[0]['id'])) { $tCData = array_merge($tCData, array('created' => $tTime)); $tCData = array_merge($tCData, array('type' => 0)); //获取天气 $tWeatherCities = array('北京', '天津', '上海', '重庆'); if (in_array($tCData['provinces'], $tWeatherCities)) { $tWeatherCity = $tCData['provinces']; } else { $tWeatherCity = $tCData['cities']; } $tWeather = Tool_Fnc::weather_juhe($tWeatherCity); $tCData['today_weather'] = $tWeather['today_weather']; $tCData['tomorrow_weather'] = $tWeather['tomorrow_weather']; if (!($tMedicalId = $tCMO->insert($tCData))) { Tool_Fnc::ajaxMsg('插入失败'); } $tUData = array('id' => $this->tUid, 'center_id' => $tMedicalId, 'medical_addr' => $tData['medical_addr'], 'updated' => $tTime); } else { $tUData = array('id' => $this->tUid, 'center_id' => $tCMOList[0]['id'], 'medical_addr' => $tData['medical_addr'], 'updated' => $tTime); } //更新用户表字段 $tUMO = new UserModel(); if (!$tUMO->update($tUData)) { Tool_Fnc::ajaxMsg('更新失败'); } } //更新普通会员的透析时间 $tODTMO = new OrdinarydialysistimeModel(); $tODTData = array(); if (isset($tData['assess_time'])) { $tData['assess_time'] = empty($tData['assess_time']) ? '' : Tool_Fnc::safe_string($tData['assess_time']); $tODTData = array_merge($tODTData, array('time' => Tool_Fnc::safe_string($tData['assess_time']))); } if (isset($tData['assess_week'])) { $tData['assess_week'] = empty($tData['assess_week']) ? '' : Tool_Fnc::safe_string($tData['assess_week']); $tODTData = array_merge($tODTData, array('week' => Tool_Fnc::safe_string($tData['assess_week']))); } if (isset($tData['assess_time_code'])) { $tData['assess_time_code'] = empty($tData['assess_time_code']) ? 0 : intval($tData['assess_time_code']); $tODTData = array_merge($tODTData, array('time_code' => intval($tData['assess_time_code']))); } if (!empty($tODTData)) { $tODTRow = $tODTMO->field('id')->where(' uid = ' . $this->tUid)->fRow(); if (empty($tODTRow['id'])) { $tODTData = array_merge($tODTData, array('created' => $tTime)); $tODTData = array_merge($tODTData, array('uid' => $this->tUid)); if (!$tODTMO->insert($tODTData)) { Tool_Fnc::ajaxMsg('插入失败'); } } else { $tODTData = array_merge($tODTData, array('updated' => $tTime)); $tODTData = array_merge($tODTData, array('id' => $tODTRow['id'])); if (!$tODTMO->update($tODTData)) { Tool_Fnc::ajaxMsg('更新失败'); } } } //判断是更新还是插入健康档案 $tUAMO = new UserassessmentModel(); $tRow = $tUAMO->field('id,medical_id')->where(' uid = ' . $this->tUid)->fRow(); $tData['uid'] = $this->tUid; $tRow['medical_id'] = empty($tRow['medical_id']) ? 0 : $tRow['medical_id']; $tData['medical_id'] = isset($tMedicalId) ? $tMedicalId : $tRow['medical_id']; if (empty($tRow['id'])) { $tData = array_merge($tData, array('created' => $tTime)); if (!$tUAMO->insert($tData)) { Tool_Fnc::ajaxMsg('插入失败'); } } else { $tData['id'] = $tRow['id']; $tData['updated'] = $tTime; if (!$tUAMO->update($tData)) { Tool_Fnc::ajaxMsg('更新失败'); } } Tool_Fnc::ajaxMsg('数据操作成功', 1); }
public function addEditOnFormSubmitted(NAppForm $form) { $error = false; dibi::begin(); // add action if ($this->getAction() == 'add') { try { $values = $form->getValues(); $roles = $values['roles']; unset($values['password2'], $values['roles']); // $values['password'] = md5($values['password']); // dibi::query('INSERT INTO ['.TABLE_USERS.'] %v;', $values); $user_id = UserModel::insert($values); if (count($roles)) { foreach ($roles as $role) { dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $user_id, $role); } } $this->flashMessage('The user has been added.', 'ok'); dibi::commit(); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Users:'); } catch (Exception $e) { $error = true; $form->addError('The user has not been added.'); throw $e; } } else { // edit action $id = $this->getParam('id'); try { $values = $form->getValues(); $roles = $values['roles']; unset($values['roles']); unset($values['password2']); // dibi::query('UPDATE ['.TABLE_USERS.'] SET %a WHERE id=%i;', $values, $id); UserModel::update($id, $values); dibi::query('DELETE FROM [' . TABLE_USERS_ROLES . '] WHERE user_id=%i;', $id); if (count($roles)) { foreach ($roles as $role) { dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $id, $role); } } $this->flashMessage('The user has been edited.', 'ok'); dibi::commit(); if (ACL_CACHING) { unset($this->cache['gui_acl']); // invalidate cache } $this->redirect('Users:'); } catch (Exception $e) { $error = true; $form->addError('The user has not been edited.'); throw $e; } } if ($error) { dibi::rollback(); } }
/** * 修改状态 * * */ public function statusAction() { $id = $this->getg('id', 0); if (empty($id)) { $this->error('id 不能为空!'); } $status = $this->getg('status', 0); $status = $status ? 0 : 1; // 实例化Model $user = new UserModel(); $row = $user->update(array('id' => $id), array('status' => $status)); if ($row) { $this->error('恭喜,操作成功', 'Message'); } else { $this->error('操作失败'); } }
} else { // TODO: populate last inputs to session // return back to form header('location:../form.php?action=create&status=failed'); } break; case 'edit': // TODO: data validation // populate input from user $user->setId($_POST['id']); $user->setFirstName($_POST['first_name']); $user->setLastName($_POST['last_name']); $user->setUsername($_POST['username']); $user->setPassword($_POST['password']); // update database if ($userModel->update($user)) { header('location:../index.php?action=edit&status=success'); } else { // TODO: populate last inputs to session // return back to form : no rows affected // header('location:../form.php?action=edit&id='.$_POST['id'].'&status=failed'); header('location:../index.php?action=edit&status=success'); } break; case 'delete': // populate input from user $user->setId($_POST['id']); // delete from database if ($userModel->delete($user)) { header('location:../index.php?action=delete&status=success'); } else {
/** * API:游戏结算 * * @access public * @param 无 * @return JsonView 响应json * {"scoreInfo":{"combo":[5,3,4],"award":10,"deduction":[3,2],"kill":{"monster":5,"boss":2}},"checkpoint_id":3,"scr_length":5,"star_num":5,"diamond":2,"pass":1} */ public function exeEndGame() { $requestParam = $this->getAllParameters(); Logger::debug('requestParam:' . print_r($requestParam, true)); $requestJsonParam = $this->getDecodedJsonRequest(); Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true)); //------------------------------------统计分数--------------------------------------- $checkPointId = $requestJsonParam['checkpoint_id']; // 评级总分 $dir = IniFileManager::getRootDir() . "files/csv/" . self::CHECKPOINT_LIST . ".csv"; $str = "checkpoint_id = " . $checkPointId; $checkpointArr = Util::readCsv($dir, $str); if (empty($checkpointArr)) { $view = new JsonView(); $messageArr['error'] = "关卡不存在"; return $this->getViewByJson($view, $messageArr, 0, "game/end_game"); } $gradeScore = $checkpointArr[0]['grade_score']; $scoreInfo = $requestJsonParam['scoreInfo']; // 连击奖励分总和 if (count($scoreInfo['combo']) > 0) { foreach ($scoreInfo['combo'] as $key => $value) { $comboNum = $value; } } $comboTotal = $comboNum * 3; // 得人参果分总和 $rewardTotal = $scoreInfo['award']; // 杀怪总分 $killTotal = $scoreInfo['kill']['monster'] + $scoreInfo['kill']['boss'] * 3; // 被击扣分总和 $deduction = $scoreInfo['deduction'][0] * 5 + $scoreInfo['deduction'][1] * 5; // 通关分 $passScore = $gradeScore * 0.1; // 技巧评分 $skillScore = ($comboTotal + $rewardTotal + $killTotal + $passScore - $deduction) / $gradeScore * 100; //------------------------------------最优关卡信息--------------------------------------- // 获取原有最优信息 $userInfo = UserCache::getAllUserCache($requestParam['user_id']); if (!$userInfo) { $userInfo = UserAction::iniUserInfo($requestParam['user_id']); } $checkPointInfo = $userInfo['s_checkpoint_info']; // 此次游戏需对比信息 $newInfo['score'] = $skillScore; $newInfo['scr_length'] = $requestJsonParam['scr_length']; $newInfo['reward'] = $scoreInfo['award']; $newInfo['kill_num'] = $scoreInfo['kill']['monster'] + $scoreInfo['kill']['boss']; $newInfo['star_num'] = $requestJsonParam['star_num']; $addStarNum = 0; if ($checkPointInfo[$checkPointId]) { // 分数判断 if ($newInfo['score'] > $checkPointInfo[$checkPointId]['score']) { $checkPointInfo[$checkPointId]['score'] = $newInfo['score']; $updateType = 1; } // 最短划痕 if ($newInfo['scr_length'] < $checkPointInfo[$checkPointId]['scr_length']) { $checkPointInfo[$checkPointId]['scr_length'] = $newInfo['scr_length']; $updateType = 1; } // 单局最多人生果 if ($newInfo['reward'] > $checkPointInfo[$checkPointId]['reward']) { $checkPointInfo[$checkPointId]['reward'] = $newInfo['reward']; $updateType = 1; } // 单局杀死最多怪物数 if ($newInfo['kill_num'] > $checkPointInfo[$checkPointId]['kill_num']) { $checkPointInfo[$checkPointId]['kill_num'] = $newInfo['kill_num']; $updateType = 1; } // 该关卡获得星星数 if ($newInfo['star_num'] > $checkPointInfo[$checkPointId]['star_num']) { $checkPointInfo[$checkPointId]['star_num'] = $newInfo['star_num']; $updateType = 1; $addStarNum = $newInfo['star_num'] - $checkPointInfo[$checkPointId]['star_num']; } } else { $updateType = 1; $checkPointInfo[$checkPointId] = $newInfo; // 预留激活下一关 } // 增加钻石 if ($requestJsonParam['diamond']) { $newUserInfo['n_diamond'] = $userInfo['n_diamond'] + $requestJsonParam['diamond']; $updateType = 1; } // 增加魂石数 if ($requestJsonParam['soul']) { $newUserInfo['n_soul'] = $userInfo['n_soul'] + $requestJsonParam['soul']; $updateType = 1; } // 增加人生果数 if ($newInfo['reward']) { $newUserInfo['n_coin'] = $userInfo['n_coin'] + $newInfo['reward']; $updateType = 1; } if ($requestJsonParam['pass'] == 1 && $checkPointId >= $userInfo['n_max_checkpoint']) { $updateType = 1; // 更新排行榜 $newRank['id'] = $user_id; $newRank['max_checkpoint'] = $checkPointId; $newRank['battle'] = $userInfo['n_battle']; $cache = UserCache::setByKey(Constants::WORLD_RANK, $user_id, $newRank); $newUserInfo['n_max_checkpoint'] = $checkPointId; UserCache::setByKey($requestParam['user_id'], 'n_max_checkpoint', $checkPointId); } if ($updateType == 1) { //成功才存关卡信息 if ($requestJsonParam['lose_type'] == 0) { $newUserInfo['s_checkpoint_info'] = serialize($checkPointInfo); UserCache::setByKey($requestParam['user_id'], 's_checkpoint_info', $checkPointInfo); } if ($newUserInfo) { UserModel::update($newUserInfo, $user = array('n_id' => $requestParam['user_id']), $pdo); } if ($newUserInfo['n_diamond']) { UserCache::setByKey($requestParam['user_id'], 'n_diamond', $newUserInfo['n_diamond']); } if ($newUserInfo['n_soul']) { UserCache::setByKey($requestParam['user_id'], 'n_soul', $newUserInfo['n_soul']); } if ($newUserInfo['n_coin']) { UserCache::setByKey($requestParam['user_id'], 'n_coin', $newUserInfo['n_coin']); } } // 任务成就信息 $statisticArr['check_point_id'] = $checkPointId; $statisticArr['pass'] = $requestJsonParam['pass']; $statisticArr['lose_type'] = $requestJsonParam['lose_type']; $statisticArr['reward'] = $scoreInfo['award']; $statisticArr['monster'] = $scoreInfo['kill']['monster']; $statisticArr['boss'] = $scoreInfo['kill']['boss']; $statisticArr['all_star'] = $requestJsonParam['star_num'] == 3 ? 1 : 0; $statisticArr['soul'] = $requestJsonParam['soul']; $statisticArr['away'] = $scoreInfo['deduction'][0]; $statisticArr['attack'] = $scoreInfo['deduction'][1]; $statisticArr['star_num'] = $newInfo['star_num']; $statisticArr['skill_num'] = $requestJsonParam['skill_num']; $beforGame = TaskAndAchieveAction::endNotice($requestParam['user_id']); TaskAndAchieveAction::taskStatistic($requestParam['user_id'], $statisticArr); $finishInfo = TaskAndAchieveAction::achieveStatistic($requestParam['user_id'], $statisticArr); /*------------------------------扣除用户体力、购买一次性道具道具----------------------*/ // 获取体力 $userThew = $userInfo['n_thew']; // 更新用户体力 $nowThew = $userThew - 1; if ($nowThew < 0) { $view = new JsonView(); $messageArr['error'] = "体力不足"; return $this->getViewByJson($view, $messageArr, 0, "game/end_game"); } else { if ($userThew == Constants::USER_MAX_THEW) { $recordArr['n_refresh_time'] = $userInfo['n_refresh_time'] = time(); } } // 购买一次性道具 if ($requestJsonParam['propArr'] && count($requestJsonParam['propArr'])) { foreach ($requestJsonParam['propArr'] as $key => $item_id) { $result = BuyPropAction::buyProp($requestParam['user_id'], $item_id); if ($result == false) { $view = new JsonView(); $messageArr['error'] = "人生果不足"; return $this->getViewByJson($view, $messageArr, 0, "game/end_game"); } } } $recordArr['n_thew'] = $nowThew; $wheresArr['n_id'] = $requestParam['user_id']; UserCache::setByKey($requestParam['user_id'], 'n_thew', $nowThew); UserCache::setByKey($requestParam['user_id'], 'n_refresh_time', $userInfo['n_refresh_time']); UserModel::update($recordArr, $wheresArr); // 生成缓存 $newSessionKey = Util::generateSessionKey($requestParam['user_id']); $oldSessionKey = $requestParam['session_key']; Logger::debug('SessionKey1:' . $oldSessionKey); Logger::debug('SessionKey2:' . $newSessionKey); UserCache::setByKey($requestParam['user_id'], Constants::PREVIOUS_SESSION_KEY, $oldSessionKey); UserCache::setByKey($requestParam['user_id'], Constants::CURRENT_SESSION_KEY, $newSessionKey); $messageArr = RankAction::getFriendRank($requestParam['user_id']); $afterGame = TaskAndAchieveAction::endNotice($requestParam['user_id']); $messageArr['unlockInfo'] = GeneralAction::isUnlock($requestParam['user_id']); //获取解锁武将 $general = GeneralAction::GetAllGeneralInfo($requestParam['user_id']); $messageArr['generalInfo'] = $general['generalInfo']; $messageArr['achieveInfo'] = array_values(array_diff($afterGame['achieveInfo'], $beforGame['achieveInfo'])); $messageArr['finish_num'] = $afterGame['finish_num'] > $beforGame['finish_num'] ? $afterGame['finish_num'] : 0; $messageArr['n_thew'] = $nowThew; $messageArr['n_refresh_time'] = $userInfo['n_refresh_time']; $messageArr['server_time'] = time(); $messageArr['time_num'] = Constants::REFRESH_THEW_TIME; $messageArr['session_key'] = $newSessionKey; $view = new JsonView(); return $this->getViewByJson($view, $messageArr, 1, "game/end_game"); }
public function addGomeAction() { Zend_Loader::loadClass('UserModel'); $user_model = new UserModel(); $params = $this->_arrParam; if ($this->_request->isPost()) { try { if (!empty($this->_user)) { $user = $user_model->getUserById($this->_user->user_id); if (!empty($user) && count($user)) { if ($user['user_gome'] + $params["gome"] >= 0) { $user_model->update(array("user_gome" => $user['user_gome'] + $params["gome"]), "user_id = " . $this->_user->user_id); $data = array("code" => 1, "content" => array("user_gome" => $user['user_gome'] + $params["gome"])); } else { $data = array("code" => 0, "content" => "Not enough gome"); } } else { $data = array("code" => 0, "content" => "Invalid user"); } } else { $data = array("code" => 0, "content" => "Authentication failed"); } } catch (exception $e) { $data = array("code" => 0, "content" => "Error in server"); } echo json_encode($data); } exit; }
/** * 重置密码 * @method POST_indexAction * @author NewFuture */ public function POST_indexAction() { $response['status'] = 0; if (!Input::post('password', $password, 'isMd5')) { $response['info'] = '密码无效'; } elseif (!($user = Session::get('find_user'))) { $response['info'] = '未验证或者验证信息过期'; } else { $user['password'] = Encrypt::encryptPwd($password, $user['number']); if (UserModel::update($user) >= 0) { $response['status'] = 1; $response['info'] = '重置成功'; } else { $response['info'] = '新密码保存失败'; } } $this->response = $response; }
public function indexAction() { $p = $_REQUEST; if (!count($p)) { Tool_Fnc::ajaxMsg('参数错误'); } $pPhone = empty($p['phone']) ? '' : trim($p['phone']); if (!Tool_Validate::mo($pPhone)) { Tool_Fnc::ajaxMsg('手机号不正确'); } //判断手机号是否是白求恩 $tBUserInfo = Oci_User::isPhone($pPhone); if (empty($tBUserInfo)) { Tool_Fnc::ajaxMsg('非白求恩用户,下一步完善必须资料', 1, array('user_type' => 0)); } $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(); $tUMO->begin(); $tRow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow(); if (!empty($tRow['c'])) { Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入'); } $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']); } $tData = array('phone' => $pPhone, 'reg_ip' => Tool_Fnc::realip(), "passwd" => $tMd5str, "reg_time" => $tTime, 'private_key' => $tKey, 'reg_did' => $pDid, 'user_type' => 1); if (!($tID = $tUMO->insert($tData))) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 001'); } //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()); if (!$tUDMO->insert($tData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 002'); } } $tTokenarr = $this->creattoken($tID); //获取数据 $tSex = $tBUserInfo['SEX'] == '男' ? 1 : 0; $tPatientId = $tBUserInfo['PATIENT_ID']; //提取干体重 $tDryWeight = Oci_User::getDryWeight($tPatientId); $tDatas = array('id' => $tID, 'nickname' => $tBUserInfo['NAME'], 'sex' => $tSex, 'dry_weight' => $tDryWeight['BODY_WEIGHT'], 'date_of_birth' => $tBUserInfo['DATE_OF_BIRTH'], 'headimg' => $tBUserInfo['PHOTO']); if (!$tUMO->update($tDatas)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 003'); } //新建健康档案 $tUserAssessment = Oci_User::getAssessment($tPatientId); $tUserAssessment['uid'] = $tID; $tUserAssessment['name'] = $tBUserInfo['NAME']; //his系统数据更新 $tCMO = new CenterModel(); $tCRow = $tCMO->field('id,name')->where(' center_id = \'' . $tBUserInfo['CENTER_ID'] . '\'')->fRow(); if (!empty($tCRow['id'])) { $tUserAssessment['medical_id'] = $tCRow['id']; //用户透析中心字段更新 $tUMedicalData = array('id' => $tID, 'center_id' => $tCRow['id'], 'medical_addr' => $tCRow['name']); if (!$tUMO->update($tUMedicalData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 003'); } } else { $tCenterdict = Oci_User::getCenterdict($tBUserInfo['CENTER_ID']); $tCData = array('center_id' => $tCenterdict['CENTER_ID'], 'center_code' => $tCenterdict['CENTER_CODE'], 'name' => $tCenterdict['CENTER_NAME'], 'position' => $tCenterdict['POSITION'], 'created' => $tTime); if (!($tUserAssessment['medical_id'] = $tCMO->insert($tCData))) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 008'); } //用户透析中心字段更新 $tUMedicalData = array('id' => $tID, 'center_id' => $tUserAssessment['medical_id'], 'medical_addr' => $tCenterdict['CENTER_NAME']); if (!$tUMO->update($tUMedicalData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 003'); } } //健康档案 $tUA = new UserassessmentModel(); foreach ($tUserAssessment as $k => $v) { $tUserAssessmentData[strtolower($k)] = $v; } $tUserAssessmentData['created'] = $tTime; //添加透析方式默认值 $tUserAssessmentData['method'] = 1; if (!$tUA->insert($tUserAssessmentData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 004'); } //干重记录表数据更新 $tDWMO = new DryweightlogModel(); /*$tDryWeightLog = array( 'uid' => $tID, 'weight' => $tDryWeight['BODY_WEIGHT'], 'date' => $tDryWeight['TREATE_DATE'], 'month' => date('Y-m',strtotime($tDryWeight['TREATE_DATE'])), 'year' => date('Y',strtotime($tDryWeight['TREATE_DATE'])), 'patient_id' => $tPatientId, 'created' => time(), );*/ $tSql = 'update ' . $tDWMO->table . ' set uid=' . $tID . ' where patient_id = \'' . $tPatientId . '\''; if (!$tDWMO->exec($tSql)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 005'); } #更新白求恩排班表 $tSDMO = new BqeschedulingdetailModel(); $tSql = 'update ' . $tSDMO->table . ' set uid = ' . $tID . ' where patient_id = \'' . $tPatientId . '\''; if (!$tSDMO->exec($tSql)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 006'); } #透析 - 治疗单主记录 $tTRMO = new BqetreatmentrecordModel(); $tSql = 'update ' . $tTRMO->table . ' set uid = ' . $tID . ' where patient_id = \'' . $tPatientId . '\''; if (!$tTRMO->exec($tSql)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 007'); } $tUMO->commit(); //匿名转实名 $tUMO->incognito_real($pDid, $tID); $tTokenarr = array_merge($tTokenarr, array('user_type' => 1)); Tool_Fnc::ajaxMsg("注册成功,白求恩用户", 1, $tTokenarr); //注册成功返回token }
public function users_updateaccount($params) { global $STRINGS; $userid = array_shift($params); //remove url params $params = array_slice($params, 1); if (empty($params['uuid'])) { unset($params['uuid']); } if (isset($params['uuid'])) { $params['uuid'] = sha1($params['uuid']); } if (empty($params['mac'])) { unset($params['mac']); } if (isset($params['mac'])) { $params['mac'] = sha1($params['mac']); } $success = UserModel::update($userid, $params); $success == true ? $alert = BootstrapHelper::alert('success', $STRINGS['event:success'], $STRINGS['user:update:success']) : ($alert = BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:update:failed'])); $this->_data->user = UserModel::find($userid); new AdminUserAccountView($this->_data, $alert); }
/** * Tests the update method */ public function testUpdate() { //update main tester user data UserModel::update('999999', array('UUID' => '1x3')); $updated_user = UserModel::find('999999'); //check if the data is updated $this->assertEquals($updated_user->UUID, '1x3'); }