/** * get all routes * get the URLs, the variables, the modules and the actions of all routes, use the "/applications/config/routes.xml" file. * @param string current url (optionnal) * @return array list of routes object */ public function getAllRoutes($currentUrl = null) { //get content of the file. $xml = new \DOMDocument(); $xml->load(__DIR__ . '/../applications/config/routes.xml'); $file = $xml->getElementsByTagName('route'); //parse the content. $varsNames = array(); $varsValues = array(); $varsList = array(); foreach ($file as $line) { //create the route. $varsNames = explode(',', $line->getAttribute('vars')); //get the name of all variables $route = new route($line->getAttribute('url'), $line->getAttribute('module'), $line->getAttribute('action'), $line->getAttribute('name'), $varsNames); //get variables. if ($varsValues = $route->match($currentUrl)) { array_shift($varsValues); // the first result contain the full captured string (cf. pregmatch manual). foreach ($varsValues as $key => $match) { $varsList[$varsNames[$key]] = $match; } $route->setVars($varsList); } //add the route to the router. $this->addRoute($route); } //return all routes. return $this->routes; }
function get_options_fincas() { $con = new con(); $msg = new messages(); $rt = new route(); $con->connect(); //consultamos fincas desde la matriz ica if (isset($_SESSION["ses_id"])) { $qry = 'SELECT DISTINCT codfinca, municipio, depto FROM tbl_matriz_ica ORDER BY codfinca ASC'; $res = mysql_query($qry); $item = " "; $script = "<script>\$(document).ready(function(){"; while ($row_res = mysql_fetch_assoc($res)) { $item .= ' <option value="' . $row_res["codfinca"] . '">' . $row_res["codfinca"] . ' (' . $row_res["municipio"] . ' - ' . $row_res["depto"] . ')</option> '; $script .= ''; } $script .= '});</script>'; } else { $rt->routing($rt->path("login")); } $html = ' <select class="form-control valued" id="cod"> ' . $item . ' </select> '; $con->disconnect(); return $script . $html; }
function __construct(route $route) { $this->config = $route->getConfig(); unset($route); $this->getCacheKey(); $this->getCache(); }
public function go() { $route = new route(); $path = $route->getRoute(); $this->controll = $path['controll'] . 'Ctrl'; $this->action = $path['action']; //加载控制器和方法 include APP . '/controll/' . $this->controll . '.php'; $c = new $this->controll(); $c->{$this->action}(); }
public function __construct($param = array()) { parent::__construct($param); if (!@$this->param['reverse']) { $this->param['reverse'] = preg_replace('/\\(.*?\\)/i', '%s', $this->param['url']); } }
static function start() { $routes = explode('/', $_GET['router']); if ($routes[0]) { $controller_name = "Controller" . $routes[0]; } elseif ($routes[0] == "") { $controller_name = "Controllerindex"; } if ($routes[1]) { $action_name = $routes[1]; } else { $action_name = "index"; } $model_name = "Model" . $routes[0]; if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/apps/controler/" . mb_strtolower($controller_name) . ".php")) { include_once $_SERVER['DOCUMENT_ROOT'] . "/apps/controler/" . mb_strtolower($controller_name) . ".php"; $controller = new $controller_name(); } else { $controller = new Controler(); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/apps/model/" . mb_strtolower($model_name) . ".php")) { include_once $_SERVER['DOCUMENT_ROOT'] . "/apps/model/" . mb_strtolower($model_name) . ".php"; } if (method_exists($controller, $action_name)) { $controller->{$action_name}(); } else { echo route::ErrorPage404(); } }
function get_fincas_list() { $con = new con(); $msg = new messages(); $rt = new route(); $con->connect(); //consultamos fincas desde la tabla de fincas if (isset($_SESSION["ses_id"])) { $qry = 'SELECT * FROM tbl_fincas WHERE fi_estado=1 ORDER BY fi_id ASC'; $res = mysql_query($qry); $item = " "; $script = "<script>\$(document).ready(function(){"; while ($row_res = mysql_fetch_assoc($res)) { $item .= ' <option value="' . $row_res["fi_id"] . '">' . $row_res["fi_codigo"] . '</option> '; $script .= ''; } $script .= '});</script>'; } else { $rt->routing($rt->path("login")); } $html = ' <select class="form-control valued" id="cod"> <option>Seleccione</option> ' . $item . ' </select> '; $con->disconnect(); return $script . $html; }
protected static function getFacadeAccessor() { if (!static::$__router) { static::$__router = kernel::single('base_routing_router', request::instance()); route::boot(); } return static::$__router; }
protected static function getFacadeAccessor() { if (!static::$__url) { $routes = route::getRoutes(); static::$__url = new base_routing_urlgenerator($routes, request::instance()); } return static::$__url; }
public function __construct($param = array()) { parent::__construct($param); if (count($this->param->part)) { foreach ($this->param->part as $k => $v) { $class = 'route_' . $v->type; $this->param->part->{$k} = class_exists($class) ? new $class($v->param) : new data($v->param); } } }
function get_reports() { $con = new con(); $msg = new messages(); $rt = new route(); $con->connect(); //consultamos fincas if (isset($_SESSION["ses_id"])) { $qry = 'SELECT * FROM tbl_reporte_consecutivo ORDER BY rp_consecutivo DESC '; $res = mysql_query($qry); $item = " "; $script = "<script>\$(document).ready(function(){"; while ($row_res = mysql_fetch_assoc($res)) { $item .= ' <tr> <td>' . $row_res["rp_timestamp"] . '</td> <td>' . $row_res["rp_consecutivo"] . '</td> <td>' . $row_res["rp_causa"] . '</td> </tr> '; $script .= ''; } $script .= '});</script>'; } else { $rt->routing($rt->path("login")); } $html = ' <table class="table table-striped table-hover "> <thead> <tr> <th>Fecha reporte</th> <th>Consecutivo</th> <th>Causa</th> </tr> </thead> <tbody> ' . $item . ' </tbody> </table> '; $con->disconnect(); return $script . $html; }
/** * ShopEx licence * * @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn) * @license http://ecos.shopex.cn/ ShopEx License */ function theme_widget_items_category(&$setting) { // 判断是否首页 if (route::currentRouteName() == 'topc') { $returnData['isindex'] = true; } if (false && base_kvstore::instance('topc_category')->fetch('category_ex_vertical_widget.data', $cat_list)) { return $cat_list; } $returnData['data'] = app::get('topc')->rpcCall('category.cat.get.list', array('fields' => 'cat_id,cat_name')); return $returnData; }
/** * ShopEx licence * * @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn) * @license http://ecos.shopex.cn/ ShopEx License */ function theme_widget_index_category(&$setting) { // 判断是否首页 $A = route::currentRouteName(); //var_dump($_SERVER); if (route::currentRouteName() == 'topc' || $_SERVER["ORIG_PATH_INFO"] == "/index.php/trading" || $_SERVER["DOCUMENT_URI"] == "/index.php/trading") { $returnData['isindex'] = true; } if (false && base_kvstore::instance('topc_category')->fetch('category_ex_vertical_widget.data', $cat_list)) { return $cat_list; } $returnData['data'] = app::get('topc')->rpcCall('category.cat.get.list', array('fields' => 'cat_id,cat_name')); //var_dump($returnData); return $returnData; }
public function handle($request, Clousure $next) { $routeAs = route::currentRouteName(); $currentPermission = shopAuth::getSellerPermission(); //$currentPermission = false 表示为店主不用判断权限 //获取当前用户的路由权限 if ($currentPermission && !in_array($routeAs, $currentPermission)) { if (request::ajax()) { return response::json(array('error' => true, 'message' => '无操作权限')); } else { return redirect::action('topshop_ctl_index@nopermission'); } } return $next($request); }
/** * match the requested route with one of the routes added to the routes array on the main maverick class * @param string $protocol the protocol specified in the routes, either post, get, or any * @param string $route the route string * @param string $action the action to take, usually in the form of controller->method * @param array $args an array of matched parameters to pass to the routing controller class * @return boolean */ private static function match_route($protocol, $route, $action, $args) { $maverick = \maverick\maverick::getInstance(); // return if a route has already been matched if (isset($maverick->route)) { return false; } // return if the protocols don't match if (strtolower($_SERVER['REQUEST_METHOD']) == $protocol || $protocol == 'any') { preg_match("~^{$route}\$~", $maverick->requested_route_string, $matches); // route match - assign the information back to the main maverick object if (!empty($matches)) { $maverick->controller = route::get_full_action($action, $args, $matches); } } else { return false; } }
/** * 初始化路由 * * @since 1.0.1 * @notice 主要的路径下,尽可能囊括更多的选择,诸如/join/?123 */ private function init_route() { route::register('/', 'index'); route::register('/index.php', 'index'); route::register('/\\?.*', 'index', true); route::register('/index.php\\?.*', 'index', true); route::register('/join', 'join'); route::register('/join\\?.*', 'join', true); route::register('/join/\\?.*', 'join', true); route::register('/baoming', 'join'); route::register('/baoming\\?.*', 'join', true); route::register('/baoming/\\?.*', 'join', true); route::register('/about', 'about'); route::register('/about\\?.*', 'about', true); route::register('/about/\\?.*', 'about', true); route::register('/links', 'links'); route::register('/links\\?.*', 'links', true); route::register('/links/\\?.*', 'links', true); route::register('/contact', 'contact'); route::register('/contact\\?.*', 'contact', true); route::register('/contact/\\?.*', 'contact', true); route::register('/bbs', 'bbs'); route::register('/bbs\\?.*', 'bbs', true); route::register('/bbs/\\?.*', 'bbs', true); route::register('/dispbbs.asp', 'bbs'); route::register('/dispbbs.asp\\?.*', 'bbs', true); route::register('/index.asp', 'bbs'); route::register('/index.asp\\?.*', 'bbs', true); route::register('/forum', 'forum'); route::register('/forum\\?.*', 'forum', true); route::register('/forum/\\?.*', 'forum', true); route::register('/thread', 'forum'); route::register('/thread\\?.*', 'forum', true); route::register('/thread/\\?.*', 'forum', true); route::register('/home.php', 'forum'); route::register('/home.php\\?.*', 'forum', true); route::register('/member.php', 'forum'); route::register('/member.php\\?.*', 'forum', true); route::register('/hi-cat', 'hi_cat'); route::register('/hi-cat\\?.*', 'hi_cat', true); route::register('.*', 'page404', true); new Route(); }
public function command_cache() { if ($this->files->exists(kernel::getCachedRoutesPath())) { $this->command_clear(); } if (!$this->files->isWritable(dirname(kernel::getCachedRoutesPath()))) { logger::info(sprintf('Route cache path:%s cannot write', kernel::getCachedRoutesPath())); exit; } $routes = route::getRoutes(); if (count($routes) == 0) { logger::info("Your application doesn't have any routes."); exit; } foreach ($routes as $route) { $route->prepareForSerialization(); } $this->files->put(kernel::getCachedRoutesPath(), $this->buildRouteCacheFile($routes)); logger::info("Routes cached successfully!"); }
/** * create routing cache * * @return array */ private function createMethodsCache() { $routing = (include 'src/Web/routing.php'); $config = array(); foreach ($routing as $key => $route) { if (!isset($route['methods'])) { $config[$key] = $route; continue; } if (isset($route['methods']) && !in_array(strtoupper($route['methods']), $this->methods)) { continue; } if (isset($route['methods']) && $this->route->getCurrentMethod() != strtoupper($route['methods'])) { continue; } $config[$key] = $route; } $config = ArrayToolkit::index($config, 'pattern'); return $config; }
public static function test_url($url, $pattern, $create_get = true) { if (is_array($pattern)) { $found = false; foreach ($pattern as $p) { $found = route::test_url($url, $p, $create_get); if ($found) { return $found; } } return false; } $testPattern = preg_replace('#\\{(\\w+)\\}#isU', '(\\w+)', $pattern); $testPattern = preg_replace('#\\{\\?(\\w+)\\}#isU', '(\\w*)', $testPattern); $testPattern = preg_replace('#\\{\\[(\\w+)\\]\\}#isU', '(.+)', $testPattern); $testPattern = preg_replace('#\\{\\?\\[(\\w+)\\]\\}#isU', '(.*)', $testPattern); $testPattern = preg_replace('#/#isU', '/*', $testPattern); if (preg_match_all('#^' . $testPattern . '$#', $url, $matches)) { if (!$create_get) { return true; } if (preg_match_all('#\\{(.+)\\}#isU', $pattern, $names)) { unset($matches[0]); if (count($matches) == count($names[1])) { foreach ($names[1] as $key => $get_name) { $name = preg_replace('#\\[(.+)\\]#isU', '$1', $get_name); $name = ltrim($name, '?'); if ($get_name[0] == '?') { if ($matches[$key + 1][0] != '') { $_GET[$name] = $matches[$key + 1][0]; } } else { $_GET[$name] = $matches[$key + 1][0]; } } } } return true; } return false; }
<?php Route::get('/', function () { return View::make('hello'); }); route::post('login/', function () { return 0; });
Route::get('/', 'PagesController@Index'); Route::get('/about', 'PagesController@about'); Route::post('user/{id}/feedback', 'Insertions\\FeedbacksController@create'); Route::resource('posts', 'Insertions\\PostsController'); Route::resource('adverts', 'Insertions\\AdvertsController'); Route::post('posts/{postId}/comments/', 'Insertions\\CommentsController@create'); Route::get('user/{id}', 'UsersController@show'); Route::get('dashboard', 'UsersController@edit'); Route::put('dashboard/{id}', 'UsersController@update'); Route::get('upload', function () { return View::make('users.upload'); }); Route::post('upload', 'UploadController@upload'); //invite Route::resource('invite', 'InvitesController'); route::resource('/auth/activate', 'InviteRegisterController'); //admin panel Route::get('/admin', 'Admin\\AdminController@index'); Route::resource('/admin/users', 'Admin\\AdminUsersController'); Route::resource('/admin/roles', 'Admin\\RolesController'); Route::resource('/admin/permissions', 'Admin\\PermissionsController'); }); Route::post('about', 'EmailController@showForm'); Route::post('about', 'EmailController@handleFormPost'); Route::get('setlocale/{locale}', function ($locale) { if (in_array($locale, \Config::get('app.locales'))) { # ѕровер¤ем, что у пользовател¤ выбран доступный ¤зык Session::put('locale', $locale); # » устанавливаем его в сессии под именем locale } });
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); route::get('client', 'ClientController@index'); route::post('client', 'ClientController@store'); route::get('client/{id}', 'ClientController@show'); route::delete('client/{id}', 'ClientController@destroy'); route::put('client/{id}', 'ClientController@update'); route::get('projects/{id}/notes', 'ProjectNotesController@index'); route::post('projects/{id}/notes', 'ProjectNotesController@store'); route::get('projects/{id}/notes/{noteId}', 'ProjectNotesController@show'); route::put('projects/{id}/notes/{noteId}', 'ProjectNotesController@update'); route::delete('projects/{id}/notes/{noteId}', 'ProjectNotesController@destroy'); route::get('projects', 'ProjectsController@index'); route::post('projects', 'ProjectsController@store'); route::get('projects/{id}', 'ProjectsController@show'); route::delete('projects/{id}', 'ProjectsController@destroy'); route::put('projects/{id}', 'ProjectsController@update');
/** * 邮箱验证 * @param int $user_id * @param string $email * @param string $token 找回密码加密串 */ public static function check_register($uid, $email, $lastname, $key) { $mail_type = 'register_mail_active'; $to_email = $email; $from_email = ''; $expire = date('Y-m-d H:i', time() + Kohana::config('password.time')); $check_url = route::action('check_register') . "user/reg_success/?key=" . $key . "&id=" . $uid . "&u=" . $lastname . "&e=" . $email; $check_link = '<a href="' . $check_url . '" target="_blank">' . $check_url . '</a>'; $title_param = array(); $content_param = array('{username}' => $lastname, '{email}' => $email, '{expire}' => $expire, '{url}' => $check_url, '{url_link}' => $check_link); self::send_mail(1, $mail_type, $to_email, $from_email, $title_param, $content_param); }
<?php Route::model('brands', 'AbuseIO\\Models\\Brand'); Route::resource('brands', 'BrandsController'); Route::group(['prefix' => 'brands', 'as' => 'brands.'], function () { // Search contacts Route::get('search/{one?}/{two?}/{three?}/{four?}/{five?}', ['middleware' => 'permission:brands_view', 'as' => 'search', 'uses' => 'BrandsController@search']); // Access to index list route::get('', ['middleware' => 'permission:brands_view', 'as' => 'index', 'uses' => 'BrandsController@index']); // Access to show object route::get('{brands}', ['middleware' => 'permission:brands_view', 'as' => 'show', 'uses' => 'BrandsController@show']); // Access to export object route::get('export/{format}', ['middleware' => 'permission:brands_export', 'as' => 'export', 'uses' => 'BrandsController@export']); // Access to create object route::get('create', ['middleware' => 'permission:brands_create', 'as' => 'create', 'uses' => 'BrandsController@create']); route::post('', ['middleware' => 'permission:brands_create', 'as' => 'store', 'uses' => 'BrandsController@store']); // Access to edit object route::get('{brands}/edit', ['middleware' => 'permission:brands_edit', 'as' => 'edit', 'uses' => 'BrandsController@edit']); route::patch('{brands}', ['middleware' => 'permission:brands_edit', 'as' => 'update', 'uses' => 'BrandsController@update']); route::put('{brands}', ['middleware' => 'permission:brands_edit', 'as' => 'update', 'uses' => 'BrandsController@update']); // Access to delete object route::delete('/{brands}', ['middleware' => 'permission:brands_delete', 'as' => 'destroy', 'uses' => 'BrandsController@destroy']); });
<?php include '../../mods/route.php'; include '../../php/jslib.php'; include '../../php/app_menu.php'; include '../../php/aside_menu.php'; include '../../php/html_snippets.php'; //menu aplicacion $app_menu = new app_menu(); $aside_menu = new aside_menu(); $html_snippet = new html_snippets(); $rt = new route(); $rt->check_session(); $libs = new jslib(); $css = $libs->get_css(); $js = $libs->get_js(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Inicio - STL SAS</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <link rel="stylesheet" href="chart/morris.css" type="text/css"> <link rel="icon" href="favicon.ico" type="image/x-icon"/> <script src="js/jquery.min.js"></script> <script src="js/jquery.easing.js"></script>
<?php include "/system/autoload.php"; route::start();
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/', 'HomeController@index'); Route::post('/signup', array('before' => 'csrf', 'uses' => 'UsersController@store')); Route::post('/login', array('before' => 'csrf', 'uses' => 'UsersController@login')); Route::get('/users/logout', array('uses' => 'UsersController@logout')); Route::get('/profile', array('before' => 'auth', 'uses' => 'ProfileController@index')); Route::post('/update', array('before' => 'auth', 'uses' => 'UsersController@update_profile')); route::post('/password', array('before' => 'csrf|auth', 'uses' => 'UsersController@change_password')); Route::post('/search', array('before' => 'csrf', 'uses' => 'UsersController@search')); Route::get('/search', function () { return Redirect::to('/'); });
<?php Route::model('users', 'AbuseIO\\Models\\User'); Route::resource('users', 'UsersController'); Route::group(['prefix' => 'users', 'as' => 'users.'], function () { // Search users Route::get('search/{one?}/{two?}/{three?}', ['middleware' => 'permission:users_view', 'as' => 'search', 'uses' => 'UsersController@search']); // Access to index list route::get('', ['middleware' => 'permission:users_view', 'as' => 'index', 'uses' => 'UsersController@index']); // Access to show object route::get('{users}', ['middleware' => 'permission:users_view', 'as' => 'show', 'uses' => 'UsersController@show']); // Access to export object route::get('export/{format}', ['middleware' => 'permission:users_export', 'as' => 'export', 'uses' => 'UsersController@export']); // Access to create object route::get('create', ['middleware' => 'permission:users_create', 'as' => 'create', 'uses' => 'UsersController@create']); route::post('', ['middleware' => 'permission:users_create', 'as' => 'store', 'uses' => 'UsersController@store']); // Access to disable object route::get('{users}/disable', ['middleware' => 'permission:users_disable', 'as' => 'disable', 'uses' => 'UsersController@disable']); // Access to enable object route::get('{users}/enable', ['middleware' => 'permission:users_enable', 'as' => 'enable', 'uses' => 'UsersController@enable']); // Access to edit object route::get('{users}/edit', ['middleware' => 'permission:users_edit', 'as' => 'edit', 'uses' => 'UsersController@edit']); route::patch('{users}', ['middleware' => 'permission:users_edit', 'as' => 'update', 'uses' => 'UsersController@update']); route::put('{users}', ['middleware' => 'permission:users_edit', 'as' => 'update', 'uses' => 'UsersController@update']); // Access to delete object route::delete('/{users}', ['middleware' => 'permission:users_delete', 'as' => 'destroy', 'uses' => 'UsersController@destroy']); });
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ App::missing(function () { return Redirect::to('/404'); }); route::get('/404', function () { return View::make('error.404'); }); Route::get('/', function () { return View::make('index'); }); Route::get('/tcit/student/subscribe', 'HomeController@showForm');
|-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ /* Route::get('/', function () { return view('welcome'); }); */ use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Auth; Route::get('/', 'MainController@home'); Route::get('home', ['as' => 'homePath', 'uses' => 'MainController@home']); Route::get('about', ['as' => 'aboutPath', 'uses' => 'MainController@about']); Route::get('contacts', ['as' => 'contactsPath', 'uses' => 'MainController@contacts']); Route::get('login', ['as' => 'loginPath', 'uses' => 'MainController@login']); Route::get('signup', ['as' => 'signupPath', 'uses' => 'MainController@signup']); Route::post('signup', ['as' => 'signup', 'uses' => 'UserController@signup']); Route::post('login', ['as' => 'login', 'uses' => 'UserController@login']); Route::get('logout', ['as' => 'logoutPath', 'uses' => 'UserController@logout']); route::get('create', ['as' => 'profilePath', 'middleware' => 'auth', 'uses' => 'UserController@profile']); route::post('create', ['as' => 'createPost', 'uses' => 'usercontroller@post']); route::get('all-posts', ['as' => 'allPostsPath', 'middleware' => 'auth', 'uses' => 'UserController@all_posts']); route::get('find-friends', ['as' => 'findFriendsPath', 'middleware' => 'auth', 'uses' => 'UserController@findFriend']); route::get('auth/login', ['as' => 'guest', 'uses' => 'UserController@guest']); route::get('/{id}', ['as' => 'myProfilePath', 'middleware' => 'auth', 'uses' => 'UserController@show']); route::get('/user/{id}', ['as' => 'userProfilePath', 'middleware' => 'auth', 'uses' => 'UserController@showUser']);