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

Размер файла: 1.98Kb
<?php
include("include/vars.php");
// Select an advertisment randomly
$adquery=mysql_query("SELECT * FROM $adverts_table WHERE active='yes' ORDER BY RAND() LIMIT 1") or die (mysql_error());
	if(mysql_num_rows($adquery) > 0) {
	$adresult=mysql_fetch_array($adquery);
	$ip = getenv("REMOTE_ADDR");
	$browser=getenv("HTTP_USER_AGENT");
	$adid=$adresult[adid];
?>
<html>
<body>
<font face="verdana" size="2"><div align="center"><b><a href="click.php?adid=<?php echo $adid ?>" target="_blank"><?php echo $adresult[linktext] ?></a></b> <?php echo $adresult[adtext] ?></div></font>
</body>
</html>
<?php
	$date=date("Y/m/d");
	mysql_query("INSERT INTO $adviews_table (adid, date, browser, ip) VALUES ('$adid', '$date', '$browser', '$ip')") or die (mysql_error());
	mysql_query("UPDATE $adverts_table SET views=views+1 WHERE adid='$adid'") or die (mysql_error());
	if($adresult[maxviews]>0) {
		if($adresult[views]>=$adresult[maxviews]) {
			mysql_query("UPDATE $adverts_table SET active='no' WHERE adid='$adid'") or die (mysql_error());
// Send mails to client and admin
// First include all necessary files
			require("include/functions.php");
			$lang=setlanguage();
			require("language/$lang");
			$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");						
			}
		}
	}
	else {
?>
<html>
<body>
<font face="verdana" size="2"><div align="center"><?php echo stripslashes($standardad) ?></div></font>
</body>
</html>
<?php
	}
?>