Ejemplo n.º 1
0
 /**
  * Store a newly created song in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Set rules for validator
     $rules = array("artist" => "required", "title" => "required", "requester" => "required", "link" => "required|url");
     // Validate input
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         // TODO: Remember form input...
         return Redirect::to('song/create')->withErrors($validator, "song");
     }
     // Create new song
     $song = Input::all();
     // Set or unset remember cookie
     if (isset($song['remember-requester'])) {
         $cookie = Cookie::make("requester", $song['requester']);
     } else {
         $cookie = Cookie::forget("requester");
     }
     $artist = DB::getPdo()->quote($song['artist']);
     $title = DB::getPdo()->quote($song['title']);
     if (Song::whereRaw("LOWER(artist) = LOWER({$artist}) AND LOWER(title) = LOWER({$title})")->count() > 0) {
         return Redirect::to('song/create')->with('error', "HEBBEN WE AL!!!")->withCookie($cookie);
     }
     Song::create($song);
     // Set success message
     $msg = "Gefeliciteerd! Je nummer is aangevraagd :D";
     // Redirect to song index page with message and cookie
     return Redirect::to("/")->with("success", $msg)->withCookie($cookie);
 }
Ejemplo n.º 2
0
 public function dcp()
 {
     $domain = Domain::whereDomain(Request::getHttpHost())->first();
     //$domain = Domain::whereDomain(Request::server("SERVER_NAME"))->first();
     $cookie = Cookie::make('domain_hash', $domain->id);
     return Redirect::to('/')->withCookie($cookie);
 }
Ejemplo n.º 3
0
 public function login()
 {
     if (UserAuthController::isLogin()) {
         return Redirect::to('/welcome');
     }
     if (Request::isMethod('get')) {
         $user_id = Input::get('id', null);
         $user_info = tb_users::where('id', $user_id)->first();
         if (null == $user_info) {
             return View::make('login')->with('deny_info', '链接失效!')->with('deny_user_id', $user_id);
         }
         // 使用免登录金牌
         if (true !== UserAuthController::login($user_id, null)) {
             return Response::make(View::make('login'))->withCookie(Cookie::make('user_id', $user_id));
         }
         return Redirect::to('/welcome');
     }
     if (Request::isMethod('post')) {
         // 使用邀请码登录
         $token = Input::get('token');
         $user_id = Cookie::get('user_id');
         self::recordAccessLog(array('token' => $token, 'user_id' => $user_id));
         $error_info = UserAuthController::login($user_id, $token);
         if (true !== $error_info) {
             return Redirect::back()->with('error_info', $error_info)->withInput();
         }
         return Redirect::to('/welcome');
     }
     return Response::make('此页面只能用GET/POST方法访问!', 404);
 }
Ejemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('private' => 'numeric|required', 'title' => 'max:46|required', 'paste' => 'required', 'expire' => 'required|numeric', 'private' => 'required|numeric', 'tags' => 'max:6|alpha');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return View::make('paste.form')->withErrors($messages);
     }
     $new_paste = new Paste();
     $new_paste->title = Input::get('title');
     $new_paste->token = Str::random(40);
     $new_paste->delete_token = Str::random(40);
     $new_paste->paste = Input::get('paste');
     $new_paste->private = Input::get('private');
     date_default_timezone_set('UTC');
     $expire_time = date('Y-m-d H:i:s', strtotime(sprintf('now + %s minutes', Input::get('expire'))));
     $new_paste->expire = $expire_time;
     if (!$new_paste->save()) {
         Debugbar::error('Saving failed!');
     }
     // Check if tags are set
     if (Input::has('hidden-tags')) {
         $tags = explode(' ', Input::get('hidden-tags'));
         foreach ($tags as $key => $tag) {
             $tag_model = new Tag();
             $tag_model->tag = $tag;
             $tag_model->paste_id = $new_paste->id;
             $new_paste->tags()->save($tag_model);
         }
     }
     if ($new_paste->id) {
         return Redirect::route('paste.show', $new_paste->token)->withCookie(Cookie::make('edittoken', $new_paste->token, 30));
     }
     return view::make('paste.form', array('page_title' => 'Create a paste'));
 }
Ejemplo n.º 5
0
 /**
  * login from auth
  * @param $login
  * @param $email
  * @param $token
  * @return \Symfony\Component\HttpFoundation\Cookie
  */
 public static function login($login, $email, $token, $teams)
 {
     $expire = 60 * 60 * 24 * 30;
     $user = new GithubUser($login, $email, $token, $teams);
     self::sessionUser($user);
     $user->set();
     return Cookie::make(self::$cookieKey, $login, $expire / 60);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 public static function setLocale($keyValue)
 {
     if ($keyValue == '') {
         return false;
     }
     self::$config['locale'] = $keyValue;
     Cookie::make('locale', $keyValue, 1440 * 7);
 }
Ejemplo n.º 8
0
 public function addCookie($sName, $mxValue, $iTime = 0)
 {
     if ($iTime > 0) {
         $this->_aCookies[] = \Cookie::make($sName, $mxValue, $iTime);
     } else {
         $this->_aCookies[] = \Cookie::forever($sName, $mxValue);
     }
 }
Ejemplo n.º 9
0
 public function index()
 {
     $lang = Cookie::get('lang', 'ru');
     $leaders = Leadership::select("lead_fio_{$lang}", "lead_post_{$lang}", "lead_text_{$lang}", "lead_photo", "lead_email", "lead_phone")->get();
     $news = News::select('news_id', 'news_alias', "news_title_{$lang}", "updated_at")->orderBy('updated_at', 'DESC')->limit(5)->get();
     $cookie = Cookie::make('page', 'about_us', 60 * 24 * 180);
     $view = View::make('leaders')->with(array('leaders' => $leaders, 'news' => $news, 'lang' => $lang));
     return Response::make($view)->withCookie($cookie);
 }
Ejemplo n.º 10
0
 private function _setCookie()
 {
     if (Auth::user()->status == 4) {
         $cookie = Cookie::make('domain_hash', Auth::user()->domain_id);
     } else {
         $cookie = Cookie::forget('domain_hash');
     }
     return $cookie;
 }
Ejemplo n.º 11
0
 public function facebookpages()
 {
     $code = Input::get('code');
     $fb = OAuth::consumer('Facebook');
     if (!empty($code)) {
         $token = $fb->requestAccessToken($code);
         $a = $token->getAccessToken();
         $result = json_decode($fb->request('/me/accounts'), true);
         $pid = $this->savePages($result);
         return Redirect::to('/pages')->withCookie(Cookie::make('pid', $pid, 10));
     } else {
         $url = $fb->getAuthorizationUri();
         return Redirect::to((string) $url);
     }
 }
Ejemplo n.º 12
0
 public function showHome($username)
 {
     // checkmemberexist
     $memberapi = MemberAPI::getMemberByUserName($username);
     if (!$memberapi) {
         return Redirect::to('https://www.gntclub.com/');
     }
     $member = User::find($memberapi->member_id);
     $page = Page::findBySlug('home')->published()->first();
     $cookie = Cookie::make('member_id', $member->member_id, 60);
     if ($page) {
         return View::make('pages.templates.home', compact('page', 'member'))->withCookie($cookie);
     } else {
         return View::make('layouts.unpublished');
     }
 }
Ejemplo n.º 13
0
 /**
  * Will store the current query, if there is no query it will look up in cookies and redirect if found.
  *
  * @author cr@nodes.dk
  * @param array $params
  * @return bool|string
  */
 function query_restorer($params = [], $blacklist = [])
 {
     // Store and return
     if (!empty(\Request::all())) {
         \Cookie::queue(\Cookie::make(md5(\Request::url() . '?' . http_build_query($params)), \Request::all(), 5));
         return false;
     }
     // Retrieve
     $query = \Cookie::get(md5(\Request::url() . '?' . http_build_query($params)));
     foreach ($blacklist as $key) {
         unset($query[$key]);
     }
     // Redirect with queries
     if (!empty($query) && is_array($query)) {
         return \Request::url() . '?' . http_build_query($query);
     }
     return false;
 }
Ejemplo n.º 14
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = \Cookie::get('locale');
     if (array_key_exists($locale, $this->app->config->get('app.locales'))) {
         $this->app->setLocale($locale);
     } else {
         \Cookie::queue('locale', 'el', 60 * 24 * 365);
     }
     $locale = $request->segment(1);
     if (array_key_exists($locale, $this->app->config->get('app.locales'))) {
         $cookie = \Cookie::make('locale', $locale, 60 * 24 * 365);
         $this->app->setLocale($locale);
         $segments = $request->segments();
         unset($segments[0]);
         return $this->redirector->to(implode('/', $segments))->withCookie($cookie);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!($token = $this->auth->setRequest($request)->getToken())) {
         return response('Token Not Provided', 400);
     }
     $user = $this->tokenManager->getUserFromToken($token);
     if (!$user instanceof User) {
         return $user;
     }
     // Since we are using cookies, we need to check the JWT xsrfToken against the csrf stored on the user
     $key_match = $this->tokenManager->compareTokenKeys($token, $user);
     // If keys do not match, invalidate the token and remove it from the cookies
     if ($key_match == false) {
         // Invalidate the JWT and retrieve the removal cookie
         $invalidate = $this->tokenManager->removeToken($token);
         return response('Token Keys Do Not Match', 401)->withCookie($invalidate);
     }
     $cookie = \Cookie::make('jwt', $token, 120, '/', env('SESSION_DOMAIN'), false, false);
     return $next($request)->header('Authorization', 'Bearer ' . $token)->withCookie($cookie);
 }
Ejemplo n.º 16
0
 public function facebook()
 {
     $fb = OAuth::consumer('Facebook');
     $code = Input::get('code');
     if ($code) {
         $token = $fb->requestAccessToken($code);
         $user = json_decode($fb->request('/me'), true);
         $user['oauth_provider'] = 'facebook';
         $user['user_accesstoken'] = $token->getAccessToken();
         $uid = $this->_saveUser($user);
         return Redirect::to('/')->withCookie(Cookie::make('uid', $uid, 10));
     } else {
         $user = $this->_getUser();
         if ($user) {
             return Redirect::to('/');
         } else {
             $url = $fb->getAuthorizationUri();
             return Redirect::to((string) $url);
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * Processes the date of birth submitted in the age gate form
  */
 public function doAgegate()
 {
     $previousTooYoung = \Session::get('laravel-agegate.previous_too_young');
     if ($previousTooYoung) {
         return \Redirect::action('Fbf\\LaravelAgegate\\AgegateController@agegate');
     }
     // Get the date of birth that the user submitted
     $dob = null;
     if (\Input::has('dob')) {
         // field name is dob when using input type date
         $dob = \Input::get('dob');
     } elseif (\Input::has('dob_year') && \Input::has('dob_month') && \Input::has('dob_day')) {
         // field name has _year, _month and _day components if input type select
         $dob = \Input::get('dob_year') . '-' . \Input::get('dob_month') . '-' . \Input::get('dob_day');
     }
     $maxDob = Carbon::now()->subYears(\Config::get('laravel-agegate::minimum_age'))->addDay()->toDateString();
     $validator = \Validator::make(array('dob' => $dob), array('dob' => 'required|date|date_format:Y-m-d|before:' . $maxDob), \Lang::get('laravel-agegate::validation.custom'));
     if ($validator->fails()) {
         $failed = $validator->failed();
         $validExceptTooYoung = array_get($failed, 'dob.Before');
         $canTryAgain = \Config::get('laravel-agegate::can_try_again');
         if ($validExceptTooYoung && !$canTryAgain) {
             \Session::put('laravel-agegate.previous_too_young', true);
         } else {
             \Session::keep('url.intended');
         }
         return \Redirect::action('Fbf\\LaravelAgegate\\AgegateController@agegate')->withErrors($validator)->withInput();
     }
     if (\Config::get('laravel-agegate::cookie_age') == 'forever') {
         // Set a forever cookie saying the user is old enough
         $cookie = \Cookie::forever(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'));
     } elseif (is_int(\Config::get('laravel-agegate::cookie_age'))) {
         // Sets a cookie lasting X minutes saying the user is old enough
         Cookie::make(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'), \Config::get('laravel-agegate::cookie_age'));
     } else {
         // Sets a session cookie saying the user is old enough
         $cookie = \Cookie::make(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'));
     }
     return \Redirect::intended('/')->withCookie($cookie);
 }
Ejemplo n.º 18
0
// Route::get ( 'user-profile/{id}', 'UserController@showProfile' );
// Naming Controller Routes
Route::get('user-profile/{id}', ['uses' => 'UserController@showProfile', 'as' => 'user-profile-2']);
// define routes to access PhotoController
Route::resource('photo', 'PhotoController');
// Supplementing Resource Controllers
Route::get('photos/popular', 'PhotoController@popular');
// Nested Resources
Route::resource('photos.comments', 'PhotoCommentController');
// Accessing Implicit Controllers
Route::controller('users', 'UserController');
// =================================================================================================
// HTTP Requests
Route::get('requests', ['as' => 'requests', function () {
    // create cookie ==> need to research more
    Cookie::make('name', 'value', 'Anna');
    // And on the next response the cookie will be added automagically.
    return view("todc.requests");
}]);
Route::put('user8/{id}', 'UserController@update');
Route::post('user8/{id}', 'UserController@update');
Route::delete('user8/{id}', 'UserController@update');
Route::get('user8/{id}', 'UserController@update');
Route::get('user9/request-path', 'UserController@getRequestPath');
Route::resource('user10', 'UserController@getRequestMatch');
Route::resource('user11', 'UserController@getRequestMatch');
Route::get('user12/request-path', 'UserController@getRequestFullPath');
Route::resource('user13', 'UserController@checkMethod');
Route::post('user13', 'UserController@retriveInputs');
Route::get('/sample-2', ['as' => 'sample-2', 'uses' => 'UserController@parseInputs']);
// retrive cookie ==> research
Ejemplo n.º 19
0
 public function rememberFrequencyCap($fwid, $expire)
 {
     $cookieName = md5("FrequencyCap:{$fwid}");
     if (!Cookie::get($cookieName)) {
         // Log::info(Cookie::get($cookieName));
         // Log::info("Cookie:$cookieName");
         //Cookie::queue($cookieName, time(), $time);
         Cookie::make($cookieName, time(), $expire);
     }
 }
 /**
  * Attaching A New Cookie To A Response
  *
  * @param Request $request
  * @return Response
  */
 public function createCookie(Request $request)
 {
     Cookie::make('name', 'value', 'minutes');
     // And on the next response the cookie will be added automagically.
 }
 /**
  * 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'));
     }
 }
Ejemplo n.º 22
0
 function deviceInfo()
 {
     $client = Client::get_instance();
     // Referral
     $client->referrer = Useragent::referrer();
     // Heavy detections will be cached in cookie
     $cookieStore = array('device', 'browser', 'browserVersion', 'os', 'country', 'city', 'lat', 'lon', 'timezone');
     $device_info_cookie = Cookie::get('device_info');
     if ($device_info_cookie && ($device_info_cookie = json_decode($device_info_cookie))) {
         foreach ($cookieStore as $key) {
             $client->{$key} = $device_info_cookie->{$key};
         }
     } else {
         // Device and browser
         // Use Mobile_Detect for better device recognition
         $client->device = Useragent::is_mobile() ? 'phone' : 'computer';
         $client->browser = Useragent::browser();
         $client->browserVersion = Useragent::version();
         $client->os = Useragent::platform();
         // Geolocation
         // Defaults to Kyiv
         $gb = new IPGeoBase();
         $geo = $gb->getRecord($client->ip);
         $client->country = empty($geo['cc']) ? 'UA' : $geo['cc'];
         $client->city = empty($geo['city']) ? 'Киев' : $geo['city'];
         $client->lat = empty($geo['lat']) ? 50.4501 : $geo['lat'];
         $client->lon = empty($geo['lon']) ? 30.5234 : $geo['lon'];
         $client->timezone = empty($geo['timezone']) ? Config::get('application.timezone', 'Europe/Kiev') : $geo['timezone'];
         $cookieStoreData = new \stdClass();
         foreach ($cookieStore as $key) {
             $cookieStoreData->{$key} = $client->{$key};
         }
         Cookie::make('device_info', json_encode($cookieStoreData), 60 * 60 * 4);
     }
 }
Ejemplo n.º 23
0
 public function vip()
 {
     return Redirect::to('/register')->withCookie(Cookie::make('vip', true, 120));
 }
Ejemplo n.º 24
0
 /**
  * 注册信息提交
  *
  * @param [type] $[name] [description]
  * @return [type] [description]
  */
 public function postRegister()
 {
     // 获取表单提交数据
     $data = Input::all();
     if (!preg_match('/^[A-Za-z]\\w{4,20}/', Input::get('user_name'))) {
         return Redirect::back()->withInput()->with('error', Lang::get('errormessages.-10063'));
     }
     // 建立验证规则
     $rules = array('user_name' => 'unique:user,wy_user_name', 'user_phone' => 'digits:11|unique:user,wy_phone', 'user_pwd' => 'confirmed|max:16|alpha_dash', 'user_auth_code' => 'numeric', 'agree_protocol' => 'accepted');
     // 验证规则
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $userName = Input::get('user_name');
     $userPhone = Input::get('user_phone');
     $authCode = Input::get('user_auth_code');
     $userPwd = Input::get('user_pwd');
     // 验证码校验
     $registCode = RegistCode::find($userPhone);
     if (empty($registCode)) {
         $context = array("errorCode" => -10001, "userPhone" => $userPhone);
         Log::error(Lang::get('errormessages.-10001'), $context);
         return Redirect::back()->withInput()->with('error', Lang::get('errormessages.-10001'));
     } else {
         $updateTime = strtotime($registCode->update_time);
         $nowTime = strtotime(Carbon::now());
         $breakTime = ceil(($nowTime - $updateTime) / AUTHCODE_MIN);
         if ($breakTime < AUTHCODE_TIME) {
             if (0 != strcmp($authCode, $registCode->code)) {
                 $context = array("errorCode" => -10002, "authCode" => $authCode, "registCode" => $registCode->code);
                 Log::error(Lang::get('errormessages.-10002'), $context);
                 return Redirect::back()->withInput()->with('error', Lang::get('errormessages.-10002'));
             }
         } else {
             $context = array("errorCode" => -10003, "authCode" => $authCode, "registCode" => $registCode->code, "breakTime" => $breakTime);
             Log::error(Lang::get('errormessages.-10002'), $context);
             return Redirect::back()->withInput()->with('error', Lang::get('errormessages.-10003'));
         }
     }
     $user = new User();
     $user->wy_user_name = $userName;
     $user->wy_phone = $userPhone;
     $user->wy_pwd = Hash::make($userPwd);
     $user->wy_regist_time = Carbon::now();
     $user->wy_user_type = USER_TYPE_2;
     //商家
     $user->wy_state = USER_STATUS_2;
     //目前设置为已激活状态
     $user->wy_login_status = LOGIN_STATUS_0;
     //离线状态
     $result = $user->save();
     if ($result) {
         $cookie = Cookie::make('login_user', $userPhone, REGISTER_COOKIE_TIME);
         return Redirect::back()->with('success', Lang::get('messages.10016'))->withCookie($cookie);
     } else {
         $context = array("errorCode" => -15000, "user" => $user->toJson());
         Log::error(Lang::get('errormessages.-15000'), $context);
         return Redirect::back()->withInput()->with('error', Lang::get('errormessages.-15000'));
     }
 }
Ejemplo n.º 25
0
 public static function changePassword($userid, $newPassword = '')
 {
     if (!isset($newPassword[1])) {
         return false;
     }
     $thisUserid = self::getCookieUserId();
     $encryptPassword = String::encrypt($newPassword);
     self::update($userid, array('password' => $encryptPassword));
     if ($userid == $thisUserid) {
         Cookie::make('password', $encryptPassword, 1440 * 7);
     }
 }
Ejemplo n.º 26
0
 public function login()
 {
     $input = \Input::get();
     $data = Auth::loginUser($input);
     $result['userID'] = $data['_id']->{'$id'};
     $result['userName'] = $data['username'];
     $result['userEmail'] = $data['email'];
     $result['userPicture'] = $data['picture'];
     $output = \Response::json($result, 200);
     return $output->withCookie(\Cookie::make('userID', $data['_id']->{'$id'}, self::COOKIE_EXPIRE));
 }
Ejemplo n.º 27
0
 public static function checkDomain()
 {
     $theDomain = $_SERVER['HTTP_HOST'];
     if (isset($_COOKIE['changed_domain'])) {
         $oldDomain = $_COOKIE['changed_domain'];
         if ($oldDomain == $theDomain) {
             return false;
         }
     }
     $filePath = ROOT_PATH . 'application/caches/domain/' . $theDomain . '.cache';
     if (!file_exists($filePath)) {
         return false;
     }
     $loadData = unserialize(file_get_contents($filePath));
     if (is_array($loadData)) {
         if (isset($loadData['prefix'])) {
             Database::setPrefix($loadData['prefix']);
             $prefixAll = isset($loadData['prefixall']) ? $loadData['prefixall'] : 'no';
             Cookie::make('prefixall', $prefixAll, 1440 * 7);
         }
         if (isset($loadData['theme'])) {
             $theme = $loadData['theme'];
             if (!file_exists(THEMES_PATH . $theme . '/index.php')) {
                 return false;
             }
             System::setTheme($theme, 'yes');
             Cookie::make('changed_domain', $theDomain, 1440 * 7);
         }
     }
 }
Ejemplo n.º 28
0
    Route::post('admin/pages/update/{id}', 'AdminController@update_pages');
    Route::get('admin/pages/delete/{id}', 'AdminController@delete_pages');
    Route::post('admin/pages/create', 'AdminController@create_pages');
    Route::get('admin/update', 'AdminController@update');
});
Route::get('pages/{slug}', function ($slug) {
    $page = Page::where('url', '=', $slug)->first();
    $data = array('page_content' => $page, 'page' => $page, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
    return View::make('Theme::page', $data);
});
Route::get('view/list', function () {
    $cookie = Cookie::make('media_view', 'list', 30);
    return Redirect::to('/')->withCookie($cookie);
});
Route::get('view/grid_large', function () {
    $cookie = Cookie::make('media_view', 'grid_large', 30);
    return Redirect::to('/')->withCookie($cookie);
});
Route::get('view/grid', function () {
    $cookie = Cookie::make('media_view', 'grid', 30);
    return Redirect::to('/')->withCookie($cookie);
});
Route::get('sidebar/hide', function () {
    $cookie = Cookie::make('sidebar', false, 30);
    return Redirect::to('/')->withCookie($cookie);
});
Route::get('sidebar/true', function () {
    $cookie = Cookie::make('sidebar', true, 30);
    return Redirect::to('/')->withCookie($cookie);
});
Route::get('sitemap.xml', 'SitemapController@generate');
 public function login_post()
 {
     $phone = Input::get('phone');
     $password = Input::get('password');
     try {
         Sentry::authenticate(array('phone' => $phone, 'password' => $password), false);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Response::json(array('error_code' => 1, 'message' => '请输入手机号码'));
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Response::json(array('error_code' => 2, 'message' => '请输入密码'));
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Response::json(array('error_code' => 3, 'message' => '手机号或密码错误'));
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Response::json(array('error_code' => 4, 'message' => '手机号或密码错误'));
     } catch (Exception $e) {
         return Response::json(array('error_code' => -1, 'message' => 'Unknown Error'));
     }
     $user = Sentry::getUser();
     if ($user->role) {
         return Response::json(array('error_code' => 5, 'message' => '无效用户'));
     }
     Session::put('user.id', $user->id);
     $error_message = array('error_code' => 0, 'message' => '登陆成功');
     // 通过ajax请求,则返回之前的uri,前端进行跳转
     if (Request::ajax()) {
         $error_message['uri_before'] = Session::pull('uri.before_login');
         $response = Response::json($error_message);
         if (($remember = Input::get('remember')) == 'true') {
             $response->headers->setCookie(Cookie::make('remember', true, self::$remember_expire));
             $response->headers->setCookie(Cookie::make('phone', $phone, self::$remember_expire));
             $response->headers->setCookie(Cookie::make('password', $password, self::$remember_expire));
         } else {
             $response->headers->setCookie(Cookie::forget('remember'));
             $response->headers->setCookie(Cookie::forget('phone'));
             $response->headers->setCookie(Cookie::forget('password'));
         }
         return $response;
     } else {
         $error_message['user'] = $user;
     }
     return Response::json($error_message);
 }
Ejemplo n.º 30
0
<?php

// This should be run only once!!!
Route::get('installation/{lang?}', function ($lang = null) {
    if ($lang != null) {
        $setCookie = Cookie::make('lang', $lang, 15);
        return Redirect::to('/installation')->withCookie($setCookie);
    }
    App::setLocale(Cookie::get('lang', 'en'));
    $setting = App::make('setting');
    $file = app_path() . '/config/production/database.php';
    if ($setting->get('install_started') == 'true') {
        return View::make('webmanager::install');
    } else {
        Log::warning('Someone tried to access the installation dir!');
        return App::abort(404, 'Page not found');
    }
});
Route::get('installation-step-2', function () {
    return View::make('webmanager::installstep2');
});
Route::get('installation-step-3', function () {
    return View::make('webmanager::installstep3');
});
Route::post('installation-step-2', 'Raymondidema\\Webmanager\\Installation\\installController@postInstallStep2');
Route::post('installation-step-3', 'Raymondidema\\Webmanager\\Installation\\installController@postInstallStep3');
Route::post('installation', 'Raymondidema\\Webmanager\\Installation\\installController@postInstall');