public static function sessioninit() { // See if we have passed in a access_token and an account id. if (Input::get('access_token') && Input::get('account_id')) { $access_token = Input::get('access_token'); $account_id = Input::get('account_id'); } else { // See if we have a session. If Not do something about it. if (!Session::get('AccountId') || !Session::get('AccessToken')) { die(header('location: ' . Config::get('site.login_url'))); } $access_token = Session::get('AccessToken'); $account_id = Session::get('AccountId'); } // Is this a multi tenant setup? If so set the account. if (Config::get('cloudmanic.account')) { if (!(self::$account = \Accounts::get_by_id($account_id))) { $data = array('status' => 0, 'errors' => array()); $data['errors'][] = 'Account not found.'; return \Laravel\Response::json($data); } } // Validate the access_token if (!($user = Users::get_by_access_token($access_token))) { $data = array('status' => 0, 'errors' => array()); $data['errors'][] = 'Access token not valid.'; return \Laravel\Response::json($data); } else { self::_do_user($user); } }
/** * Generate an html link with a query string * * @param array $file * @return string */ public static function link($file = array()) { if (!is_array($file['location'])) { $querystring = array('location' => $file['location'], 'name' => $file['name'], 'translate' => \Laravel\Input::get('translate')); $text = $file['name']; } else { $querystring = array('location' => $file['location']['location'], 'name' => $file['name'], 'translate' => \Laravel\Input::get('translate')); $text = $file['location']['location'] . '/' . $file['name']; } $querystring = http_build_query($querystring); return \Laravel\HTML::link('language-builder/edit?' . $querystring, $text); }
public function get_my_quotes_load($quote_id) { // If the user clicks the link in the email then this code is used to bypass the login process $code = \Laravel\Input::get('c', null); // Does quote exist $quote = $quote = Quotation::find($quote_id); if (is_null($quote)) { return Redirect::to_action('quotations/sign_in')->with('success', 'Quote could not be found!'); } // Check if quote belongs to the logged in user // If code is present skip login user checks and authenticate with code if (is_null($code)) { $customer_id = \Laravel\Session::get('quote_account_id'); $customer = Customer::find($customer_id); if (is_null($customer) && $customer->id != $quote->id) { return Redirect::to_action('quotations/sign_in')->with('success', 'Quote could not be found!'); } } else { if ($quote->quick_access_code != $code) { return Redirect::to_action('quotations/sign_in')->with('success', 'Quote could not be found!'); } } // Load quote into session data self::loadQuote($quote); return Redirect::to_action('quotations/view', array('id' => $quote->quotation_layouts_id))->with('success', 'Successfully loaded quotation #' . $quote->id . ', please progress to view or edit your quotation.'); }
/** * Determine if the request has been forged. * * The session CSRF token will be compared to the CSRF token in the request input. * * @return bool */ public static function forged() { return Input::get(Session::csrf_token) !== Session::token(); }
public static function sort_link($url, $sort_by, $name) { return HTML::link($url . '?' . http_build_query(array_merge(Input::all(), array('sort_by' => $sort_by, 'order' => Input::get('sort_by') == $sort_by ? Input::get('order') == 'ASC' ? 'DESC' : 'ASC' : 'ASC'))), $name); }
public function post_deletestep() { $input = Input::get(); Log::write('User', 'Delete Step ID ' . Step::find($input['id'])->step . ' by ' . Auth::user()->username); Step::find($input['id'])->delete(); Step::where('parentid', '=', $input['id'])->delete(); return Menu::flowtree($input['flowid']); }
private function _validate_request($type) { // A hook before we go any further. if (method_exists($this, '_before_validation')) { $this->_before_validation(); } // Set rules. if ($type == 'create') { $rules = $this->rules_create; } else { $rules = $this->rules_update; } // If we have rules we validate. if (is_array($rules) && count($rules > 0)) { // Time to validate. $validation = Validator::make(Input::get(), $rules, $this->rules_message); if ($validation->fails()) { if (Input::get('redirect_fail')) { return Redirect::to(Input::get('redirect_fail'))->with_errors($validation)->with('data', Input::get()); } else { return $this->api_response(null, 0, $validation->errors->messages); } } } return false; }
/** * Return the request CSRF token * * It can come from the request input or the HTTP_X_CSRF_TOKEN header * * @return string */ public static function csrf_token() { return isset($_SERVER['HTTP_X_CSRF_TOKEN']) ? $_SERVER['HTTP_X_CSRF_TOKEN'] : Input::get(Session::csrf_token); }
/** * Determine if the request has been forged. * * The session CSRF token will be compared to the CSRF token in the request input. * * @return bool */ public static function forged() { return Input::get(Session::csrf_token) !== IoC::core('session')->token(); }
}); Route::get('case-studies/categories/(:any)', function ($category) { $category = Category::where('slug', '=', $category)->first(); $organisation = Organisation::find(1); $latest_posts = $organisation->posts()->order_by('created_at', 'desc')->where('visibility', '=', '1')->take(5)->get(); $categories = $organisation->categories()->where('visibility', '=', '1')->order_by('title')->get(); $posts = $category->posts()->where('visibility', '=', '1')->order_by('created_at', 'desc')->paginate(20); $galleries = $organisation->galleries()->order_by('sort_order', 'asc')->get(); return View::make('pages.blog.blog')->with('posts', $posts)->with('categories', $categories)->with('category', $category)->with('latest_posts', $latest_posts)->with('galleries', $galleries); }); Route::get('/faqs', function () { $organisation = Organisation::find(1); // Get all FAQ data $faqs = $organisation->faqs()->order_by('sort_order', 'asc')->get(); // Get search term data $search = \Laravel\Input::get('search', ''); // Load FAQ data if (!empty($search)) { $search_faqs = $organisation->faqs()->where(function ($query) use($search) { $query->where('answer', 'LIKE', '%' . $search . '%')->or_where('question', 'LIKE', '%' . $search . '%'); })->order_by('sort_order', 'asc')->get(); } return View::make('pages.faqs')->with('faqs', $faqs)->with('search', $search)->with('search_faqs', $search_faqs); }); Route::get('/galleries/(:any)', function ($gallery) { $gallery = Gallery::where('slug', '=', $gallery)->first(); $organisation = Organisation::find(1); $images = $gallery->images; $galleries = $organisation->galleries()->order_by('sort_order', 'asc')->get(); return View::make('pages.gallery')->with('images', $images)->with('gallery', $gallery)->with('galleries', $galleries); });
public static function input($name) { $tags = explode(',', Input::get($name)); $tags = array_map('trim', $tags); return Tag::prep($tags); }
/** * Saves input from the $input parameter (array) into the form model's * field_data array if the key is present in the $fields array then * serializes the field_data array to the session. * * The $fields array is a simple array. Only the fields declared in * the $field array will be stored. * * <code> * // save form input data * ExampleForm::save_input( array( 'first_name', 'last_name' ) ); * </code> * * @param array $fields * @param array $input */ public static function save_input($fields = null, $input = null) { // $fields must be an array if (!is_array($fields) && !is_null($fields)) { return false; } // by default we save all fields if (is_null($fields)) { $fields = array_keys(Input::all()); } // by default we save all input, this can be overridden by passing // a second parameter to the save_input() method if (is_null($input)) { $input = Input::all(); } // when storing input it's important to load the persistent form // data that may exist from previous requests, otherwise we will // overwrite them if (empty(static::$field_data)) { static::unserialize_from_session(); } // ideally we'll have either a value for a field or an empty value // for a field. this isn't strictly necessary and may change in the // future given an appropriately convincing argument foreach ($fields as $field_name) { if (Input::has($field_name)) { static::$field_data[$field_name] = Input::get($field_name); } else { static::$field_data[$field_name] = ''; } } // serialize the field data to session static::serialize_to_session(); }