Location: PHPKode > projects > Ads Exchange Server > estigi_0.1.1_RC2/zones.php
<?php

/***************************************************************************
 *                             zones.php
 *                            -------------------
 *   begin                : mar, ago 28, 2007
 *   copyright            : (C)
 *   email                : hide@address.com
 *   Desc                 : Banner and Ad Zones
 *
 *
 ***************************************************************************/

define('IN_ADSERVER', true);

include_once("./inc/common.inc.php");

checkLogin($web_address);
 //Restricted Access
get_User_Settings($session['id_User'], 'edit_Cat', $web_address);

/* Declare the TPL */
$zones_Tpl = new tpl($s_path_Tpl . "/zones.tpl");

$s_Warning = "";

function f_Select_Zone($s_Selected, $s_Image, $s_Text){

	if($s_Selected == "text"){
		$s_Selected_Text = "Selected";
		$s_Selected_Img = "";
	}
		else{
			$s_Selected_Text = "";
			$s_Selected_Img = "Selected";
		}

	return $s_Select = "
			<select name='zone_Zone'>
				<option value='0' $s_Selected_Img>".$s_Image."</option>
				<option value='1' $s_Selected_Text>".$s_Text."</option>
			</select>";
}

//Modify a Zone
if(isset($_POST['modify_Zone'])){

	$q = "
		UPDATE ".$db_Pre."zones
		SET dimensions = '".sprintf("%sx%sx%s",$_POST['width'],$_POST['height'],$_POST['max'])."',
			 text = ".$_POST['zone_Zone'].",
			 active = ".(isset($_POST['active']) ? 1 : 0)."
		WHERE id_Zone = ".$_POST['curr_Id_Zone']."
		";

	$q_Mod_Zone = mysql_query($q) or die("Unable to Modify Zone: " . mysql_error());

	$s_Warning = $_lang['zones_Msg_Mod'];

}

//Add a new Zone
if(isset($_POST['new_Zone'])){

	$q = "
		INSERT INTO ".$db_Pre."zones
				(dimensions, text, active)
		VALUES ('".sprintf("%sx%sx%s",$_POST['width'],$_POST['height'],$_POST['max'])."', '" . $_POST['zone_Zone'] . "', 1)
	";

	$q_Add_Zone = mysql_query($q) or die("Unable to Create New Zone: " . mysql_error());

	$s_Warning = $_lang['zones_Msg_Created'];
}

//Select all Existing Zones

$q = "
	SELECT *
	FROM  ".$db_Pre."zones
	ORDER BY text
	";

$q_Get_Zones = mysql_query($q) or die("Unable to Get Zones: " . mysql_error());

$s_Zones = "";

while($row = mysql_fetch_array($q_Get_Zones, MYSQL_ASSOC)){

	$dimm = explode("x", $row['dimensions']);

	$a_Zones_Values[] = array(
		$row['id_Zone'],
		$dimm[0],
		$dimm[1],
		$dimm[2],
		($row['active'] == 1 ? "checked" : ""),
		f_Select_Zone(($row['text'] == 1 ? "text" : ""), $_lang['zones_Image'], $_lang['zones_Text']),
		$_lang['zones_Change']
	);

}

/* Main Array Values */
$a_Zones =  array(
	"{ZONES_HELP_TITLE}" => $_lang['zones_Help_Title'],
	"{ZONES_HELP_TEXT}"  => $_lang['zones_Help_Text'],
	"{ZONES_ADD}"        => $_lang['zones_Add'],
	"{ZONES_DIMM}"       => $_lang['zones_Dimensions'],
	"{ZONES_ACTIVE}"     => $_lang['zones_Active'],
	"{ZONES_TYPE}"       => $_lang['zones_Zone_Type'],
	"{ZONES_ZONE}"       => $_lang['zones_Zone'],
	"{ZONES_DUMMY}"      => f_Select_Zone("", $_lang['zones_Image'], $_lang['zones_Text']),
	"{ZONES_NEW}"        => $_lang['zones_New'],
	"{ZONES_EXISTING}"   => $_lang['zones_Existing']
);

$a_Zones_Keys = array(
	"{ZONES_ID_ZONE}",
	"{ZONES_WIDTH_V}",
	"{ZONES_HEIGHT_V}",
	"{ZONES_MAX_V}",
	"{ZONES_ACTIVE_CHECK}",
	"{ZONES_TYPE_V}",
	"{ZONES_CHANGE}"
);

$zones_Tpl->rblock($a_Zones, "");
$zones_Tpl->rblock_Several($a_Zones_Keys, $a_Zones_Values, "ZONES");
$zones_Tpl->localize_It($_lang);
include_once("./header.inc.php");
/* Print the tpl */
$zones_Tpl->print_Tpl();
include_once("./footer.inc.php");
?>
Return current item: Ads Exchange Server