本文整理汇总了PHP中Input::referrer方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::referrer方法的具体用法?PHP Input::referrer怎么用?PHP Input::referrer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::referrer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
// log out.
\Model_Accounts::logout();
// go back
if (\Input::referrer() != null && \Input::referrer() != \Uri::main()) {
\Response::redirect(\Input::referrer());
} else {
\Response::redirect(\Uri::base());
}
}
示例2: redirect_back
/**
* Redirects back to the previous page, if that page is within the current
* application. If not, it will redirect to the given url, and if none is
* given, back to the application root
*
* @param string $url The url
* @param string $method The redirect method
* @param int $code The redirect status code
*
* @return void
*/
public static function redirect_back($url = '', $method = 'location', $code = 302)
{
// do we have a referrer?
if ($referrer = \Input::referrer()) {
// is it within our website? And not equal to the current url?
if (strpos($referrer, \Uri::base()) === 0 and $referrer != \Uri::current()) {
// redirect back to where we came from
static::redirect($referrer, $method, $code);
}
}
// no referrer or an external link, do a normal redirect
static::redirect($url, $method, $code);
}
示例3: post_terms
/**
* An editor view for the fuel lang entries
*/
public function post_terms()
{
$terms = \Input::post('terms', array());
try {
foreach ($terms as $lang => $phrases) {
\Lang::save('common.db', $phrases, $lang);
}
} catch (\Exception $e) {
// Nothing
}
\Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-success'), 'msg' => \Lang::get('admin.messages.translations_save_success')));
$referrer = \Input::referrer('/admin');
return \Response::redirect($referrer);
}
示例4: getAndSetSubmitRedirection
/**
* get and set submit redirection url
*
* @return string
*/
private function getAndSetSubmitRedirection()
{
$session = \Session::forge();
if ($session->get('submitted_redirect') == null) {
if (\Input::referrer() != null && \Input::referrer() != \Uri::main()) {
$session->set('submitted_redirect', \Input::referrer());
return \Input::referrer();
} else {
$redirect_uri = 'dbhelper/admin';
$session->set('submitted_redirect', $redirect_uri);
return $redirect_uri;
}
} else {
return $session->get('submitted_redirect');
}
}
示例5: action_deleteAvatar
public function action_deleteAvatar()
{
// get account id from cookie
$account = new \Model_Accounts();
$cookie = $account->getAccountCookie();
if (\Input::method() == 'POST') {
if (!\Extension\NoCsrf::check()) {
// validate token failed
$output['form_status'] = 'error';
$output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
$output['result'] = false;
} else {
if (!isset($cookie['account_id']) || \Model_Accounts::isMemberLogin() == false) {
$output['result'] = false;
} else {
$output['result'] = true;
$account->deleteAccountAvatar($cookie['account_id']);
}
}
}
unset($account, $cookie);
if (\Input::is_ajax()) {
// re-generate csrf token for ajax form to set new csrf.
$output['csrf_html'] = \Extension\NoCsrf::generate();
$response = new \Response();
$response->set_header('Content-Type', 'application/json');
$response->body(json_encode($output));
return $response;
} else {
if (\Input::referrer() != null && \Input::referrer() != \Uri::main()) {
\Response::redirect(\Input::referrer());
} else {
\Response::redirect(\Uri::base());
}
}
}
示例6: redirect_back
/**
* Redirects back to the previous page, if that page is within the current
* application. If not, it will redirect to the given url, and if none is
* given, back to the application root. If the current page is the application
* root, an exception is thrown
*
* @param string $url The url
* @param string $method The redirect method
* @param int $code The redirect status code
*
* @return void
*
* @throws RuntimeException If it would redirect back to itself
*/
public static function redirect_back($url = '', $method = 'location', $code = 302)
{
// do we have a referrer?
if ($referrer = \Input::referrer()) {
// is it within our website? And not equal to the current url?
if (strpos($referrer, \Uri::base()) === 0 and $referrer != \Uri::current()) {
// redirect back to where we came from
static::redirect($referrer, $method, $code);
}
}
// make sure we're not redirecting back to ourself
if (\Uri::create($url) == \Uri::current()) {
throw new \RuntimeException('You can not redirect back here, it would result in a redirect loop!');
}
// no referrer or an external link, do a normal redirect
static::redirect($url, $method, $code);
}
示例7: action_view
public static function action_view($short_url)
{
if (is_object($short_url) === false) {
$short_url = Model_Url::query()->where('short_url', $short_url)->get_one();
}
$short_url->hits = $short_url->hits + 1;
$short_url->save();
if (empty($short_url) === false) {
$results = Controller_Url::check_loop($short_url);
$data['url'] = $results['url'];
$data['iframe'] = $results['iframe'];
if (isset($results['image']) === true) {
$data['image'] = $results['image'];
}
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$ip = $_SERVER["HTTP_CF_CONNECTING_IP"];
} else {
$ip = Input::real_ip();
}
$country = Model_Url_Stats_Country::query()->where('start_ip', '<=', ip2long($ip))->where('end_ip', '>=', ip2long($ip))->get_one();
if (empty($country) === false) {
$country = $country->country;
} else {
$country = 'N/A';
}
$lang = Agent::languages();
// Insert Some Stats
$stats = Model_Url_Stat::forge(array('url_id' => $short_url->id, 'ip' => $ip, 'country' => $country, 'referer' => Input::referrer(), 'language' => serialize($lang)));
$stats->save();
return new Response(View::Forge('url/redirect', $data));
} else {
Session::set('error', 'We couldn\'t');
Response::Redirect(Uri::Base());
}
}
示例8: action_delete
public function action_delete($id = false)
{
if (is_numeric($id)) {
// Get news item to edit
if ($item = Model_Attribute_Group::find_one_by_id($id)) {
// Delete item
try {
// Delete relation to attributes
$attributes = Model_Attribute_To_Groups::find_by_group_id($item->id);
if (!is_null($attributes)) {
foreach ($attributes as $attribute) {
$attribute->delete();
}
}
$item->delete();
\Messages::success('Attribute group successfully deleted.');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to delete attribute group</strong>');
// Uncomment lines below to show database errors
//$errors = $e->getMessage();
//\Messages::error($errors);
}
}
}
\Response::redirect(\Input::referrer(\Uri::create('admin/attribute/group/list')));
}
示例9: action_delete_image
/**
* Delete content image
*
* @param $content_id = Content ID
*/
public function action_delete_image($content_id = null)
{
try {
if ($application = Model_Application::find_one_by_id($content_id)) {
if (!empty($application->hotspot) && !empty($application->hotspot->images)) {
foreach ($application->hotspot->images as $image) {
$this->delete_image($image->image);
$image->delete();
}
}
$this->delete_image($application->hotspot_image);
$application->hotspot_alt_text = null;
$application->hotspot_image = null;
if ($application->save()) {
\Messages::success('Hotspot image was successfully deleted.');
} else {
\Messages::error('There was an error while trying to delete hotspot image.');
}
}
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('There was an error while trying to delete hotspot image.');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
}
\Response::redirect(\Input::referrer());
}
示例10: save_order
protected function save_order()
{
if (!$this->check_logged()) {
\Messages::error('You must be logged in if you want to continue with your order.');
\Response::redirect(\Uri::create('order/checkout/address'));
}
// Save order
$user = false;
$order = false;
$items = \Cart::items();
if (\Sentry::check()) {
$user = \Sentry::user();
}
if (\Input::post() && $items && $user) {
$group_id = $user['groups'][0]['id'];
$item_with_discount = array();
foreach ($items as $item) {
$id = $item->get('id');
$product_groups = \Product\Model_Product_To_Groups::find_by_product_id($item->get('id'));
foreach ($product_groups as $group) {
$all_discounts = \Product\Model_Group_Discounts::find_by(array('user_group_id' => $group_id, 'product_group_id' => $group->group_id), null, null, null);
foreach ($all_discounts as $discount) {
$discount = (int) $item_with_discount[$id]['discount'] + $discount->discount;
$sub_total = $item->totalPrice(true) - (int) $discount / $item->totalPrice(true) * 100;
$item_with_discount[$id] = array('product_group_id' => $group->product_id, 'user_group_id' => $group->group_id, 'discount' => $discount, 'sub_total' => $sub_total);
}
}
$item_with_discount['total_discount'] = (int) $item_with_discount['total_discount'] + (int) $item_with_discount[$id]['total_discount'];
$item_with_discount['total_price'] = (double) $item_with_discount['total_price'] + (double) $item_with_discount[$id]['sub_total'];
}
// check for a valid CSRF token
if (!\Security::check_token()) {
\Messages::error('CSRF attack or expired CSRF token.');
\Response::redirect(\Input::referrer(\Uri::create('order/checkout/cost')));
}
try {
// Update or create order
if (is_numeric(\Session::get('order.id'))) {
$order = \Order\Model_Order::find_one_by_id(\Session::get('order.id'));
}
if (!$order) {
$order = \Order\Model_Order::forge();
}
$shipping_price = $order->shipping_price(null, null, true);
$metadata = $user['metadata'];
if ($billing = \Arr::filter_prefixed($metadata, 'shipping_')) {
foreach ($billing as $key => $value) {
$order->{$key} = $metadata[$key];
unset($metadata[$key]);
}
}
foreach ($metadata as $key => $value) {
$order->{$key} = $value;
}
$order->email = $user->get('email');
$order->user_id = $user->get('id');
$order->status = 'Pending';
$order->discount_amount = $item_with_discount['total_discount'];
//\Cart::getTotal('price');
$order->total_price = $item_with_discount['total_price'];
//\Cart::getTotal('price');
$order->finished = 1;
$order->guest = $metadata['guest'] ? 1 : 0;
$order->accepted = $metadata['master'] == 1 ? 1 : 0;
$order->credit_account = $metadata['credit_account'] == 1 ? 1 : 0;
$order->shipping_price = $shipping_price;
// Save order, add products to order products
if ($order->save()) {
foreach ($items as $item) {
$product_data = null;
if ($product = \Product\Model_Product::find_one_by_id($item->get('id'))) {
$product_data = \Product\Model_Product::product_data($product, $item->get('attributes'));
}
if ($product_data) {
$order_products = \Order\Model_Products::forge();
$order_products->order_id = $order->id;
$order_products->title = $product->title;
$order_products->code = $product_data['code'];
$order_products->price = $item->singlePrice(true);
$order_products->price_type = $product_data['price_type'];
$order_products->quantity = $item->get('quantity');
$order_products->product_id = $product->id;
$order_products->artwork_required = $product->artwork_required;
$order_products->artwork_free_over = $product->artwork_free_over;
$order_products->subtotal = $item_with_discount[$item->get('id')]['sub_total'];
//$item->totalPrice(true);
$order_products->attributes = json_encode(\Product\Model_Attribute::get_combination($item->get('attributes')));
if (!empty($product->categories)) {
$categories = array();
foreach ($product->categories as $category) {
$categories[] = $category->title;
}
if ($categories) {
$order_products->product_category = implode(',', $categories);
}
}
$order_products->save();
// Find artworks
if ($unique_id = $item->get('unique_id')) {
if ($artworks = \Order\Model_Artwork::find(array('where' => array('unique_id' => $unique_id, 'order_id' => $order->id)))) {
//.........这里部分代码省略.........
示例11: action_clear_cart
public function action_clear_cart()
{
$items = \Cart::items();
$order = null;
if (is_numeric(\Session::get('order.id'))) {
$order = \Order\Model_Order::find_one_by_id(\Session::get('order.id'));
}
if ($order) {
$order->delete();
}
if ($items) {
foreach ($items as $item) {
// Find artworks
if ($unique_id = $item->get('unique_id')) {
if ($artworks = \Order\Model_Artwork::find(array('where' => array('unique_id' => $unique_id, 'order_id' => \Session::get('order.id'))))) {
$ysi = \Yousendit\Base::forge();
// Artworks (update, delete)
foreach ($artworks as $artwork) {
// Remove deleted artwork
if ($artwork->file_id) {
$ysi->delete_artwork($artwork->file_id);
}
}
}
}
}
}
// Delete order & cart session
\Session::delete('order.id');
\Cart::clear();
\Messages::info('Your cart is empty.');
if (\Input::is_ajax()) {
echo \Messages::display();
exit;
} else {
\Response::redirect(\Input::referrer(\Uri::create('order/checkout/address')));
}
}
示例12: action_delete_image
/**
* Delete content image
*
* @param $content_id = Content ID
*/
public function action_delete_image($id = false)
{
if (is_numeric($id)) {
// Get news item to edit
if ($item = Model_Product_To_Infotabs::find_by_pk($id)) {
// Delete hotspot images
if (!empty($item->images)) {
foreach ($item->images as $image) {
\Request::forge('admin/product/delete_infotab_image/' . $image->id . '/' . $image->infotab_id)->execute()->response();
}
}
// Delete item
try {
$this->delete_image($item->image);
$item->image = NULL;
$item->alt_text = NULL;
// Make infotab inactive as it cant show without image
$item->active = 0;
$item->save();
\Messages::success('Info Tab image successfully deleted.');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to delete info tab image</strong>');
// Uncomment lines below to show database errors
//$errors = $e->getMessage();
//\Messages::error($errors);
}
}
}
if (\Request::is_hmvc()) {
\Messages::reset();
} else {
\Response::redirect(\Input::referrer(\Uri::create('admin/product/infotab/list')));
}
}
示例13: action_list
/**
* Manage upsell products
*
* @param $id = Product ID
*/
public function action_list($id)
{
if (!is_numeric($id)) {
\Response::redirect('admin/product/list');
}
// Get news item to edit
if (!($item = Model_Product::find_one_by_id($id))) {
\Response::redirect('admin/product/list');
}
if (\Input::post()) {
$add = \Input::post('products.add', array());
$remove = \Input::post('products.remove', array());
$discounts = \Input::post('discount', array());
if (\Input::post('add', false)) {
foreach ($add as $value) {
$upsell = Model_Product_To_Upsell::forge(array('upsell_id' => $value, 'product_id' => $item->id));
$upsell->save();
}
\Messages::success('Upsell products successfully added.');
} else {
if (\Input::post('remove', false)) {
foreach ($remove as $value) {
$upsell = Model_Product_To_Upsell::find_one_by(array(array('upsell_id', '=', $value), array('product_id', '=', $item->id)));
if (!is_null($upsell)) {
$upsell->delete();
}
}
\Messages::success('Upsell products successfully removed.');
} else {
if (\Input::post('save', false)) {
foreach ($discounts as $key => $value) {
$upsell = Model_Product_To_Upsell::find_one_by(array(array('upsell_id', '=', $key), array('product_id', '=', $item->id)));
if (!is_null($upsell)) {
$upsell->discount = round($value, 0);
$upsell->save();
}
}
\Messages::success('Upsell discounts successfully saved.');
}
}
}
if (\Input::is_ajax()) {
echo \Messages::display('left', false);
exit;
} else {
\Response::redirect(\Input::referrer(\Uri::create('admin/product/list')));
}
}
\View::set_global('title', 'List Upsell Products');
$search = $this->get_search_items($item);
$pagination = $search['pagination'];
$status = $search['status'];
$item = $search['item'];
\Theme::instance()->set_partial('content', $this->view_dir . 'list')->set('product', $item)->set('pagination', $pagination, false)->set('status', $status);
}
示例14: action_delete_referral
public function action_delete_referral($id = false)
{
if (is_numeric($id)) {
// Get user delete
if ($item = Model_Referal::find_one_by_id((int) $id)) {
// Delete item
try {
// Delete group
$item->delete();
\Messages::success('User successfully deleted.');
} catch (\Sentry\SentryUserException $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to delete item</strong>');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
}
}
}
\Response::redirect(\Input::referrer());
}
示例15: action_delete_artwork
public function action_delete_artwork($file_id = null)
{
$ysi = \Yousendit\Base::forge();
$response = $ysi->delete_artwork($file_id, true);
if (isset($response['errormessage'])) {
\Messages::error('<strong>' . 'There was an error while trying to delete artwork file.' . '</strong>');
} else {
\Messages::success('Artwork file successfully deleted.');
}
\Response::redirect(\Input::referrer(\Uri::create('admin/order/list')));
}