php:
|
<?php
/************************************************************************/
/* PHP Coded System */
/* =========================== */
/* */
/* Avertising Block with Random for phpnuke 7.6 */
/* */
/* Copyright (c) 2006 ld-software.co.uk */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (eregi("block-Advertising-Random.php",$_SERVER[PHP_SELF])) {
Header("Location: ../index.php");
die();
}
global $prefix, $db;
$numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_banner WHERE type='1' AND active='1'"));
$result_max = $db->sql_fetchrow($db->sql_query("SELECT MAX(cid) as max_cid FROM ".$prefix."_banner WHERE position='1' AND active='1'"));
$cid_max = $result_max['max_cid'];
$result_min = $db->sql_fetchrow($db->sql_query("SELECT MIN(cid) as min_cid FROM ".$prefix."_banner WHERE position='1' AND active='1'"));
$cid_min = $result_min['min_cid'];
$bannum = rand($cid_min, $cid_max);
$row = $db->sql_fetchrow($db->sql_query("SELECT bid, imageurl, alttext FROM ".$prefix."_banner WHERE type='1' AND active='1' LIMIT $bannum,1"));
$bid = intval($row['bid']);
$imageurl = $row['imageurl'];
$alttext = $row['alttext'];
if (!is_admin($admin)) {
$db->sql_query("UPDATE ".$prefix."_banner SET impmade=impmade+1 WHERE bid='$bid'");
}
if($numrows>0) {
$row2 = $db->sql_fetchrow($db->sql_query("SELECT cid, imptotal, impmade, clicks, date FROM ".$prefix."_banner WHERE bid='$bid'"));
$cid = intval($row2['cid']);
$imptotal = intval($row2['imptotal']);
$impmade = intval($row2['impmade']);
$clicks = intval($row2['clicks']);
$date = $row2['date'];
/* Check if this impression is the last one and print the banner */
if (($imptotal <= $impmade) AND ($imptotal != 0)) {
$db->sql_query("UPDATE ".$prefix."_banner SET active='0' WHERE bid='$bid'");
}
$content = "<center><br><a href=\"banners.php?op=click&bid=$bid\" target=\"_blank\"><img src=\"$imageurl\" border=\"1\" alt=\"$alttext\" title=\"$alttext\"></a><br><br></center>";
}
?>
|