public function match($store) { if ($store_id = Request::server('LAVENDER_STORE')) { return $store->find($store_id); } return false; }
protected function setupLayout() { $is_rapyd = Request::server('HTTP_HOST') == "www.rapyd.com" ? true : false; View::composer('rapyd::demo.*', function ($view) use($is_rapyd) { $view->with('is_rapyd', $is_rapyd); }); }
/** * Register the service provider. * * @return void */ public function register() { $this->app['router']->before(function ($request) { // First clear out all "old" visitors Visitor::clear(); $page = Request::path(); $ignore = Config::get('visitor-log::ignore'); if (is_array($ignore) && in_array($page, $ignore)) { //We ignore this site return; } $visitor = Visitor::getCurrent(); if (!$visitor) { //We need to add a new user $visitor = new Visitor(); $visitor->ip = Request::getClientIp(); $visitor->useragent = Request::server('HTTP_USER_AGENT'); $visitor->sid = str_random(25); } $user = null; $usermodel = strtolower(Config::get('visitor-log::usermodel')); if (($usermodel == "auth" || $usermodel == "laravel") && Auth::check()) { $user = Auth::user()->id; } if ($usermodel == "sentry" && class_exists('Cartalyst\\Sentry\\SentryServiceProvider') && Sentry::check()) { $user = Sentry::getUser()->id; } //Save/Update the rest $visitor->user = $user; $visitor->page = $page; $visitor->save(); }); }
private function getExceptionData($exception) { $data = []; $data['host'] = Request::server('HTTP_HOST'); $data['method'] = Request::method(); $data['fullUrl'] = Request::fullUrl(); if (php_sapi_name() === 'cli') { $data['host'] = parse_url(config('app.url'), PHP_URL_HOST); $data['method'] = 'CLI'; } $data['exception'] = $exception->getMessage(); $data['error'] = $exception->getTraceAsString(); $data['line'] = $exception->getLine(); $data['file'] = $exception->getFile(); $data['class'] = get_class($exception); $data['storage'] = array('SERVER' => Request::server(), 'GET' => Request::query(), 'POST' => $_POST, 'FILE' => Request::file(), 'OLD' => Request::hasSession() ? Request::old() : [], 'COOKIE' => Request::cookie(), 'SESSION' => Request::hasSession() ? Session::all() : [], 'HEADERS' => Request::header()); $data['storage'] = array_filter($data['storage']); $count = $this->config['count']; $data['exegutor'] = []; $data['file_lines'] = []; $file = new SplFileObject($data['file']); for ($i = -1 * abs($count); $i <= abs($count); $i++) { list($line, $exegutorLine) = $this->getLineInfo($file, $data['line'], $i); $data['exegutor'][] = $exegutorLine; $data['file_lines'][$data['line'] + $i] = $line; } // to make Symfony exception more readable if ($data['class'] == 'Symfony\\Component\\Debug\\Exception\\FatalErrorException') { preg_match("~^(.+)' in ~", $data['exception'], $matches); if (isset($matches[1])) { $data['exception'] = $matches[1]; } } return $data; }
/** * Get locales supported by client (from HTTP header) * @return array Supported locales */ private function getSupportedByClient() { $supportedByClient = explode(',', Request::server('HTTP_ACCEPT_LANGUAGE')); array_walk($supportedByClient, function ($val) { return substr($val, 0, 2); }); return $supportedByClient; }
/** * Register any other events for your application. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function boot(DispatcherContract $events) { parent::boot($events); $events->listen('auth.login', function ($user, $remember) { // Record user login Activity::create(['subject_type' => 'User', 'subject_id' => '', 'event' => 'Logged In', 'user_id' => $user->id, 'ip' => Request::server('REMOTE_ADDR')]); }); }
public function match($store) { return $store->whereHas('config', function ($q) { $hostname = Request::server('SERVER_NAME'); $q->where('key', '=', 'url'); $q->where('value', '=', $hostname); })->first(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->input('number') < 100) { $server = Request::server(); // return Response::json($server); } return $next($request); }
public function edit(Sample $sample) { $iSet = IndexSet::lists('name', 'id'); $iAll = IndexSet::all(); $pg = ProjectGroup::lists('name', 'id'); // Set the page where edit came from session(['edit_sample_url' => Request::server('HTTP_REFERER')]); return view('samples.edit', ['iSet' => $iSet, 'iAll' => $iAll, 'pg' => $pg, 'sample' => $sample]); }
public function GetUserIP() { if (!$this->getUrlData()) { return Response::json(array('success' => false, 'result' => $this->errmsg), 400); } else { //return a response in json return Response::json(array('success' => true, 'user_ip' => Request::server('REMOTE_ADDR')), 200); } }
public function match($store) { $hostname = Request::server('SERVER_NAME'); $host = explode('.', $hostname); if (isset($host[count($host) - 3])) { $subdomain = $host[count($host) - 3]; return $store->whereHas('config', function ($q) use($subdomain) { $q->where('key', '=', 'subdomain'); $q->where('value', '=', $subdomain); })->first(); } return false; }
/** * Bootstrap any application services. * * @return void */ public function boot() { $url = explode('.', Request::server('HTTP_HOST')); $subdomain = $url[0]; Session::put('sub', $subdomain); view()->composer(['admin.parts.header', 'admin.partials.models.add_task', 'admin.pages.my_dashboard'], function ($view) { $view->with('user', User::where('id', Auth::user()->id)->with('leads')->first())->with('task_names', TaskName::groupBy('task_name')->get()); }); view()->composer('admin.parts.user_notifications', function ($view) { $view->with('userTasks', Task::userAllNonCompletedTasks()); }); view()->composer('admin.leads.parts.reassign_lead', function ($view) { $view->with('users', User::all()); }); }
public function __construct($slug, $params) { if ($slug && $params) { $result = EmailsTemplate::where("slug", $slug)->first(); foreach ($params as $k => $el) { $search[] = "{" . $k . "}"; $replace[] = $el; } $search[] = "{domen}"; $replace[] = $_SERVER['HTTP_HOST']; if ($result->id) { $this->subject = $result->subject; $this->body = $result->body; $this->body = str_replace('/images/', 'http://' . Request::server("HTTP_HOST") . "/images/", $this->body); $this->body = str_replace($search, $replace, $this->body); $this->subject = str_replace($search, $replace, $this->subject); } } }
public function transformMessage(\CarMessage $message, $redundantly = false) { $content = []; $resp = ['message_id' => $message->id, 'chat_id' => $message->chat_id, 'timestamp' => $message->created_at, 'delivered_at' => $message->delivered_at, 'viewed_at' => $message->viewed_at]; if (!is_null($message->text)) { $content['text'] = $message->text; } if (!is_null($message->long)) { $content['geo'] = ['lat' => $message->lat, 'long' => $message->long, 'location' => $message->location]; } if (!is_null($message->image_id)) { $domain = 'http' . (Request::server('HTTPS') ? '' : 's') . '://' . Request::server('HTTP_HOST'); $content['image'] = ['id' => $message->attachmentImage->id, 'thumb' => "{$domain}/api/carchats/{$message->chat_id}/attachments/{$message->attachmentImage->id}", 'origin' => "{$domain}/api/carchats/{$message->chat_id}/attachments/{$message->attachmentImage->id}/origin", 'width' => $message->attachmentImage->width, 'height' => $message->attachmentImage->height]; } if (!is_null($message->car_id)) { $content['car'] = ['id' => $message->attachmentCar->id, 'mark' => $message->attachmentCar->mark, 'model' => $message->attachmentCar->model, 'year' => $message->attachmentCar->year, 'color' => $message->attachmentCar->color, 'vehicle_type' => $message->attachmentCar->vehicle_type, 'body_type' => $message->attachmentCar->body_type]; if (!is_null($message->car_number)) { $content['car']['number'] = $message->car_number; } } if ($redundantly) { if (!$message->via_car) { $user = User::find($message->user_id); $resp['user'] = ['id' => $user->id, 'name' => $user->name, 'img' => ['middle' => $user->img_middle]]; } else { $chat = CarChat::find($message->chat_id); $resp['car'] = ['id' => $message->user_car_id, 'number' => $chat->number]; } } else { if ($message->via_car) { $resp['car_id'] = $message->user_car_id; } else { $resp['user_id'] = $message->user_id; } } $resp['content'] = $content; if ($message->isUnread()) { $resp['unread'] = true; } // dd($resp); return $resp; }
public function onViewLoad($route) { $data = []; $routeAction = $route->getAction(); if (Auth::check()) { $request = App::make(Request::class); $this->mixPanel->identify(Auth::user()->id); $this->mixPanel->people->set(Auth::user()->id, [], $request->ip()); } if (CurrentRequest::url()) { $data['Url'] = CurrentRequest::url(); } if (is_array($routeAction) && array_key_exists('as', $routeAction)) { $data['Route'] = $routeAction['as']; } if (CurrentRequest::server('HTTP_REFERER')) { $data['Referrer'] = CurrentRequest::server('HTTP_REFERER'); } $this->mixPanel->track('Page View', $data); }
/** * Wrapper function for getting server variables. * Since Shibalike injects $_SERVER variables Laravel * doesn't pick them up. So depending on if we are * using the emulated IdP or a real one, we use the * appropriate function. */ private function getServerVariable($variableName) { if (config('shibboleth.emulate_idp') == true) { return isset($_SERVER[$variableName]) ? $_SERVER[$variableName] : null; } else { return !empty(Request::server($variableName)) ? Request::server($variableName) : Request::server('REDIRECT_' . $variableName); } }
public static function clear() { $self = strtok(Request::server('REQUEST_URI'), '?'); Session::forget('rapyd.' . $self); }
public function getIndex() { $is_rapyd = Request::server('HTTP_HOST') == "www.rapyd.com" ? true : false; return View::make('rapyd::demo.demo', compact('is_rapyd')); }
/** * Fetches the shortened IP used in hashing * * @return string The shortened IP address */ protected function fetchIp() { $ip = Request::server('REMOTE_ADDR'); return implode('.', array_slice(explode('.', $ip), 0, 4 - 1)); }
/** * Fetches the users "alt_ip" (vbulletin; see class_core.php) * * @return string IP address */ public function fetchAltIp() { $alt_ip = Request::server('REMOTE_ADDR'); if (Request::server('HTTP_CLIENT_IP') !== null) { $alt_ip = Request::server('HTTP_CLIENT_IP'); } elseif (Request::server('HTTP_X_FORWARDED_FOR') !== null and preg_match_all('#\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}#s', Request::server('HTTP_X_FORWARDED_FOR'), $matches)) { // make sure we dont pick up an internal IP defined by RFC1918 foreach ($matches[0] as $ip) { if (!preg_match("#^(10|172\\.16|192\\.168)\\.#", $ip)) { $alt_ip = $ip; break; } } } elseif (Request::server('HTTP_FROM') !== null) { $alt_ip = Request::server('HTTP_FROM'); } return $alt_ip; }
/** * Handle the avatar upload. * * @return \Illuminate\Http\JsonResponse */ public function postAvatar() { if (isset($_SERVER['HTTP_ORIGIN'])) { ImageUpload::enableCORS($_SERVER['HTTP_ORIGIN']); } if (Request::server('REQUEST_METHOD') == 'OPTIONS') { exit; } $json = ImageUpload::handle(Input::file('filedata')); if ($json !== false) { return Response::json($json, 200); } return Response::json('error', 400); }
public function return_and_addbill($order_id, $result) { $recharge_result = DB::select("select * from dql_account_recharge where trade_no = ? ", [$order_id]); if (!empty($recharge_result)) { if ($recharge_result[0]->status == 1) { return true; } else { $up_result = DB::update("update dql_account_recharge set status = 1 ,amount = money , verify_time = ? ,verify_remark = ? where trade_no = ? ", [time(), $result, $order_id]); $account_result = DB::select("select * from dql_account where user_id = ? ", [$recharge_result[0]->user_id]); if ($up_result && !empty($account_result)) { $log_add['user_id'] = $recharge_result[0]->user_id; $log_add['type'] = "recharge"; $log_add['flow'] = "in"; $log_add['total'] = $account_result[0]->total + $recharge_result[0]->money; $log_add['money'] = $recharge_result[0]->money; $log_add['use_money'] = $account_result[0]->use_money + $recharge_result[0]->money; $log_add['no_use_money'] = $account_result[0]->no_use_money; $log_add['collection'] = $account_result[0]->collection; $log_add['remark'] = "充值{$log_add['money']}元成功"; $log_add['addtime'] = time(); $log_add['addip'] = Request::server("REMOTE_ADDR"); $insert_log = DB::insert("insert into dql_account_log(user_id,type,flow,total,money,use_money,no_use_money,collection,remark,addtime,addip) values(?,?,?,?,?,?,?,?,?,?,?)", array_values($log_add)); if ($insert_log) { $up_account = DB::update("update dql_account set total = ?, use_money = ? where user_id = ? ", [$log_add['total'], $log_add['use_money'], $log_add['user_id']]); if ($up_account) { return true; } } } } } return false; }
/** * Retrieve a server variable from the request. * * @param string $key * @param mixed $default * @return string */ public function server($key = null, $default = null) { return parent::server($key, $default); }
/** * Create new visitor. * * @return self */ public static function createNewVisitor() { return static::create(['online' => time(), 'ip' => Request::server('REMOTE_ADDR'), 'hits' => 1, 'url' => URL::full(), 'path' => Request::path()]); }
/** * Controller filter to process to the authentication. * * @param mixed $route * @param Request $request * * @return void|Response */ public function processAuthentication($route, $request) { if (\App::isDownForMaintenance()) { return $this->jsonErrorResponse("We're currently down for maintenance.", 503); } $user = null; try { $credentials = array('login' => Request::server('PHP_AUTH_USER'), 'password' => Request::server('PHP_AUTH_PW')); $user = Subbly::api('subbly.user')->authenticate($credentials, false); } catch (\Exception $e) { if (in_array(get_class($e), array('Cartalyst\\Sentry\\Users\\UserNotActivatedException', 'Cartalyst\\Sentry\\Users\\UserSuspendedException', 'Cartalyst\\Sentry\\Users\\UserBannedException'))) { return $this->jsonErrorResponse($e->getMessage()); } elseif (in_array(get_class($e), array('Cartalyst\\Sentry\\Users\\LoginRequiredException', 'Cartalyst\\Sentry\\Users\\PasswordRequiredException', 'Cartalyst\\Sentry\\Users\\WrongPasswordException', 'Cartalyst\\Sentry\\Users\\UserNotFoundException'))) { // do not return basic auth if AJAX $httpHeaders = Request::ajax() ? array() : array('WWW-Authenticate' => 'Basic realm="Subbly authentication"'); return $this->jsonErrorResponse('Auth required! Something is wrong with your credentials.', 401, $httpHeaders); } return $this->jsonErrorResponse('FATAL ERROR!', 500); } if (!$user instanceof User || !$user->hasAccess('subbly.backend.auth')) { return $this->jsonErrorResponse('Access refused! You have not the premission to access this page.', 401); } }
public static function serverIp() { return Request::server('SERVER_ADDR'); }