'; $bbadOptions['opt_0']='R'; bb_update_option('bbad_options',$bbadOptions); } function bbad_ad_block(){ global $bbAds,$bbadOptions,$bbad_counter,$bb_alt; $bbad_counter++; $bbadOptions=bb_get_option('bbad_options'); if($bbad_counter<2){ for($x=0;$x<10;$x++){ if('' != $bbadOptions['ad_'.$x] && '' != $bbadOptions['opt_'.$x]){ $temp=$bbadOptions['opt_'.$x]; if($temp=='r' || $temp=='R'){ // Random post, chose a post number that exists $GFP=get_forum_posts(); $PPP=bb_get_option('page_topics'); // PPP = Posts displayed Per Page $LastPage=ceil($GFP/$PPP); if($PPP > $GFP){ // Single page, random between 0 and Total Posts in Topic (GFP) $temp=rand(0,$GFP); }else{ if($_GET['page']==$LastPage){ // Random between 0 and ( Total Posts - Posts Per Page ) $temp=rand(0,($GFP-$PPP)); }else{ // Random between 0 and full page of posts $temp=rand(0,$PPP); } } } $bbAds[$temp]=$bbadOptions['ad_'.$x]; } } } if(array_key_exists($bbad_counter,$bbAds)){ echo '