"; } else { $sSQL="select n_Credits, n_Views, n_Clicks, n_ID from t_Users where n_ID=".stripjunk($id); $results=mysql_query($sSQL); if(mysql_num_rows($results)>0) { list($n_Credits, $n_Views, $n_Clicks, $banUserID)=mysql_fetch_row($results); $sSQL="update t_Users set n_Credits=n_Credits+(".stripjunk($ratiolow)."/".stripjunk($ratiohigh)."), n_Views=n_Views+1 where n_ID=".stripjunk($id); mysql_query($sSQL); } $sSQL="select * from t_Banners where n_UserID=".stripjunk($id)." and b_Authorised>0"; $results=mysql_query($sSQL); if($ratiohigh>$ratiolow) { $mullow=($ratiolow/$ratiohigh) * 100; } else{ $mullow=95; } if((mysql_num_rows($results)==0 && rand(0,100)>75) || (rand(0,100)>$mullow)) { echo "
"; } else { $sSQL="select n_ID from t_Users where n_Credits>=1 and b_Authedban>0 and n_ID<>".stripjunk($id)." order by rand()"; $results=mysql_query($sSQL); if(mysql_num_rows($results)==0) { echo "
"; } else { list($remoteID)=mysql_fetch_row($results); $sSQL="select n_UserID, s_URL, s_Graphic, n_Category, n_Displays, n_ID, b_Paid, n_ExpireViews, n_ExpireClicks from t_Banners where (b_Authorised>0 and n_UserID=".stripjunk($remoteID)." and b_Paid=0) or ((n_ExpireViews>0 or n_ExpireClicks>0) and b_Paid=1) order by rand() limit 1"; $results=mysql_query($sSQL); list($n_UserID, $s_URL, $s_Graphic, $n_Category, $n_Displays, $banID, $b_Paid, $n_ExpireViews, $n_ExpireClicks)=mysql_fetch_row($results); echo "
"; $sSQL="update t_Banners set n_Displays=n_Displays+1 where n_ID=".stripjunk($banID); mysql_query($sSQL); if($b_Paid==0) { $sSQL="update t_Users set n_Credits=n_Credits-1 where n_ID=".stripjunk($n_UserID); mysql_query($sSQL); } else { if($n_ExpireViews>0) { $sSQL="update t_Banners set n_ExpireViews=n_ExpireViews-1 where n_ID=".stripjunk($banID); mysql_query($sSQL); $sSQL="select * from t_Banners where n_UserID=".stripjunk($n_UserID)." and (b_Authorised>0 and b_Paid<>1) or (b_Paid=1 and (n_ExpireViews>0 or n_ExpireClicks>0))"; $results=mysql_query($sSQL); if(mysql_num_rows($results)==0) { $sSQL="update t_Users set b_Authedban=0 where n_ID=".stripjunk($n_UserID); mysql_query($sSQL); } } } } } } $sSQL="update t_Stats set n_Value=n_Value+1 where s_Name=\"totalviews\""; mysql_query($sSQL); mysql_close(); ?>