| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/thegioimaycongnghiep.vn/public_html/site/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ajax extends CI_Controller
{
protected $_templates;
function __construct()
{
parent::__construct();
//$this->load->model('home_model','home');
}
public function index()
{
$data['title'] = '';
/*$data['start'] = (int) $this->uri->segment(4) ;
$config['base_url'] = base_url().'home/index/'.(int)$this->uri->segment(3);
$data['num'] = $this->home->count_all();
$config['total_rows'] = $data['num'];
$config['per_page'] = 20;
$config['uri_segment'] = 4;
$config['num_links'] = 3 ;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['list'] = $this->home->get_all($config['per_page'],$data['start']);
$this->site->load('home/product', $data);*/
}
function addcart()
{
$req = $this->_get_form() ;
$ses_cart = isset($_SESSION['cart'])? (!empty($_SESSION['cart']) ? $_SESSION['cart'] : array()) : array() ;
array_push($ses_cart, $req) ;
$_SESSION['cart'] = $ses_cart ;
}
function editcart()
{
$req = $this->_get_form() ;
$ses_cart = isset($_SESSION['cart'])? (!empty($_SESSION['cart']) ? $_SESSION['cart'] : array()) : array() ;
//xoa item cu ra khoi gio hang
$item = $this->input->post('item') ;
array_splice($ses_cart, $item, 1) ;
//them vao gio hang
array_push($ses_cart, $req) ;
$_SESSION['cart'] = $ses_cart ;
}
function removecart()
{
$ses_cart = isset($_SESSION['cart'])? (!empty($_SESSION['cart']) ? $_SESSION['cart'] : array()) : array() ;
$proid = $this->uri->segment(4) ;
$item = $this->uri->segment(3) ;
array_splice($ses_cart, $item, 1) ;
$_SESSION['cart'] = $ses_cart ;
redirect('sanpham/viewcart') ;
}
function getItem($id)
{
global $ses_product;
$item = -1 ;
for($i=0;$i<count($ses_product);$i++)
{
if($ses_product[$i]['proid']== $id){
$item = $i ;
return $item ;
}
}
return $item ;
}
function _get_form()
{
$data['proid'] = $this->input->post('proid') ;
$data['pro_name'] = $this->input->post('pro_name') ;
$data['pro_img'] = $this->input->post('pro_img') ;
$data['price'] = $this->input->post('price') ;
return $data ;
}
}
?>