| Server IP : 103.48.194.25 / Your IP : 216.73.216.131 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/nhadatkhangdien.net-bk/public_html/admin/sources/ |
Upload File : |
<?php if(!defined('_source')) die("Error");
$act = (isset($_REQUEST['act'])) ? addslashes($_REQUEST['act']) : "";
switch($act){
case "man":
get_items();
$template = "gioithieu/items";
break;
case "add":
$template = "gioithieu/item_add";
break;
case "edit":
get_item();
$template = "gioithieu/item_add";
break;
case "save":
save_item();
break;
case "delete":
delete_item();
break;
#===================================================
case "man_cat":
get_cats();
$template = "gioithieu/cats";
break;
case "add_cat":
$template = "gioithieu/cat_add";
break;
case "edit_cat":
get_cat();
$template = "gioithieu/cat_add";
break;
case "save_cat":
save_cat();
break;
case "delete_cat":
delete_cat();
break;
default:
$template = "index";
default:
$template = "index";
}
function fns_Rand_digit($min,$max,$num)
{
$result='';
for($i=0;$i<$num;$i++){
$result.=rand($min,$max);
}
return $result;
}
function get_items(){
global $d, $items, $paging;
if(@$_REQUEST['tinnoibat']!='')
{
$id_up = @$_REQUEST['tinnoibat'];
$sql_sp = "SELECT id,tinnoibat FROM table_gioithieu where id='".$id_up."' ";
$d->query($sql_sp);
$cats= $d->result_array();
$tinnoibat=$cats[0]['tinnoibat'];
//echo "id:". $spdc1;
if($tinnoibat==0)
{
$sqlUPDATE_ORDER = "UPDATE table_gioithieu SET tinnoibat =1 WHERE id = ".$id_up."";
$resultUPDATE_ORDER = mysql_query($sqlUPDATE_ORDER) or die("Not query sqlUPDATE_ORDER");
}
else
{
$sqlUPDATE_ORDER = "UPDATE table_gioithieu SET tinnoibat =0 WHERE id = ".$id_up."";
$resultUPDATE_ORDER = mysql_query($sqlUPDATE_ORDER) or die("Not query sqlUPDATE_ORDER");
}
}
if(@$_REQUEST['hienthi']!='')
{
$id_up = @$_REQUEST['hienthi'];
$sql_sp = "SELECT id,hienthi FROM table_gioithieu where id='".$id_up."' ";
$d->query($sql_sp);
$cats= $d->result_array();
$hienthi=$cats[0]['hienthi'];
//echo "id:". $spdc1;
if($hienthi==0)
{
$sqlUPDATE_ORDER = "UPDATE table_gioithieu SET hienthi =1 WHERE id = ".$id_up."";
$resultUPDATE_ORDER = mysql_query($sqlUPDATE_ORDER) or die("Not query sqlUPDATE_ORDER");
}
else
{
$sqlUPDATE_ORDER = "UPDATE table_gioithieu SET hienthi =0 WHERE id = ".$id_up."";
$resultUPDATE_ORDER = mysql_query($sqlUPDATE_ORDER) or die("Not query sqlUPDATE_ORDER");
}
}
$sql = "select * from #_gioithieu ";
if(isset($_REQUEST['id_cat'])){
if((int)$_REQUEST['id_cat']!='')
{
$sql.=" where id_item=".$_REQUEST['id_cat']."";
}}
$sql.=" order by id desc";
$d->query($sql);
$items = $d->result_array();
$curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 1;
if(isset($_REQUEST['id_cat']) && ($_REQUEST['id_cat']!='')){
$url="index.php?com=gioithieu&act=man&id_cat=".$_REQUEST['id_cat'];
}
else $url="index.php?com=gioithieu&act=man";
$maxR=25;
$maxP=4;
$paging=paging($items, $url, $curPage, $maxR, $maxP);
$items=$paging['source'];
}
function get_item(){
global $d, $item;
$id = isset($_GET['id']) ? themdau($_GET['id']) : "";
if(!$id)
transfer("Không nhận được dữ liệu", "index.php?com=gioithieu&act=man");
$sql = "select * from #_gioithieu where id='".$id."'";
$d->query($sql);
if($d->num_rows()==0) transfer("Dữ liệu không có thực", "index.php?com=gioithieu&act=man");
$item = $d->fetch_array();
}
function save_item()
{
global $d;
if(empty($_POST)) transfer("Không nhận được dữ liệu", "index.php?com=gioithieu&act=man");
$data['id_item'] = (int)$_POST['id_item'];
$data['ten'] = addslashes($_POST['ten']);
$data['keyword'] = $_POST['keyword'];
$data['description'] = $_POST['description'];
$data['tenkhongdau'] = changeTitle($_POST['ten']);
$data['mota'] =addslashes( $_POST['mota']);
$data['noidung'] = addslashes($_POST['noidung']);
$data['stt'] = $_POST['stt'];
$data['hienthi'] = isset($_POST['hienthi']) ? 1 : 0;
$data['httop'] = isset($_POST['httop']) ? 1 : 0;
$data['ngaysua'] = time();
//cap nhat hinh anh
$file_name = alias($data['ten']);
if(isset($_FILES['file']['name']) && $_FILES['file']['name']!='')
{
$photo = upload_image("file", _upload_tintuc,$file_name) ;
$data['photo'] = $photo;
}
$id = isset($_POST['id']) ? $_POST['id'] : 0;
if($id)
{
$d->setTable('gioithieu');
$d->setWhere('id', $id);
if($d->update($data))
redirect("index.php?com=gioithieu&act=man");
else
transfer("Cập nhật dữ liệu bị lỗi", "index.php?com=gioithieu&act=man");
}else{
$d->setTable('gioithieu');
if($d->insert($data))
redirect("index.php?com=gioithieu&act=man");
else
transfer("Lưu dữ liệu bị lỗi", "index.php?com=gioithieu&act=man");
}
}
function delete_item(){
global $d;
if(isset($_GET['id'])){
$id = themdau($_GET['id']);
$d->reset();
$sql = "select * from #_gioithieu where id='".$id."'";
$d->query($sql);
if($d->num_rows()>0){
while($row = $d->fetch_array()){
delete_file(_upload_tintuc.$row['photo']);
delete_file(_upload_tintuc.$row['thumb']);
}
$sql = "delete from #_gioithieu where id='".$id."'";
$d->query($sql);
}
if($d->query($sql))
redirect("index.php?com=gioithieu&act=man");
else
transfer("Xóa dữ liệu bị lỗi", "index.php?com=gioithieu&act=man");
}elseif (isset($_GET['listid'])==true){
$listid = explode(",",$_GET['listid']);
for ($i=0 ; $i<count($listid) ; $i++){
$idTin=$listid[$i];
$id = themdau($idTin);
$d->reset();
$sql = "select * from #_gioithieu where id='".$id."'";
$d->query($sql);
if($d->num_rows()>0){
while($row = $d->fetch_array()){
delete_file(_upload_tintuc.$row['photo']);
delete_file(_upload_tintuc.$row['thumb']);
}
$sql = "delete from #_gioithieu where id='".$id."'";
$d->query($sql);
}
} redirect("index.php?com=gioithieu&act=man");} else transfer("Không nhận được dữ liệu", "index.php?com=gioithieu&act=man");
}
//===========================================================
function get_cats(){
global $d, $items, $paging;
$sql = "select * from #_gioithieu_item order by stt";
$d->query($sql);
$items = $d->result_array();
$curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 1;
$url="index.php?com=gioithieu&act=man_cat";
$maxR=20;
$maxP=4;
$paging=paging($items, $url, $curPage, $maxR, $maxP);
$items=$paging['source'];
}
function get_cat(){
global $d, $item;
$id = isset($_GET['id']) ? themdau($_GET['id']) : "";
if(!$id)
transfer("Không nhận được dữ liệu", "index.php?com=gioithieu&act=man_cat");
$sql = "select * from #_gioithieu_item where id='".$id."'";
$d->query($sql);
if($d->num_rows()==0) transfer("Dữ liệu không có thực", "index.php?com=gioithieu&act=man_cat");
$item = $d->fetch_array();
}
function save_cat()
{
global $d;
if(empty($_POST)) transfer("Không nhận được dữ liệu", "index.php?com=gioithieu&act=man_cat");
$data['ten'] = addslashes($_POST['ten']);
$data['keyword'] = $_POST['keyword'];
$data['description'] = $_POST['description'];
$data['tenkhongdau'] = changeTitle($_POST['ten']);
$data['mota'] = addslashes($_POST['mota']);
$data['noidung'] =addslashes( $_POST['noidung']);
$data['stt'] = $_POST['stt'];
$data['hienthi'] = isset($_POST['hienthi']) ? 1 : 0;
$data['httop'] = isset($_POST['httop']) ? 1 : 0;
$data['ngaysua'] =time();
$file_name = alias($data['ten']);
if(isset($_FILES['file']['name']) && $_FILES['file']['name']!='')
{
$photo = upload_image("file", _upload_tintuc,$file_name) ;
$data['photo'] = $photo;
}
$id = isset($_POST['id']) ? $_POST['id'] : 0;
if($id)
{
/*if($photo = upload_image("file", 'JPG|jpg|png|gif',_upload_tintuc,$file_name)){
$data['photo'] = $photo;
$d->setTable('gioithieu');
$d->setWhere('id', $id);
$d->select();
if($d->num_rows()>0){
$row = $d->fetch_array();
delete_file(_upload_tintuc.$row['photo']);
}
}*/
$d->setTable('gioithieu_item');
$d->setWhere('id', $id);
if($d->update($data))
redirect("index.php?com=gioithieu&act=man_cat&curPage=".$_REQUEST['curPage']."");
else
transfer("Cập nhật dữ liệu bị lỗi", "index.php?com=gioithieu&act=man_cat");
}
else
{
/*if($photo = upload_image("file", 'JPG|jpg|png|gif',_upload_tintuc,$file_name)){
$data['photo'] = $photo;
}
$data['ten'] = ($_POST['ten']);
$data['keyword'] = $_POST['keyword'];
$data['description'] = $_POST['description'];
$data['tenkhongdau'] = changeTitle($_POST['ten']);
$data['mota'] = addslashes($_POST['mota']);
$data['noidung'] =addslashes( $_POST['noidung']);
$data['stt'] = $_POST['stt'];
$data['hienthi'] = isset($_POST['hienthi']) ? 1 : 0;
$data['httop'] = isset($_POST['httop']) ? 1 : 0;
$data['ngaytao'] =time(); */
$d->setTable('gioithieu_item');
if($d->insert($data))
redirect("index.php?com=gioithieu&act=man_cat");
else
transfer("Lưu dữ liệu bị lỗi", "index.php?com=gioithieu&act=man_cat");
}
}
function delete_cat(){
global $d;
if(isset($_GET['id'])){
$id = themdau($_GET['id']);
$d->reset();
$sql = "delete from #_gioithieu_item where id='".$id."'";
if($d->query($sql))
redirect("index.php?com=gioithieu&act=man_cat");
else
transfer("Xóa dữ liệu bị lỗi", "index.php?com=gioithieu&act=man_cat");
}else transfer("Không nhận được dữ liệu", "index.php?com=gioithieu&act=man_cat");
}
?>