mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-16 12:57:32 -04:00
Remove duplicated cookie cleanup hack (CI 2.x issue)
This commit is contained in:
@@ -14,7 +14,6 @@ class Config extends Secure_area
|
||||
$data['stock_locations'] = $this->Stock_location->get_all()->result_array();
|
||||
$data['support_barcode'] = $this->barcode_lib->get_list_barcodes();
|
||||
$this->load->view("configs/manage", $data);
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function save()
|
||||
@@ -62,7 +61,6 @@ class Config extends Secure_area
|
||||
$message = $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully');
|
||||
$message = $upload_success ? $message : $this->upload->display_errors();
|
||||
echo json_encode(array('success'=>$success,'message'=>$message));
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function save_locale()
|
||||
@@ -81,8 +79,7 @@ class Config extends Secure_area
|
||||
$result = $this->Appconfig->batch_save( $batch_save_data );
|
||||
$success = $result ? true : false;
|
||||
echo json_encode(array('success'=>$success, 'message'=>$this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
}
|
||||
|
||||
function stock_locations()
|
||||
{
|
||||
@@ -127,7 +124,6 @@ class Config extends Secure_area
|
||||
}
|
||||
$success = $this->db->trans_complete();
|
||||
echo json_encode(array('success'=>$success,'message'=>$this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function save_barcode()
|
||||
|
||||
@@ -43,7 +43,6 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
$data['manage_table'] = get_item_kits_manage_table($item_kits, $this);
|
||||
|
||||
$this->load->view('item_kits/manage', $data);
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -66,7 +65,6 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
}
|
||||
|
||||
$data_rows = get_item_kits_manage_table_data_rows($item_kits, $this);
|
||||
$this->_remove_duplicate_cookies();
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
|
||||
}
|
||||
@@ -89,7 +87,6 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
$item_kit = $this->add_totals_to_item_kit($this->Item_kit->get_info($item_kit_id));
|
||||
|
||||
echo (get_item_kit_data_row($item_kit, $this));
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function view($item_kit_id=-1)
|
||||
|
||||
@@ -39,7 +39,6 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
$this->load->view('items/manage', $data);
|
||||
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function find_item_info()
|
||||
@@ -84,8 +83,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$data_rows = get_items_manage_table_data_rows($items, $this);
|
||||
|
||||
// do not move this line to be after the json_encode otherwise the searhc function won't work!!
|
||||
$this->_remove_duplicate_cookies();
|
||||
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
|
||||
}
|
||||
|
||||
@@ -266,7 +264,6 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
echo $data_row;
|
||||
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function view($item_id=-1)
|
||||
|
||||
@@ -225,7 +225,6 @@ class Receivings extends Secure_area
|
||||
$this->load->view("receivings/receipt",$data);
|
||||
$this->receiving_lib->clear_all();
|
||||
}
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
private function _substitute_variable($text, $variable, $object, $function)
|
||||
@@ -320,7 +319,6 @@ class Receivings extends Secure_area
|
||||
$data['print_after_sale'] = FALSE;
|
||||
$this->load->view("receivings/receipt",$data);
|
||||
$this->receiving_lib->clear_all();
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
private function _reload($data=array())
|
||||
@@ -361,7 +359,6 @@ class Receivings extends Secure_area
|
||||
$data['invoice_number_enabled']=$this->receiving_lib->is_invoice_number_enabled();
|
||||
$data['print_after_sale']=$this->receiving_lib->is_print_after_sale();
|
||||
$this->load->view("receivings/receiving",$data);
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function save($receiving_id)
|
||||
|
||||
@@ -64,7 +64,6 @@ class Sales extends Secure_area
|
||||
$this->load->view($data['controller_name'] . '/manage', $data);
|
||||
}
|
||||
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function get_row()
|
||||
@@ -129,8 +128,7 @@ class Sales extends Secure_area
|
||||
$payment_summary = get_sales_manage_payments_summary($payments, $sales, $this);
|
||||
|
||||
// do not move this line to be after the json_encode otherwise the search function won't work!!
|
||||
$this->_remove_duplicate_cookies();
|
||||
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $sale_rows, 'pagination' => $links, 'payment_summary' => $payment_summary));
|
||||
}
|
||||
|
||||
@@ -460,7 +458,6 @@ class Sales extends Secure_area
|
||||
$this->sale_lib->clear_all();
|
||||
}
|
||||
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
private function _invoice_email_pdf($data)
|
||||
@@ -482,7 +479,6 @@ class Sales extends Secure_area
|
||||
$sale_data['image_prefix'] = base_url();
|
||||
$this->load->view('sales/invoice_email', $sale_data);
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function send_invoice($sale_id)
|
||||
@@ -507,7 +503,6 @@ class Sales extends Secure_area
|
||||
}
|
||||
echo json_encode(array('success'=>$result, 'message'=>$message, 'id'=>$sale_id));
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
private function _substitute_variable($text, $variable, $object, $function)
|
||||
@@ -629,7 +624,6 @@ class Sales extends Secure_area
|
||||
$data = $this->_load_sale_data($sale_id);
|
||||
$this->load->view("sales/receipt",$data);
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function invoice($sale_id, $sale_info='')
|
||||
@@ -639,7 +633,6 @@ class Sales extends Secure_area
|
||||
}
|
||||
$this->load->view("sales/invoice",$sale_info);
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function edit($sale_id)
|
||||
@@ -762,7 +755,6 @@ class Sales extends Secure_area
|
||||
|
||||
$this->load->view("sales/register", $data);
|
||||
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function cancel_sale()
|
||||
|
||||
@@ -61,57 +61,5 @@ class Secure_area extends CI_Controller
|
||||
return $this->pagination->create_links();
|
||||
}
|
||||
|
||||
function _remove_duplicate_cookies ()
|
||||
{
|
||||
//php < 5.3 doesn't have header remove so this function will fatal error otherwise
|
||||
if (function_exists('header_remove'))
|
||||
{
|
||||
$CI = &get_instance();
|
||||
|
||||
// clean up all the cookies that are set...
|
||||
$headers = headers_list();
|
||||
$cookies_to_output = array ();
|
||||
$header_session_cookie = '';
|
||||
$session_cookie_name = $CI->config->item('sess_cookie_name');
|
||||
|
||||
foreach ($headers as $header)
|
||||
{
|
||||
list ($header_type, $data) = explode (':', $header, 2);
|
||||
$header_type = trim ($header_type);
|
||||
$data = trim ($data);
|
||||
|
||||
if (strtolower ($header_type) == 'set-cookie')
|
||||
{
|
||||
header_remove ('Set-Cookie');
|
||||
|
||||
$cookie_value = current(explode (';', $data));
|
||||
list ($key, $val) = explode ('=', $cookie_value);
|
||||
$key = trim ($key);
|
||||
|
||||
if ($key == $session_cookie_name)
|
||||
{
|
||||
// OVERWRITE IT (yes! do it!)
|
||||
$header_session_cookie = $data;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a session related cookie, add it as normal. Might be a CSRF or some other cookie we are setting
|
||||
$cookies_to_output[] = array ('header_type' => $header_type, 'data' => $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty ($header_session_cookie))
|
||||
{
|
||||
$cookies_to_output[] = array ('header_type' => 'Set-Cookie', 'data' => $header_session_cookie);
|
||||
}
|
||||
|
||||
foreach ($cookies_to_output as $cookie)
|
||||
{
|
||||
header ("{$cookie['header_type']}: {$cookie['data']}", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user