putContext() публичный статический Метод

public static putContext ( $name, $value, $escapeType = Escape::TEXT_RECURSIVE )
Пример #1
0
 /**
  * Show text and redirect to another page
  * @param string $text Content
  * @param string $link Target page
  * @param int $timeout Time before redirect
  */
 public static function show($text, $link = null, $timeout = 3)
 {
     Template::setView('Misc/Redirect');
     Template::putContext('text', $text);
     Template::putContext('timeout', $timeout);
     Template::putContext('link', $link === null ? null : Response::generateURL($link));
     Filter::preRender();
     Template::render();
     Filter::afterRender();
     exit;
 }
Пример #2
0
 /**
  * 创建订单
  *
  */
 public function create()
 {
     $user = User::getCurrent();
     $data['custom_plan_name'] = json_decode(Option::get('custom_plan_name'), true);
     $data['custom_transfer_level'] = json_decode(Option::get('custom_transfer_level'), true);
     $plan = strtoupper($_GET['plan']);
     $money = 0;
     switch ($plan) {
         case 'B':
             $money = 12;
             break;
         case 'C':
             $money = 20;
             break;
         case 'D':
             $money = 35;
             break;
         case 'VIP':
             $money = 50;
             break;
         case 'Z':
             $money = 50;
             break;
     }
     /*
     if(count(MOrder::getByUserId($user->uid)) > 0) {
         header("Location: /order/lists");
         exit();
     }
     */
     $order = new MOrder();
     $order->uid = $user->uid;
     $order->createTime = time();
     $order->money = $money;
     $order->plan = $plan;
     $order->status = 0;
     $order->type = 0;
     // 类型: 0 - 购买套餐 1 - 账户金额充值 2 - 购买卡号
     $remark = $order->type == 0 ? "购买套餐 " : $order->type == 1 ? "金额充值 " : "购买卡号 ";
     $remark .= $plan . ', ' . $money . '元';
     $order->remark = $remark;
     $order->save(Model::SAVE_INSERT);
     Template::putContext("order_id", $order->id);
     Template::putContext('transfer', $data['custom_transfer_level'][$plan]);
     Template::putContext('plan', $plan);
     Template::putContext('plan_name', $data['custom_plan_name'][$plan]);
     Template::putContext('money', $money);
     Template::putContext('user', $user);
     Template::setView('panel/order_create');
 }
Пример #3
0
 /**
  * Show text and redirect to another page
  * @param string $text Content
  * @param string $link Target page
  * @param int $timeout Time before redirect
  */
 public static function show($text, $link = null, $timeout = 3)
 {
     Template::setView('Misc/Redirect');
     if (is_array($text)) {
         array_unshift($text, $text[0]);
         // Set fallback string
         Template::putContext('text', call_user_func_array(array('I18N', 'parse'), $text));
     } else {
         Template::putContext('text', I18N::parse($text, $text));
     }
     Template::putContext('timeout', $timeout);
     Template::putContext('link', $link === null ? null : Response::generateURL($link));
     Filter::preRender();
     Template::render();
     Filter::afterRender();
     exit;
 }
Пример #4
0
 public function actCard()
 {
     Template::putContext('user', User::getUserByUserId(User::getCurrent()->uid));
     Template::setView('panel/actCard');
 }
Пример #5
0
 public function index()
 {
     Template::putContext('user', User::getCurrent());
     Template::setView('panel/ticket');
 }
Пример #6
0
 /**
  * 修改 自定义加密方式
  * @JSON
  * @throws Error
  */
 public function method()
 {
     $user = MUser::getCurrent();
     if ($_POST['method'] != null) {
         $method = null;
         if ($_POST['method'] != '-1') {
             $method = htmlspecialchars(trim($_POST['method']));
         }
         $user = MUser::getUserByUserId($user->uid);
         $user->method = $method;
         $user->save();
         $_SESSION['currentUser'] = $user;
         return array('error' => 0, 'message' => '修改加密方式成功,全部节点同步大约5分钟内生效。');
     } else {
         $nodeList = Node::getSupportCustomMethodArray();
         Template::putContext('user', $user);
         Template::putContext('nodeList', $nodeList);
         Template::setView("panel/change_method");
     }
 }
Пример #7
0
 public function index()
 {
     Template::putContext('cardList', MCard::queryAll());
     Template::putContext('user', User::getCurrent());
     Template::setView("admin/card");
 }
Пример #8
0
 public function getCustomMailContentList()
 {
     $opts = Option::getLike('custom_mail_');
     Template::putContext('custom_mail_list', $opts);
 }
Пример #9
0
 public function index()
 {
     $inviteList = InviteModel::getInviteArray(-1);
     Template::setView('panel/home_invite');
     Template::putContext('inviteList', $inviteList);
 }
Пример #10
0
 /**
  * @JSON
  * @throws \Core\Error
  */
 public function forgePwd()
 {
     $result = array('error' => 1, 'message' => '请求找回密码失败,请刷新页面重试。');
     $siteName = SITE_NAME;
     if (isset($_POST['email']) && $_POST['email'] != '') {
         $user = User::getUserByEmail(htmlspecialchars(trim($_POST['email'])));
         if (!$user) {
             return $result;
         }
         if ($user->enable == 0) {
             $verify_code = json_decode($user->forgePwdCode, true)['verification'];
             if ($verify_code != null) {
                 $result['message'] = '您的账户还未进行邮箱校验,请校验完毕后再试!';
                 return $result;
             }
         }
         $user->lastFindPasswdTime = time();
         if ($user->lastFindPasswdCount != 0 && $user->lastFindPasswdCount > 2) {
             $result['message'] = '找回密码重试次数已达上限!';
             return $result;
         }
         $code = Utils::randomChar(10);
         $forgePwdCode['code'] = $code;
         $forgePwdCode['time'] = time();
         $user->forgePwdCode = json_encode($forgePwdCode);
         $content = Option::get('custom_mail_forgePassword_content');
         $params = ['code' => $code, 'nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime)];
         $content = Utils::placeholderReplace($content, $params);
         $mailer = Mailer::getInstance();
         $mail = new \Model\Mail();
         $mail->to = $user->email;
         $mail->subject = "[" . SITE_NAME . "] Password Recovery";
         $mail->content = $content;
         $mailer->toQueue(true);
         // 添加到邮件列队
         $isOk = $mailer->send($mail);
         $user->save();
         $result['uid'] = $user->uid;
         if ($isOk) {
             $result['message'] = '验证代码已经发送到该注册邮件地址,请注意查收!<br/>请勿关闭本页面,您还需要验证码来验证您的账户所有权才可重置密码!!';
             $result['error'] = 0;
         } else {
             $result['message'] = '邮件发送失败, 请联系管理员检查邮件系统设置!';
             $result['error'] = 1;
         }
         return $result;
     } else {
         if ($_POST['code'] != '' && $_POST['uid'] != '') {
             $uid = $_POST['uid'];
             $code = trim($_POST['code']);
             $user = User::GetUserByUserId(trim($uid));
             $forgePwdCode = json_decode($user->forgePwdCode, true);
             // forgePwdCode.length > 1 且 验证码一样 且 时间不超过600秒(10分钟)
             if (count($forgePwdCode) > 1 && $forgePwdCode['code'] == $code && time() - intval($forgePwdCode['time']) < 600) {
                 $newPassword = Utils::randomChar(10);
                 $user->setPassword($newPassword);
                 $user->lastFindPasswdCount = 0;
                 $user->lastFindPasswdTime = 0;
                 $user->save();
                 $content = Option::get('custom_mail_forgePassword_content_2');
                 $params = ['code' => $code, 'newPassword' => $newPassword, 'nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime)];
                 $content = Utils::placeholderReplace($content, $params);
                 $mailer = Mailer::getInstance();
                 $mail = new \Model\Mail();
                 $mail->to = $user->email;
                 $mail->subject = "[" . SITE_NAME . "] Your new Password";
                 $mail->content = $content;
                 $mailer->toQueue(true);
                 // 添加到邮件列队
                 $isOk = $mailer->send($mail);
                 if ($isOk) {
                     $result['message'] = '新密码已经发送到该账户邮件地址,请注意查收!<br/> 并且请在登录后修改密码!';
                     $result['error'] = 0;
                 } else {
                     $result['message'] = '邮件发送失败, 请联系管理员检查邮件系统设置!';
                     $result['error'] = 1;
                 }
             } else {
                 $result['message'] = '验证码已经超时或者 验证码填写不正确。请再次确认';
                 $result['error'] = -1;
             }
             return $result;
         } else {
             Template::putContext('user', User::getCurrent());
             Template::setView('panel/forgePwd');
         }
     }
     return $result;
 }