public function testGetOverridedTemplateFile() { $t = new Template($this->container); $t->setTemplateOverride('a/b', 'myplugin:c'); $this->assertStringEndsWith('app/Core/../../plugins/Myplugin/Template/c.php', $t->getTemplateFile('a/b')); $this->assertStringEndsWith('app/Core/../Template/d.php', $t->getTemplateFile('d')); }
public function Lockscreen() { global $user; if (isset($_POST['email']) && isset($_POST['passwd'])) { $result = array("status" => 0, "message" => "验证失败"); $passwd = htmlspecialchars($_POST['passwd']); $result['passwd'] = $passwd; $user = User::getInstance(); $user = $user->GetUserByEmail($user->email); $result['obj'] = $user; if ($user->verifyPassword($passwd)) { Util::setToken(); $result['status'] = 1; $result['message'] = "验证成功, 将跳转到 >> 仪表盘"; } else { $result['message'] = "我跟你讲, 你密码错的在试2遍就给你锁了."; } echo json_encode($result); exit; } else { if (!\Helper\Listener::checkLogin()) { \Core\Response::redirect('/Auth/login'); exit; } include Template::load('/panel/lockscreen'); } exit; }
public static function get_template($name) { $t = \Core\Template::create(); $t->_jsapps = array(); $t->set_file(sprintf("%s/plugins/%s/templates/%s", CORE_PATH, static::plugin_name(), $name), True); return $t; }
public function afterRoute(&$className, &$method) { $user = User::getCurrent(); $reflection = new ReflectionMethod($className, $method); $docComment = $reflection->getDocComment(); // $this->isJson = $this->isJSON($docComment); if (strpos($docComment, '@Authorization') !== false && !$user) { $this->black = true; } $reflection = new ReflectionObject(new $className()); $docCommentC = $reflection->getDocComment(); if (strpos($docCommentC, '@Authorization') !== false && !$user) { $this->black = true; } if (strpos($docComment, '@Admin') !== false || strpos($docCommentC, '@Admin') !== false) { if ($user && !$user->isAdmin()) { $this->data['message'] = '你不是管理员,无法访问此页面'; $this->black = true; } } if ($this->black) { if ($this->isJson) { Template::setContext($this->data); Filter::preRender(); } else { Message::show($this->data['message'], 'auth/login', 3); } } }
public function index() { $data['user'] = User::getCurrent(); $data['nodes'] = NodeModel::getNodeArray(); Template::setContext($data); Template::setView('admin/node'); }
protected function _init_template() { $t = \Core\Template::create(); $t['__uri__'] = $this->_args['__uri__']; $t->_jsapps = array(); $this->_template = $t; }
public function index() { $data['selectMail'] = Option::get('MAIL_AVAILABLE'); $data['user'] = User::getCurrent(); Template::setContext($data); Template::setView('admin/mailer'); }
public function index() { $data['user'] = User::getCurrent(); $data['lists'] = MessageModel::getPushMessage(-1); Template::setContext($data); Template::setView('admin/message'); }
public function index() { $data['user'] = User::getCurrent(); $data['cronList'] = CronModel::getCronArray(); Template::setContext($data); Template::setView('admin/cron'); }
/** * Common layout for project views * * @access protected * @param string $template Template name * @param array $params Template parameters * @return string */ protected function projectLayout($template, array $params) { $content = $this->template->load($template, $params); $params['project_content_for_layout'] = $content; $params['title'] = $params['project']['name'] === $params['title'] ? $params['title'] : $params['project']['name'] . ' > ' . $params['title']; $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); return $this->template->layout('project/layout', $params); }
public function Index() { $data['user'] = User::getCurrent(); $data['nodes'] = MNode::getNodeArray(0); $data['nodeVip'] = MNode::getNodeArray(1); Template::setContext($data); Template::setView("panel/node"); }
public function inviteOldList() { $data['user'] = User::getCurrent(); $data['inviteList'] = InviteModel::getInviteArray(1); $data['planList'] = json_decode(Option::get('custom_plan_name'), true); array_splice($data['planList'], -1, 1); Template::setContext($data); Template::setView('admin/invite'); }
/** * 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; }
public function index() { $data['user'] = User::getCurrent(); $data['flow_num10'] = Stats::dataUsage(0); $data['flow_num30'] = Stats::dataUsage(1); $data['flow_num100'] = Stats::dataUsage(2); $data['flow_max'] = Stats::dataUsage(3); $data['userCount'] = Stats::countUser(); $data['money'] = Stats::countMoney(); Template::setContext($data); Template::setView('admin/index'); }
public function JsonList() { global $user; $id = trim($_REQUEST['id']); $nodeList = Nodem::GetNodeArray(); $info = ""; foreach ($nodeList as $node) { $info .= NodeUtil::NodeJson($node->server, $node->port, $user->sspwd, $node->method) . ","; } include Template::load('/node/JsonAll'); exit; }
/** * 创建订单 * */ 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'); }
/** * Display the template show task (common between different actions) * * @access protected * @param array $task Task data * @param array $comment_form Comment form data * @param array $description_form Description form data * @param array $comment_edit_form Comment edit form data */ protected function showTask(array $task, array $comment_form = array(), array $description_form = array(), array $comment_edit_form = array()) { if (empty($comment_form)) { $comment_form = array('values' => array('task_id' => $task['id'], 'user_id' => $this->acl->getUserId()), 'errors' => array()); } if (empty($description_form)) { $description_form = array('values' => array('id' => $task['id']), 'errors' => array()); } if (empty($comment_edit_form)) { $comment_edit_form = array('values' => array('id' => 0), 'errors' => array()); } else { $hide_comment_form = true; } $this->response->html($this->template->layout('task_show', array('hide_comment_form' => isset($hide_comment_form), 'comment_edit_form' => $comment_edit_form, 'comment_form' => $comment_form, 'description_form' => $description_form, 'comments' => $this->comment->getAll($task['id']), 'task' => $task, 'columns_list' => $this->board->getColumnsList($task['project_id']), 'colors_list' => $this->task->getColors(), 'menu' => 'tasks', 'title' => $task['title']))); }
/** * @JSON * @Authorization */ public function getList() { $port = $_GET['port']; $email = $_GET['email']; $where = ' WHERE 1=1 '; if ($port) { $where .= " AND port={$port} "; } if ($email) { $where .= " AND email like '%{$email}%' "; } $pageData = new PageData('member', " {$where} ORDER BY uid", ['uid', 'port', 'email', 'nickname', 'plan', 'flow_up', 'flow_down', 'transfer', 'expireTime']); $pageData->execute(); Template::setContext($pageData->getContext()); }
public function preRender() { if ($this->handle) { $context = Template::getContext(); if (Template::getView() == 'Misc/Error') { /** @var Error $error */ $error = $context['instance']; $this->outputJson(array('code' => $error->getCode() ? $error->getCode() : 500, 'data' => null, 'hasError' => true, 'message' => $error->getMessage())); } elseif (Template::getView() == 'Misc/Redirect') { $this->outputJson(array('code' => 302, 'data' => null, 'hasError' => true, 'message' => $context['text'] ? $context['text'] : 'JSON request has been redirected', 'target' => $context['link'])); } else { $this->outputJson(array('code' => self::$statusCode, 'data' => $context)); } } }
/** * 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; }
private function findController($requestPath) { $route = array(); $parameter = array(); $context = null; $key = strtolower($requestPath); if ($this->StaticRoute[$key]) { $route = $this->StaticRoute[$key]; } else { foreach ($this->DynamicRoute as $router) { if (!preg_match($router['regexp'], $requestPath, $matches)) { continue; } // Remove the request string array_shift($matches); $route = $router['callback']; $parameter = $matches; break; } } if (!$route) { if ($this->FallbackRouter) { $route = $this->FallbackRouter; } else { throw new Error(I18N::parse('Error.Messages.PageNotExists', 'The request URL is not exists'), 404); } } list($className, $method) = $route; Filter::afterRoute($className, $method); $controller = new $className(); if ($parameter) { $context = call_user_func_array(array($controller, $method), $parameter); } else { $context = $controller->{$method}(); } if ($context) { Template::setContext($context); } Filter::preRender(); Template::render(); Filter::afterRender(); }
public function action_edit() { $this->title = 'Редактировать страницу'; $id = $this->params[2]; $errors = []; if (isset($_POST['update'])) { $fields = Arr::extract($_POST, ['id_parent', 'url', 'title', 'content', 'base_template', 'inner_template']); if ($this->model->edit($id, $fields)) { header('Location: /' . ADMIN_URL . '/page/'); exit; } else { $errors = $this->model->errors(); } } else { $fields = $this->model->one($this->params[2]); } $this->scripts[] = 'ckeditor/ckeditor'; $this->scripts[] = 'url_page'; $this->scripts[] = 'ck_init'; $this->content = View::template('page/v_edit.php', ['fields' => $fields, 'errors' => $errors, 'pages' => $this->model->tree(), 'base_templates' => Template::all('base'), 'inner_templates' => Template::all('inner')]); }
/** * 进入首页 */ public function index() { Template::setView('../Home/index'); }
public function index() { $inviteList = \Model\Invite::GetInvitesByUid(-1); include Template::load('/home/invite'); }
/** * @Home * @Route /Index */ function index() { Template::setView('Index'); }
/** * Get the mail content for a given template name * * @access public * @param string $template Template name * @param array $data Template data */ public function getMailContent($template, array $data) { $tpl = new Template(); return $tpl->load('notification/' . $template, $data + array('application_url' => $this->config->get('application_url'))); }
/** * Get the event html content * * @access public * @param array $params Event properties * @return string */ public function getContent(array $params) { $tpl = new Template(); return $tpl->load('event_' . str_replace('.', '_', $params['event_name']), $params); }
/** * Get the mail content for a given template name * * @access public * @param string $template Template name * @param array $data Template data */ public function getMailContent($template, array $data) { $tpl = new Template(); return $tpl->load($template, $data); }
public function actCard() { Template::putContext('user', User::getUserByUserId(User::getCurrent()->uid)); Template::setView('panel/actCard'); }
public function ChangePlanLevel() { global $user; include Template::load("panel/changePlanLevel"); }