/** * When visiting any page on the site, check if the user is already logged in, * or they are visiting a page that is allowed when logged out. Otherwise, * redirect to the login page. If visiting the login page, check the browser * supports cookies. */ public function check() { $uri = new URI(); // Skip check when accessing the data services, as it is redundant but would slow the services down. // Also no need to login when running the scheduled tasks. if ($uri->segment(1) == 'services' || $uri->segment(1) == 'scheduled_tasks') { return; } // check for setup request // if ($uri->segment(1) == 'setup_check') { // get kohana paths // $ipaths = Kohana::include_paths(); // check if indicia_setup module folder exists // clearstatcache(); foreach ($ipaths as $path) { if (preg_match("/indicia_setup/", $path) && file_exists($path)) { return; } } } // Always logged in $auth = new Auth(); if (!$auth->logged_in() and !$auth->auto_login() and $uri->segment(1) != 'login' and $uri->segment(1) != 'logout' and $uri->segment(1) != 'new_password' and $uri->segment(1) != 'forgotten_password') { $_SESSION['requested_page'] = $uri->string(); url::redirect('login'); } else { if ($auth->logged_in() and is_null($_SESSION['auth_user']->password) and $uri->segment(1) != 'new_password' and $uri->segment(1) != 'logout' and $uri->segment(1) != 'setup_check') { $_SESSION['requested_page'] = $uri->string(); url::redirect('new_password'); } } }
public function get_requestDetailinfo() { $data['claimID'] = $claimID = URI::segment(5); $data['app'] = $claimApp = Claims_App::appInfo($claimID); $data['detailList'] = Claims_App::listDetailsHistory($claimID); return View::make('claims.request.inforequestdetails', $data); }
function get_list($gid) { $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role()); Event::run('steamcore.aclcheck', $data); // which model are we using? one passed through or the default? $model = steamcore::get_controls_model($this->gallery); $controller = URI::segment(1); $tdata = array(); $page = Input::instance()->get('page', 0); $num = 18; $offset = 0; $limit = 18; if ($page) { $offset = $num * $page - $num; } $where = array(); if (isset($gid) and is_numeric($gid)) { $where = array('galleries_id' => $gid); } // query the model $data['query'] = $model->where($where)->limit($limit, $offset)->find_all(); $data['controller'] = $controller; $total = $model->count_last_query(); $data['pagination'] = ''; if ($total > $num) { $data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $num, 'query_string' => 'page', 'total_items' => $total)); } // merge any passed data and the data returned from the model $tdata = array_merge($tdata, $data); // return the result return $tdata; }
public function __construct() { $this->filter('before', array('admin')); if (is_numeric(URI::Segment(4))) { $this->studio_id = URI::Segment(4); $this->layout_id = URI::segment(4); } }
public function __construct() { parent::__construct(); $this->filter('before', 'auth'); $this->filter('before', 'perm', array('solder_modpacks')); $this->filter('before', 'perm', array('solder_create'))->only(array('create')); $this->filter('before', 'modpack', array(URI::segment(3)))->only(array('view', 'create', 'delete', 'edit')); $this->filter('before', 'build', array(URI::segment(3)))->only(array('build')); }
public function get_datacontent() { $groupID = URI::segment(5); Group::getDataModel($groupID); $data['list'] = Group::getDataList(); $data['groupID'] = $groupID; $data['header'] = Group::getDataHeader(); return View::make('admin::data.data', $data); }
/** * breadcrumb function * Create breadcrumb * @return string * @author joharijumali **/ public static function breadcrumb() { $Menu = Admin_Menu::menuGenerator(); $butternbread = array(); foreach ($Menu as $floor => $packet) { foreach ($packet->page->action as $key => $action) { if ($packet->packet == Str::lower(URI::segment(1)) && $packet->controller->name == Str::lower(URI::segment(2)) && $action->name == Str::lower(URI::segment(3)) || URI::segment(3) == NULL && $action->name == $packet->controller->name && Str::lower(URI::segment(2)) == $packet->controller->name) { $butternbread[Str::upper($packet->controller->alias)] = '#'; array_push($butternbread, Str::title($action->alias)); } } } return Breadcrumb::create($butternbread); }
/** * return list * * @param object $lc * @return array * @author Andy Bennett */ public function get_list() { $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role()); Event::run('steamcore.aclcheck', $data); $tdata = array(); $limit = 10; $page_num = $this->input->get('page', 1); $offset = ($page_num - 1) * $limit; $model = ORM::factory($this->setup['model'], null); $data['query'] = $model->where('role', URI::segment(1))->find_all($limit, $offset); $data['controller'] = Kohana::instance()->uri->segment(1); $data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $limit, 'query_string' => 'page', 'total_items' => $model->count_last_query())); // merge any passed data and the data returned from the model $tdata = array_merge($tdata, $data); // return the result return $tdata; }
public function get_view() { // Convert a GET request layout ID to url format if (Input::get('layout_id', null) !== null) { return Redirect::to_action('quotations/view', array('id' => Input::get('layout_id'))); } // Make sure we have the layout ID $layout_id = URI::segment(3); if (is_null($layout_id) && \Laravel\Session::get('quote_layout_id', null) !== null) { return Redirect::to_action('quotations/view', array('id' => \Laravel\Session::get('quote_layout_id'))); } if (is_null($layout_id)) { return Redirect::to_action('quotations'); } // Load page $data['layout'] = Layout::find($layout_id); if ($data['layout'] === null) { return Redirect::to_action('quotations')->with('error', 'Unable to find the studio layout you have selected. Please select from the list below'); } $data['formatted_cost'] = $data['layout'] == '' ? '' : '£' . number_format($data['layout']->cost, 2); $data['layouts'] = Layout::where('studio_id', '=', $data['layout']->studio_id)->order_by('size_x', 'asc')->order_by('size_y', 'asc')->get(); $data['size'] = $data['layout']->size_x . 'x' . $data['layout']->size_y; $data['postcode'] = Session::get('postcode') ? Session::get('postcode') : \Laravel\Session::get('quote_postcode'); $data['layout_id'] = $layout_id; $data['error'] = Session::get('error') ? Session::get('error') : ''; $data['success'] = Session::get('success') ? Session::get('success') : ''; $data['establishedQuote'] = self::establishedQuote(); $data['quotation_current_price'] = '£' . number_format(Quotation::calcSessionQuotationCurrentValue(), 2); // Its possible the selected layout has been changed // If this is the case we want to flush session data as we dont want any of the previous quotation customise data presisting and potentially causing errors if (\Laravel\Session::get('quote_layout_id', null) !== null) { if ((int) \Laravel\Session::get('quote_layout_id') !== $data['layout']->id) { self::resetQuotationSession(); return Redirect::back(); } } return View::make('quotations.view')->with('data', $data); }
/** * sidebar function * Create sidebar * @return string * @author joharijumali **/ public static function next() { $path = URI::segment(2) . '/' . URI::segment(3) . '/' . URI::segment(4); $page = Console_Page::where('modul', '=', URI::segment(2))->where('controller', '=', URI::segment(3))->where('action', '=', URI::segment(4))->first(); if ($page) { try { $currentStep = Console_Step::where('page', '=', $page->modulpageid)->first(); if (!empty($currentStep)) { if ($currentStep->parentid == 0) { return $currentStep->stepid; } else { $nextStep = Console_Step::where('flowid', '=', $currentStep->flowid)->where('parentid', '=', $currentStep->stepid)->first(); if ($nextStep) { return $nextStep->stepid; } } } } catch (Exception $e) { Log::write('Flow', 'Status Retrieving Failed: ' . $e->getMessage()); } } else { Log::write('Flow', 'Page Not Exist: '); } }
public function action_display() { $user = $this->is_logged(); if ($user === false) { return Redirect::to_action('login'); } else { $id_playlist = URI::segment(3); $adminPlaylist = new adminPlaylist($user->get_id_user_lif(), $id_playlist); if ($adminPlaylist->check_exists() == 1) { $song_array = array(); $all = SongPlaylist::all_from_ids($id_playlist); foreach ($all as $value) { $song = new Song($value->id_song); $song->load(); array_push($song_array, $song); } $playlist = new Playlist($id_playlist); $playlist->load(); return View::make('playlist.display')->with('playlist', $playlist)->with('songs', $song_array); } else { return Redirect::to_action('home@index'); } } }
} /** * Activate a new user and log them in * @todo Finish email authentication mechanism */ if (FALSE && Config::get('xysti.routes.auth.activate')) { Route::get('activate/(:any)/(:any)', function () { Xysti::helper('dbug'); $auth_driver = Config::get('xysti.auth', 'default'); // Default auth if ($auth_driver == 'default') { Xysti::error(500, 'Default auth currently not configured for activation.'); // Sentry auth } elseif ($auth_driver == 'sentry') { try { $activate_user = Sentry::activate_user(URI::segment(2), URI::segment(3), FALSE); } catch (Sentry\SentryException $e) { // issue activating the user // store/set and display caught exceptions such as a suspended user with limit attempts feature. $errors = $e->getMessage(); } } else { return Xysti::error(500, 'Unknown authentication driver.'); } if ($activate_user) { //Sentry::force_login(URI::segment(2)); return Redirect::to(Xysti::page('login', 'post_login')); } else { return Xysti::make(500, 'User activation failed.'); } });
/** * Test the URI::segment method. * * @group laravel */ public function testSegmentMethodReturnsAURISegment() { $this->setRequestUri('/user/profile'); $this->assertEquals('user', URI::segment(1)); $this->assertEquals('profile', URI::segment(2)); }
| You can even respond to more than one URI: | | Route::post(array('hello', 'world'), function() | { | return 'Hello World!'; | }); | | It's easy to allow URI wildcards using (:num) or (:any): | | Route::put('hello/(:any)', function($name) | { | return "Welcome, $name."; | }); | */ Log::info(sprintf("%s %s %s Seg[%d]: %s %s %s", Request::method(), URI::full(), Request::ip(), Router::$segments, URI::segment(1, '-'), URI::segment(2, '-'), URI::segment(3, '-'))); // start page Route::get('/', 'sapoc@index'); // login/logout Route::get('login', 'sapoc@login'); Route::post('login', 'sapoc@auth'); Route::get('logout', function () { Auth::logout(); return Redirect::to('/'); }); // register Route::get('verify', 'sapoc@verify'); Route::post('verify', 'sapoc@send_verification'); //Route::get('register', 'user@register'); Route::get('register', 'sapoc@register'); Route::post('register', 'sapoc@create_user');
public static function menuGenerator() { $Menus = Admin_Menu::order_by('arrangement', 'asc')->get(); $acces = Admin_UserAcl::aclRegistered(); $selected = new stdClass(); $page = new stdClass(); $dev = array(); $sub = array(); $logged_user = Auth::user(); foreach ($Menus as $id => $menu) { $content = new stdClass(); $controller = new stdClass(); $action = new stdClass(); $pieces = explode("/", $menu->controller); if ($menu->action == NULL || $menu->header == 1 && $menu->footer == 1) { $content->footer = $menu->footer; $content->header = $menu->header; $content->auth = $menu->auth; $content->admin = $menu->admin; $content->packet = $pieces[0]; if ($menu->action == NULL && ($menu->header == 1 || $menu->footer == 1)) { $controller->name = $pieces[1]; $controller->alias = $menu->controlleralias; } else { $controller->name = $menu->action; $controller->alias = $menu->actionalias; } $content->controller = $controller; if ($content->controller->name == URI::segment(2)) { $content->status = "active"; } else { $content->status = ""; } } elseif ($menu->action != NULL && ($menu->header != 0 || $menu->footer != 0)) { $action->name = $menu->action; $action->alias = $menu->actionalias; $action->footer = $menu->footer; $action->header = $menu->header; $action->auth = $menu->auth; if ($action->name == URI::segment(3) || URI::segment(3) == NULL && $action->name == $pieces[1] && URI::segment(2) == $pieces[1]) { $action->status = "active"; } else { $action->status = ""; } //check acl access if (Auth::check()) { if (isset($acces[$logged_user->role])) { if (isset($acces[$logged_user->role][$menu->controller])) { if (isset($acces[$logged_user->role][$menu->controller][$menu->action])) { $sub[$pieces[1]][] = $action; } } } } else { $sub[$pieces[1]][] = $action; } } $cont = (array) $content; if (!empty($cont)) { $dev[$id] = $content; } } $final = array(); foreach ($dev as $key => $value) { $action = new stdClass(); $page = new stdClass(); $ctrl = $value->controller->name; if (!empty($sub[$ctrl])) { $action->action = $sub[$ctrl]; } $value->page = $action; // check acl access if (Auth::check()) { $pages = (array) $value->page; if (isset($acces[$logged_user->role])) { if (isset($acces[$logged_user->role][$value->packet . '/' . $ctrl])) { if ((!empty($pages) || $ctrl == 'dashboard') && ($value->admin == 1 ? $value->admin == Auth::user()->role : TRUE)) { $final[$key] = $value; } } } } else { $final[$key] = $value; } } return $final; }
public function get_delete() { $affected = DB::table('brand')->where('id', '=', URI::segment(3))->delete(); return Redirect::to_route('brand_admin')->with('message', 'Brand deleted successfully'); }
/** * Output breadcrumbs * * Generate Bootstrap styled breadcrumbs * @param array $args */ function breadcrumbs($args = array()) { $args = array_merge(array('echo' => TRUE, 'sep' => ' › '), $args); $output = '<li><a href="">Home</a></li>' . PHP_EOL; for ($i = 1; $i < Xysti::uri_count(); $i++) { $output .= '<li><span class="divider"> /</span><a href="' . URI::segment($i) . '">'; $output .= Xysti::page('title', $i); $output .= '</a></li>' . PHP_EOL; } $output .= '<li class="active"><span class="divider"> /</span>' . Xysti::page('title') . '</li>' . PHP_EOL; if ($args['echo']) { echo $output; } else { return $output; } }
public function limit($start = 0, $limit = 0) { if ($start === NULL) { $start = URI::segment(-1); } if (!empty($limit)) { $comma = ' , '; } else { $comma = ''; } $this->pagination['start'] = (int) $start; $this->pagination['limit'] = (int) $limit; $this->limit = ' LIMIT ' . (int) $start . (!empty($limit) ? $comma . (int) $limit . ' ' : ''); return $this; }
/** * Prepares vars for creating table head elements * * @access protected * @return void */ protected static function initialize() { // Set default sort order & so we can use it for reset() function static::$default_sort_by = static::$sort_by; static::$default_direction = static::$direction; $sort_uri = \URI::segment(static::$uri_segment); if ($sort_uri && strpos($sort_uri, static::$uri_delimiter) !== false) { $sort_uri = explode(static::$uri_delimiter, $sort_uri); static::$sort_by = $sort_uri[0]; static::$direction = $sort_uri[1]; if (static::$use_cookies === true) { $cookie_url = static::$base_url; \Cookie::set('fuel_ts_sort_by', static::$sort_by, null, $cookie_url); \Cookie::set('fuel_ts_direction', static::$direction, null, $cookie_url); } } elseif (static::$use_cookies === true) { static::$sort_by = \Cookie::get('fuel_ts_sort_by', static::$sort_by); static::$direction = \Cookie::get('fuel_ts_direction', static::$direction); } }
} } }); /* ************************************************ * Forum Filters * * * ************************************************ */ /** * | Saas forum filter to determine whether or not a user has the proper groups, * | in order to access the forum category. */ Route::filter('forum_permissions', function ($permission) { return; $category_slug = URI::segment(2); $category = \Saas\Forum\Models\Categories::by_slug($category_slug); if (empty($category)) { return Redirect::to('forum'); } try { if (Sentry::check()) { $user_id = \Saas\Forum\Models\User::ofSentry()->id; $brand_id = \Saas\Forum\Models\User::ofSentry()->active_brand(); $result = \Saas\Forum\Models\Permissions::CheckPermissions((int) $category->id, $user_id, $brand_id, $permission); if (!$result) { return Redirect::to('forum')->with('errors', "Sorry Dave, I can't do that."); } } else { $user_id = 0; $brand_id = 0;
/** * Prepares vars for creating links * * @access public * @return array The pagination variables */ protected static function initialize() { static::$total_pages = ceil(static::$total_items / static::$per_page) ?: 1; is_null(static::$current_page) and static::$current_page = (int) \URI::segment(static::$uri_segment); if (static::$current_page > static::$total_pages) { static::$current_page = static::$total_pages; } elseif (static::$current_page < 1) { static::$current_page = 1; } // The current page must be zero based so that the offset for page 1 is 0. static::$offset = (static::$current_page - 1) * static::$per_page; }
<li class="<?php echo URI::segment(2) == 'sections' ? 'active' : false; ?> "><a href="<?php echo url('admin/sections'); ?> "><i class="icon-pencil"></i> Sections</a></li> <li class="nav-header">Users & Roles</li> <li class="<?php echo URI::segment(2) == 'users' ? 'active' : false; ?> "><a href="<?php echo url('admin/users'); ?> "><i class="icon-user"></i> Users</a></li> <li class="<?php echo URI::segment(2) == 'roles' ? 'active' : false; ?> "><a href="<?php echo url('admin/roles'); ?> "><i class="icon-cog"></i> Roles</a></li> <li class="divider"></li> <li class="<?php echo URI::segment(2) == 'help' ? 'active' : false; ?> "><a href="<?php echo url('admin/help'); ?> "><i class="icon-flag"></i> Help & Support</a></li> </ul>
<a class="brand" href="<?php echo URL::to('backend/feriados'); ?> ">Backend Api: Feriados legales de Chile</a> <ul class="nav"> <li class="<?php echo URI::segment(2) == 'feriados' ? 'active' : ''; ?> "> <a href="<?php echo URL::to('backend/feriados'); ?> ">Feriados</a> </li> <li class="<?php echo URI::segment(2) == 'leyes' ? 'active' : ''; ?> "> <a href="<?php echo URL::to('backend/leyes'); ?> ">Leyes</a> </li> </ul> <ul class="nav pull-right"> <li> <a href="<?php echo URL::to('logout'); ?> ">Salir</a> </li>
<a href="/user/register">Register</a> </li> <li class="li_top_border"></li> @endif </ul> </div> </div> <div class="content-wrap"> <div> <div class="page_id"> <div class="page"> <?php $cur = URI::segment(1); $cur = htmlspecialchars($cur); ?> @if(!empty($cur)) <?php $url = explode('/', URI::current()); $str = ''; for ($i = 1; $i < count($url); $i++) { $str .= ' / ' . htmlspecialchars(ucfirst($url[$i])); } ?> <a href="/{{URI::segment(1)}}">{{ htmlspecialchars(ucfirst(URI::segment(1))) }}</a> <span style="font-size:75%">{{ htmlspecialchars($str) }}</span> @else <a href="/">Home</a> @endif
//accountingjs $assets->add('accountingjs', 'js/accounting.js'); //historyjs $assets->add('historyjs', 'js/history/native.history.js'); //and finally the admin js file $assets->add('admin', 'js/admin.js'); }); //validate_admin filter Route::filter('validate_admin', function () { //get the admin check closure that should be supplied in the config $authCheck = Config::get('administrator::administrator.auth_check'); if (!$authCheck()) { $loginUrl = URL::to(Config::get('administrator::administrator.login_path', 'user/login')); $redirectKey = Config::get('administrator::administrator.login_redirect_key', 'redirect'); $redirectUri = URL::to_route('admin_dashboard'); return Redirect::to($loginUrl)->with($redirectKey, $redirectUri); } }); //validate_model filter Route::filter('validate_model', function () { $modelName = URI::segment(2); $model = ModelHelper::getModelInstance($modelName); //if the model doesn't exist at all, redirect to 404 if (!$model) { return Response::error('404'); } //if the model does exist, check if this user has permission to access it if (!ModelHelper::checkPermission($modelName)) { Redirect::to_route('admin_dashboard'); } });