Okay frustrated by the lack of more then 1 add per call i took it apon my self to rewrite small part of the code.
in the ad.php
now what you need to do is update how you call the banner
<?php AdServe(3,"home"); ?> will server up a max of 3 random banners.
if there is less matchs it will server all of them
I did not test with the other method of embed it. post your feedback
Jonathon
replace the function ri_AdServe_GetBanner starts about line 151
function iri_AdServe_GetBanner($quantity=1, $zone='' ) {
global $wpdb;
global $userdata;
$table_name = $wpdb->prefix . "adserve";
$ret="";
# get banner
$wherecond="((credits = -1) or (credits > 0)) AND (active = 1) AND (concat(keywords,' ') LIKE '%".$zone." %')";
$numrows = $wpdb->get_var("SELECT count(id) FROM $table_name WHERE $wherecond;");
if($numrows > 0) {
usleep(2000);
$bannum = array();
$temp = null;
if($numrows <= $quantity) {
$bannerIDs = $wpdb->get_results("SELECT * FROM $table_name WHERE $wherecond ");
$ret="\n\n<!-- Begin AdServe code -->\n";
shuffle($bannerIDs);
foreach($bannerIDs as $rk ) {
$ret.="<a target='_blank' href='".get_settings('siteurl')."/wp-content/plugins/wp-adserve/adclick.php?id=$rk->id' style='margin:0px;border:0px;'><img src='$rk->src' alt='$rk->title' /></a>";
get_currentuserinfo();
if($userdata->user_login != $rk->user) {
if($rk->credits > 0) {
$results = $wpdb->query( "update $table_name set credits=credits-1 where id=$rk->id" );
}
$results = $wpdb->query( "update $table_name set impressions=impressions+1 where id=$rk->id" );
}
}
$ret.="\n<!-- End AdServe code -->\n\n";
} else if($numrows >= $quantity) {
$bannerIDs = $wpdb->get_results("SELECT * FROM $table_name WHERE $wherecond order by rand() limit $quantity");
$ret="\n\n<!-- Begin AdServe code -->\n";
shuffle($bannerIDs);
foreach($bannerIDs as $rk ) {
$ret.="<a target='_blank' href='".get_settings('siteurl')."/wp-content/plugins/wp-adserve/adclick.php?id=$rk->id' style='margin:0px;border:0px;'><img src='$rk->src' alt='$rk->title' /></a>";
get_currentuserinfo();
if($userdata->user_login != $rk->user) {
if($rk->credits > 0) {
$results = $wpdb->query( "update $table_name set credits=credits-1 where id=$rk->id" );
}
$results = $wpdb->query( "update $table_name set impressions=impressions+1 where id=$rk->id" );
}
}
$ret.="\n<!-- End AdServe code -->\n\n";
} else {
$bannum = mt_rand(1, $numrows)-1;
if ($bannum>=0) {
$rk = $wpdb->get_row("SELECT * FROM $table_name WHERE $wherecond LIMIT 1 OFFSET $bannum;");
$ret="\n\n<!-- Begin AdServe code : banner:$zone-$bannum/$numrows -->\n";
$ret.="<a target='_blank' href='".get_settings('siteurl')."/wp-content/plugins/wp-adserve/adclick.php?id=$rk->id' style='margin:0px;border:0px;'><img src='$rk->src' alt='$rk->title' /></a>";
$ret.="\n<!-- End AdServe code -->\n\n";
get_currentuserinfo();
if($userdata->user_login != $rk->user) {
if($rk->credits > 0) {
$results = $wpdb->query( "update $table_name set credits=credits-1 where id=$rk->id" );
}
$results = $wpdb->query( "update $table_name set impressions=impressions+1 where id=$rk->id" );
}
}
}
}
return $ret;
}