/** * @return mixed */ public function showNews() { $slug = Request::segment(2); $news_title = "Not active"; $news_text = "Either this news item is not active, or it does not exist"; $active = 1; $news_id = 0; $results = DB::table('news')->where('slug', '=', $slug)->get(); foreach ($results as $result) { $active = $result->active; if ($active > 0 || Auth::check() && Auth::user()->hasRole('news')) { if (Session::get('lang') == null || Session::get('lang') == "en") { $news_title = $result->title; $news_text = $result->news_text; $news_id = $result->id; } else { $news_title = $result->title_fr; $news_text = $result->news_text_fr; $news_id = $result->id; } $news_image = $result->image; $news_date = $result->news_date; } } return View::make('public.news')->with('news_title', $news_title)->with('news_text', $news_text)->with('page_content', $news_text)->with('active', $active)->with('news_id', $news_id)->with('news_date', $news_date)->with('news_image', $news_image)->with('menu', $this->menu)->with('page_category_id', 0)->with('page_title', $news_title); }
public function build($string) { $prefix = Request::segment(1) == 'admin' ? Request::segment(1) : null; $HTMLFormattedList = $this->formatList($string, $prefix, config('tabmenu.nowrap')); $this->countTags($HTMLFormattedList); return $HTMLFormattedList; }
public function rules() { $id = Request::segment(3); $rules = ['name' => 'required', 'email' => 'required|unique:users,email,' . $id]; if ($this->has('password')) { $rules['password'] = '******'; } return $rules; }
/** * @param $dependents * @return array * @author Bertrand Kintanar */ public function setupDataTable($dependents) { $table = []; $table['title'] = 'Assigned Dependents'; $table['permission'] = str_replace('pim', 'profile', Request::segment(1)) . '.dependents'; $table['headers'] = ['Full Name', 'Relationship', 'Birth Date']; $table['model'] = ['singular' => 'dependent', 'plural' => 'dependents', 'dashed' => 'dependents']; $table['items'] = $dependents; return $table; }
public function change_status() { $coupon_id = Request::segment(3); $status = Request::segment(4); $coupon = Coupon::find($coupon_id); $coupon['status'] = $status; $coupon->save(); Session::flash('success', 'Coupon status updated successfully'); return redirect('admin/coupon'); }
/** * @param $emergency_contacts * @return array * @author Bertrand Kintanar */ public function setupDataTable($emergency_contacts) { $table = []; $table['title'] = 'In case of Emergency'; $table['permission'] = str_replace('pim', 'profile', Request::segment(1)) . '.emergency-contacts'; $table['headers'] = ['Full Name', 'Relationship', 'Home Telephone', 'Mobile']; $table['model'] = ['singular' => 'emergency_contact', 'plural' => 'emergency_contacts', 'dashed' => 'emergency-contacts']; $table['items'] = $emergency_contacts; return $table; }
/** * Check visitor is revisit or unique new. */ public function checkVisitor() { if (isset($_COOKIE["infogue-visitor"]) && $_COOKIE["infogue-visitor"] == Request::ip()) { if (Request::segment(1) == null) { $this->hit(); } } else { $this->revisit(); } }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * * @return void */ public function boot(Router $router) { parent::boot($router); if (Request::segment(1) != 'admin' && Request::segment(1) != 'api') { $router->bind('category', function ($slug) { $repository = app(CategoryInterface::class); return $repository->bySlug($slug); }); } }
/** * @param $job_histories * @return array * @author Bertrand Kintanar */ public function setupDataTable($job_histories) { $table = []; $table['title'] = 'Job History'; $table['permission'] = str_replace('pim', 'profile', Request::segment(1)) . '.job-histories'; $table['headers'] = ['Job Title', 'Department', 'Effective Date', 'Employment Status', 'Location', 'Comments']; $table['model'] = ['singular' => 'job_history', 'plural' => 'job_histories', 'dashed' => 'job-histories']; $table['items'] = $job_histories; return $table; }
/** * Register the service provider. * * @return void */ public function register() { $app = $this->app; /* |-------------------------------------------------------------------------- | Set app locale in front office. |-------------------------------------------------------------------------- */ if (Request::segment(1) != 'admin') { $firstSegment = Request::segment(1); if (in_array($firstSegment, config('translatable.locales'))) { Config::set('app.locale', $firstSegment); } // Not very reliable, need to be refactored setlocale(LC_ALL, config('app.locale') . '_' . strtoupper(config('app.locale')) . '.utf8'); } /* |-------------------------------------------------------------------------- | Init list of modules. |-------------------------------------------------------------------------- */ Config::set('typicms.modules', []); /* |-------------------------------------------------------------------------- | TypiCMS utilities. |-------------------------------------------------------------------------- */ $this->app->singleton('typicms', function (Application $app) { return new TypiCMS(); }); /* |-------------------------------------------------------------------------- | TypiCMS upload service. |-------------------------------------------------------------------------- */ $this->app->singleton('upload.file', function (Application $app) { return new FileUpload(); }); /* |-------------------------------------------------------------------------- | Sidebar view creator. |-------------------------------------------------------------------------- */ $app->view->creator('core::admin._sidebar', 'TypiCMS\\Modules\\Core\\Composers\\SidebarViewCreator'); /* |-------------------------------------------------------------------------- | View composers. |--------------------------------------------------------------------------| */ $app->view->composers(['TypiCMS\\Modules\\Core\\Composers\\MasterViewComposer' => '*', 'TypiCMS\\Modules\\Core\\Composers\\LocaleComposer' => '*::public.*', 'TypiCMS\\Modules\\Core\\Composers\\LocalesComposer' => ['*::*._form']]); $this->registerCommands(); $this->registerModuleRoutes(); $this->registerCoreModules(); }
/** * Return the context type or match against the given type. * @return int|boolean */ public static function context($is = null) { if (is_int($is)) { return static::context() === $is; } // Determine the type of request. switch (Request::segment(1)) { case config('app.cms_uri'): return static::CXT_CMS; case "api": return static::CXT_API; default: return static::CXT_SITE; } }
public function memberDelete(Request $request) { $id = (int) Request::segment(3); $action = Request::segment(4); if (Request::isMethod('get')) { $validator = Validator::make(Input::all(), User::$memberDeleteRules); if ($validator->passes()) { if (User::deleteMember($id)) { return Redirect::to('users/members')->with('message', 'The following errors occurred')->withErrors('Delete successfully')->with('flag', 'success'); } else { return Redirect::to('users/member/' . $id . '/update')->with('message', 'The following errors occurred')->withErrors('Delete failed')->with('flag', 'danger'); } } else { return Redirect::to('users/member/' . $id . '/update')->with('message', 'The following errors occurred')->withErrors($validator)->withInput()->with('flag', 'danger'); } } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $firstSegment = Request::segment(1); $locale = config('app.locale'); if (in_array($firstSegment, config('translatable.locales'))) { $locale = $firstSegment; } // Throw a 404 if website in this language is offline if (!config('typicms.' . $locale . '.status')) { abort(404); } // Remove preview param if no admin user connected if (Input::get('preview') && !Auth::check()) { return Redirect::to(Request::path()); } return $next($request); }
/** * Register any application services. * * @return void */ public function register() { $this->app->bind('findLocale', function () { // If compatible ISO code if provided in URL if (in_array(Request::segment(1), $this->available)) { $this->setLocale(Request::segment(1)); return App::getLocale(); } // Search for compatible ISO code in HTTP header foreach ($this->getSupportedByClient() as $iso) { if (in_array($iso, $this->available)) { $this->setLocale($iso); break; } } return false; }); }
/** * Show a page * * @return mixed */ public function showPage() { $slug = Request::segment(1); $page_title = "Not active"; $page_content = "Either the page you requested is not active, or it does not exist."; $meta = ""; $meta_keywords = ""; $active = 1; $page_id = 0; $results = DB::table('pages')->where('slug', '=', $slug)->get(); foreach ($results as $result) { $active = $result->active; if ($active > 0 || Auth::check() && Auth::user()->hasRole('pages')) { $page_title_field = Localize::localize('page_title'); $page_content_field = Localize::localize('page_content'); $page_title = $result->{$page_title_field}; $page_content = $result->{$page_content_field}; $page_id = $result->id; $meta_keywords = $result->meta_tags; $meta = $result->meta; } } return View::make('public.inside')->with('page_title', $page_title)->with('page_content', $page_content)->with('meta', $meta)->with('meta_tags', $meta_keywords)->with('active', $active)->with('page_id', $page_id)->with('menu', $this->menu); }
/** * @return mixed */ public function showProvincialData() { $slug = Request::segment(1); $page_title = "Not active"; $page_content = "Either the page you requested is not active, or it does not exist."; $meta = ""; $meta_keywords = ""; $active = 1; $page_id = 0; $menu_choice = ""; if (Cache::has('page_' . $slug . '_' . App::getLocale()) && getenv('APP_DEBUG') == false) { $results = Cache::get('page_' . $slug . '_' . App::getLocale()); } else { $results = CatraPage::where('slug', '=', $slug)->get(); Cache::forever('page_' . $slug . '_' . App::getLocale(), $results); } foreach ($results as $result) { $active = $result->active; if ($active > 0 || Auth::check() && Auth::user()->hasRole('pages')) { $page_title_field = Localize::localize('page_title'); $page_content_field = Localize::localize('page_content'); $page_title = $result->{$page_title_field}; $page_content = $result->{$page_content_field}; $page_id = $result->id; $meta_keywords = $result->meta_tags; $meta = $result->meta; } } return View::make('public.provincial-data')->with('page_title', $page_title)->with('page_content', $page_content)->with('meta', $meta)->with('meta_tags', $meta_keywords)->with('active', $active)->with('page_id', $page_id)->with('menu', $this->menu)->with('menu_choice', $menu_choice)->with('page_category_id', 2); }
public function rules() { return ['name' => 'required', 'slug' => 'required|unique:roles,slug,' . Request::segment(3)]; }
public function proxyCodeDxRequest() { $user = User::getIndex(Session::get('user_uid')); // check viewer // $viewerInstance = ViewerInstance::where('proxy_url', '=', Request::segment(1))->first(); if ($viewerInstance) { // get virtual machine info // $vm_ip = $viewerInstance->vm_ip_address; $content = Request::instance()->getContent(); $tfh = tmpfile(); fwrite($tfh, $content); $uri = stream_get_meta_data($tfh)['uri']; $url = "https://{$vm_ip}" . $_SERVER['REQUEST_URI']; $req = "curl -X {$_SERVER['REQUEST_METHOD']} '{$url}' "; if (isset($_COOKIE['JSESSIONID'])) { $req .= " -H 'Cookie: JSESSIONID={$_COOKIE['JSESSIONID']}' "; } $req .= " -H 'Host: {$vm_ip}' "; foreach (getallheaders() as $key => $value) { if (strtolower($key) == 'origin') { $req .= " -H " . escapeshellarg("Origin: {$value}"); } if (strtolower($key) == 'accept-encoding') { $req .= " -H " . escapeshellarg("Accept-Encoding: {$value}"); } if (strtolower($key) == 'accept-language') { $req .= " -H " . escapeshellarg("Accept-Language: {$value}"); } if (strtolower($key) == 'content-type') { $req .= " -H " . escapeshellarg("Content-Type: {$value}"); } if (strtolower($key) == 'accept') { $req .= " -H " . escapeshellarg("Accept: {$value}"); } if (strtolower($key) == 'cache-control') { $req .= " -H " . escapeshellarg("Cache-Control: {$value}"); } if (strtolower($key) == 'x-requested-with') { $req .= " -H " . escapeshellarg("X-Requested-With: {$value}"); } if (strtolower($key) == 'connection') { $req .= " -H " . escapeshellarg("Connection: {$value}"); } if (strtolower($key) == 'referer') { $req .= " -H " . escapeshellarg("Referer: {$value}"); } } $req .= " -H 'AUTHORIZATION: SWAMP " . strtolower($user->username) . "' "; $req .= " -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36' "; $req .= " --data-binary @{$uri} "; $req .= " --compressed --insecure -i"; $response = `{$req}`; fclose($tfh); function get_headers_from_curl_response($headerContent) { $headers = array(); // split the string on every "double" new line. // foreach (explode("\r\n", $headerContent) as $i => $line) { if ($i === 0) { $headers['http_code'] = $line; } else { if (strpos($line, ': ') !== false) { list($key, $value) = explode(': ', $line); $headers[$key][] = $value; } } } return $headers; } $values = preg_split("/\\R\\R/", $response, 2); $header = isset($values[0]) ? $values[0] : ''; $body = isset($values[1]) ? $values[1] : ''; preg_match('|HTTP/\\d\\.\\d\\s+(\\d+)\\s+.*|', $header, $match); $status = $match[1]; $headers = get_headers_from_curl_response($header); $response = Response::make($body ? $body : '', $status); if (isset($headers) && array_key_exists('Content-Type', $headers)) { $response->header('Content-Type', $headers['Content-Type'][0]); } // handle 301 / 302 redirect locations // if (in_array($status, array('301', '302'))) { if (isset($headers) && array_key_exists('Location', $headers)) { $response->header('Location', $headers['Location'][0]); } } // set JSESSIONID when present // if (array_key_exists('Set-Cookie', $headers)) { foreach ($headers['Set-Cookie'] as $setcookie) { $response->header('Set-Cookie', $setcookie); } } return $response; } }
/** * @param $navigation * @param $pim * @return array * @author Bertrand Kintanar */ protected static function formatHref($navigation, $pim) { if ($pim) { $href = str_replace('profile', 'pim/employee-list/' . Request::segment(3), $navigation->href); $permission = str_replace('pim/employee-list/' . Request::segment(3), 'pim', $href); $link = str_replace('/', '.', $permission); } else { $href = $navigation->href; $link = str_replace('/', '.', $href); } return ['href' => $href, 'link' => $link]; }
public function rules() { return ['title' => 'required', 'slug' => 'required|unique:articles,slug,' . Request::segment(3), 'body' => 'required']; }
private function isOnRootOfDomain() { $firstSegment = \Illuminate\Support\Facades\Request::segment(1); return empty($firstSegment); }
public function change_related_status() { $product_id = Request::segment(3); $related = Request::segment(4); $pro = Product::find($product_id); $pro['related'] = $related; $pro->save(); Session::flash('success', 'Product updated successfully'); return redirect('admin/product-list/' . $pro['discountinue']); }
private function inAdminContext() { $adminPrefix = Config::get('asgard.core.core.admin-prefix'); $firstSegment = \Illuminate\Support\Facades\Request::segment(1); return $firstSegment === $adminPrefix; }
/** * Defines the Form Back Button destination * @return string */ protected function returnTo() { $fallback = Request::root() . "/" . Request::segment(1); if (explode("?", $this->_referer)[0] == $fallback) { return "javascript:history.go(-1)"; } else { return $fallback; } }
function setActiveSub($route1, $route2, $class = 'active') { $request_1 = \Illuminate\Support\Facades\Request::segment(2); $request_2 = \Illuminate\Support\Facades\Request::segment(3); return $request_1 == $route1 && $request_2 == $route2 ? $class : ''; }
public function rules() { $id = Request::segment(3); return ['name' => 'required|unique:projects,id,' . $id]; }
/** * Return active state from prefix * * @access protected * @return bool */ protected function getActiveStateFromPrefix() { $collection = $this->get('prefix'); if (false === is_array($collection)) { return false; } $prefix = isset($collection['0']) ? $collection['0'] : null; $index = isset($collection['1']) ? $collection['1'] : null; if (is_null($prefix) || is_null($index)) { return false; } return $prefix == Request::segment($index); }
public function rules() { $id = Request::segment(5); return ['number' => 'required|unique_with:versions,project_id,' . $id . '=id', 'startdate' => 'required|before:enddate', 'enddate' => 'required|after:startdate']; }
function active_route($route = null, $segment = 1) { if (Request::segment($segment) == $route) { return 'active'; } }
public function rules() { $id = Request::segment(3); return ['name' => 'required', 'username' => 'required|unique:users,username,' . $id, 'email' => 'required|email|unique:users,email,' . $id, 'password' => 'required|min:6|max:20']; }