本文整理汇总了PHP中Req::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Req::get方法的具体用法?PHP Req::get怎么用?PHP Req::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Req
的用法示例。
在下文中一共展示了Req::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main()
{
$this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
$cookie = Lib::cookie();
$identifier = $cookie->get(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
$this->set('user', $user);
$this->set('isLoggedIn', $isLoggedIn);
$this->js[] = $isLoggedIn ? 'inbox' : 'login';
if ($isLoggedIn) {
array_shift($this->js);
$id = Req::get('id');
if (empty($id)) {
Lib::redirect('index');
}
$report = Lib::table('report');
if (!$report->load($id)) {
$this->template = 'no-report';
return;
}
$report->init();
$assignees = Lib::model('user')->getProjectAssignees($report->project_id);
$projectTable = Lib::table('project');
$projectTable->load($report->project_id);
$this->set('report', $report);
$this->set('assignees', $assignees);
$this->set('project', $projectTable);
}
}
示例2: execute
public function execute()
{
$api = Lib::api('admin', array('response' => 'return', 'format' => 'php'));
$type = Req::get('type');
if (!is_callable(array($api, $type))) {
return Lib::redirect('error');
}
$result = $api->{$type}();
$options = array('view' => 'admin');
$ref = Req::post('ref');
if (!$result['state']) {
if (!empty($ref)) {
$options['ref'] = $ref;
}
} else {
$segments = explode('/', base64_decode(urldecode($ref)));
$base = array_shift($segments);
$type = array_shift($segments);
$subtype = array_shift($segments);
if (!empty($type)) {
$options['type'] = $type;
}
if (!empty($subtype)) {
$options['subtype'] = $subtype;
}
}
Lib::redirect('admin', $options);
}
示例3: env
public static function env($checkget = true)
{
if ($checkget && Req::hasget('environment')) {
return Req::get('environment');
}
$serverName = $_SERVER['SERVER_NAME'];
return isset(Config::$baseurl[$serverName]) ? Config::$baseurl[$serverName] : 'production';
}
示例4: main
public function main()
{
$filterProject = Req::get('project');
if (empty($filterProject)) {
$this->template = 'empty-project';
return;
}
$projectTable = Lib::table('project');
if (!$projectTable->load(array('name' => $filterProject))) {
$this->set('name', $filterProject);
$this->template = 'new-project';
return;
}
$this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com');
$cookie = Lib::cookie();
$identifier = $cookie->get(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
$this->set('user', $user);
$this->set('filterProject', $filterProject);
$this->set('filterSettingsProject', $filterProject);
$this->set('isLoggedIn', $isLoggedIn);
if (!$isLoggedIn) {
$this->js[] = 'login';
}
if ($isLoggedIn) {
$this->js[] = 'inbox';
$this->js[] = 'settings';
array_shift($this->js);
$userModel = Lib::model('user');
$assignees = $userModel->getProjectAssignees($projectTable->id);
$users = $userModel->getUsers();
$filterState = $cookie->get('filter-state', 'pending');
$filterAssignee = $cookie->get('filter-assignee', empty($assignees[$user->id]) ? 'all' : $user->id);
$filterSort = $cookie->get('filter-sort', 'asc');
$reportModel = Lib::model('report');
$reports = $reportModel->getItems(array('state' => constant('STATE_' . strtoupper($filterState)), 'assignee_id' => $filterAssignee, 'order' => 'date', 'direction' => $filterSort, 'project_id' => $projectTable->id));
$userSettingsTable = Lib::table('user_settings');
if (!$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => $projectTable->id))) {
$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => 0));
}
$userSettings = $userSettingsTable->getData();
if ($userSettings['color'] !== 'cyan' && $userSettings['color'] !== 'custom') {
$this->css[] = 'theme-' . str_replace(' ', '', $userSettings['color']);
}
$categories = Lib::model('category')->getCategories(['projectid' => $projectTable->id]);
$this->set('filterState', $filterState);
$this->set('filterAssignee', $filterAssignee);
$this->set('filterSort', $filterSort);
$this->set('reports', $reports);
$this->set('assignees', $assignees);
$this->set('userSettings', $userSettings);
$this->set('users', $users);
$this->set('projectTable', $projectTable);
$this->set('categories', $categories);
}
}
示例5: env
public static function env()
{
if (Req::hasget('development')) {
Lib::cookie()->set('development', Req::get('development'));
}
if (Lib::cookie()->get('development')) {
return 'development';
}
return self::$env;
}
示例6: form
public function form()
{
$ref = Req::get('ref');
$this->set('ref', $ref);
$model = Lib::model('admin');
if (!$model->hasAdmins()) {
$this->template = 'formcreate';
return;
}
$this->template = 'form';
}
示例7: main
public function main()
{
$slug = Req::get('slug');
$this->set('slug', $slug);
if (file_exists(Config::getBasePath() . '/assets/css/' . $slug . '.' . (Config::env() === 'development' ? 'less' : 'css'))) {
$this->css[] = $slug;
}
if (file_exists(Config::getBasePath() . '/assets/js/' . $slug . '.' . (Config::env() === 'development' ? 'coffee' : 'js'))) {
$this->js[] = $slug;
}
$page = $this->getPages()->{$slug};
$this->set('slug', $slug);
$this->set('page', $page);
$this->set('pagetitle', $page->title);
$this->set('pagedate', $page->date);
$content = $this->loadTemplate($slug . '/content');
$this->set('content', $content);
}
示例8: init
public function init()
{
$menu = new Menu();
$this->assign('mainMenu', $menu->getMenu());
$menu_index = $menu->current_menu();
$this->assign('menu_index', $menu_index);
$this->assign('subMenu', $menu->getSubMenu($menu_index['menu']));
$this->assign('menu', $menu);
$nav_act = Req::get('act') == null ? $this->defaultAction : Req::get('act');
$nav_act = preg_replace("/(_edit)\$/", "_list", $nav_act);
$this->assign('nav_link', '/' . Req::get('con') . '/' . $nav_act);
$this->assign('node_index', $menu->currentNode());
$this->safebox = Safebox::getInstance();
$this->assign('manager', $this->safebox->get('manager'));
$currentNode = $menu->currentNode();
if (isset($currentNode['name'])) {
$this->assign('admin_title', $currentNode['name']);
}
}
示例9: css
public function css()
{
header('Content-Type: text/css');
$script = Req::get('script');
switch ($script) {
case 'theme-custom':
$identifier = Lib::cookie(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
if (!$isLoggedIn) {
echo '';
return;
}
$project = Req::get('name');
$projectTable = Lib::table('project');
if ($project !== 'all' && $project !== '-1' && !$projectTable->load(array('name' => $project))) {
echo '';
return;
}
$userSettingsTable = Lib::table('user_settings');
if ($project === '-1') {
$projectTable->id = '-1';
}
if (!$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => $project === 'all' ? 0 : $projectTable->id)) && $project !== 'all') {
$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => 0));
}
$userSettings = $userSettingsTable->getData();
$basecss = $this->output('css/theme-custom');
$keys = array(50, 100, 200, 300, 400, 500, 600, 700, 800, 900);
$search = array();
$replace = array();
foreach ($keys as $key) {
$search[] = '"@@color' . $key . '"';
$replace[] = '#' . $userSettings['color' . $key];
}
$css = str_replace($search, $replace, $basecss);
echo $css;
break;
}
}
示例10: getLogDetails
public function getLogDetails($dbh, $args)
{
$from_ts = isset($args['from_ts']) ? trim($args['from_ts']) : date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
$to_ts = isset($args['to_ts']) ? trim($args['to_ts']) : date("Y-m-d");
$today = date("Y-m-d");
$params[] = date("Y-m-d", strtotime($from_ts));
$params[] = date("Y-m-d", strtotime($to_ts));
if ($args['caltype'] == '0') {
$str_config = " SELECT u.name as oname,u.username,oncall_to,oncall_from,'P' as octype,'US' as timezone \n\t\t\t\tFROM backupTapeopencalCalendar as btc \n\t\t\t\tLEFT JOIN opencal.user as u on (btc.user_id=u.user_id) \n\t\t\t\tWHERE oncall_to BETWEEN ? AND ?";
} else {
$str_config = "SELECT \n\t\t\t\t\tu.name as oname,u.username,d.name as timezone,if(oncall_type=1,'P','S') as octype,oncall_to,oncall_from \n\t\t\t FROM backupAssigneeConfig as bac \n\t\t\t LEFT JOIN opencal.user as u on (bac.user_id=u.user_id) \n\t\t\t LEFT JOIN opencal.dictionary as d on (bac.assign_time=d.dict_id) \n\t\t\t WHERE oncall_to BETWEEN ? AND ?";
}
if (trim($args['search']) != 'any' && trim($args[search]) != '') {
$str_config .= " AND u.username like ?";
$params[] = "%" . trim($args['search']) . "%";
}
if (isset($args[timezone]) && $args[timezone] != -1) {
$str_config .= " AND bac.assign_time=?";
$params[] = $args[timezone];
}
$options = array('page' => array('per_page' => Req::has('per_page') ? Req::get('per_page') : 50, 'current_page' => Req::get('page'), 'order_by' => Req::get('order_by') ? Req::get('order_by') : 'oncall_from'));
$options['page']['query'] = $str_config;
$options['page']['db'] = $dbh;
$options['page']['params'] = $params;
$recs = Pager::paginate($options['page']);
return $recs;
}
示例11: order_status
public function order_status()
{
if ($this->checkOnline()) {
$order_id = Filter::int(Req::get("order_id"));
if ($order_id) {
$order = $this->model->table("order as od")->join("left join payment as pa on od.payment= pa.id")->fields("od.id,od.order_no,od.payment,od.pay_status,od.order_amount,pa.pay_name as payname,od.type,od.status")->where("od.id={$order_id} and od.status<4 and od.user_id = " . $this->user['id'])->find();
if ($order) {
if ($order['pay_status'] == 0) {
$payment_plugin = Common::getPaymentInfo($order['payment']);
if ($payment_plugin != null && $payment_plugin['class_name'] == 'received' && $order['status'] == 3) {
$this->redirect("/simple/order_completed/order_id/{$order_id}");
}
$this->assign("order", $order);
$this->redirect();
} else {
if ($order['pay_status'] == 1) {
$this->redirect("/simple/order_completed/order_id/{$order_id}");
}
}
} else {
Tiny::Msg($this, 404);
}
} else {
Tiny::Msg($this, 404);
}
} else {
$this->redirect("login");
}
}
示例12: url
public static function url($key, $options = array(), $external = false)
{
$values = array();
$link = $external ? Config::getHTMLBase() : '';
if (Req::hasget('environment')) {
$options['environment'] = Req::get('environment');
}
if (Config::$sef) {
Lib::load('router');
$segments = array();
foreach (Router::getRouters() as $router) {
if (is_string($router->allowedBuild) && $key !== $router->allowedBuild) {
continue;
}
if (is_array($router->allowedBuild) && !in_array($key, $router->allowedBuild)) {
continue;
}
$router->encode($key, $options, $segments);
}
if (!empty($segments)) {
$link .= implode('/', $segments);
}
} else {
$link .= 'index.php';
}
if (!empty($options)) {
$values = array();
foreach ($options as $k => $v) {
$values[] = urlencode($k) . '=' . urlencode($v);
}
$queries = implode('&', $values);
if (!empty($queries)) {
$queries = '?' . $queries;
}
$link .= $queries;
}
return $link;
}
示例13: urlFormat
/**
*路径格式化处理
*/
static function urlFormat($path)
{
if ($path == '') {
return self::baseDir();
}
if (preg_match('@[/\\@#*!]?(http://.+)$@i', $path, $matches)) {
return $matches[1];
}
switch (substr($path, 0, 1)) {
case '/':
$path = self::createUrl($path);
return rtrim(self::baseUri(), '/') . $path;
//解释成绝对路由地址
case '@':
return self::baseDir() . substr($path, 1);
//解析成绝对路径
//解析成绝对路径
case '#':
if (Tiny::app()->getTheme() !== null) {
return Tiny::app()->getTheme()->getBaseUrl() . '/' . substr($path, 1);
} else {
return self::baseDir() . substr($path, 1);
}
case '*':
if (Tiny::app()->getTheme() !== null && Tiny::app()->getSkin() !== null) {
$theme = Tiny::app()->getTheme();
return $theme->getBaseUrl() . '/skins/' . Tiny::app()->getSkin() . '/' . substr($path, 1);
} else {
if (Tiny::app()->getSkin() !== null) {
return self::baseDir() . 'skins/' . Tiny::app()->getSkin() . '/' . substr($path, 1);
} else {
return self::urlFormat('#' . substr($path, 1));
}
}
case '!':
return Tiny::app()->getRuntimeUrl() . '/' . substr($path, 1);
default:
$q = Req::get();
$url = '/' . $q['con'] . '/' . $q['act'];
unset($q['con'], $q['act']);
$query = explode('/', trim($path, '/'));
$new_q = array();
$len = count($query);
for ($i = 0; $i < $len; $i++) {
if ($i % 2 == 1) {
$new_q[$query[$i - 1]] = $query[$i];
}
}
$q = array_merge($q, $new_q);
foreach ($q as $k => $v) {
if (is_string($k)) {
$url .= '/' . $k . '/' . $v;
}
}
$path = self::createUrl($url);
return rtrim(self::baseUri(), '/') . $path;
//解释成绝对路由地址
}
}
示例14: redirect
/**
* 重新定位
*
* @access public
* @param string $operator 操作path
* @param bool $jump 真假跳转方式
* @param array $args 需要传送的数据
* @return void
*/
public function redirect($operator = '', $jump = true, $args = array())
{
//初始化 $con $act
$old_args_num = count($args);
$con = $this->getId();
$act = Req::get('act') == null ? $this->defaultAction : Req::get('act');
$controllerId = $con;
if (stripos($operator, "http://") === false) {
if ($operator != '') {
$operator = trim($operator, '/');
$operator = explode('/', $operator);
$args_num = count($operator);
if ($args_num >= 2) {
$con = $operator[0];
//$controllerName = ucfirst($operator[0]).'Controller';
//if(class_exists($controllerName))$controller = new $controllerName($operator[1],$this->module);
//else if($con != $this->getId()) $controller = new Controller($operator[1],$this->module);
if ($args_num > 2) {
for ($i = 2; $i < $args_num; $i = $i + 2) {
$args[$operator[$i]] = isset($operator[$i + 1]) ? $operator[$i + 1] : '';
}
}
$operator = $operator[1];
} else {
$operator = $operator[0];
}
} else {
$operator = $act;
}
}
//如果请求的action 和新的跳转是同一action则进入到对应的视图Action
if ($act == $operator && $controllerId == $con) {
$this->action = new ViewAction($this, $act);
$this->action->setData($args);
$this->action->run();
} else {
if ($jump == false) {
if ($controllerId == $con) {
$_GET['act'] = $operator;
$this->setDatas($args);
$this->run();
} else {
$_GET['act'] = $operator;
$_GET['con'] = $con;
$controller = $this->module->createController();
$controller->setDatas($args);
$this->module->setController($controller);
$this->module->getController()->run();
}
} else {
if ($old_args_num != 0 && is_array($args) && !empty($args)) {
$args['tiny_token_redirect'] = Tiny::app()->getToken('redirect');
//var_dump($args);exit();
header("Content-type: text/html; charset=" . $this->encoding);
$str = '<!doctype html><html lang="zh"><head></head><body>';
if (stripos($operator, "http://") !== false) {
$str .= '<form id="hiddenForm" name="hiddenForm" action="' . $operator . '" method="post">';
} else {
$str .= '<form id="hiddenForm" name="hiddenForm" action="' . Url::urlFormat('/' . $con . '/' . $operator) . '" method="post">';
}
foreach ($args as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$str .= '<input type="hidden" name="' . $key . '[' . $k . ']" value="' . $v . '" />';
}
} else {
$str .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
}
}
$str .= '</form><script type="text/javascript">document.forms["hiddenForm"].submit();</script></body></html>';
echo $str;
exit;
} else {
$urlargs = '';
if (is_array($args) && !empty($args)) {
$urlargs = '?' . http_build_query($args);
}
header('Location:' . Url::urlFormat('/' . $con . '/' . $operator . $urlargs));
}
}
}
}
示例15: override
/**
* override what the username() function returns
* GET params:
* - user: what user to act as
* - ttl: for how long (defaults to 60 sec)
*/
public final function override()
{
if (defined('OPS_ENV') && strncasecmp(OPS_ENV, 'prod', 4) === 0) {
header("HTTP/1.1 401 Unauthorized");
echo "Can't do that in production.";
exit;
}
$user = Req::get('user');
if (false === array_search(username_strict(), $this->authorizedUsers(), true)) {
header("HTTP/1.1 401 Unauthorized");
echo "You are not authorized to perform this action";
exit;
}
$ttl = Req::get('ttl') ? Req::get('ttl') : 60;
Log::debug('User ' . username_strict() . ' will act as ' . $user . ' for ' . $ttl . ' seconds');
apc_store(username_override_hash(username_strict()), $user, $ttl);
echo "Now {$user}";
exit;
}