Exemple #1
0
 /**
  * Creates the view object for the HTML client.
  *
  * @param \Aimeos\MW\Config\Iface $config Configuration object
  * @param array $templatePaths List of base path names with relative template paths as key/value pairs
  * @param string|null $locale Code of the current language or null for no translation
  * @return \Aimeos\MW\View\Iface View object
  */
 public function create(\Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null)
 {
     $params = $fixed = array();
     if ($locale !== null) {
         $params = Route::current()->parameters() + Input::all();
         $fixed = $this->getFixedParams();
         $i18n = app('\\Aimeos\\Shop\\Base\\I18n')->get(array($locale));
         $translation = $i18n[$locale];
     } else {
         $translation = new \Aimeos\MW\Translation\None('en');
     }
     $view = new \Aimeos\MW\View\Standard($templatePaths);
     $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
     $view->addHelper('translate', $helper);
     $helper = new \Aimeos\MW\View\Helper\Url\Laravel5($view, app('url'), $fixed);
     $view->addHelper('url', $helper);
     $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
     $view->addHelper('param', $helper);
     $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
     $view->addHelper('config', $helper);
     $sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
     $sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
     $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
     $view->addHelper('number', $helper);
     $helper = new \Aimeos\MW\View\Helper\Request\Laravel5($view, Request::instance());
     $view->addHelper('request', $helper);
     $helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', csrf_token());
     $view->addHelper('csrf', $helper);
     return $view;
 }
 public function postRegister()
 {
     $request = Request::instance();
     $request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8', '127.0.0.1'));
     if ($request->has("email")) {
         $requestData = $request->all();
         $rules = array("email" => "required|max:255|email");
         $validator = Validator::make($requestData, $rules);
         if ($validator->fails()) {
             return redirect("/")->withErrors(array("Dit is geen correct e-mail adres."));
         } else {
             $email = $request->input("email");
             $verificationCode = md5(uniqid(rand(), true));
             DB::table("contestants")->insert(array("email" => $email, "verification_code" => $verificationCode, "verification_received" => false, "ip_address" => $request->getClientIp()));
             $url = URL::action("HomeController@handleVerification", array("verify" => $verificationCode, "email" => $email));
             $emailData = array("url" => $url);
             Mail::send("email.email", $emailData, function ($message) use($email) {
                 $message->from("*****@*****.**", "Laravel Contest");
                 $message->subject("Deelname wedstrijd!");
                 $message->to($email);
             });
             $data = array("email" => $email);
             return view("register.success", $data);
         }
         //Captcha
     }
     return redirect()->action("HomeController@getRegister");
 }
Exemple #3
0
 public function __construct(VisitInterface $visitRepo, VisitMetaInterface $visitMetaRepo)
 {
     $this->visitRepo = $visitRepo;
     $this->visitMetaRepo = $visitMetaRepo;
     $this->request = Request::instance();
     $this->config = Config::get('simplytics');
 }
 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin()
 {
     if (Auth::attempt(Binput::only(['email', 'password']))) {
         return Redirect::intended('dashboard');
     }
     Throttle::hit(Request::instance(), 10, 10);
     return Redirect::back()->withInput(Binput::except('password'))->with('error', 'Invalid email or password');
 }
 public function testBeforeReturnsTrueIfTheyCanManagePages()
 {
     Auth::shouldReceive('check')->once()->with('managePages', Request::instance())->andReturn(true);
     Auth::shouldReceive('check')->once()->with('managePages', Request::instance())->andReturn(false);
     $policy = new PagePolicy();
     $this->assertTrue($policy->before(new Person(), ''));
     $this->assertNull($policy->before(new Person(), ''));
 }
 /**
  * Get all components.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getComponents()
 {
     if (app(Guard::class)->check()) {
         $components = Component::whereRaw('1 = 1');
     } else {
         $components = Component::enabled();
     }
     return $this->paginator($components->paginate(Binput::get('per_page', 20)), Request::instance());
 }
 /**
  * Get all groups.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getGroups()
 {
     $groups = ComponentGroup::query();
     $groups->search(Binput::except(['sort', 'order', 'per_page']));
     if ($sortBy = Binput::get('sort')) {
         $direction = Binput::has('order') && Binput::get('order') == 'desc';
         $groups->sort($sortBy, $direction);
     }
     $groups = $groups->paginate(Binput::get('per_page', 20));
     return $this->paginator($groups, Request::instance());
 }
Exemple #8
0
 /**
  * Get all incidents.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getIncidents()
 {
     $incidentVisibility = app(Guard::class)->check() ? 0 : 1;
     $incidents = Incident::where('visible', '>=', $incidentVisibility);
     $incidents->search(Binput::except(['sort', 'order', 'per_page']));
     if ($sortBy = Binput::get('sort')) {
         $direction = Binput::has('order') && Binput::get('order') == 'desc';
         $incidents->sort($sortBy, $direction);
     }
     $incidents = $incidents->paginate(Binput::get('per_page', 20));
     return $this->paginator($incidents, Request::instance());
 }
 /**
  * Get all components.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getComponents()
 {
     if (app(Guard::class)->check()) {
         $components = Component::whereRaw('1 = 1');
     } else {
         $components = Component::enabled();
     }
     $components->search(Binput::except(['sort', 'order', 'per_page']));
     if ($sortBy = Binput::get('sort')) {
         $direction = Binput::has('order') && Binput::get('order') == 'desc';
         $components->sort($sortBy, $direction);
     }
     $components = $components->paginate(Binput::get('per_page', 20));
     return $this->paginator($components, Request::instance());
 }
Exemple #10
0
 public static function items()
 {
     $items = Config::get('boomcms.menu');
     foreach ($items as $key => $item) {
         if (isset($item['role']) && !Auth::check($item['role'], Request::instance())) {
             unset($items[$key]);
             continue;
         }
         $items[$key]['title'] = isset($item['title']) ? $item['title'] : Lang::get('boomcms::menu.' . $key);
     }
     usort($items, function ($a, $b) {
         if ($a['title'] === $b['title']) {
             return 0;
         }
         return $a['title'] < $b['title'] ? -1 : 1;
     });
     return $items;
 }
Exemple #11
0
 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin()
 {
     $loginData = Binput::only(['email', 'password']);
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // Do we have Two Factor Auth enabled?
         if (Auth::user()->hasTwoFactor) {
             // Temporarily store the user.
             Session::put('2fa_id', Auth::user()->id);
             return Redirect::route('two-factor');
         }
         // We probably want to add support for "Remember me" here.
         Auth::attempt(Binput::only(['email', 'password']));
         return Redirect::intended('dashboard');
     }
     Throttle::hit(Request::instance(), 10, 10);
     return Redirect::back()->withInput(Binput::except('password'))->with('error', trans('forms.login.invalid'));
 }
 public function verificaEmail(Request $request)
 {
     // Recebe o parametro email
     $request = Request::instance();
     $inputRequest = json_decode($request->getContent(), true);
     $email = $inputRequest['value'];
     $user = User::where('email', $email)->first();
     if ($user === null) {
         return response()->json(['isValid' => true, 'email' => $email]);
     } else {
         return response()->json(['isValid' => false, 'email' => $email]);
     }
 }
 public function before(Person $person, $ability)
 {
     if ($person->isSuperuser() || Auth::check('managePages', Request::instance())) {
         return true;
     }
 }
Exemple #14
0
 /**
  * Get all metric points.
  *
  * @param \CachetHQ\Cachet\Models\Metric $metric
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function getMetricPoints(Metric $metric)
 {
     $points = $metric->points()->paginate(Binput::get('per_page', 20));
     return $this->paginator($points, Request::instance());
 }
 /**
  * Get all groups.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getGroups()
 {
     $groups = ComponentGroup::paginate(Binput::get('per_page', 20));
     return $this->paginator($groups, Request::instance());
 }
 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;
     }
 }
Exemple #17
0
 /**
  * Adds the "request" helper to the view object
  *
  * @param \Aimeos\MW\View\Iface $view View object
  * @return \Aimeos\MW\View\Iface Modified view object
  */
 protected function addRequest(\Aimeos\MW\View\Iface $view)
 {
     $helper = new \Aimeos\MW\View\Helper\Request\Laravel5($view, Request::instance());
     $view->addHelper('request', $helper);
     return $view;
 }
 /**
  * Get all subscribers.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getSubscribers()
 {
     $subscribers = Subscriber::paginate(Binput::get('per_page', 20));
     return $this->paginator($subscribers, Request::instance());
 }
 public function __construct()
 {
     $this->model = $this->getRelatedModel();
     $this->ctx = new Context(RequestFacade::instance());
     $this->response = ResponseBuilderFactory::forRequest(RequestFacade::instance(), $this);
 }
 /**
  * Get all incidents.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getIncidents()
 {
     $incidentVisibility = app(Guard::class)->check() ? 0 : 1;
     $incidents = Incident::where('visible', '>=', $incidentVisibility)->paginate(Binput::get('per_page', 20));
     return $this->paginator($incidents, Request::instance());
 }
 /**
  * Get all metrics.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function getMetrics()
 {
     $metrics = Metric::paginate(Binput::get('per_page', 20));
     return $this->paginator($metrics, Request::instance());
 }
Exemple #22
0
 /**
  * Apply any available transformations to the given model and return the result.
  *
  * @param Model   $model
  * @param Request $request
  * 
  * @return mixed
  */
 public static function transform($object, $request = null)
 {
     return Transformations::transform($object, $request ?: Request::instance());
 }
 public function cekToken()
 {
     // Template for getting $data from middleware ApiAccess
     $data = Request::instance()->query('data');
     return Response::json(['status' => 200, 'message' => http_codes(200), 'data' => $data], 200);
 }