/******************************************************************************
Power Banner Manager 2.0 !
(banner.php file)
Copyright Armin Kalajdzija, 2003.
E-Mail: armin@akde.com
WebSite: http://www.akde.com
******************************************************************************/
include "pbmadmin/config.inc.php";
include "pbmadmin/open.inc.php";
$bcount = 0;
$found = false;
$fbcount = 0;
$query = "SELECT * FROM powerban";
if (isset($bid) && ($bid <> "")) {
$query .= " WHERE id = '$bid'";
}else if (isset($uid) && ($uid <> "") or (isset($zid) && ($zid <> ""))) {
$query .= " WHERE ";
if (isset($uid) && ($uid <> "")) {
$query .= "uid = '$uid'";
}
if (isset($uid) && ($uid <> "") && (isset($zid) && ($zid <> ""))) {
$query .= " AND ";
}
if (isset($zid) && ($zid <> "")) {
$query .= " zone = '$zid'";
}
}
$result = mysql_query($query) or die("Unable to get banner list");
while ($line = mysql_fetch_array($result)) {
$bcount = $bcount + 1;
$banners[$bcount] = $line;
}
while ($found <> true) {
if ($fbcount == $bcount) {
die("No more banners to display");
}else{
$dban = rand(1,$bcount);
if (($banners[$dban]["dis_times"] > $banners[$dban]["dised_times"]) or ($banners[$dban]["dis_times"] == 0)) {
$found = true;
$banners[$dban]["dised_times"] += 1;
$query = "UPDATE powerban SET dised_times=".$banners[$dban]["dised_times"]." WHERE id=".$banners[$dban]["id"];
$result = mysql_query($query) or die("Query failed");
if ($banners[$dban]["type"] == 1) {
if ($banners[$dban]["dtype"] == 1) {
echo "";
}else if ($banners[$dban]["dtype"] == 2) {
$fp = fopen ("pbmadmin/tmp/bantemp.htm", "w");
fputs($fp,"