public function getRouteController() { $routes = ["^/\$" => "LoginController", "^/firstcontroller/" => "FirstController", "^/secondcontroller/" => "SecondController"]; foreach ($routes as $key => $route) { if (preg_match("#{$key}#", $this->request->getRequestUri())) { return $route; } } throw new \Exception('No route controller.'); }
/** * @test */ public function testConstruct() { $request = new Request(); $this->assertTrue($request instanceof Request); $request = new Request('/test'); $this->assertTrue($request->getRequestUri() == '/test'); }
function delete_button($entity_name, $id, $delete_path) { ?> <form name="elimina_<?php echo $entity_name; ?> _<?php echo $id; ?> " method="POST" action="<?php echo $delete_path; ?> "> <input type="hidden" name="id" value="<?php echo $id; ?> " /> <button type="submit" onclick="return window.confirm('Sei sicuro di volerlo eliminare?');"> <span>Elimina</span> </button> <?php Form::after(Request::getRequestUri()); ?> </form> <?php }
/** * Generates a signature for a packet request response * * @param array $packet * @param int|null $code * @param string|\Exception|null $message * * @return array * */ protected static function signPacket(array $packet, $code = null, $message = null) { $_ex = false; if ($code instanceof \Exception) { $_ex = $code; $code = null; } elseif ($message instanceof \Exception) { $_ex = $message; $message = null; } !$code && ($code = Response::HTTP_OK); $code = $code ?: ($_ex ? $_ex->getCode() : Response::HTTP_OK); $message = $message ?: ($_ex ? $_ex->getMessage() : null); $_startTime = \Request::server('REQUEST_TIME_FLOAT', \Request::server('REQUEST_TIME', $_timestamp = microtime(true))); $_elapsed = $_timestamp - $_startTime; $_id = sha1($_startTime . \Request::server('HTTP_HOST') . \Request::server('REMOTE_ADDR')); // All packets have this $_packet = array_merge($packet, ['error' => false, 'status_code' => $code, 'request' => ['id' => $_id, 'version' => static::PACKET_VERSION, 'signature' => base64_encode(hash_hmac(config('dfe.signature-method'), $_id, $_id, true)), 'verb' => \Request::method(), 'request-uri' => \Request::getRequestUri(), 'start' => date('c', $_startTime), 'elapsed' => (double) number_format($_elapsed, 4)]]); // Update the error entry if there was an error if (!array_get($packet, 'success', false) && !array_get($packet, 'error', false)) { $_packet['error'] = ['code' => $code, 'message' => $message, 'exception' => $_ex ? Json::encode($_ex) : false]; } else { array_forget($_packet, 'error'); } return $_packet; }
function __get($var) { $val = parent::__get($var); if ($val === null) { if ($var == 'action') { return Request::getRequestUri(); } } return $val; }
/** * Register any application services. * * @return void */ public function register() { if ($this->app->isLocal()) { $this->app->register('Barryvdh\\LaravelIdeHelper\\IdeHelperServiceProvider'); $this->app->register('Barryvdh\\Debugbar\\ServiceProvider'); } if (starts_with(\Request::getRequestUri(), "/admin/")) { $this->app->singleton('ConfigWriter', function ($app) { return new ConfigWriter(); }); } }
public function __invoke(array $record) { $record['context']['app'] = $this->appName; $record['context']['environement'] = $this->environment; $record['context']['Hostname'] = gethostname(); try { if (null === $this->request) { $this->request = $this->container->get('request'); } $record['request']['base_url'] = $this->request->getBaseUrl(); $record['request']['scheme'] = $this->request->getScheme(); $record['request']['port'] = $this->request->getPort(); $record['request']['request_uri'] = $this->request->getRequestUri(); $record['request']['uri'] = $this->request->getUri(); $record['request']['query_string'] = $this->request->getQueryString(); $record['request']['_route'] = $this->request->get('_route'); } catch (\Exception $e) { // This stops errors occuring in the CLI } return $record; }
public static function make($idioma = null, $uri = null) { $server = explode('.', $_SERVER['HTTP_HOST']); $idioma = null === $idioma ? Translate::locale() : $idioma; if (sizeof($server) > 2) { $server = array_slice($server, -2); } if (!(Translate::locale() == $idioma)) { $uri = ''; } $url = 'http://' . $idioma . '.' . implode('.', $server) . (null === $uri ? Request::getRequestUri() : $uri); return $url; }
public function institucion($categoria, $id = null) { $this->options['categoria'] = $categoria; $this->options['id'] = $id; Estructuras::setOptions($this->options); $encabezado = Estructuras::getEncabezado(); if ($encabezado) { $this->data = Estructuras::getEstructuraEncabezado($encabezado); } $response = ApiHelper::prepareResponse($this->data, 'institucion', $this->options, $this->total); Cache::add(Request::getRequestUri(), $response, Config::get('cache.time')); return $response; }
public function testIndex() { $req = new Request('test/test', ['td1' => 'd1']); $this->assertEquals('test/test', $req->getRequestUri()); $this->assertEquals('d1', $req->td1); $this->assertTrue(isset($req->td1)); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->assertTrue($req->isXmlHttpRequest()); $req->setParam('a', 1); $this->assertEquals(1, $req->a); $this->assertEquals(1, $req->env('q', 1)); $this->assertEquals(1, $req->cookie('q', 1)); $this->assertEquals(1, $req->server('q', 1)); $this->assertInstanceOf('Yagrysha\\MVC\\User', $req->user); }
public static function dispatch($urls) { $found = false; $requestUri = Request::getRequestUri(); // $_SERVER['REQUEST_URI']; foreach ($urls as $url => $className) { if (preg_match("~{$url}~", $requestUri, $args)) { array_shift($args); if ($found = self::instance($className, $args)) { break; } } } if (!$found) { self::error(404); } }
public function index() { if (\Input::get('l')) { LaravelLogViewer::setFile(base64_decode(\Input::get('l'))); } if (\Input::get('dl')) { return \Response::download(storage_path() . '/logs/' . base64_decode(\Input::get('dl'))); } if (\Input::get('del')) { $file = storage_path() . '/logs/' . base64_decode(\Input::get('del')); try { if (file_exists($file)) { unlink($file); } } catch (\Exception $ex) { // DO NOTHING } $url = parse_url(\Request::getRequestUri(), PHP_URL_HOST) . parse_url(\Request::getRequestUri(), PHP_URL_PATH); return \Redirect::to($url); } $logs = LaravelLogViewer::all(); return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); }
/** * Generate a URL into a PKPApp. (This is a wrapper around Dispatcher::url() to make it available to Smarty templates.) * {url} 標籤 */ function smartyUrl($params, &$smarty) { if (!isset($params['context'])) { // Extract the variables named in $paramList, and remove them // from the params array. Variables remaining in params will be // passed along to Request::url as extra parameters. $context = array(); $contextList = Application::getContextList(); foreach ($contextList as $contextName) { if (isset($params[$contextName])) { $context[$contextName] = $params[$contextName]; unset($params[$contextName]); } else { $context[$contextName] = null; } } $params['context'] = $context; } // Extract the variables named in $paramList, and remove them // from the params array. Variables remaining in params will be // passed along to Request::url as extra parameters. $paramList = array('router', 'context', 'page', 'component', 'op', 'path', 'anchor', 'escape', 'source'); foreach ($paramList as $param) { if (isset($params[$param])) { ${$param} = $params[$param]; unset($params[$param]); } else { ${$param} = null; } } if (isset($source)) { $params['source'] = Request::getRequestUri(); } // Set the default router $request =& PKPApplication::getRequest(); if (is_null($router)) { if (is_a($request->getRouter(), 'PKPComponentRouter')) { $router = ROUTE_COMPONENT; } else { $router = ROUTE_PAGE; } } // Check the router $dispatcher =& PKPApplication::getDispatcher(); $routerShortcuts = array_keys($dispatcher->getRouterNames()); assert(in_array($router, $routerShortcuts)); // Identify the handler switch ($router) { case ROUTE_PAGE: $handler = $page; break; case ROUTE_COMPONENT: $handler = $component; break; default: // Unknown router type assert(false); } // Let the dispatcher create the url return $dispatcher->url($request, $router, $context, $handler, $op, $path, $params, $anchor, !isset($escape) || $escape); }
| Application & Route Filters |-------------------------------------------------------------------------- | | Below you will find the "before" and "after" events for the application | which may be used to do any work before or after a request into your | application. Here you may also register your custom route filters. | */ App::before(function ($request) { if (Auth::check()) { $count = Session::get(SESSION_COUNTER, 0); Session::put(SESSION_COUNTER, ++$count); } if (App::environment() == ENV_PRODUCTION) { if (!Request::secure()) { return Redirect::secure(Request::getRequestUri()); } } if (Input::has('lang')) { $locale = Input::get('lang'); App::setLocale($locale); Session::set(SESSION_LOCALE, $locale); if (Auth::check()) { if ($language = Language::whereLocale($locale)->first()) { $account = Auth::user()->account; $account->language_id = $language->id; $account->save(); } } } else { if (Auth::check()) {
public function start() { if (empty($this->routeType)) { //默认兼容模式 echo '1'; $this->routeType = 1; } if ($this->routeType == 1) { //r=app/controller/action形式 $route = Request::getGet('r'); $route = explode('/', $route); $len = count($route); if ($len == 1) { $this->app = $route[0]; } if ($len == 2) { $this->app = $route[0]; $this->controller = $route[1]; } if ($len == 3) { $this->app = $route[0]; $this->controller = $route[1]; $this->action = $route[2]; } } else { if ($this->routeType == 2) { //其他方式。。。 //获取出除域名和参数之外的路径 ,例如 /oneapi/index.php $script_name = Request::getScriptUrl(); //获取完整的路径,包含"?"之后的字符串/demo/index.php/group/module... ,eg :/oneapi/index.php/home/db/index $uri = Request::getRequestUri(); //去除url包含的当前文件的路径信息,只截取文件后的参数 if ($uri && @strpos($uri, $script_name, 0) !== false) { $uri = substr($uri, strlen($script_name)); ///home/db/index } else { //网址中省略引导文件名时 $script_name = dirname($_SERVER['SCRIPT_NAME']); if ($uri && @strpos($uri, $script_name, 0) !== false) { $uri = substr($uri, strlen($script_name)); } } $uri = ltrim($uri, '/'); //去除问号后面的查询字符串 if ($uri && false !== ($pos = @strrpos($uri, '?'))) { $uri = substr($uri, 0, $pos); } //分割数组 $uriInfoArray = explode('/', $uri); //'/'可以替换为其他的url分隔符 //去除后缀例如.html .json等的名称 $pathinfo = trim($_SERVER['PATH_INFO'], '/'); if ($pathinfo) { $suffix = strtolower(pathinfo($_SERVER['PATH_INFO'], PATHINFO_EXTENSION)); } if ($suffix) { Config::set('url.url_suffix', $suffix); } if ($uri && ($pos = strrpos($uri, Config::get('url.url_suffix'))) > 0) { $url = substr($url, 0, $pos); } //解析app 、controller、method和参数(放入$_GET) if (isset($uriInfoArray[0]) && $uriInfoArray[0] == true) { //获取controller及action名称 $this->app = $uriInfoArray[0]; $this->controller = isset($uriInfoArray[1]) && $uriInfoArray[1] == true ? $uriInfoArray[1] : Config::get('url.default_controller'); $this->action = isset($uriInfoArray[2]) && $uriInfoArray[2] == true ? $uriInfoArray[2] : Config::get('url.default_action'); //变量重组,将网址(URL)中的参数变量及其值赋值到$_GET全局超级变量数组中 if (($totalNum = sizeof($uriInfoArray)) > 4) { //dump($uriInfoArray); for ($i = 3; $i < $totalNum; $i += 2) { if (!isset($uriInfoArray[$i]) || !$uriInfoArray[$i] || !isset($uriInfoArray[$i + 1])) { continue; } $_GET[$uriInfoArray[$i]] = $uriInfoArray[$i + 1]; //dump($_GET); } } } } } //统一处理 if (!$this->app) { //app $this->app = Config::get('url.default_app'); } if (!$this->controller) { //控制器 $this->controller = Config::get('url.default_controller'); } if (!$this->action) { //动作 $this->action = Config::get('url.default_action'); } //定义 if (!defined('APP_NAME')) { define('APP_NAME', strtolower($this->app)); } if (!defined('CONTROLLER_NAME')) { define('CONTROLLER_NAME', ucfirst($this->controller)); } if (!defined('ACTION_NAME')) { define('ACTION_NAME', $this->action); } }
<?php require_once './logics/class.php'; $routes = array('/' => 'views/home.html', '/works/' => 'views/works.php', '/404/' => 'views/404.html'); $request = new Request(); $requestUri = $request->getRequestUri(); foreach ($routes as $currentUri => $templateUri) { if ($requestUri === $currentUri) { include_once $templateUri; exit; } } include_once $routes['/404/'];
/** * Handles all service requests * * @param null|string $version * @param string $service * @param null|string $resource * * @return ServiceResponseInterface|null */ public function handleService($version = null, $service, $resource = null) { try { $service = strtolower($service); // fix removal of trailing slashes from resource if (!empty($resource)) { $uri = \Request::getRequestUri(); if (false === strpos($uri, '?') && '/' === substr($uri, strlen($uri) - 1, 1) || '/' === substr($uri, strpos($uri, '?') - 1, 1)) { $resource .= '/'; } } $response = ServiceHandler::processRequest($version, $service, $resource); } catch (\Exception $e) { $response = ResponseFactory::create($e); } if ($response instanceof RedirectResponse) { return $response; } return ResponseFactory::sendResponse($response, null, null, $resource); }
public function p_EditResume() { $rules = ['Real_name' => 'required', 'sex' => 'required', 'skill' => 'required', 'profession' => 'required', 'qqnumber' => 'required', 'Blog' => 'required', 'province' => 'required', 'city' => 'required', 'district' => 'required', 'summery' => 'required', 'experience' => 'required', 'work_experience' => 'required']; $time = true; $projectNum = intval(Input::get('projectNum')); $ProjectName = Input::get('ProjectName'); $num = count($ProjectName); if ($num != $projectNum) { $projectNum = $num; } $ProjectPosition = Input::get('ProjectPosition'); $PtStartTime = Input::get('starttime'); $PtEndTime = Input::get('endtime'); if (is_null($PtStartTime)) { $time = false; } $ProjectUrl = Input::get('ProjectUrl'); $Projectecperience = Input::get('Projectexperience'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withInput()->with('message', $validator->messages()); } if (Auth::check()) { $id = Auth::user()->id; $Resume = Resume::firstOrNew(array('user_id' => $id)); $Resume->user_id = $id; $Resume->sex = Input::get('sex'); $Resume->profession_id = Input::get('skill'); $Resume->remote_status = Input::get('profession'); $Resume->skill_id = Input::get('skill'); $Resume->qq = Input::get('qqnumber'); $position = Input::get('province') . '-' . Input::get('city') . '-' . Input::get('district'); $Resume->position = $position; $Resume->blog = Input::get('Blog'); $Resume->summary = Input::get('summery'); $Resume->skill_experience = Input::get('experience'); $Resume->real_name = Input::get('Real_name'); $Resume->work_experience = Input::get('work_experience'); Userproject::where('user_id', '=', $id)->delete(); for ($i = 0; $i < $projectNum; $i++) { $OneProject = new Userproject(); $OneProject->user_id = $id; $OneProject->project_name = $ProjectName[$i]; $OneProject->role = $ProjectPosition[$i]; if ($time == false) { $OneProject->start_time = "1989-01-01"; $OneProject->end_time = "1989-01-01"; } else { $OneProject->start_time = $PtStartTime[$i]; $OneProject->end_time = $PtEndTime[$i]; } $OneProject->url = $ProjectUrl[$i]; $OneProject->description = $Projectecperience[$i]; $OneProject->save(); } $Resume->save(); } $url = Request::getRequestUri(); if (stripos($url, 'account') == false) { return Redirect::to('/EditResume'); } else { return Redirect::to('/account')->with('sucessmsg', "资料完善成功!"); } }
public function testGetRequestUri() { $this->assertThat($this->object->getRequestUri(), $this->equalTo('/Bachelor-Thesis/Source/Tryout/default/request')); }
$request = \Request::all(); $target = ['url' => $request['url']]; $rules = ['url' => 'required|url']; $message = ['url' => '请输入合法的链接地址', 'required' => '链接地址不能为空']; $validation = \Validator::make($target, $rules, $message); if ($validation->fails()) { $errmes = $validation->errors()->toArray(); dd($errmes['url'][0]); } return $request['url']; }); Route::get('show', function () { return view('test'); }); Route::get('url', function () { return Request::getRequestUri(); }); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ Route::group(['middleware' => ['web']], function () { // Route::get('/', 'HomeController@index'); Route::post('/short', 'HomeController@short');
/** * 检查是否具有权限并跳转 * @param $authStr * @return \Illuminate\Http\RedirectResponse */ function check_auth_to($authStr) { if (!check_auth($authStr)) { return redirect()->action("Admin\\LoginController@noAuthority", 'callback=' . base64_encode(Request::getRequestUri())); } }
| | Access filters based on roles. | */ // Check for role on all admin routes Entrust::routeNeedsRole('admin/*', array('admin'), function () { $user = null; $is_admin = false; if (!Auth::guest()) { $user = Auth::user(); } if ($user !== null) { $is_admin = $user->hasRole('admin'); } if (Request::ajax() === false && $is_admin === false) { Log::error('failed to authenticate in Entrust route ' . Request::getRequestUri()); return Redirect::to('user/login'); } }); // Check for permissions on admin actions Entrust::routeNeedsPermission('admin/blogs*', 'manage_blogs', Redirect::to('/admin')); Entrust::routeNeedsPermission('admin/comments*', 'manage_comments', Redirect::to('/admin')); Entrust::routeNeedsPermission('admin/users*', 'manage_users', Redirect::to('/admin')); Entrust::routeNeedsPermission('admin/roles*', 'manage_roles', Redirect::to('/admin')); /* |-------------------------------------------------------------------------- | CSRF Protection Filter |-------------------------------------------------------------------------- | | The CSRF filter is responsible for protecting your application against | cross-site request forgery attacks. If this special token in a user
<div class="container-fluid" > <div class="row"> <div class="nav-box " style="border-bottom:0px solid transparent"> <div id='menu' ng-app = "MangeMenu"> <div ng-controller = "MenuController as menu" ng-init = "menu.Init('/Menu','Catagories')"> <ul class="menu-list"> <li ng-repeat = 'list in menu.posts'><a href="#">[[list.menu_name]]</a></li> </ul> </div> </div> </div> </div> <div><?php echo "<a class = 'a_nav' href='" . url() . "'>Home</a>" . "<a class='a_nav_active' href='Request::getRequestUri();'>" . Request::getRequestUri() . "</a>"; ?> </div> <div class = "extraspace-tiny bg_line"></div> <div class = "extraspace-large"></div> <div id = "article" ng-app="article"> <div ng-controller="BlogController as blog" > <div class="topbar"> <div class="container"> <div class="row"> <div class="col-sm-4"> <h1 ng-click="blog.selectTab('blog')" class="push-left">[[blog.title]]</h1> </div> <div class="offset-sm-4 col-sm-4"> <nav role='navigation' class="push-right">
private function loadModels() { $modelBase = $this->getModelClass(); $this->models = $modelBase::getAll($this->request->getRequestUri()); }
public function destroy($id) { $topic = Topic::findOrFail($id); $this->authorOrAdminPermissioinRequire($topic->user_id); //删除文章 $topic->delete(); //该文章相关的通知删除 Notification::where('user_id', '=', $topic->user_id)->where('topic_id', '=', $topic->id)->delete(); //该文章的回复删除 Reply::where('topic_id', '=', $topic->id)->delete(); Flash::success(lang('Operation succeeded.')); $url = Request::getRequestUri(); if (stripos($url, 'account') == false) { return Redirect::route('topics.index'); } else { return Redirect::route('ac_topices'); } }
/** * Act as an internal constructor. * * @param Request request, the request * @param Response response, the response */ private function instantiate(Request $request, Response $response) { // class memebers $this->request = $request; $this->response = $response; $this->params = $request->getParameters(); $this->logger = Registry::get('__logger'); $this->injector = Registry::get('__injector'); $this->config = Registry::get('__configurator'); $this->session = $request->getSession(); $this->app_path = $this->injector->getPath('__base'); $this->template_root = $this->injector->getPath('views') . $this->params['controller'] . DIRECTORY_SEPARATOR; $this->template = ActionView::factory('php'); // register session container if any // TODO: this should be moved elsewhere if ($this->config->getWebContext()->session !== NULL && $this->config->getWebContext()->session->container !== NULL) { // container location. $c_location = str_replace('.', DIRECTORY_SEPARATOR, (string) $this->config->getWebContext()->session->container) . '.php'; include_once $c_location; // container class name. $e = explode('.', (string) $this->config->getWebContext()->session->container); // reflect on container. $container = new ReflectionClass(end($e)); if ($container->implementsInterface('ISessionContainer')) { $this->session->setContainer($container->newInstance()); } } // predefined variables: // TODO: check if we have a / at the end, if not, add one $this->template->assign('__base', (string) $this->config->getWebContext()->document_root); $this->template->assign('__server', (string) $this->config->getWebContext()->server_name); $this->template->assign('__controller', $this->params['controller']); $this->template->assign('__version', Medick::getVersion()); $this->template->assign('__self', $this->__base . $this->request->getRequestUri()); $this->logger->debug($this->request->toString()); }
/** * Get the query string * * @return string */ public function getQueryString() { return rtrim((string) $this->request->getRequestUri(), '/'); }
public static function getParametersPart($full_request_uri = null) { if ($full_request_uri === null) { $full_request_uri = Request::getRequestUri(); } $path_parts = explode("?", $full_request_uri); if (count($path_parts) > 1) { $parameters_part = $path_parts[1]; return $parameters_part; } return null; }
echo $strings[$mode]['legend']; ?> </legend> <?php } ?> <?php echo view('prettyforms::inputs-foundation', compact('item', 'fields', 'values'))->render(); ?> </fieldset> <br/> <div class="senddata button success" data-link="<?php echo Request::getRequestUri(); ?> " id="btn-save" data-input="#save-form"> <?php echo $mode === 'add' ? 'Создать' : 'Применить'; ?> </div> <a class="button tiny" href="<?php echo $home_link; ?> " id="btn-save"
} ?> value="text">Text</option> </select> </div> <div class="button-group col-xs-10 col-xs-offset-0 col-sm-8 col-sm-offset-2 col-md-3 col-md-offset-0"> <button class="btn btn-primary btn-sm" value="search" type="submit">Search</button> <a href="{{url('inbox')}}" class="btn btn-default btn-sm" value="reset" name="reset" type="reset">Reset</a> </div> </div> </form> </div> <!-- END SEARCH --> <?php $murl = Input::has('q') || Input::has('filter') ? Request::getRequestUri() . '&' : '?'; ?> <table class="table"> <tr> <th><input type="checkbox" onClick="checkAll(this)"></th> <th>#</th> <th> <a <?php if (Input::get('sort') == 'phone') { echo 'href="?sort" style="color:#33B7A3;"'; } else { echo 'href="' . $murl . 'sort=phone"'; } ?> >Phone</a>