"; } $link = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname) or die(banniere_defaut()); if(!$id) { // - Bannière par défaut banniere_defaut(); } else { $sSQL="select n_Credits, n_Views, n_Clicks, n_ID from t_Users where n_ID=".stripjunk($id); $results=$link->query($sSQL); if($results->num_rows>0) { list($n_Credits, $n_Views, $n_Clicks, $banUserID)=$results->fetch_row(); $sSQL = "update t_Users set n_Credits=n_Credits+(".stripjunk($ratiolow)."/".stripjunk($ratiohigh)."), n_Views=n_Views+1 where n_ID=".stripjunk($id); $link->query($sSQL); } $sSQL = "select * from t_Banners where n_UserID=".stripjunk($id)." and b_Authorised>0"; $results=$link->query($sSQL); if( $ratiohigh > $ratiolow) { $mullow = ( $ratiolow / $ratiohigh ) * 100; } else { $mullow=95; } if(($results->num_rows==0 && rand(0,100)>75) || (rand(0,100)>$mullow)) { // - Bannière par défaut banniere_defaut(); } else { //$sSQL="select n_ID from t_Users where n_Credits >= 1 and b_Authedban > 0 and n_ID <>".stripjunk($id)." order by rand() limit 1"; $sSQL="select distinct t_Users.n_ID FROM t_Banners, t_Users WHERE t_Users.n_ID = t_Banners.n_UserID AND t_Users.n_Credits >= 1 AND t_Users.b_Authedban > 0 AND t_Banners.b_Authorised > 0 and t_Users.n_ID <> ".stripjunk($id)." order by rand() limit 1"; $results=$link->query($sSQL); if( $results->num_rows == 0) { // - Bannière par défaut banniere_defaut(); } else { list($remoteID)=$results->fetch_row(); $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=$link->query($sSQL); if( $results->num_rows == 0 ) { // - Bannière par défaut banniere_defaut(); } else { list($n_UserID, $s_URL, $s_Graphic, $n_Category, $n_Displays, $banID, $b_Paid, $n_ExpireViews, $n_ExpireClicks)=$results->fetch_row(); echo "
"; $sSQL = "update t_Banners set n_Displays=n_Displays+1 where n_ID=".stripjunk($banID); $link->query($sSQL); if( $b_Paid == 0 ) { $sSQL = "update t_Users set n_Credits=n_Credits-1 where n_ID=".stripjunk($n_UserID); $link->query($sSQL); } else { if($n_ExpireViews>0) { $sSQL = "update t_Banners set n_ExpireViews=n_ExpireViews-1 where n_ID=".stripjunk($banID); $link->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=$link->query($sSQL); if( $results->num_rows == 0 ) { $sSQL = "update t_Users set b_Authedban=0 where n_ID=".stripjunk($n_UserID); $link->query($sSQL); } } } } } } } $sSQL = "INSERT INTO t_stats_banners (id,n_ID,n_date,s_url) VALUES (NULL ," . stripjunk($id) . ", NOW(), '" . $_SERVER['HTTP_REFERER'] . "')"; $link->query($sSQL); // - Mise à jour des statistiques globales $sSQL="update t_Stats set n_Value=n_Value+1 where s_Name=\"totalviews\""; $link->query($sSQL); mysqli_close($link); ?>