<?php
session_start();
include_once('../config/#Config.php');
if(!$_SESSION['UserName']){
die('<script>window.location.href=\''.$config['site']['url'].'index.php\';</script>');
} else {
$get_AD = mysqli_query($conn, "Select * From config_admin WHERE Account = '".$_SESSION['UserName']."'");
if(!mysqli_num_rows($get_AD)){
	die('Không đủ quyền.');
}
$gettt = mysqli_query($conn, "Select * From config_setting WHERE ID = '1'");
if(mysqli_num_rows($gettt)){
	if($_POST['action'] == 0){
	mysqli_query($conn, "UPDATE config_setting Set Url = N'".$_POST['a']."',Title_Index = N'".$_POST['b']."',Des_Index = N'".$_POST['c']."',Key_Index = N'".$_POST['d']."',Google_ID = N'".$_POST['e']."', enable_autocharge = N'".$_POST['f']."' WHERE ID = '1'");		
	} else if($_POST['action'] == 2){
	mysqli_query($conn, "UPDATE config_setting Set recard_id = N'".$_POST['a']."',recard_ma = N'".$_POST['b']."',sdt_id = N'".$_POST['c']."',sdt_user = N'".$_POST['d']."',sdt_pass = N'".$_POST['e']."' WHERE ID = '1'");				
	} else {
	mysqli_query($conn, "UPDATE config_setting Set Close = 1 WHERE ID = '1'");
	}
	die('Chỉnh sữa thành công.');
} else {
	die('Thất bại');
}
}
?>