[PHP] Random mirrors and download quota

2002-08-10 Thread Andrew Conner

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()*100);

$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




[PHP] Printing line x in a file

2002-05-11 Thread Andrew Conner

I have a script where I need to get the text from line number $line in
file $filename then save it to a var ($text) and then print it. For
example, in the file lamb.txt (just an example file):
Mary was
a little lamb, whose
fleece
was as
white as snow.
I need to get line number 3 (fleece) and print it (print $text).
How would I go about this?

Andrew Conner
(All apologies if this messes up and does a multi-post)




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php