Просмотр файла MyLounge/myred/click.php

Размер файла: 1.49Kb
<?php
include("include/vars.php");
// Select the advertisment
$adquery=mysql_query("SELECT * FROM $adverts_table WHERE adid='$adid'") or die (mysql_error());
if(mysql_num_rows($adquery) > 0) {
	$adresult=mysql_fetch_array($adquery);
	$date=date("Y/m/d");
	$ip=getenv("REMOTE_ADDR");
	$browser=getenv("HTTP_USER_AGENT");
	$adlink=$adresult[adlink];
	mysql_query("INSERT INTO $adclicks_table (adid, date, browser, ip) VALUES ('$adid', '$date', '$browser', '$ip')") or die (mysql_error());
	mysql_query("UPDATE $adverts_table SET hits=hits+1,lastip='$ip' WHERE adid='$adid'") or die (mysql_error());
	if($adresult[maxhits]>0) {
		if($adresult[hits]>=$adresult[maxhits]) {
			mysql_query("UPDATE $adverts_table SET active='no' WHERE adid='$adid'") or die (mysql_error());
// Send mails to client and admin
			$userid=$adresult[userid];
			$client_email=mysql_fetch_array(mysql_query("SELECT email FROM $advertiser_table WHERE userid='$userid'"));
			$subject="An advert has ended";
			$body="Hello!\n\nThe advert with the id $adid has reached its maximum views or hits.\nYou may views its stats online in your clients area.";
		   	mail($client_email[0],$subject,$body,"From: $adminmail\nReply-To: $adminmail");
			$body2="Hello!\n\nThe advert with the id $adid has reached its maximum views or hits.\nAn email has been sent to the client.";
		   	mail($adminmail,$subject,$body2,"From: $adminmail\nReply-To: $adminmail");		
			}
		}
	header("Location: $adlink");
	}
	else {
	errormsg($text_106);
	}
?>