| 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/khonguyenlieu.vn/public_html/webadmin/controllers/ |
Upload File : |
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Ajax extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('ajax_model', 'ajax');
$this->load->model('common');
$this->load->helper('img');
$this->load->helper('status');
}
public function orderlast()
{
$data['list'] = $this->ajax->get_last_order();
$this->load->view('ajax/orderlast', $data);
}
public function update()
{
$id_name = $this->input->post('id_name');
$id_value = $this->input->post('id_value');
$field_name = $this->input->post('field_name');
$field_value = $this->input->post('field_value');
$tbl = $this->input->post('table'); //log_message('error', "Trit :" .$field_value);
/*$incoming = file_get_contents("php://input");
$obj = json_decode($incoming, TRUE); //trit($obj);
$id_name = isset($obj['id_name'])? $obj['id_name'] : '';
$id_value = isset($obj['id_value'])? $obj['id_value'] : '';
$field_name = isset($obj['field_name'])? $obj['field_name'] : '';
$field_value = isset($obj['field_value'])? $obj['field_value'] : '';
$tbl = isset($obj['table'])? $obj['table'] : '';*/
if ($tbl) {
$data[$field_name] = $field_value;
$this->common->save($tbl, $data, $id_name, $id_value);
$res['code'] = 1;
$res['msg'] = 'Cập nhật thành công';
echo json_encode($res);
} else {
$res['code'] = 0;
$res['msg'] = 'Không có table ko làm gì';
echo json_encode($res);
}
}
public function transfer_notice_last()
{
$list = $this->ajax->get_transfer_notice_last();
$data['list'] = '
<table class="admindata">
<thead>
<th>Mã ĐH</th>
<th>Tài khoản</th>
<th>Xem</th>
</thead>
';
$k = 1;
foreach ($list as $rs):
$data['list'] .= '
<tr class="row' . $k . '">
<td><a href="' . site_url('chonmua/chitietdonhang/' . $rs->CartID) . '">' . $rs->CartID . '</a></td>
<td>' . $rs->LoginName . '</td>
<td><a href="' . site_url('chonmua/notice_detail/' . $rs->TransferID) . '">Xem</td>
</tr>
';
$k = 1 - $k;
endforeach;
$data['list'] .= '</table> ';
echo json_encode($data);
}
public function thongke()
{
$this->load->view('ajax/thongke');
}
public function publish()
{
$status = $this->input->post('status');
$id = $this->input->post('id');
$field = $this->input->post('field');
$table = $this->input->post('table');
if ($status == 0) {
$pub = 1;
} else {
$pub = 0;
}
$this->ajax->setActiveDeactive($table, $field, $id, $pub);
echo icon_active("'$table'", "'$field'", $id, $pub);
}
public function getalias()
{
$name = $this->input->post('name');
echo alias($name);
}
public function upload($ProductID = 0)
{
}
public function uploader($ProductID = 0)
{
$session_info = $this->session->userdata('session_id');
$dir = ROOT_IMG . 'images/';
$size = $_FILES['uploadfile']['size'];
if ($size > 204857600) {
echo "file_biger";
unlink($_FILES['uploadfile']['tmp_name']);
}
$extension = pathinfo($_FILES['uploadfile']['name'], PATHINFO_EXTENSION);
$extension = $extension == 'jpeg' ? 'jpg' : $extension;
$filename = time() . '.' . $extension;
$fullpath = ROOT_IMG . 'images/' . $filename;
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $fullpath)) {
if ($filename != '') {
$this->resize(ROOT_IMG . 'images/' . $filename, ROOT_IMG . 'products/200/' . $filename, 600);
$this->resize(ROOT_IMG . 'images/' . $filename, ROOT_IMG . 'products/100/' . $filename, 320);
$this->resize(ROOT_IMG . 'images/' . $filename, ROOT_IMG . 'products/40/' . $filename, 40);
}
$id_img = $this->ajax->add_img($filename, $ProductID, $extension, $session_info);
echo $id_img . ',' . $filename;
} else {
echo 'error';
}
}
public function resize($src, $desc, $width)
{
$this->load->library('ResizeImg');
$this->resizeimg->load($src);
$this->resizeimg->resizeToWidth($width);
$this->resizeimg->save($desc);
}
}