function toUsername($uid) { if (!$uid) { return L("Unnamed"); } $userData = getUserCache(); return $userData[$uid]["username"]; }
public function index() { $data = parent::index(true); $users = getUserCache(); foreach ($data as $k => $v) { if ($v["leader"]) { $leadersLabel = array(); $leaders = explode(",", $v["leader"]); foreach ($leaders as $l) { $leadersLabel[] = $users[$l]["truename"]; } $data[$k]["leader"] = implode(",", $leadersLabel); } } $this->response($data); }
public function address() { $uid = $this->login(); /** 热词调用 热门搜索**/ $hotsearch = C('HOT_SEARCH'); $this->assign('hotsearch', $hotsearch); if (IS_POST) { } else { $address = M("transport"); $list = $address->where("uid='{$uid}'")->select(); $user = getUserCache(); $this->assign('list', $list); $this->meta_title = $user['username'] . '的地址管理'; $this->display(); } }
break; case -4: $msg = array('error' => 'case-4', 'msg' => 'Sessió ja iniciada'); break; case -3: $msg = array('error' => 'case -3', 'msg' => 'Usuari no existent!'); break; case -2: $msg = array('error' => 'case -2', 'msg' => 'Error amb la BD'); break; case -1: $msg = array('error' => 'case -1', 'msg' => 'Error not captured'); break; case 0: //success $msg = getUserCache($login); $msg = array('success' => 'case 0'); break; default: die('login return unknown result code'); break; } } else { $msg = array('error' => 'true', 'msg' => 'Login i/o password no estan presents'); } //$msg[] = array("userLogin"=>"$login"); echo "<br> JSON RESPONSE: " . json_encode($msg); // }else{ //If the form button wasn't submitted go to the index page, or login page // header("Location: index.php"); // exit; // }
/** 发送邮箱验证 **/ public function send_email() { if (IS_AJAX) { $uid = is_login(); if (!$uid) { $this->ajaxError('对不起,您还没有登陆'); } $user = getUserCache(); $mail = $user['email']; $verification = M("verification"); $ver_email = $verification->where(array('uid' => $uid, 'email' => $mail))->field('email')->find(); if (!empty($ver_email)) { $this->ajaxError('您已验证过,无须重复验证!'); } $title = "邮箱验证"; $token = Md5("{$uid}_{$mail}_check"); $name = $_SERVER['SERVER_NAME']; $url = $_SERVER['SERVER_NAME'] . U("wine/check/" . $token); $this->assign('mail', $mail); $this->assign('time', date('Y-m-d H:i:s')); $this->assign('url', $url); $content = $this->fetch('User:checkmail'); if (SendMail($mail, $title, $content)) { $data['msg'] = '已成功发送验证信息到您的邮件!'; $data['damain'] = $url; $data['uid'] = $uid; $data['content'] = $content; $data['account'] = $mail; $data['username'] = $user['username']; $data['create_time'] = NOW_TIME; $email = M("email"); $data['sendname'] = "system"; $data['status'] = 1; $email->create(); $email->add($data); S($token, array('email' => $mail, 'uid' => $uid), 3600 * 24 * 3); //有效期3天 $this->ajaxSuccess($data); } else { $this->ajaxError('发送失败,无效的邮箱地址'); } } else { $this->error('对不起,访问有误'); } }
/** * 记录日志 有用户id则记录用户没有记录0 * @param $title * @return bool */ function user_log($title) { if (C('IS_USER_LOG')) { $uid = is_login(); $data['create_time'] = time(); $data['update_time'] = time(); $data['title'] = $title; $data['uid'] = $uid; $userCache = getUserCache(); $data['email'] = $userCache['email']; M('UserLog')->add($data); } }