Esempio n. 1
1
function Check_User_Cart()
{
    $Identifier = '';
    if (!Sentry::check()) {
        return false;
    } else {
        $Identifier = Sentry::user()->id;
        if (Cookie::has('Anon_Cart_Extension')) {
            $AnonIdentifier = Cookie::get('Anon_Cart_Extension');
            $dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
            if (Cache::has('user_cart.' . $Identifier)) {
                $dataUser = Cache::get('user_cart.' . $Identifier);
                if ($dataAnon != null && $dataUser != null) {
                    foreach ($dataAnon as $key => $value) {
                        if (!isset($dataUser[$key])) {
                            $dataUser[$key] = $value;
                        }
                    }
                    Cache::forever('user_cart.' . $Identifier, $dataUser);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            } else {
                if ($dataAnon != null) {
                    Cache::forever('user_cart.' . $Identifier, $dataAnon);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            }
        }
    }
}
Esempio n. 2
0
 /**
  * [showRefLink description]
  * Route::get('{link?}', ['as' => 'reflink', 'uses' => 'LinkController@showRefLink']);
  *
  * @param [text] $link [referral link]
  *
  * @return [json] [all info abou the link]
  */
 public function showRefLink($link = null)
 {
     //  // If it has a Sponsor Cookie
     if (\Cookie::has('sponsor')) {
         return Redirect::to('/');
         // Load Referral Link View
     }
     if (is_null($link)) {
         return Redirect::to('/');
         // Redirect To HomePage
     }
     try {
         // If has $Link then Look in Database if Exist
         $link = Link::findByLink($link)->load('user.profile');
         $link = $link->toArray();
         // Note Cookie Wont Be Created if Exceeded More than 4kb
         \Cookie::queue('sponsor', $link, 2628000);
         // Return Referral View with Variable Link
         return Redirect::to('/')->with('link', $link);
         // If No Record Found Throw Exception!
     } catch (ModelNotFoundException $e) {
         // Return Back to Home
         return Redirect::to('/');
         // return view('nosponsor');
     }
 }
Esempio n. 3
0
 private function load_skin()
 {
     global $globals;
     //Force h4ck3s (reloaded)
     /*
     $gf = new GroupFilter((Group::isId('h4ck3s')) ? new GFC_Id('h4ck3s') : new GFC_Name('h4ck3s'));
     $group = $gf->get(true);
     if(!S::user()->hasRights($group, new Rights('member')) && !isSmartphone()){
         S::set('skin', 'default.h4ck3s');
     }
     */
     if (!S::has('skin') || S::v('skin') == "") {
         if (Cookie::has('skin')) {
             $skin = Cookie::v('skin');
         } else {
             $skin = isSmartphone() ? $globals->smartphone_skin : $globals->skin;
         }
         S::set('skin', $skin);
     } else {
         $skin = S::v('skin');
         if (S::v('auth') >= AUTH_COOKIE && Cookie::v('skin') != $skin) {
             Cookie::set('skin', $skin, 300);
         }
     }
     return $skin;
 }
 public function inPlaceEditing($inPlaceEditing = null)
 {
     if ($inPlaceEditing !== null) {
         $this->inPlaceEditing = $inPlaceEditing;
         if ($this->useCookies) {
             \Cookie::queue($this->cookiePrefix . 'lang_inplaceedit', $this->inPlaceEditing);
         } else {
             $session = $this->app->make('session');
             if ($session->all()) {
                 // only put a value if session has already has some value set, meaning its been loaded
                 $session->put($this->cookiePrefix . 'lang_inplaceedit', $this->inPlaceEditing);
             }
         }
     }
     if ($this->inPlaceEditing === null) {
         if ($this->useCookies) {
             if (\Cookie::has($this->cookiePrefix . 'lang_inplaceedit')) {
                 $this->inPlaceEditing = \Cookie::get($this->cookiePrefix . 'lang_inplaceedit', 0);
                 $tmp = 0;
             }
         } else {
             $session = $this->app->make('session');
             $this->inPlaceEditing = $session->get($this->cookiePrefix . 'lang_inplaceedit', 0);
         }
     }
     return $this->inPlaceEditing;
 }
 /**
  * Get data from the cookied.
  *
  * @param string $index
  *
  * @return bool|array
  */
 public function getCookie($index)
 {
     if (\Cookie::has($index)) {
         return unserialize(\Cookie::get($index));
     }
     return false;
 }
Esempio n. 6
0
 public static function errors($code = 404, $title = 'Oops! You\'re lost.', $message = '')
 {
     $ajax = Request::ajax();
     if ($code == 404) {
         $title = 'Oops! You\'re lost.';
         $message = 'We can not find the page you\'re looking for.';
         if (!$ajax) {
             $message .= '<br/><a href="' . URL . '/admin">Return home </a>';
         }
     } else {
         if ($code == 403) {
             $title = 'Oops! You are not allowed to go to this page.';
             $message = 'Please check your permission.';
             if (!$ajax) {
                 $message .= '<a href="' . URL . '/admin">
                     Return home </a>';
             }
         } else {
             if (!$code || $code == 500) {
                 $code = 500;
                 if (empty($title)) {
                     $title = 'Internal Server Error';
                 }
                 if (empty($message)) {
                     $message = 'We got problems over here. Please try again later!';
                 }
             }
         }
     }
     if ($ajax) {
         return Response::json(['error' => ['title' => $title, 'message' => $message]], $code);
     }
     return View::make('admin.errors.error')->with(['title' => $title, 'code' => $code, 'message' => $message, 'admin' => Auth::admin()->get(), 'sideMenu' => Menu::getCache(['sidebar' => true]), 'currentTheme' => Cookie::has('theme') ? Cookie::get('theme') : 'default']);
 }
Esempio n. 7
0
 public function getCookie($cookie_name)
 {
     $value = "";
     if (\Cookie::has($cookie_name) && \Cookie::get($cookie_name) != null) {
         $value = \Cookie::get($cookie_name);
     }
     return $value;
 }
 public function on_start()
 {
     $this->token = Loader::helper('validation/token');
     $this->error = Loader::helper('validation/error');
     $this->set('interface', Loader::helper('concrete/ui'));
     $this->set('dashboard', Loader::helper('concrete/dashboard'));
     $hideDashboardPanel = false;
     if (\Cookie::has('panels/dashboard/closed') && intval(\Cookie::get('panels/dashboard/closed')) == 1) {
         $hideDashboardPanel = true;
     }
     $this->set('hideDashboardPanel', $hideDashboardPanel);
 }
Esempio n. 9
0
 private function getIdentifier()
 {
     $idt = '';
     if (!Sentry::check()) {
         if (!Cookie::has('Anon_Cart_Extension')) {
             Cookie::forever('Anon_Cart_Extension', get_unique_id());
         }
         $idt = Cookie::get('Anon_Cart_Extension');
     } else {
         $idt = Sentry::user()->id;
     }
     return $idt;
 }
 public function __construct()
 {
     $this->package = \Vsch\TranslationManager\ManagerServiceProvider::PACKAGE;
     $this->packagePrefix = $this->package . '::';
     $this->manager = \App::make($this->package);
     $this->connectionList = [];
     $this->connectionList[''] = 'default';
     $connections = $this->manager->config(Manager::DB_CONNECTIONS_KEY);
     if ($connections && array_key_exists(\App::environment(), $connections)) {
         foreach ($connections[\App::environment()] as $key => $value) {
             if (array_key_exists('description', $value)) {
                 $this->connectionList[$key] = $value['description'];
             } else {
                 $this->connectionList[$key] = $key;
             }
         }
     }
     $this->cookiePrefix = $this->manager->config('persistent_prefix', 'K9N6YPi9WHwKp6E3jGbx');
     $connectionName = \Cookie::has($this->cookieName(self::COOKIE_CONNECTION_NAME)) ? \Cookie::get($this->cookieName(self::COOKIE_CONNECTION_NAME)) : '';
     $this->setConnectionName($connectionName);
     $locale = \Cookie::get($this->cookieName(self::COOKIE_LANG_LOCALE), \Lang::getLocale());
     \App::setLocale($locale);
     $this->primaryLocale = \Cookie::get($this->cookieName(self::COOKIE_PRIM_LOCALE), $this->manager->config('primary_locale', 'en'));
     $this->locales = $this->loadLocales();
     $this->translatingLocale = \Cookie::get($this->cookieName(self::COOKIE_TRANS_LOCALE));
     $this->showUsageInfo = \Cookie::get($this->cookieName(self::COOKIE_SHOW_USAGE));
     $this->transFilters = \Cookie::get($this->cookieName(self::COOKIE_TRANS_FILTERS), ['filter' => 'show-all', 'regex' => '']);
     if (!$this->translatingLocale || $this->translatingLocale === $this->primaryLocale && count($this->locales) > 1) {
         $this->translatingLocale = count($this->locales) > 1 ? $this->locales[1] : $this->locales[0];
         \Cookie::queue($this->cookieName(self::COOKIE_TRANS_LOCALE), $this->translatingLocale, 60 * 24 * 365 * 1);
     }
     $this->displayLocales = \Cookie::has($this->cookieName(self::COOKIE_DISP_LOCALES)) ? \Cookie::get($this->cookieName(self::COOKIE_DISP_LOCALES)) : implode(',', array_slice($this->locales, 0, 5));
     $this->displayLocales .= implode(',', array_flatten(array_unique(explode(',', ($this->displayLocales ? ',' : '') . $this->primaryLocale . ',' . $this->translatingLocale))));
     //$this->sqltraces = [];
     //$this->logSql = 0;
     //
     //$thisController = $this;
     //\Event::listen('illuminate.query', function ($query, $bindings, $time, $name) use ($thisController)
     //{
     //    if ($thisController->logSql)
     //    {
     //        $thisController->sqltraces[] = ['query' => $query, 'bindings' => $bindings, 'time' => $time];
     //    }
     //});
 }
Esempio n. 11
0
 /** Checks the cookie and set user_id according in cookie_uid variable
  */
 private function tryCookie()
 {
     S::kill('cookie_uid');
     //Remove previously stored id
     if (!Cookie::has('uid') || !Cookie::has('hash')) {
         return self::COOKIE_INCOMPLETE;
     }
     $res = XDB::query("SELECT   uid, password\n                             FROM   account\n                            WHERE   uid = {?} AND state = 'active'", Cookie::i('uid'));
     if ($res->numRows() == 1) {
         list($uid, $password) = $res->fetchOneRow();
         if (sha1($password) == Cookie::v('hash')) {
             S::set('cookie_uid', $uid);
             return self::COOKIE_SUCCESS;
         } else {
             return self::COOKIE_WRONG_HASH;
         }
     }
     return self::COOKIE_WRONG_UID;
 }
Esempio n. 12
0
 /** Check the cookie and set the associated uid in the auth_by_cookie session variable.
  */
 private function tryCookie()
 {
     S::kill('auth_by_cookie');
     if (Cookie::v('access') == '' || !Cookie::has('uid')) {
         return self::NO_COOKIE;
     }
     $res = XDB::query('SELECT  uid, password
                          FROM  accounts
                         WHERE  uid = {?} AND state = \'active\'', Cookie::i('uid'));
     if ($res->numRows() != 0) {
         list($uid, $password) = $res->fetchOneRow();
         if (sha1($password) == Cookie::v('access')) {
             S::set('auth_by_cookie', $uid);
             return self::COOKIE_SUCCESS;
         } else {
             return self::INVALID_COOKIE;
         }
     }
     return self::INVALID_USER;
 }
 public function on_start()
 {
     $this->token = Loader::helper('validation/token');
     $this->error = Loader::helper('validation/error');
     $this->set('interface', Loader::helper('concrete/ui'));
     $this->set('dashboard', Loader::helper('concrete/dashboard'));
     $this->entityManager = \Core::make('Doctrine\\ORM\\EntityManager');
     $hideDashboardPanel = false;
     if (\Cookie::has('dashboardPanelStatus') && \Cookie::get('dashboardPanelStatus') == 'closed') {
         $hideDashboardPanel = true;
     }
     $this->set('hideDashboardPanel', $hideDashboardPanel);
     \Core::make('helper/concrete/dashboard');
     $dh = \Concrete\Core\Application\Service\DashboardMenu::getMine();
     if ($dh->contains($this->getPageObject())) {
         $this->set("_bookmarked", true);
     } else {
         $this->set('_bookmarked', false);
     }
 }
 /**
  * [showRefLink description]
  * Route::get('{link?}', ['as' => 'reflink', 'uses' => 'LinkController@showRefLink']);
  *
  * @param [text] $link [referral link]
  *
  * @return [json] [all info about the link]
  */
 public function showRefLink($link = null)
 {
     //  // If it has a Sponsor Cookie
     if (\Cookie::has('sponsor')) {
         $cookie = \Cookie::get('sponsor');
         $link = $cookie['link'];
         $link = Link::findByLink($link)->load('user.profile');
         $product = Product::find(1);
         return view('pages.referralLink')->with(compact('link', 'product'));
     }
     // Check if the Provided Link is Valid  Redirect to Home if Invalid Link!
     try {
         $link = Link::findByLink($link);
         $sp_lid = $link->id;
         // If Sponsor is Not Active LeapFrog to ActiveSponsor
         if (!$link->active) {
             $sp_lid = $link->activeSponsor($sp_lid);
         }
         // Load User Profile
         $link = Link::find($sp_lid)->load('user.profile');
         $splink = [];
         $splink['id'] = $link->id;
         $splink['user_id'] = $link->user_id;
         $splink['link'] = $link->link;
         // Load Product
         $product = Product::find(1);
         // Assign $splink to the cookie
         // Note Cookie Wont Be Created if Exceeded More than 4kb
         // Cookie set Forever / 5 Years or until Cache Clear
         // No Needed To Return With Cookie if it is Queue
         $cookie = \Cookie::queue('sponsor', $splink, 2628000);
         // Return Referral View with Variable Link
         return view('pages.referralLink')->with(compact('link', 'product'));
         // LINK PROVIDED IS INVALID REDIRECT HOME
     } catch (ModelNotFoundException $e) {
         return Redirect::to('/');
     }
 }
 public function index()
 {
     $controlName = 'admincp/controlDashboard';
     if (Cookie::has('userid')) {
         $valid = UserGroups::getPermission(Users::getCookieGroupId(), 'can_view_admincp');
         if ($valid != 'yes') {
             Alert::make('You not have permission to view this page');
         }
         $controlName = 'admincp/controlDashboard';
         $default_adminpage_method = trim(System::getSetting('default_adminpage_method', 'none'));
         if ($default_adminpage_method == 'url') {
             $default_adminpage = trim(System::getSetting('default_adminpage_url', 'admincp/'));
             if ($default_adminpage != 'admincp/' && System::getUri() == 'admincp/') {
                 $beginUri = 'admincp';
                 if ($default_adminpage[0] != '/') {
                     $beginUri .= '/';
                 }
                 System::setUri($beginUri . $default_adminpage);
             }
         }
         if ($match = Uri::match('^admincp\\/(\\w+)')) {
             $controlName = 'admincp/control' . ucfirst($match[1]);
         }
     } else {
         $controlName = 'admincp/controlLogin';
         if ($match = Uri::match('^admincp\\/forgotpass')) {
             $controlName = 'admincp/controlForgotpass';
         }
     }
     $codeHead = Plugins::load('admincp_header');
     $codeHead = is_array($codeHead) ? '' : $codeHead;
     $codeFooter = Plugins::load('admincp_footer');
     $codeFooter = is_array($codeFooter) ? '' : $codeFooter;
     // print_r($codeHead);die();
     System::defineGlobalVar('admincp_header', $codeHead);
     System::defineGlobalVar('admincp_footer', $codeFooter);
     Controller::load($controlName);
 }
Esempio n. 16
0
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
});
App::after(function ($request, $response) {
});
/*
|--------------------------------------------------------------------------
| Site Protection
|--------------------------------------------------------------------------
*/
Route::filter('siteprotection', function () {
    if (Cookie::has('siteprotection') == false) {
        return View::make('site.pages.site-login');
    }
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function () {
    if (Auth::guest()) {
Esempio n. 17
0
 public static function hasLogin()
 {
     if (!Cookie::has('username') || !Cookie::has('password') || !isset($_COOKIE['groupid'])) {
         return false;
     }
     $username = Cookie::get('username');
     $password = Cookie::get('password');
     $userid = self::getCookieUserId();
     $groupid = self::getCookieGroupId();
     $loadData = self::get(array('cache' => 'no', 'where' => "where userid='{$userid}' AND groupid='{$groupid}' AND username='******' AND password='******'"));
     if (!isset($loadData[0]['userid'])) {
         return false;
     }
     return true;
 }
Esempio n. 18
0
<?php

/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    // Detect site language from browser and cookies.
    /* @var $request \Illuminate\Http\Request */
    if (Cookie::has('lang')) {
        $lang = Cookie::get('lang');
    } else {
        $lang = $request->getLocale();
    }
    App::setLocale($lang);
    Lang::setLocale($lang);
    // Update user's session expiration time.
    if (Auth::user()) {
        /* @var $user User */
        $user = Auth::user();
        $expires = new Carbon\Carbon();
        $expires->addMinutes(5);
        $user->session_expires = $expires;
        $user->save();
    }
Esempio n. 19
0
 public function step_3()
 {
     // dd(Session::all());
     // echo '<pre>';
     // dd(var_dump(Input::all()));
     // dd(var_dump(Session::get('task')));
     // echo '</pre>';
     // Validator::extend('positive', function($attribute, $value, $parameters) {
     // 	if ($value < 0) {
     // 		return false;
     // 	} else {
     // 		return true;
     // 	}
     // },"The amount field cannot be negative");
     Validator::extend('future', function ($attribute, $value, $parameters) {
         $expiration = strtotime($value);
         $now = strtotime("now");
         if ($expiration > $now) {
             return true;
         } else {
             return false;
         }
     }, "Expiration is out of date!");
     $task = Session::get('task', array());
     if (Request::method() == "POST") {
         $taskType = Input::get('type');
         // dd(Input::all());
         if (Input::has('academy_id') && !Cookie::has('school_id_session')) {
             $academy_id = Input::get('academy_id');
             // Session::set('school_id_session', $academy_id);
             Cookie::queue('school_id_session', $academy_id, 7 * 24 * 60);
             // 7 days
             return Redirect::to('/task/create/step-3');
         }
         $userInput = ['type' => Input::get('type'), 'expiration' => Input::get('expiration'), 'category_id' => Input::get('category_id')];
         if ($taskType == 1) {
             // $userInput = [
             // 'type'       => Input::get('type'),
             // 'amount'     => Input::get('amount'),
             // 'expiration' => Input::get('expiration'),
             // 'category_id'=> Input::get('category_id')
             // ];
             $userInput['amount'] = Input::get('amount');
             // $userInput['totalAmount'] = Input::get('totalAmount');
         } else {
             if ($taskType == 2) {
                 // $userInput = [
                 // 'type'       => Input::get('type'),
                 // 'amountStart'     => Input::get('amountStart'),
                 // 'amountEnd'     => Input::get('amountEnd'),
                 // 'expiration' => Input::get('expiration'),
                 // 'category_id'=> Input::get('category_id')
                 // ];
                 $userInput['amountStart'] = Input::get('amountStart');
                 $userInput['amountEnd'] = Input::get('amountEnd');
                 if ($userInput['amountStart'] > $userInput['amountEnd']) {
                     $temp = $userInput['amountStart'];
                     $userInput['amountStart'] = $userInput['amountEnd'];
                     $userInput['amountEnd'] = $temp;
                 }
                 if ($userInput['amountStart'] == $userInput['amountEnd']) {
                     $userInput['amount'] = $userInput['amountStart'];
                     unset($task['amountStart']);
                     unset($task['amountEnd']);
                 }
             }
         }
         // Session::set('type', Input::get('type'));
     } else {
         $taskType = $task['type'];
         // echo '<pre>';
         // dd(var_dump(Session::all()));
         // echo '</pre>';
         // if (Session::get('type') == 1) {
         // 	$userInput = [
         // 		'type'       => Session::get('type'),
         // 		'amount'     => Session::get('amount'),
         // 		'expiration' => Session::get('expiration'),
         // 		'category_id'=> Session::get('category_id')
         // 	];
         // } else if (Session::get('type') == 2) {
         // 	$userInput = [
         // 		'type'       => Session::get('type'),
         // 		'amountStart'     => Session::get('amountStart'),
         // 		'amountEnd'     => Session::get('amountEnd'),
         // 		'expiration' => Session::get('expiration'),
         // 		'category_id'=> Session::get('category_id')
         // 	];
         // }
         $userInput = ['type' => $task['type'], 'expiration' => $task['expiration'], 'category_id' => $task['category_id']];
         if ($taskType == 1 || !isset($task['amountStart'])) {
             $userInput['amount'] = $task['amount'];
         } elseif ($taskType == 2 && isset($task['amountStart'])) {
             $userInput['amountStart'] = $task['amountStart'];
             $userInput['amountEnd'] = $task['amountEnd'];
         }
     }
     // if (Input::get('type') == 1 || Session::get('type') == 1) {
     // 	$userInput = [
     // 		'type'       => Input::get('type'),
     // 		'amount'     => Input::get('amount'),
     // 		'expiration' => Input::get('expiration'),
     // 		'category_id'=> Input::get('category_id')
     // 	];
     // } else if (Input::get('type') == 2 || Session::get('type') == 2) {
     // 	$userInput = [
     // 		'type'       => Input::get('type'),
     // 		'amountStart'     => Input::get('amountStart'),
     // 		'amountEnd'     => Input::get('amountEnd'),
     // 		'expiration' => Input::get('expiration'),
     // 		'category_id'=> Input::get('category_id')
     // 	];
     // }
     // if (Request::method() == "POST") {
     // 	Session::set('type', Input::get('type'));
     // }
     // if (Input::get('type') == 1 || Session::get('type') == 1) {
     // 	$rules = [
     // 		'type'       => 'required',
     // 		'amount'     => 'required|numeric|between:0.1,5000',
     // 		'expiration' => 'required|date|future',
     // 		'category_id'=> 'required'
     // 	];
     // } else  if (Input::get('type') == 2 || Session::get('type') == 2) {
     // 	$rules = [
     // 		'type'       => 'required',
     // 		'amountStart'     => 'required|numeric|between:0.1,5000',
     // 		'amountEnd'     => 'required|numeric|between:0.1,5000',
     // 		'expiration' => 'required|date|future',
     // 		'category_id'=> 'required'
     // 	];
     // }
     // $taskType = Input::get('type');
     if ($taskType == 1) {
         $rules = ['type' => 'required', 'amount' => 'required|numeric|between:0.1,5000', 'expiration' => 'required|date|future', 'category_id' => 'required'];
     } else {
         if ($taskType == 2) {
             $rules = ['type' => 'required', 'amountStart' => 'numeric|between:0.1,5000', 'amountEnd' => 'numeric|between:0.1,5000', 'expiration' => 'required|date|future', 'category_id' => 'required'];
         }
     }
     // $rules = [
     // 	'type'       => 'required',
     // 	'amount'     => 'required|numeric|between:0.1,5000',
     // 	'expiration' => 'required|date|future',
     // 	'category_id'=> 'required'
     // ];
     $task = Session::get('task');
     // dd('dd');
     if (isset($userInput) && isset($rules)) {
         $validator = Validator::make($userInput, $rules);
         // dd($userInput);
         // dd($validator->passes());
         if ($validator->passes()) {
             // Session::set('type'      , $userInput['type']);
             $task['type'] = $userInput['type'];
             if ($task['type'] == 1 || !isset($userInput['amountStart'])) {
                 // Session::set('amount'    , $userInput['amount']);
                 $task['amount'] = $userInput['amount'];
                 // $task['totalAmount'] = $userInput['amount'] * (1 + 0.04);
                 $task['totalAmount'] = Util::getTotalFee($userInput['amount']);
             } else {
                 if ($task['type'] == 2) {
                     // Session::set('amountStart'    , $userInput['amountStart']);
                     // Session::set('amountEnd'    , $userInput['amountEnd']);
                     $task['amountStart'] = $userInput['amountStart'];
                     $task['amountEnd'] = $userInput['amountEnd'];
                     if ($userInput['amountStart'] == $userInput['amountEnd']) {
                         $task['amount'] = $userInput['amountStart'];
                         unset($task['amountStart']);
                         unset($task['amountEnd']);
                     }
                 }
             }
             // Session::set('expiration', $userInput['expiration']);
             // Session::set('category_id', $userInput['category_id']);
             $task['expiration'] = $userInput['expiration'];
             $task['category_id'] = $userInput['category_id'];
             $task['trade_no'] = date('ymdHis') . '0' . $task['type'] . rand(1000, 9999);
             // 0 stands for task
             Session::set('task', $task);
             // echo '<pre>';
             // dd(var_dump(Session::get('task')));
             // echo '</pre>';
             return View::make('task.publish.step_3')->with('task', $task);
         } else {
             // return Redirect::back()->withErrors($validator);
             return Redirect::to('/task/create/step-2')->withErrors($validator);
         }
     } else {
         return Redirect::to('/task/create/step-2');
     }
 }
Esempio n. 20
0
 function val($key, $default = null)
 {
     return Cookie::has($key) ? $_COOKIE[$key] : $default;
 }
Esempio n. 21
0
 public function changeTheme()
 {
     if (!Request::ajax()) {
         return App::abort(404);
     }
     $arrReturn = ['status' => 'error'];
     if (Input::has('type') && Input::has('value')) {
         $arrThemes = ['default', 'darkblue', 'blue', 'light', 'light2'];
         $type = Input::get('type');
         $value = Input::get('value');
         $theme = Cookie::has('theme') ? (array) Cookie::get('theme') : [];
         if ($type == 'color') {
             if (!in_array($value, ['default', 'darkblue', 'blue', 'light', 'light2'])) {
                 $arrReturn = ['status' => 'error', 'message' => 'Please choose a valid theme color.'];
             } else {
                 $arrReturn = ['status' => 'ok'];
             }
         } else {
             if ($type == 'style') {
                 $arrReturn = ['status' => 'ok'];
                 if (!in_array($value, ['square', 'rounded'])) {
                     $arrReturn = ['status' => 'error', 'message' => 'Please choose a valid theme style.'];
                 } else {
                     $arrReturn = ['status' => 'ok'];
                     if ($value == 'rounded') {
                         $value = 'components-rounded';
                     } else {
                         $value = 'components';
                     }
                 }
             } else {
                 if ($type == 'sidebar' || $type == 'footer') {
                     if (!in_array($value, ['default', 'fixed'])) {
                         $arrReturn = ['status' => 'error', 'message' => 'Please choose a valid theme style.'];
                     } else {
                         $arrReturn = ['status' => 'ok'];
                     }
                 } else {
                     $arrReturn = ['status' => 'error', 'message' => 'This theme option is not existed!'];
                 }
             }
         }
         if ($arrReturn['status'] == 'ok') {
             $theme = array_merge($theme, [$type => $value]);
             Cookie::queue('theme', $theme, 43200);
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
Esempio n. 22
0
<?php

Route::filter('patrickrose.sharedauth', function () {
    if (Cookie::has('patrickrosesharedhost')) {
        if (Cookie::get('patrickrosesharedhost') != Config::get('laravel-sharedhost::password')) {
            die(var_dump(Config::get('app.key')));
            Cookie::forget('patrickrosesharedhost');
            return Redirect::route('patrickrose.sharedhost.login');
        }
    } else {
        return Redirect::route('patrickrose.sharedhost.login');
    }
});
Esempio n. 23
0
 public static function getDomainFromCookie()
 {
     if (Cookie::has('domain')) {
         return Cookie::s('domain', '');
     }
     if (Cookie::has('uid')) {
         $uid = Cookie::i('uid');
         $res = XDB::query("SELECT  f.domain\n                                 FROM  formations AS f\n                            LEFT JOIN  studies AS s ON (s.formation_id = f.formation_id)\n                                WHERE  s.uid = {?}\n                             ORDER BY  s.promo ASC\n                                LIMIT  1", $uid);
         if ($res->numRows()) {
             return $res->fetchOneCell();
         }
     }
     return "";
 }
Esempio n. 24
0
 * Markdown Function...
 */
function markdown($value)
{
    return with(new dflydev\markdown\MarkdownExtraParser())->transformMarkdown($value);
}
/**
 * Let query string by used to force version...
 */
if (isset($_GET['v'])) {
    Cookie::queue('docs_versions', $_GET['v']);
}
/**
 * Set Docs Cookie If Not Set...
 */
if (!Cookie::has('docs_version')) {
    Cookie::queue('docs_versions', '4.2');
}
/**
 * Define Current Docs Version Constant
 */
if (!defined('DOCS_VERSION')) {
    $version = Cookie::get('docs_version', '4.2');
    if (Input::query('version') and in_array(Input::query('version'), array('4.0', '4.1', '4.2', 'master'))) {
        $version = Input::query('version');
    }
    define('DOCS_VERSION', $version);
}
/**
 * Catch A 404 On Docs...
 */
 private function initialize()
 {
     $connectionName = \Cookie::has($this->cookieName(self::COOKIE_CONNECTION_NAME)) ? \Cookie::get($this->cookieName(self::COOKIE_CONNECTION_NAME)) : '';
     $this->setConnectionName($connectionName);
     $locale = \Cookie::get($this->cookieName(self::COOKIE_LANG_LOCALE), \Lang::getLocale());
     \App::setLocale($locale);
     $this->primaryLocale = \Cookie::get($this->cookieName(self::COOKIE_PRIM_LOCALE), $this->manager->config('primary_locale', 'en'));
     $this->locales = $this->loadLocales();
     $locales = $this->locales;
     if (!\Gate::allows(Manager::ABILITY_ADMIN_TRANSLATIONS) && $this->manager->areUserLocalesEnabled()) {
         // see what locales are available for this user
         $userId = \Auth::id();
         if ($userId !== null) {
             $userLocale = new UserLocales();
             $userLocale->setConnection($connectionName);
             $userLocales = $userLocale->query()->where('user_id', $userId)->first();
             if ($userLocales && trim($userLocales->locales)) {
                 $locales = explode(',', $userLocales->locales);
             }
         }
     }
     $packedLocales = implode(',', array_intersect($this->locales, $locales));
     $this->userLocales = $packedLocales ? ',' . $packedLocales . ',' : '';
     $this->translatingLocale = \Cookie::get($this->cookieName(self::COOKIE_TRANS_LOCALE));
     $this->showUsageInfo = \Cookie::get($this->cookieName(self::COOKIE_SHOW_USAGE));
     $this->transFilters = \Cookie::get($this->cookieName(self::COOKIE_TRANS_FILTERS), ['filter' => 'show-all', 'regex' => '']);
     if (!$this->translatingLocale || $this->translatingLocale === $this->primaryLocale && count($this->locales) > 1) {
         $this->translatingLocale = count($this->locales) > 1 ? $this->locales[1] : $this->locales[0];
         \Cookie::queue($this->cookieName(self::COOKIE_TRANS_LOCALE), $this->translatingLocale, 60 * 24 * 365 * 1);
     }
     $this->displayLocales = \Cookie::has($this->cookieName(self::COOKIE_DISP_LOCALES)) ? \Cookie::get($this->cookieName(self::COOKIE_DISP_LOCALES)) : implode(',', array_slice($this->locales, 0, 5));
     $this->displayLocales .= implode(',', array_flatten(array_unique(explode(',', ($this->displayLocales ? ',' : '') . $this->primaryLocale . ',' . $this->translatingLocale))));
     //$this->sqltraces = [];
     //$this->logSql = 0;
     //
     //$thisController = $this;
     //\Event::listen('illuminate.query', function ($query, $bindings, $time, $name) use ($thisController)
     //{
     //    if ($thisController->logSql)
     //    {
     //        $thisController->sqltraces[] = ['query' => $query, 'bindings' => $bindings, 'time' => $time];
     //    }
     //});
 }
Esempio n. 26
0
 public function logout()
 {
     // Set cookie expiry time to the past, thus removing them
     Flyspray::setcookie('flyspray_userid', '', time() - 60);
     Flyspray::setcookie('flyspray_passhash', '', time() - 60);
     Flyspray::setcookie('flyspray_project', '', time() - 60);
     if (Cookie::has(session_name())) {
         Flyspray::setcookie(session_name(), '', time() - 60);
     }
     // Unset all of the session variables.
     $_SESSION = array();
     session_destroy();
     return !$this->isAnon();
 }
        $progress = Progress::find($progress_id);
        if ($progress) {
            $progress->delete();
        }
    }
    $cookie = Cookie::forget('quiz_progress');
    return Redirect::to('/')->withCookie($cookie);
});
Route::get('cookies', function () {
    return View::make('legal.cookies');
});
Route::get('privacy', function () {
    return View::make('legal.privacy');
});
Route::get('continue', array('before' => 'reload', function () {
    if (!Cookie::has('quiz_progress')) {
        return Redirect::to('/');
    }
    $questions = Config::get('questions');
    $progress_id = Cookie::get('quiz_progress');
    $progress = Progress::find($progress_id);
    if (!$progress) {
        return Redirect::to('/');
    }
    $saved_progress = json_decode($progress->progress, true);
    $new_questions = array_merge_recursive($questions, $saved_progress);
    reset($new_questions);
    //add to session
    Session::put('questions', $new_questions);
    Session::put('source', json_decode($progress->source, true));
    foreach ($new_questions as $section => $pages) {
Esempio n. 28
0
<?php

/*
    This script is the AJAX callback that deletes a user's saved search
*/
define('IN_FS', true);
require_once '../../header.php';
$baseurl = dirname(dirname($baseurl)) . '/';
if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) {
    $user = new User(Cookie::val('flyspray_userid'));
    $user->check_account_ok();
    $db->Query('DELETE FROM {searches} WHERE id = ? AND user_id = ?', array(Get::num('id'), $user->id));
}
Esempio n. 29
0
 /**
  * Check if the User has not set a new filter, or if his Cookies are empty.
  * Update/Create a new Cookie and then redirect if needed (in a bool return).
  *
  * @param $filters
  * @return void
  */
 private function checkFilters($filters)
 {
     foreach ($filters as $filter => $values) {
         /**
          * We check the filters in the Cookies.
          */
         if (!\Cookie::has($filter)) {
             \Cookie::queue(\Cookie::forever($filter, $values[0]));
             // The default value is the first one.
         }
     }
 }