View file www/admin/ads/action.php

File size: 2.65Kb
<?
define("ADMIN_AUTHORIZATION",1);
include("../../../includes/common.php");

$table = "exchanger_ads";

$id = $_GET['id']==""?$_POST['id']:$_GET['id'];
$group_ids = $_GET['group_ids']==""?$_POST['group_ids']:$_GET['group_ids'];
$action = trim($_GET['action']=="")?trim($_POST['action']):trim($_GET['action']);

if(is_numeric($id)){
	$group_ids = Array();
	$group_ids[0]=$id;
}

$result_flag = true;

if(sizeof($group_ids)==0||!is_array($group_ids)){
	header("Location: ./index.php?l_pager");
	exit;
}

$url = "index.php";

switch($action){
	case "c_delete":
		$url = "c_index.php";
		$flag = true;
		foreach($group_ids as $value){
    		if(!(@DeleteRecord("exchanger_codes",$value))){
				$result_flag = false;
				break;
			}

		}
		break;
	case "c_activate":
		$url = "c_index.php";
		$flag = true;
		foreach($group_ids as $value){
			if(!(@UpdateRecord("exchanger_codes",array("status"=>1),$value))){
				$result_flag = false;
				break;
			}
		}
		break;
	case "c_unactivate":
		$url = "c_index.php";
		$flag = true;
		foreach($group_ids as $value){
			if(!(@UpdateRecord("exchanger_codes",array("status"=>0),$value))){
				$result_flag = false;
				break;
			}
		}
		break;
	case "p_delete":
		$url = "p_index.php";
		$flag = true;
		foreach($group_ids as $value){
    		if(!(@DeleteRecord("partner_ads",$value))){
				$result_flag = false;
				break;
			}

		}
		break;
	case "p_activate":
		$url = "p_index.php";
		$flag = true;
		foreach($group_ids as $value){
			if(!(@UpdateRecord("partner_ads",array("status"=>1),$value))){
				$result_flag = false;
				break;
			}
		}
		break;
	case "p_unactivate":
		$url = "p_index.php";
		$flag = true;
		foreach($group_ids as $value){
			if(!(@UpdateRecord("partner_ads",array("status"=>0),$value))){
				$result_flag = false;
				break;
			}
		}
		break;
	case "delete":
		$flag = true;
		foreach($group_ids as $value){
    		if(!(@DeleteRecord($table,$value))){
				$result_flag = false;
				break;
			}

		}
		break;
	case "activate":
		$flag = true;
		foreach($group_ids as $value){
			if(!(@UpdateRecord($table,array("status"=>1),$value))){
				$result_flag = false;
				break;
			}
		}
		break;
	case "unactivate":
		$flag = true;
		foreach($group_ids as $value){
			if(!(@UpdateRecord($table,array("status"=>0),$value))){
				$result_flag = false;
				break;
			}
		}
		break;
}
if($result_flag){
	$_SESSION['STATUS_MSG'] = "Операция успешно завершена.";
	header("Location: ./$url?l_pager");
}
else{
	$_SESSION['ERROR_MSG'] = "Ошибка. Возможно стоит запрет на операцию в базе данных.";
	header("Location: ./$url?l_pager");
}
exit;
?>