コード例 #1
0
ファイル: HomepageController.php プロジェクト: niksrc/SF
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function saveUser(Response $response, Request $request)
 {
     $despo = new Valentine();
     $Userexists = Valentine::getExistingUser($request->input('id'));
     if (is_object($Userexists)) {
         if (!is_null($Userexists->interests)) {
             $response->setContent('/findlove');
             $response->withCookie(cookie()->forever('shy_first_college', $Userexists->college));
         } else {
             $response->setContent('/profile/complete');
         }
         $response->withCookie(cookie()->forever('shy_first_id', $Userexists->id));
         $response->withCookie(cookie()->forever('shy_first_sex', $Userexists->sex));
     } else {
         $despo->name = $request->input('name');
         $despo->age = $request->input('birthday', '');
         $despo->sex = $request->input('gender');
         $despo->userId = $request->input('id');
         $despo->tel = $request->input('name');
         $despo->social = $request->input('social');
         $despo->url = $request->input('link');
         $despo->email = $request->input('email');
         if ($despo->save()) {
             $response->setContent('/profile/complete');
             $response->withCookie(cookie()->forever('shy_first_id', $despo->id));
             $response->withCookie(cookie()->forever('shy_first_sex', $request->input('sex')));
         }
     }
     return $response;
 }
コード例 #2
0
 private function setViewWithDR($view)
 {
     $response = new Response($view->with('dr', $this->dr));
     $response->withCookie(cookie('to', $this->dr->to->format('Y-m-d'), 45000));
     $response->withCookie(cookie('fr', $this->dr->fr->format('Y-m-d'), 45000));
     $response->withCookie(cookie('date', $this->dr->date->format('Y-m-d'), 45000));
     return $response;
 }
コード例 #3
0
 public function store()
 {
     $preferences = Request::all();
     $response = new Response('OK');
     $response->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_AMOUNT, $preferences['amount'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_PERIOD, $preferences['period'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXCDB, $preferences['taxcdb'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXLCI, $preferences['taxlci'], PreferencesVO::PREFERENCES_LIFESPAN));
     return $response;
 }
コード例 #4
0
 /**
  * [nextDate description]
  * @return [type] [description]
  */
 public function setVisitor(Request $request)
 {
     // Fetch cookie
     $cvuid_val = $request->cookie('CVUID');
     // Check if cookie exists
     if (isset($cvuid_val)) {
         $u = Visitor::where('session', '=', $cvuid_val)->first();
         // Check if user is alive
         if ($u != Null && $u->count() > 0) {
             $uid = $cvuid_val;
             $u->touch();
             //touch user to keep alive
         } else {
             // Create new user cause seems dead
             $uid = uniqid('_csnvaka', true);
             $v = new Visitor();
             $v->session = $uid;
             $v->save();
         }
     } else {
         // Create new user, cause totaly new :)
         $uid = uniqid('_csnvaka', true);
         $v = new Visitor();
         $v->session = $uid;
         $v->save();
     }
     // Create response with cookie
     $response = new Response($uid);
     $response->withCookie(cookie('CVUID', $uid, 720));
     return $response;
 }
コード例 #5
0
 public function getIndex(Request $request)
 {
     $data = [];
     $userControllerObj = new UserController();
     $cookie = $userControllerObj->checkCookie($request);
     $data['categories'] = Categories::getCategories();
     if ($cookie === 0) {
         return View::make('index', $data);
     } else {
         if ($cookie === -1) {
             $response = new Response('Your cookie is invalid, We have cleared it for you, Refresh to re-login to NEUP-Channel');
             return $response->withCookie('neupchan', "", -1);
         } else {
             if ($cookie->shortCookie === NULL) {
                 $shortCookie = $cookie->short_cookie;
                 $data['firstLogin'] = true;
             } else {
                 $shortCookie = $cookie->shortCookie;
                 $data['lastLoginIP'] = $cookie->last_login_ip;
             }
         }
     }
     $data['shortCookie'] = $shortCookie;
     //return View::make('index', $data)->withCookie(cookie('neupchan', $cookie, 90 * 24 * 60));
     $response = new Response(view('index', $data));
     if (isset($data['firstLogin'])) {
         return $response->withCookie('neupchan', $cookie, 90 * 24 * 60);
     } else {
         return $response;
     }
 }
コード例 #6
0
 public function createCookie(Request $request)
 {
     // create .seeties.me token Cookie
     $token = 'JDJ5JDEwJFdDdGRLLlo4OWRCeDlMMTEyUTFtbXVPUDNBN3kxV1VNQ0NEdC9ORXp6WmtSRWkwOTd5WGwy';
     $cookie = \Cookie::make('token', $token, 60, null, env('COOKIE_DOMAIN'));
     $response = new Response('Hello world');
     return $response->withCookie($cookie);
 }
コード例 #7
0
 /**
  * 获取Cookie
  */
 public function getAddCookie()
 {
     $response = new Response();
     //第一个参数是cookie名,第二个参数是cookie值,第三个参数是有效期(分钟)
     $response->withCookie(cookie('website', 'LaravelAcademy.org', 1));
     //如果想要cookie长期有效使用如下方法
     //$response->withCookie(cookie()->forever('name', 'value'));
     return $response;
 }
コード例 #8
0
 /**
  * Responds to requests to GET /users
  */
 public function getIndex(CookieJar $cookiejar, Request $request)
 {
     //return Auth::user()->email;
     event(new DevCheckedIn(Auth::user()));
     $response = new Response(view('signup')->with(['data' => Auth::user()]));
     if (Cookie::get('success') !== false) {
         $response->withCookie(Cookie::forget('success'));
         return $response;
     }
     return $response;
     //        return view("users");
 }
コード例 #9
0
 public function add(Request $request)
 {
     $info = $request->info;
     $name = $info['name'];
     if (null !== Cookie::get($name)) {
         $existCart = json_decode(Cookie::get($name), true);
         $existCart[$name]['qty']++;
         $cartjson = json_encode($existCart);
     } else {
         $cartvalue[$name]['price'] = $info['price'];
         $cartvalue[$name]['qty'] = 1;
         $cartjson = json_encode($cartvalue);
     }
     $response = new Response(view('welcome'));
     $response->withCookie(cookie($name, $cartjson, 86400));
     return $response;
 }
 /**
  * delete the count cookie
  * @return Response object
  */
 public function destroyCookie()
 {
     $cookie = Cookie::forget('count');
     $response = new Response($cookie);
     $response->withCookie($cookie);
     return $response;
 }
コード例 #11
0
 /**
  * Attaching A New Cookie To A Response
  *
  * @param Request $request        	
  * @return Response
  */
 public function attachCookieToResponse(Response $response)
 {
     $response = new Illuminate\Http\Response('Hello World');
     $response->withCookie(cookie('name', 'value', 300));
     var_dump($response);
 }
コード例 #12
0
 /**
  * Show a single event
  * @param  [type] $slug [description]
  * @return [type]       [description]
  */
 public function show($slug)
 {
     // Grab the requestersId
     $setFriendCookie = \Input::get('suarayrequestfrom');
     // Instantiate the APIHelper
     $api = new \App\Helpers\ApiHelper();
     $id = null;
     // Check if user is logged in
     $appendAuthUserId = \Auth::check() ? 'auth_user_id=' . \Auth::user()->id . '&' : null;
     // Is this event being accessed via a private link
     $isAccessedByPrivateLink = empty($hash) ? false : true;
     // Sets private hash if available
     // Aborts if we are public and there is no hash or its empty
     // Sets events variable once validated
     $events = $this->setEvent($isAccessedByPrivateLink, $appendAuthUserId, $slug, $api);
     $eventId = isset($events['id']) ? $events['id'] : null;
     $address = urlencode($events['address1'] . ", " . $events['city'] . ", " . $events['state']);
     // Sets attendees for idividual event with count and user information
     $attendees = $this->setAttendees($appendAuthUserId, $slug, $api);
     $attendeeInfo = $attendees['attendeeInfo'];
     $attendeeList = $attendees['attendeeList'];
     $events['ticketsInventory'] = $this->unsetDisabledTickets($events);
     // QR code hash
     $hash = '$2y$10$TfnEb9qbeS4hXu.EsE.yM.nWe6uRP3XQVPXwevQeJCaDd.Pfbgt1i';
     // Sets admin check to false
     $isAdmin = false;
     $attendingStatus = [];
     $ownedEvent = [];
     // Set variables for the different privacy levels
     $shareableLink = $events['meta']['private']['shareableLink'];
     $friendsOnly = $events['meta']['private']['friendsOnly'];
     $byInvite = $events['meta']['private']['byInvite'];
     // create a privacy array
     $private = [$shareableLink, $friendsOnly, $byInvite];
     // Check if user is signed in
     if (\Auth::check()) {
         // Find if the user is attending
         $attendingStatus = $api->show('events', urlencode($slug) . '?with[]=times&auth_user_id=' . \Auth::user()->id);
         $attendingStatus = isset($attendingStatus['data']['event']['auth']['isAttending']) ? $attendingStatus['data']['event']['auth']['isAttending'] : null;
         $isAdmin = $events['userId'] == \Auth::user()->id ? true : $isAdmin;
         $friends = $this->setFriends($api);
         $api = new \App\Helpers\ApiHelper();
         // If the users ID matches the UserId of the event
         if (\Auth::user()->id == $events['userId']) {
             // Otherwise show privacy options
         } else {
             // While the one of the 3 privacy settings are true
             while (list($key, $value) = each($events['meta']['private'])) {
                 if ($value === true) {
                     $private = true;
                     // If the privacy setting is shareableLink
                     if ($private === true && $key === 'shareableLink') {
                         // Set the privacy message
                         $privateMessage = 'This event is private and only viewed with a private link';
                         // Return view
                         return \View::make('events.private')->with('privateMessage', $privateMessage);
                         // Else if the privacy setting is friends only
                     } elseif ($private === true && $key === 'friendsOnly') {
                         $friendIds = [];
                         foreach ($friends as $key => $friendId) {
                             $friendIds[] = $friendId['pivot']['friendId'];
                         }
                         // If the creater of the event are friends with the logged in user
                         if (in_array($events['userId'], $friendIds)) {
                             // Else continue on
                         } else {
                             // Set the privacy message
                             $privateMessage = 'This event is private';
                             // Return view
                             return \View::make('events.private')->with('privateMessage', $privateMessage);
                         }
                         // If the privacy setting is by invite only
                     } elseif ($private === true && $key === 'byInvite') {
                         // Set privacy message
                         $privateMessage = 'This event is private and only viewed by an invite';
                         // Return view
                         return \View::make('events.private')->with('privateMessage', $privateMessage);
                     }
                 }
             }
         }
     } else {
         // If the user is not logged in
         if (!\Auth::check() && $private === true) {
             // Return view login with the title of the event and the slug
             return \Redirect::route('login')->with('warning_message', 'In order to view ' . $events['title'] . ' you must log in')->with('previous_page', $events['slug']);
         }
         // While the one of the 3 privacy settings are true
         while (list($key, $value) = each($events['meta']['private'])) {
             if ($value === true) {
                 $private = true;
                 // If the privacy setting is shareableLink
                 if ($private === true && $key === 'shareableLink') {
                     // Set the privacy message
                     $privateMessage = 'This event is private and only viewed with a private link';
                     // Return view
                     return \View::make('events.private')->with('privateMessage', $privateMessage);
                     // Else if the privacy setting is friends only
                 } elseif ($private === true && $key === 'friendsOnly') {
                     // Set the privacy message
                     $privateMessage = 'This event is private';
                     // Return view
                     return \View::make('events.private')->with('privateMessage', $privateMessage);
                     // If the privacy setting is by invite only
                 } elseif ($private === true && $key === 'byInvite') {
                     // Set the privacy message
                     $privateMessage = 'This event is private and only viewed by an invite';
                     // Return view
                     return \View::make('events.private')->with('privateMessage', $privateMessage);
                 }
             }
         }
     }
     if (!empty($events)) {
         // Set default photo
         $defaultPhoto = null;
         // Use featured photo if available
         if (isset($events['featuredPhoto'])) {
             $defaultPhoto = $events['featuredPhoto'];
         }
         // Use first photo if available and featured photo is not available
         if ($defaultPhoto == null && isset($events['photos'][0])) {
             $defaultPhoto = $events['photos'][0];
         }
         // Sets events meta data
         $meta = $this->setMetaData($events);
         $metaTitle = $meta['metaTitle'];
         $metaDescription = $meta['metaDescription'];
         $metaKeywords = $meta['metaKeywords'];
         // Set ticket type to ticket or reservation
         $ticketType = $this->setTicketType($events);
         $tickets = $ticketType['tickets'];
         $reservations = $ticketType['reservations'];
         // Shows related events
         $relatedEvents = $this->setRelatedEvents($events, $api);
         // Set times default
         $times = [];
         // Set times Id default
         $eventTimeIdSelected = null;
         // Set times Id default
         $timesId = [];
         // Times array build and set
         foreach ($events['times'] as $key => $value) {
             // Set key if set to null
             if ($eventTimeIdSelected === null) {
                 $eventTimeIdSelected = $value['id'];
             }
             $key = $value['id'];
             $value = date('M d @ g:ia', strtotime($value['start']));
             $times[$key] = $value;
         }
         // View data
         $data = ['address' => $address, 'attendeeInfo' => $attendeeInfo, 'attendeeList' => $attendeeList, 'eventId' => $eventId, 'events' => $events, 'times' => $times, 'tickets' => $tickets, 'reservations' => $reservations, 'eventTimeIdSelected' => $eventTimeIdSelected, 'timesId' => $timesId, 'friends' => isset($friends) ? $friends : [], 'defaultPhoto' => $defaultPhoto, 'relatedEvents' => $relatedEvents, 'hash' => $hash, 'metaKeywords' => $metaKeywords, 'attendingStatus' => $attendingStatus, 'ownedEvent' => $ownedEvent, 'metaDescription' => $metaDescription, 'metaTitle' => $metaTitle, 'isAdmin' => $isAdmin, 'id' => $id, 'slug' => $slug, 'isAccessedByPrivateLink' => $isAccessedByPrivateLink];
         // Check if user is signed in
         if (\Auth::check()) {
             $user = $api->index('users/' . \Auth::user()->id . '?with[]=ticketInventories&with[]=stripeManagedAccounts&auth_user_id=' . \Auth::user()->id);
             $user = $user['data']['user'];
         }
         // The view
         $view = \View::make('events.show', $data)->with(['data' => $data, 'user' => isset($user) ? $user : null]);
         // Instanciate response
         $response = new Response($view);
         // Return response
         return $response->withCookie(\Cookie::make('suarayrequestfrom', $setFriendCookie, 43829.1))->withCookie(\Cookie::forget('purchaseCookieData'));
     }
 }
コード例 #13
0
ファイル: Theme.php プロジェクト: fajardm/theme-manager
 /**
  * Return a template with content.
  *
  * @param  integer $statusCode
  * @throws UnknownLayoutFileException
  * @return Response
  */
 public function render($statusCode = 200)
 {
     // Fire the event before render.
     $this->fire('after', $this);
     // Flush asset that need to serve.
     $this->asset->flush();
     // Layout directory.
     $layoutDir = $this->getConfig('containerDir.layout');
     $path = $this->getThemeNamespace($layoutDir . '.' . $this->layout);
     if (!$this->view->exists($path)) {
         throw new UnknownLayoutFileException("Layout [{$this->layout}] not found.");
     }
     $content = $this->view->make($path)->render();
     // Append status code to view.
     $content = new Response($content, $statusCode);
     // Having cookie set.
     if ($this->cookie) {
         $content->withCookie($this->cookie);
     }
     return $content;
 }
コード例 #14
0
ファイル: Proxy.php プロジェクト: GameWisp/api-proxy-laravel
 /**
  * @param $proxyResponse
  * @param $cookie
  * @return Response
  */
 private function setApiResponse($proxyResponse, $cookie)
 {
     $response = new Response($proxyResponse->getContent(), $proxyResponse->getStatusCode());
     if ($proxyResponse->getStatusCode() === 200) {
         if ($this->callMode === ProxyAux::MODE_LOGIN) {
             $response->setContent(json_encode($this->successAccessToken()));
         }
         if (isset($cookie)) {
             $response->withCookie($cookie);
         }
     }
     return $response;
 }
コード例 #15
0
 public function getTkIndex(Request $request)
 {
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] === '127.0.0.1') {
         $timelogs = Timelog::with('employee.branch')->orderBy('datetime', 'DESC')->take(20)->get();
     } else {
         $timelogs = Timelog::with(['employee' => function ($query) {
             $query->with(['branch' => function ($query) {
                 $query->select('code', 'descriptor', 'id');
             }, 'position' => function ($query) {
                 $query->select('code', 'descriptor', 'id');
             }])->select('code', 'lastname', 'firstname', 'branchid', 'positionid', 'id');
         }])->select('timelog.*')->join('hr.employee', function ($join) {
             $join->on('timelog.employeeid', '=', 'employee.id')->where('employee.branchid', '=', $this->_branchid);
         })->orderBy('datetime', 'DESC')->take(20)->get();
     }
     //return $timelogs;
     //if(count($timelogs) <= 0)
     //	return redirect()->route('auth.getlogin');
     $response = new Response(view('tk.index', compact('timelogs')));
     //->with('timelogs', $timelogs));
     $response->withCookie(cookie('branchid', $this->_branchid, 45000));
     $response->withCookie(cookie('code', session('user.branchcode'), 45000));
     return $response;
     //return view('tk.index', compact($timelogs));//->with('timelogs', $timelogs);
 }
コード例 #16
0
ファイル: Settings.php プロジェクト: linhntaim/katniss
 /**
  * @param \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse $response
  * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
  */
 public function storeCookie($response)
 {
     if (count($this->changingDataStore) > 0) {
         foreach ($this->changingDataStore as $key => $value) {
             $response->withCookie(cookie()->forever('settings_' . $key, $value));
         }
     }
     return $response;
 }
コード例 #17
0
ファイル: Proxy.php プロジェクト: rhalff/vdragon-api
 /**
  * @param $proxyResponse
  * @param $cookie
  * @return Response
  */
 private function setApiResponse($proxyResponse, $cookie)
 {
     $response = new Response($proxyResponse->getContent(), $proxyResponse->getStatusCode());
     if ($proxyResponse->getStatusCode() === 200 || in_array($proxyResponse->getStatusCode(), $this->allowedErrors['errorCodes'])) {
         $content = $proxyResponse->getContent();
         if (array_key_exists('error', $content) && in_array($content['error'], $this->allowedErrors['except'])) {
             return $response;
         }
         if ($this->callMode === ProxyAux::MODE_LOGIN) {
             $response->setContent(json_encode($this->successAccessToken()));
         }
         if (isset($cookie)) {
             $response->withCookie($cookie);
         }
     }
     return $response;
 }
コード例 #18
0
 public function checkbounds(Request $request)
 {
     $found = "false";
     $cities_active = User::all();
     $currLat = $request->lat;
     $currLng = $request->lng;
     if (!is_null($cities_active)) {
         foreach ($cities_active as $city) {
             $polygon = explode("~", $city->boundaries);
             $c = false;
             $i = -1;
             $j = count($polygon) - 1;
             while (($i += 1) < count($polygon)) {
                 $xi = explode(",", $polygon[$i])[0];
                 $yi = explode(",", $polygon[$i])[1];
                 $xj = explode(",", $polygon[$j])[0];
                 $yj = explode(",", $polygon[$j])[1];
                 if ($yi <= $currLng && $currLng < $yj || $yj <= $currLng && $currLng < $yi) {
                     if ($currLat < ($xj - $xi) * ($currLng - $yi) / ($yj - $yi) + $xi) {
                         $c = !$c;
                     }
                 }
                 $j = $i;
             }
             if ($c) {
                 $found = $city->id;
                 $count = $city->visits;
                 if ($count == null) {
                     $count = 1;
                 }
                 $count++;
                 $city->visits = $count;
                 $city->save();
                 $response = new Response($found);
                 $response->withCookie(cookie('city', $city->id, 99999));
                 return $response;
                 break;
             }
         }
     }
     return $found;
 }