| Server IP : 103.48.194.25 / Your IP : 216.73.216.74 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 : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/namduongmarket.com-bk/public_html/site/components/api/controllers/ |
Upload File : |
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
/*require_once ROOT_SITE."libraries/Format.php";
require_once ROOT_SITE."libraries/Rest.php";*/
class Category extends MX_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('common');
$this->load->model('category_model','category');
$this->load->config('rest') ;
/*$this->load->library('Format');
$this->load->library('Rest') ;*/
}
function addcategory()
{
header('Access-Control-Allow-Origin: *');
header('Content-Type:application/json');
$key = $this->input->post('key');
if($key == 'xbKjXT56a9Fbqvfr4ztdF2gbQ7vM7zKhe4sGwZ6x')
{
$req['cat_name'] = $this->input->post('cat_name');
$req['cat_alias'] = $this->input->post('cat_alias');
$req['parent_id'] = (int) $this->input->post('parent_id');
$req['nb_level'] = (int) $this->input->post('nb_level');
$req['is_home'] = (int) $this->input->post('is_home');
$req['is_mainmenu'] = (int) $this->input->post('is_mainmenu');
$req['nb_order'] = (int) $this->input->post('nb_order');
$req['metatitle'] = $this->input->post('metatitle');
$req['metadesc'] = $this->input->post('metadesc');
$req['metakey'] = $this->input->post('metakey');
$req['bl_active'] = (int) $this->input->post('bl_active');
$rs = $this->common->get_record('category','cat_name',$req['cat_name']);
if($rs)
{
$catid = $this->common->save('category',$req,'catid',$rs->catid);
echo $catid;
// $res["status"] = "failed";
// $res["catid"] = 0;
// echo json_encode($res);
}
else
{
$catid = $this->common->save('category',$req);
echo $catid;
// $res["status"] = "success";
// $res["catid"] = $catid;
// echo json_encode($res);
}
}
else
{
echo 0;
//$res["status"] = "failed";
// $res["catid"] = 0;
// echo json_encode($res);
}
}
function addproduct()
{
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$key = $this->input->post('key');
if($key == 'xbKjXT56a9Fbqvfr4ztdF2gbQ7vM7zKhe4sGwZ6x')
{
$req['pro_code'] = $this->input->post('pro_code');
$req['pro_name'] = $this->input->post('pro_name');
$req['proimg'] = $this->input->post('proimg');
$req['pro_desc'] = $this->input->post('pro_desc');
$req['price'] = $this->input->post('price');
$req['price_old'] = 0;
$req['catid'] = (int) $this->input->post('catid');
$req['pro_status'] = 0;
$req['status_text'] = '';
$req['is_promo'] = 0;
$req['pro_type'] = 0;
//$req['is_hot'] = 0;
$req['is_group'] = 0;
$req['is_home'] = 0;
$req['nb_view'] = 0;
$req['nb_order'] = 0;
$req['metatitle'] = $this->input->post('metatitle');
$req['metadesc'] = $this->input->post('metadesc');
$req['metakey'] = $this->input->post('metakey');
$req['dt_create'] = time();
$req['dt_modify'] = date("Y-m-d H:i:s");
$req['bl_active'] = 1;
$rs = $this->common->get_record('product','pro_name',$req['pro_name']);
if($rs)
{
$proid = $this->common->save('product',$req,'proid',$rs->proid);
echo $rs->proid;
}
else
{
$proid = $this->common->save('product',$req);
echo $proid;
}
}
else
{
echo 0;
}
}
//test
function post_index()
{
$mang = array (
new Casy("Hương Tràm", "https://zmp3-photo.zadn.vn/thumb/240_240/avatars/5/0/50e613e21b499290633d17cff0776e61_1489400757.jpg" ),
new Casy("Noo Phước Thịnh", "https://zmp3-photo.zadn.vn/thumb/240_240/avatars/7/4/74375080377499ab76dad37484ee7f15_1507800201.jpg" ),
new Casy("Bảo Anh", "https://zmp3-photo.zadn.vn/thumb/240_240/avatars/6/8/68bcf97b41cd37e918cdf2dc0b85e895_1509438182.jpg" ),
new Casy("MIN", "https://zmp3-photo.zadn.vn/thumb/240_240/avatars/3/c/3cfed0bdaf8d309d3d83e9819a0a439a_1509951123.jpg" ),
new Casy("Bích Phương", "https://zmp3-photo.zadn.vn/thumb/240_240/avatars/4/3/43d8be33dc00a33132c82adb9d0d3a54_1509355224.jpg" ),
new Casy("Chi Pu", "https://zmp3-photo.zadn.vn/thumb/240_240/avatars/3/f/3f1a335a75e9d7308b88e11cae73c38c_1512446666.jpg" )
);
//$this->response($mang,200);
echo json_encode($mang);
}
function get_index()
{
ob_start();
header('Access-Control-Allow-Origin: *');
header('Content-Type:application/json');
//ob_clean();
$list = $this->category->get_member(); //trit($list);
$users = array();
foreach ($list as $rs) :
//$users[] = array("user" => $rs);
array_push($users,$rs);
endforeach ;
$a = '{"cid":"QQD","flightType":"1","msg":""}';
//echo json_encode(array("a"=>$users));
//$this->rest->response($users,201);
$this->output->set_output(json_encode(array("a"=>$a)));
}
}
class Casy {
public $ten ;
public $hinh;
function Casy($t,$h)
{
$this->ten = $t ;
$this->hinh = $h;
}
}
?>