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

/***************************************************************************
 *                             logads.php
 *                            -------------------
 *   begin                : jue, ago 30, 2007
 *   copyright            : (C)
 *   email                : hide@address.com
 *   Desc                 : Log views
 *
 *
 ***************************************************************************/

/*
	It is invoked in this form
	<script language="JavaScript" src="http://serversDNS/serveads.php?wid=###&type=###"> </script>
	Where:
		wid = WebSite Id
		type = Banner Type
*/


define('IN_ADSERVER', true);

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

//Fraud Prevention
$s_Fraud = 0;
$s_Website = "";

//Get ad details
$q = "
	SELECT ".$db_Pre."ads.id_Zone, ".$db_Pre."ads.id_User, ".$db_Pre."groups.click_Ratio, ".$db_Pre."ads.link
	FROM ".$db_Pre."ads
	INNER JOIN ".$db_Pre."users ON ".$db_Pre."users.id_User = ".$db_Pre."ads.id_User
	INNER JOIN ".$db_Pre."groups ON ".$db_Pre."users.id_Group = ".$db_Pre."groups.id_Group
	WHERE ".$db_Pre."ads.id_Ads = ".$_GET['idad']."
	";

$q_Details = mysql_query($q) or die("Unable to Get Details" . mysql_error());

$row = mysql_fetch_array($q_Details, MYSQL_ASSOC);
	$s_Click_Ratio = $row['click_Ratio'];
	$i_Id_User = $row['id_User'];
	$i_Id_Zone = $row['id_Zone'];
	$s_Link = "http://" . $row['link'];

//Register the click
$q = "
	UPDATE ".$db_Pre."view_Log
	SET clicked = 1
	WHERE id_Ads = ".$_GET['idad']."
	AND timestamp = ".$_GET['t']."
	";

$q_Add_Click = mysql_query($q) or die("Unable to Add a Click" . mysql_error());

//Add Credits
$q = "
	UPDATE ".$db_Pre."credits
	SET credits = credits + ".$s_Click_Ratio."
	WHERE id_User = ".$i_Id_User."
	AND id_Zone = ".$i_Id_Zone."
	AND credits >= 0
	";

$q_Add_Views_Left = mysql_query($q) or die("Unable to Add Credits" . mysql_error());

//Register the click to the ad itself
$q = "
	UPDATE ".$db_Pre."ads
	SET clicks = clicks + 1
	WHERE id_Ads = ".$_GET['idad']."
	AND active = 1
	";

$q_Add_Views_Left = mysql_query($q) or die("Unable to register the click to the ad" . mysql_error());

if($s_Link != ""){
	refrescar(($s_Link != "" ? $s_Link : $web_address), 0, 1);
}


?>
Return current item: Ads Exchange Server