Icy Phoenix

     
 


Post new topic  This topic is locked: you cannot edit posts or make replies. 
Page 1 of 1
 
 
Reply with quote Download Post
Post Using a mirror automatically for hits from popular websites 
 
Using a mirror automatically for hits from popular websites
Posted by Martin Porcheron

This article was initially written on the 17th December 2006, it was last updated on 22nd of May 2007.


Ok, so you’ve spent ages building your website, put quite a bit of money into the hosting and then to top it off, you write a gripping article that circulates around major websites like a disease. Your server gets hammered by thousands of geeks trying to read what you wrote, but your poor little server that you thought was reliable turns out it can’t handle and swarm of people all at once.


Luckily, there are caching services available that are free. One of the most notable is the Coral Content Distribution Network. They provide a cached version of your webpage so that when your website goes down, people can still access it. But why should you wait until your server is attacked before your users start using the cache? This script will automatically send users, who come from a high-traffic website, to the Coral cache of the requested page. Neat, huh?

Information/Background
The idea behind this script came from Digg defender by Elliot Back. Sadly, Elliot’s script is only a WordPress plug in, and well, Word Press blogs aren’t the only websites that can experience high traffic. Although I wrote this script myself, the credit for the idea does reside with Elliot. Note: At the time of writing this script, I was using a custom CMS for the website however as of recently I have switched to WordPress.

License
This script is licensed under GNU GPL Version 2.

Code: [Download] [Hide] [Select]
Source code
    <?php
$sites    = Array(
        'digg.com',
        'slashdot.org',
        'reddit.com',
        'fark.com',
        'somethingawful.com',
        'kuro5hin.org',
        'engadget.com',
        'boingboing.net',
        'del.icio.us',
        'netscape.com'
        );
 
if (isset ($_SERVER['HTTP_REFERER']) && !strstr ($_SERVER['HTTP_USER_AGENT'], 'CoralWebPrx'))
{
    $referer = parse_url ($_SERVER['HTTP_REFERER']);
    $referer = $referer['host'];
    foreach ($sites as $site)
    {
        if (stristr ($referer['host'], $site))  
        {
            header ('Location: http://'. $_SERVER['HTTP_HOST'] .'.nyud.net:8080'. $_SERVER['REQUEST_URI']);
            exit;
        }
    }
    unset ($sites);
    unset ($referer);
    unset ($site);
}
?>



Usage
To use this code, simply include it above all the PHP code in your website. You must make sure there is no output (including whitespace) otherwise the script will fail when it comes to redirection.
 




____________
jack of all trades, master of none
http://www.mieloma.com/ - http://www.casimedicos.com/ - http://www.egalego.com/ - http://www.casimedicos.com.es/ - http://www.medicosmir.com/
 
casimedicosSend private messageVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Post new topic  This topic is locked: you cannot edit posts or make replies.  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events


  

 

  cron