"; $article = ereg_replace($pattern, $replacement, $article); $pos++; } } closedir($dir); } srand((double)microtime()*1000000); $randval = rand(1, 10000); $pattern = "\[RAND\]" ; $replacement = "$randval"; $article = ereg_replace($pattern, $replacement, $article); // [ROTOR('/images/carfr/ca_rfr_%03d.gif',1,12)] $article = preg_replace ("/\[ROTOR\('(.*)',([0-9]{1,5}),([0-9]{1,5})\)\]/e", "sprintf(\"\\1\", rand(\\2, \\3))", $article); return $article; } function CallBanner($position){ global $DB, $DBID; $position = $position + 1; $position = $position - 1; $SQL = "SELECT count(*) as cnt FROM banblocks WHERE position='$position' and visible='Y'"; $result = mysql_query($SQL, $DBID); if( $result == 0 ){ return; } $cnt = mysql_result($result, 0, "cnt"); if( $cnt == 0 ){ @mysql_freeresult($result); return; } if( $cnt == 1 ){ $randbanno = 0 ; }else{ srand((double)microtime()*1000000); $randbanno = rand(0,$cnt-1); } $SQL = "SELECT * FROM banblocks WHERE position='$position' and visible='Y' limit $randbanno,1"; $result = mysql_query($SQL, $DBID); if( ($result>0) && (mysql_num_rows($result)>0) ){ $id = mysql_result($result, 0, "id"); $name = mysql_result($result, 0, "name"); $banblock = mysql_result($result, 0, "banblock"); $visible = mysql_result($result, 0, "visible"); $position = mysql_result($result, 0, "position"); return PrepareImagesBanBlocks($id, $banblock); } @mysql_freeresult($result); return ""; } ?>