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

/***************************************************************************
 *                             pickup.php
 *                            -------------------
 *   begin                : dom, set 9, 2007
 *   copyright            : (C)
 *   email                : hide@address.com
 *   Desc                 : Pickup codes
 *
 *
 ***************************************************************************/

define('IN_ADSERVER', true);

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

checkLogin($web_address);

/* Declare the TPL */
$pick_Up_Tpl = new tpl($s_path_Tpl . "/pickup.tpl");

$s_Div = "--";

//Create pick up code
if(isset($_POST['create_code'])){

	$a_Zone = explode($s_Div, $_POST['zones']);
	$a_Img_Specs = explode("x", $a_Zone[1]);

	$s_Warning = $_lang['pickup_Msg_Copy'];
	$s_Warning .=
				"&lt;iframe align=top width='". $a_Img_Specs[0] ."' height='". $a_Img_Specs[1] ."' marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no
				src='".$web_address."/serveads.php?site=".$_POST['websites']."&wid=".$session['id_User']."&zone=".$a_Zone[0]."&t=".$_POST['target']."'> &lt;/iframe&gt;";

	//Create credits registry in case there is none
	$q = "
		SELECT id_User
		FROM ".$db_Pre."credits
		WHERE id_User = ".$session['id_User']."
		AND id_Zone = ".$a_Zone[0]."
	";

	$q_Get_Credits = mysql_query($q) or die("Unable to Get Zone Credits: " . mysql_error());

	if(mysql_num_rows($q_Get_Credits) < 1){
		$q = "
			INSERT INTO ".$db_Pre."credits (id_User, id_Zone)
			VALUES (".$session['id_User'].",".$a_Zone[0].")
		";

		$q_Assign_Credits = mysql_query($q) or die("Unable to Create Credits Registry: " . mysql_error());

	}

}

//Get websites
$q = "
	SELECT id_Website, name
	FROM  ".$db_Pre."websites
	WHERE id_User = ".$session['id_User']."
	ORDER BY name
	";

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

if(mysql_num_rows($q_Get_Websites) > 0){
	while($row = mysql_fetch_array($q_Get_Websites, MYSQL_ASSOC)){
		$s_Websites .= "<option value='".$row['id_Website']."'>".$row['name']."</option>";
		$s_Stop = 0;
	}
}
	else{
		$s_Warning = $_lang['pickup_Msg_No_Sites'];
		$s_Stop = 1;
	}

if($s_Stop == 0){
	//Select all zones
	$q = "
		SELECT *
		FROM ".$db_Pre."zones
		WHERE active = 1
		ORDER BY text
		";

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

	if(mysql_num_rows($q_Get_Zones) > 0){
		while($row = mysql_fetch_array($q_Get_Zones, MYSQL_ASSOC)){

	/* Human readable */
	$a_Img_Specs = explode("x", $row['dimensions']);
	/* Format Text ads */
	if($row['text'] == 1){
		$add_Detail = sprintf($_lang['ads_Text_Text'], $a_Img_Specs[0], $a_Img_Specs[1], $a_Img_Specs[2]);
	}
	else{
		$add_Detail = sprintf($_lang['ads_Text_Img'], $a_Img_Specs[0], $a_Img_Specs[1], $a_Img_Specs[2]);
	}
		//$s_Zones .= "<option value='".$row['id_Zone'] . $s_Div . $row['dimensions'] . $s_Div . $row['text'] . "'>".($row['text'] == 1 ? $_lang['pickup_Text'] : $_lang['pickup_Img']). $row['dimensions'] . "</option>";
		$s_Zones .= "<option value='".$row['id_Zone'] . $s_Div . $row['dimensions'] . $s_Div . $row['text'] . "'>".$add_Detail. "</option>";
		}
	}
		else{
			$s_Warning = $_lang['pickup_Msg_No_Cats'];
	}
}

$a_Pick_Up = array(
	"{PICK_HELP_TITLE}" => $_lang['pickup_Help_Title'],
	"{PICK_HELP_TEXT}" => $_lang['pickup_Help_Options'],
	"{PICK_OPTIONS}" => $_lang['pickup_Options'],
	"{PICK_WEBSITE}" => $_lang['pickup_Website'],
	"{PICK_WEBSITES_SELECT}" => $s_Websites,
	"{PICK_ZONE}" => $_lang['pickup_Zone'],
	"{PICK_ZONE_SELECT}" => $s_Zones,
	"{PICK_TARGET}" => $_lang['pickup_Target'],
	"{PICK_BLANK}" => $_lang['pickup_Blank'],
	"{PICK_SAME}" => $_lang['pickup_Same'],
	"{PICK_GIVE_ME}" => $_lang['pickup_Give_Me']
);

/* Replace main TPL */
$pick_Up_Tpl->rBlock($a_Pick_Up, "");

include_once("./header.inc.php"); 
/* Print the tpl */
$pick_Up_Tpl->print_Tpl();
include_once("./footer.inc.php");

?>
Return current item: Ads Exchange Server