Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Posts
    32

    * Automatic mirrors for downloading

    I need to know if I have two or three mirrors to a file, so that those mirrors automatically switch by themselves for different ip addresses. for example, if a user comes into my site with an ip address between 1.xxx.xxx.xxx to 99.xxx.xxx.xxx, the download link that shows up is different from the one that will show up for a user whose ip is between 100.xxx.xxx.xxx and 199.xxx.xxx.xxx.

    is there html or php code to achieve this?

    thanks

  2. #2
    Join Date
    Sep 2005
    Location
    Southern California
    Posts
    179
    In PHP, the variable $_SERVER['REMOTE_ADDR'] contains the person's IP address visiting your site. It would not be too difficult to compare the IP addresses, it can be done many ways.

    However, i would suggest a random strategy for mirroring the files on your site. I think you will find the majority of your visitors (at least, for a US site) will come from the first range that you specified. It would be a better idea to have a list of mirrors and then randomly select one.

  3. #3
    Join Date
    Dec 2005
    Posts
    32
    How can I make the random list idea into reality? I don't know much PHP

  4. #4
    Join Date
    Sep 2005
    Location
    Southern California
    Posts
    179
    PHP Code:
    $filename="somefile.exe";
    $mirrors=array("http://mirror1.com","http://mirror2.com","http://mirror3.com");
    echo 
    "downloading your file from: ${mirrors[rand(0,count($mirrors)-1)]}/$filename";

    //or a more simple version:
    $filename="somefile.exe";
    $mirrors=array("http://mirror1.com","http://mirror2.com","http://mirror3.com");
    $mirror=$mirrors[rand(0,count($mirrors)-1)];
    echo 
    "downloading your file from: $mirror/$filename"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •