how about using the counter to store an id of the mirrors instead of randomly picking one? this will provide you a sequential traverse through all mirror sites.
if there are 10 sites, the counter will always be from 0 -> 9. this way each mirror site will have equal share on hits. so if the counter == 2, your script will know that the next hit will be to mirror site 2. $_nextSite = (isset($_nextSite))?++$_nextSite % 10:0; the above code will always ensure the counter counts from: 0 -> 9 -> 0 -> ... this way, you can store all counters (into database?) on the main site for all mirrors. > > "Andrew Conner" <[EMAIL PROTECTED]> escreveu na mensagem > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >>Hello, >>I have a script (at bottom) that, upon loading, will randomly select a >>mirror or primary server (on average, the primary servers will be selected >>twice as much). It all works good, but now, I have to add a "quota > > manager" > >>that will, for both mirrors, limit the times the file can be downloaded to >>1200 times (there is only one file being downloaded). I have thought about >>storing a text file for each of the two mirrors that shows the current > > count > >>of downloads, and it will be checked if the mirror is randomly selected > > and > >>if it is above 1200, will randomly select another server, and if it isn't, >>will just add one to it and update the file. How would I go about this, or >>is there a better way to do this? >>Thanks in advance. >>Andrew Conner >> >>The script (I know it doesn't use the best design, but it works, any > > better > >>ways of doing this?): >>---------------- >><? >> >>// This array holds the servers, and has a double entry for the primary >>servers >> >>$adArr = array("http://www.someprimaryserver.com/file.exe", >> >>"http://www.someprimaryserver.com/file.exe", >> >>"http://www.someprimaryserver2.com/file.exe", >> >>"http://www.someprimaryserver2.com/file.exe", >> >>"http://www.someprimaryserver3.com/file.exe", >> >>"http://www.someprimaryserver3.com/file.exe", >> >>"http://www.someprimaryserver4.com/file.exe", >> >>"http://www.someprimaryserver4.com/file.exe", >> >>"http://www.somemirror.com/file.exe", >> >>"http://www.somemirror2.com/file.exe"); >> >>// This randomly gets a server... >> >>srand((double)microtime()*1000000); >> >>$wOne = rand(0, 9); >> >>$choice = $adArr[$wOne]; >> >>// This fwds the user to the server picked. >> >>// Somewhere in here needs to be the mirror stuff... >> >>header("Location: $choice"); >> >>?> >> >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php