Zadarmo.cz Lsu.cz Webhosting Google.com Sms
"; echo mysql_error(); page_footer(); exit; } // Display a custom error message and die function php_die($title="Error", $message="Unkown error") { ?>

$value"; break; case "==": $inclusive[] = "bannerID = $value"; break; } } } $where_exclusive = !empty($exclusive) ? implode(" AND ", $exclusive): ""; $where_inclusive = !empty($inclusive) ? implode(" OR ", $inclusive): ""; $where = sprintf("$where_inclusive %s $where_exclusive", (!empty($where_inclusive) && !empty($where_exclusive)) ? "AND": ""); $where = trim($where); if(!empty($where)) { $where .= " AND "; } $select = "SELECT bannerID, banner, format, width, height, alt, bannertext, url FROM $phpAds_tbl_banners WHERE $where active = 'true' "; if($clientID != 0) { $select .= " AND clientID = $clientID "; } if(is_string($what) && !ereg("[0-9]x[0-9]", $what)) { switch($what) { // Get all HTML banners case "html": $select .= " AND format = 'html' "; break; //Not any of the special words (i.e. 'html'), So, must be a keyword default: $select .= " AND ("; $what_array = explode(",",$what); // changed acording to the post from phpAds mailing list //From: Wim Godden //Date: Sat Jun 17, 2000 12:08pm //Subject: [phpAds] Solution to 2 problems : keywords and limited banner selection for($k=0; $k */ $select .= "keyword = 'global') "; } //switch($what) } elseif(is_int($what)) { $select .= " AND bannerID = $what "; } else { list($width, $height) = explode("x", $what); // Get all banners with the specified width/height $select .= " AND width = $width AND height = $height "; } // print($select); $res = @mysql_db_query($phpAds_db, $select); if(!$res) return(false); $rows = array(); while ($tmprow = @mysql_fetch_array($res)) { $rows[] = $tmprow; } $date = getdate(time()); $request = array('remote_host' => $REMOTE_ADDR, 'user_agent' => $HTTP_USER_AGENT, 'weekday' => $date['wday']); count($rows) > 0 ? $cr = count($rows) : $cr = 1; mt_srand((double)microtime()*1000000+ 1); $randval = mt_rand() % $cr; // this can be infinite loop that's why thereis check for $cnt for($cnt=0; (!empty($displayed[$rows[$randval]["id"]]) or !acl_check($request, $rows[$randval])) and $cnt<$cr*100; $cnt++) { $randval = mt_rand() % $cr; } $row = $rows[$randval]; $displayed[$row["id"]]=1; return($row); } // Log an adview for the banner with $bannerID function log_adview($bannerID) { global $phpAds_log_adviews, $phpAds_ignore_hosts, $phpAds_reverse_lookup, $phpAds_insert_delayed; global $row, $phpAds_tbl_adviews; global $REMOTE_HOST, $REMOTE_ADDR; if(!$phpAds_log_adviews) { return(false); } if($phpAds_reverse_lookup) { $host = isset($REMOTE_HOST) ? $REMOTE_HOST : @gethostbyaddr($REMOTE_ADDR); } else { $host = $REMOTE_ADDR; } // Check if host is on list of hosts to ignore $found = 0; while(($found == 0) && (list($key, $ignore_host)=each($phpAds_ignore_hosts))) { if(eregi($ignore_host, $host)) // host found in ignore list { $found = 1; } } if($found == 0) { $res = @mysql_db_query($GLOBALS["phpAds_db"], sprintf(" INSERT %s INTO $phpAds_tbl_adviews VALUES ( '$bannerID', null, '$host' ) ", $phpAds_insert_delayed ? "DELAYED": "")); } } // view a banner function view($what, $clientID=0, $target = "", $withtext=0, $context=0) { global $phpAds_db, $REMOTE_HOST; if(!is_int($clientID)) { $target = $clientID; $clientID = 0; } @mysql_pconnect($GLOBALS["phpAds_hostname"], $GLOBALS["phpAds_mysqluser"], $GLOBALS["phpAds_mysqlpassword"]); $row = get_banner($what, $clientID, $context); if(!empty($row["bannerID"])) { if(!empty($target)) { $target = " target=\"$target\""; } if($row["format"] == "html") { if(!empty($row["url"])) { echo ""; } echo $row["banner"]; if(!empty($row["url"])) { echo ""; } } else { echo "\"$row[alt]\""; if($withtext && !empty($row["bannertext"])) { echo "
\n".$row["bannertext"].""; } } } log_adview($row["bannerID"]); return($row["bannerID"]); } function view_t($what, $target = "") { view ($what, $target, 1); } ?>