本文整理汇总了PHP中Input::uri方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::uri方法的具体用法?PHP Input::uri怎么用?PHP Input::uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::uri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
if (!\Auth::check() && !$this->getNotLoginAllowed()) {
\Response::redirect('/ucenter/login?to_url=' . \Input::uri());
}
}
示例2: action_index
/**
* The basic welcome message
*
* @access public
* @return Response
*/
public function action_index()
{
if (!Auth::check()) {
return Response::redirect('auth/login?url=' . Input::uri());
}
return Response::forge(View::forge('welcome/index'));
}
示例3: action_catchall
/**
* Will attempt to find an item based on the current URL, and route it through a controller before returning a 404 error
*
* @access public
* @return Response
*/
public function action_catchall()
{
// Will try to find the model based on the URL
$model = $this->model = \CMF::currentModel();
\CMF::$routed = true;
// Return the normal 404 error if not found
if (is_null($model)) {
$action = trim(\Input::uri(), '/');
if (!empty($action)) {
return \Request::forge('base/' . $action, false)->execute()->response();
}
return $this->show404();
}
// So the model was found - check if it has a controller to route to
$template = \CMF::$template;
$action = \CMF::$action;
if (\CMF::hasController($template)) {
$module = \CMF::$module;
$path = \CMF::$path;
$route = (empty($module) ? '' : $module . '/') . $path . (empty($action) ? '' : '/' . $action);
return \Request::forge($route, false)->execute()->response();
} else {
if (!empty($action)) {
return $this->show404();
} else {
if (\CMF::$root) {
return \Request::forge('base/' . $action, false)->execute()->response();
}
}
}
}
示例4: action_index
public function action_index()
{
$ext = Input::extension();
Log::info('500:' . Input::uri() . '.' . $ext);
$this->response_status = 500;
$this->template->content = View_Smarty::forge('500');
}
示例5: action_send
public function action_send()
{
if (!\Security::check_token()) {
\Log::error('CSRF: ' . \Input::uri() . ' ' . \Input::ip() . ' "' . \Input::user_agent() . '"');
throw new HttpInvalidInputException('Invalid input data');
}
$val = $this->form()->validation();
$val->add_callable('myvalidation');
if ($val->run()) {
$post = $val->validated();
\Config::load('contact', true);
$data = array();
$data['email'] = $post['email'];
$data['name'] = $post['name'];
$data['to'] = \Config::get('contact.admin_email');
$data['to_name'] = \Config::get('contact.admin_name');
$data['subject'] = \Config::get('contact.mail_subject');
$data['ip'] = \Input::ip();
$data['ua'] = \Input::user_agent();
$langs = implode(' ', $post['lang']);
$data['body'] = <<<END
====================
名前: {$post['name']}
メールアドレス: {$post['email']}
IPアドレス: {$data['ip']}
ブラウザ: {$data['ua']}
====================
コメント:
{$post['comment']}
性別: {$post['gender']}
問い合わせの種類: {$post['kind']}
好きな鳥: {$langs}
====================
END;
try {
$this->sendmail($data);
$this->save($data);
$this->template->title = 'コンタクトフォーム: 送信完了';
$this->template->content = View::forge('contact/send');
} catch (EmailValidationFailedException $e) {
$this->template->title = 'コンタクトフォーム: 送信エラー';
$this->template->content = View::forge('contact/error');
\Log::error(__METHOD__ . ' email validation error: ' . $e->getMessage());
} catch (EmailSendingFailedException $e) {
$this->template->title = 'コンタクトフォーム: 送信エラー';
$this->template->content = View::forge('contact/error');
\Log::error(__METHOD__ . ' email sending error: ' . $e->getMessage());
} catch (EmailSavingFailedException $e) {
$this->template->title = 'コンタクトフォーム: 送信エラー';
$this->template->content = View::forge('contact/error');
\Log::error(__METHOD__ . ' email saving error: ' . $e->getMessage());
}
} else {
$this->template->title = 'コンタクトフォーム: エラー';
$this->template->content = View::forge('contact/index');
$this->template->content->set_safe('html_error', $val->show_errors());
}
}
示例6: uri
public function uri($includeBaseUrl = false)
{
$base = \Uri::base(false);
$baseUrl = $this->generateBaseUrl();
if ($includeBaseUrl && strpos($base, $baseUrl) === false && strpos($base, 'http') !== 0 && strpos($base, '//') !== 0) {
$base = $baseUrl . trim($base, '/');
}
return rtrim($base, '/') . '/' . trim(\Input::uri(), '/');
}
示例7: Action_Index
public function Action_Index()
{
if (!Auth::check()) {
return Response::redirect('auth/login?url=' . Input::uri());
}
$data["auth_username"] = Auth::get('username', 'Unnamed');
$this->template->title = "Fuck you!";
$this->template->auth_username = $data["auth_username"];
$this->template->content = View::Forge('dashboard/index', $data);
}
示例8: action_index
public function action_index()
{
$ext = Input::extension();
Log::info('404:' . Input::uri() . '.' . $ext);
// コンテンツの場合は404を返す
$ext = Input::extension();
if (in_array($ext, array('png', 'jpg', 'jpeg', 'gif', 'js', 'css', 'aspx', 'xml', 'json'))) {
header('HTTP/1.1 404 Not Found');
exit;
}
$this->response_status = 404;
$this->template->content = View_Smarty::forge('404');
}
示例9: before
public function before()
{
parent::before();
try {
if (!$this->user) {
\Session::set_flash('error', "Please login to access this page.");
//non logged in users must login first
$destination = Uri::create(Input::uri());
Response::redirect(Uri::create('user/login', array(), array('destination' => $destination)));
//require login first
}
} catch (Exception $e) {
\Session::set_flash('error', $e->getMessage());
\Response::redirect('/welcome/404');
}
}
示例10: render
/**
* renders the navigation
*
* @param array array with tag attribute settings
* @access public
* @return void
*/
public static function render($type = 'default', array $attributes = array(), $header = false)
{
if (empty($type)) {
return;
}
$links = \Config::get('navigation.' . $type, false);
if (empty($links)) {
throw new BootstrapException('Missing navigation links in config');
return;
}
$callback = \Config::get('bootstrap.navigation_links_callback', null);
if ($callback != null) {
$links = $callback($links);
}
foreach ($links as $key => &$link) {
if (empty($link['url'])) {
$link['url'] = \Inflector::friendly_title($link['title'], '-', true);
}
// Set link to active if it matches the current page URI.
if (!isset($link['active'])) {
$link['active'] = $link['url'] == ltrim(\Input::uri(), '/');
}
if (empty($link['attributes'])) {
$link['attributes'] = array();
}
$anchor_classs = \Config::get('bootstrap.navigation.anchor_class', true);
if ($anchor_classs) {
if (!isset($link['attributes']['class'])) {
$link['class'] = \Inflector::friendly_title($link['title'], '-', true);
}
$anchor_prefix = \Config::get('bootstrap.navigation.anchor_prefix', 'nav-');
if (!empty($anchor_prefix)) {
$link['class'] = $anchor_prefix . $link['class'];
}
}
if (!empty($link['class'])) {
$link['attributes']['class'] = $link['class'];
}
}
if (isset($attributes['class'])) {
$attributes['class'] = 'nav ' . $attributes['class'];
} else {
$attributes['class'] = 'nav';
}
echo \View::forge('navigation', array('header' => $header, 'links' => $links, 'attributes' => array_to_attr($attributes)))->render();
}
示例11: router
public function router($method, $params)
{
Config::load('base');
//$action = $this->request->controller . '_' . $this->request->action;
$action = $this->request->route->translation;
Logger::params($action, Input::all(), $this->params());
// ssl
$cfg = empty($this->subsystem) ? 'site' : 'site.' . $this->subsystem;
list($need, $action_list, $both_list) = $this->get_onoff(Config::get($cfg . '.ssl'));
$redirect = false;
if (empty($both_list) || !in_array($action, $both_list)) {
$ssl = Input::protocol() == 'http';
if ($ssl) {
$redirect = $need ? in_array($action, $action_list) : !in_array($action, $action_list);
} else {
$redirect = $need ? !in_array($action, $action_list) : in_array($action, $action_list);
}
}
if ($redirect) {
return Response::redirect(Uri::create(Input::uri(), [], [], $ssl));
}
// authentication
$flg = false;
list($need, $action_list, $both_list) = $this->get_onoff(Config::get($cfg . '.auth'));
if (empty($both_list) || !in_array($action, $both_list)) {
if ($this->is_login()) {
$flg = $need ? !in_array($action, $action_list) : in_array($action, $action_list);
} else {
$flg = $need ? in_array($action, $action_list) : !in_array($action, $action_list);
}
}
if ($flg) {
return Response::redirect($this->subsystem . '/auth');
}
// call controller
$call = 'action_' . $this->request->action;
if (is_callable([$this, $call])) {
$this->{$call}($params);
}
}
示例12: action_pictures
/**
* @access public
* @return Response
*/
public function action_pictures()
{
$data = array();
$data['Form'] = new \Form();
$data['Input'] = new \Input();
// $options = array();
$options = \Input::get();
$config = array('pagination_url' => \Input::uri() . '?' . http_build_query($options), 'total_items' => \Collection\Interaction::countSearchResults($options), 'uri_segment' => 'page', 'name' => 'bootstrap', 'per_page' => 50);
$pagination = \Pagination::forge('venues', $config);
$data['pagination'] = $pagination->render();
// get venues
$options['per_page'] = $pagination->per_page;
$options['offset'] = $pagination->offset;
$data['pictures'] = \Collection\Interaction::search($options);
// get all regions
$options = array();
$data['regions'] = \Collection\Region::search($options);
$data['order_by'] = \Form::select('order_by', \Input::get('order_by'), array('time_created' => 'Date', 'likes' => 'Likes', 'comments' => 'Comments'), array('style' => 'width: 80px'));
$data['order_dir'] = \Form::select('order_dir', \Input::get('order_dir'), array('desc' => 'Desc', 'asc' => 'Asc'), array('style' => 'width: 80px'));
$data['date_range'] = \Form::select('filter[date_range]', \Input::get('filter.date_range'), array('today' => 'Today', 'yesterday' => 'Yesterday', 'last2days' => 'Last 2 days ago', '2days' => '2 days ago', '3days' => '3 days ago', 'thisweek' => 'This week', 'thismonth' => 'This month'), array('style' => 'width: 80px'));
$view = \View::forge('dashboard/pictures.twig', $data);
return \Response::forge($view);
}
示例13: getItemByUrl
/**
* Finds the model associated with the given URL
*
* @param string $url The URL to search against (no trailing slashes please)
* @param string|null $type The model class, in case you want to narrow down the search
* @return object The model
*/
public static function getItemByUrl($url, $type = null)
{
// Plain query for the urls table to avoid initialising Doctrine for 404s
$url_item = \DB::query("SELECT type, item_id, parent_id FROM urls WHERE url = '{$url}' AND alias_id IS NULL " . ($type !== null ? "AND type = '{$type}' " : "") . "ORDER BY item_id DESC")->execute();
// If multilingual is enabled, we need to check the ext_translations table too
if (count($url_item) === 0 && static::langEnabled()) {
$lang = static::$lang ?: static::$lang_default;
if ($item_id = \DB::query("SELECT foreign_key FROM ext_translations WHERE locale = '{$lang}' AND field = 'url' AND object_class = 'CMF\\\\Model\\\\URL' AND content = '{$url}'")->execute()->get('foreign_key')) {
$url_item = \DB::query("SELECT type, item_id FROM urls WHERE id = {$item_id}")->execute();
}
}
if (count($url_item) === 0 && $url == '/') {
$url_item = static::settings()->start_page;
if (is_null($url_item)) {
return null;
}
$item = $url_item->item();
} else {
if (count($url_item) === 0) {
return null;
} else {
$url_item = $url_item[0];
$type = $url_item['type'];
// Redirect
if (!empty($url_item['parent_id'])) {
$parentUrl = \DB::query("SELECT url FROM urls WHERE id = " . $url_item['parent_id'])->execute()->get('url');
if (!empty($parentUrl)) {
$uri = '/' . ltrim(\Input::uri(), '/');
$q = \Input::get();
if (isset($q[$uri])) {
unset($q[$uri]);
}
$qs = str_replace('=&', '&', trim(http_build_query($q), '='));
return \Response::redirect($parentUrl . (!empty($qs) ? '?' . $qs : ''), 'location', !empty($type) && is_numeric($type) ? intval($type) : 301);
}
}
if (empty($type) || $type == \CMF\Model\URL::TYPE_EXTERNAL || !class_exists($type) || is_null($url_item['item_id'])) {
return null;
}
$item = $type::select('item')->where('item.id = ' . $url_item['item_id'])->getQuery()->getResult();
}
}
if (is_array($item) && count($item) > 0) {
$item = $item[0];
} else {
$item = null;
}
return $item;
}
示例14: __construct
/**
* Construct takes a URI or detects it if none is given and generates
* the segments.
*
* @param string The URI
* @return void
*/
public function __construct($uri = null)
{
if (\Fuel::$profiling) {
\Profiler::mark(__METHOD__ . ' Start');
}
$this->uri = trim($uri ?: \Input::uri(), '/');
$this->segments = $this->uri === '' ? array() : explode('/', $this->uri);
if (\Fuel::$profiling) {
\Profiler::mark(__METHOD__ . ' End');
}
}
示例15: __construct
/**
* Construct takes a URI or detects it if none is given and generates
* the segments.
*
* @param string The URI
* @return void
*/
public function __construct($uri = null)
{
if (\Fuel::$profiling) {
\Profiler::mark(__METHOD__ . ' Start');
}
// if the route is a closure, an object will be passed here
is_object($uri) and $uri = null;
$this->uri = trim($uri ?: \Input::uri(), '/');
if (empty($this->uri)) {
$this->segments = array();
} else {
$this->segments = explode('/', $this->uri);
}
if (\Fuel::$profiling) {
\Profiler::mark(__METHOD__ . ' End');
}
}