<?php
$t = 'Редактор тарифов';
require_once '../../wcore/core.php';
require_once '../../wcore/head.php';
iank(3);
$id = (isset($_GET['id']) && !empty($_GET['id'])?intval($_GET['id']):0);
$type = (isset($_GET['type']) && !empty($_GET['type'])?intval($_GET['type']):0);
$act = (isset($_GET['act']) && !empty($_GET['act'])?antixs($_GET['act']):'home');
$type_name = array(
1=>$lang['ord_t_vhost'],
2=>$lang['ord_t_ress'],
3=>$lang['ord_t_vds'],
4=>$lang['ord_t_dedic'],
5=>$lang['ord_t_domain'],
);
$tlist[] = array('id'=>1,'name'=>$type_name[1]);
$tlist[] = array('id'=>2,'name'=>$type_name[2]);
$tlist[] = array('id'=>3,'name'=>$type_name[3]);
$tlist[] = array('id'=>4,'name'=>$type_name[4]);
$tlist[] = array('id'=>5,'name'=>$type_name[5]);
if ($act == 'info'){
$sql_query = mysqli_query($mysqli,"SELECT * FROM `servers` WHERE `type` = '$type' ") or die("Ошибка запроса: ".mysqli_error($mysqli));;
while ($tarifs = mysqli_fetch_assoc($sql_query)){
$array[] = $tarifs;
}
} elseif ($act == 'listcat'){
if ($id == 0){
go('?');
}
$sql_query = mysqli_query($mysqli,"SELECT * FROM `tarifs` WHERE `sid` = '$id' ") or die("Ошибка запроса: ".mysqli_error($mysqli));;
while ($tarifs = mysqli_fetch_assoc($sql_query)){
$array[] = $tarifs;
}
} elseif ($act == 'delete'){
if (isset($_POST['ok'])){
mysqli_query($mysqli,"DELETE FROM `tarifs` WHERE `tid` = '$id'");
echo msg_err('suc',$lang['adm_tar_d_t_4']);require_once '../../wcore/foot.php';exit();
} else {
$sql = mysqli_query($mysqli,"SELECT * FROM `tarifs` WHERE `tid` = '$id' LIMIT 1");
if (mysqli_num_rows($sql) == 0){echo msg_err('err',$lang['amd_none_search']);require_once '../../wcore/foot.php';exit();}
$array = mysqli_fetch_object($sql);
}
} elseif ($act == 'create'){
if (isset($_POST['ok'])){
$name = (isset($_POST['name']) && !empty($_POST['name'])? antixs($_POST['name']):NULL);
$preset = (isset($_POST['preset']) && !empty($_POST['preset'])?antixs($_POST['preset']):NULL);
$bits = (isset($_POST['bits']) && !empty($_POST['bits'])? antixs($_POST['bits']):NULL);
mysqli_query($mysqli,"INSERT INTO `tarifs`(`sid`, `namepack`, `preset`, `bits`) VALUES ('$id','$name','$preset','$bits')");
echo msg_err('suc',$lang['adm_tar_e_t_10']);require_once '../../wcore/foot.php';exit();
}
} elseif ($act == 'edit'){
if (isset($_POST['ok'])){
$name = (isset($_POST['name']) && !empty($_POST['name'])? antixs($_POST['name']):NULL);
$ins['disk'] = (isset($_POST['disk']) && !empty($_POST['disk'])? antixs($_POST['disk']):NULL);
$ins['www'] = (isset($_POST['www']) && !empty($_POST['www'])? antixs($_POST['www']):NULL);
$ins['ftp'] = (isset($_POST['ftp']) && !empty($_POST['ftp'])? antixs($_POST['ftp']):NULL);
$ins['db'] = (isset($_POST['db']) && !empty($_POST['db'])? antixs($_POST['db']):NULL);
$ins['domain'] = (isset($_POST['domain']) && !empty($_POST['domain'])?antixs($_POST['domain']):NULL);
$ins['mail'] = (isset($_POST['mail']) && !empty($_POST['mail'])? antixs($_POST['mail']):NULL);
$ins['vcpu'] = (isset($_POST['vcpu']) && !empty($_POST['vcpu'])? antixs($_POST['vcpu']):NULL);
$ins['vram'] = (isset($_POST['vram']) && !empty($_POST['vram'])? antixs($_POST['vram']):NULL);
$ins['users'] = (isset($_POST['users']) && !empty($_POST['users'])? antixs($_POST['users']):NULL);
$ins['cpu'] = (isset($_POST['cpu']) && !empty($_POST['cpu'])? antixs($_POST['cpu']):NULL);
$ins['ram'] = (isset($_POST['ram']) && !empty($_POST['ram'])? antixs($_POST['ram']):NULL);
$ins['hdd'] = (isset($_POST['hdd']) && !empty($_POST['hdd'])? antixs($_POST['hdd']):NULL);
$ins['eth'] = (isset($_POST['eth']) && !empty($_POST['eth'])? antixs($_POST['eth']):NULL);
$ins['panel'] = (isset($_POST['panel']) && !empty($_POST['panel'])? antixs($_POST['panel']):NULL);
$ins['os'] = (isset($_POST['os']) && !empty($_POST['os'])? antixs($_POST['os']):NULL);
$ins['location']= (isset($_POST['location'])&& !empty($_POST['location'])?antixs($_POST['location']):NULL);
$preset = (isset($_POST['preset']) && !empty($_POST['preset'])?antixs($_POST['preset']):NULL);
$bits = (isset($_POST['bits']) && !empty($_POST['bits'])? antixs($_POST['bits']):NULL);
$bits_eternal = (isset($_POST['bits_eternal']) && !empty($_POST['bits_eternal'])? antixs($_POST['bits_eternal']):0);
$eternal_service= (isset($_POST['eternal_service']) && !empty($_POST['eternal_service'])? antixs($_POST['eternal_service']):0);
$block_a_monthly_payment = (isset($_POST['block_a_monthly_payment']) && !empty($_POST['block_a_monthly_payment'])?antixs($_POST['block_a_monthly_payment']):0);
$sign_dp = base64_encode(json_encode($ins));
if ($block_a_monthly_payment == 1 && $eternal_service == 0){
echo msg_err('err',$lang['orders_var_admin_error']);
require_once '../../wcore/foot.php';
exit();
}
mysqli_query($mysqli,"UPDATE `tarifs` SET `namepack`='$name',`deskpack`='$sign_dp',`preset`='$preset',`bits`='$bits',`bits_eternal`='$bits_eternal',`eternal_service`='$eternal_service',`block_a_monthly_payment`='$block_a_monthly_payment' WHERE `tid` = '$id'");
echo msg_err('suc',$lang['adm_tar_e_t_8']);require_once '../../wcore/foot.php';exit();
} else {
$sql = mysqli_query($mysqli,"SELECT * FROM `tarifs` WHERE `tid` = '$id' LIMIT 1");
if (mysqli_num_rows($sql) == 0){echo msg_err('err',$lang['amd_none_search']);require_once '../../wcore/foot.php';exit();}
$data = mysqli_fetch_object($sql);
$array = array(
'tid' => $data->tid,
'sid' => $data->sid,
'namepack' => $data->namepack,
'desk' => json_decode(base64_decode($data->deskpack)),
'preset' => $data->preset,
'bits' => $data->bits,
'bits_eternal' => $data->bits_eternal,
'block_a_monthly_payment' => $data->block_a_monthly_payment,
'eternal_service' => $data->eternal_service,
);
}
} else {
}
if (!isset($array)){$array = FALSE;}
echo $twig->render('admin_tarifs.tpl', array(
'data' => $array,
'lang' =>$lang,
'act' =>$act,
'type_list'=>$tlist,
'id' => $id,
'crfs'=>_csrf()));
require_once '../../wcore/foot.php';
?>