Further to my post above, here are the changes I made to PPN's hack to make it randomise. As I said, let us all work together to make my code more efficient.
Willie
////////////////////START//////////////////////////
In global.php, FIND:
if(isset($advert_forumid)) {
$foruminfo = getforuminfo($advert_forumid);
$advert=$DB_site->query_first("SELECT * FROM ads WHERE LOCATE(CONCAT(',',forumid,','),',$foruminfo[parentlist],')>0 AND
time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()");
} else {
$advert=$DB_site->query_first("SELECT * FROM ads WHERE wholeforum='1' AND time>=".time()." AND (exposed<=exposures OR
exposures=0) ORDER BY RAND()");
}
AND REPLACE IT WITH:
$DB_site;
$sql="SELECT * FROM ads WHERE LOCATE(CONCAT(',',forumid,','),',$foruminfo[parentlist],')>0 AND time>=".time()." AND (exposed<=exposures OR exposures=0) ORDER BY RAND()";
$advert1 = mysql_query($sql);
$advert2 = mysql_query($sql);
$adcounter=0;
while($countrow = mysql_fetch_row($advert1))
{
$adcounter++;
}
$act1=rand(0,$adcounter-1);
$adcounter3=0;
while($countrow3 = mysql_fetch_row($advert2))
{
if($adcounter3==$act1)
{
$DB_site->query("UPDATE ads SET exposed=exposed+1 WHERE adid='$countrow3[0]'");
eval("\$advert = trim(\"".str_replace("\'", "'", addslashes($countrow3[7]))."\");");
}
$adcounter3++;
}
///////////////END///////////////////
I just noticed that there is another block of code that should also be included in the Find It and Replace above, essentially it's the code immediately following that set out above and beginning with $DB_site->query("UPDATE ads SET exposed - one query only.
|