Secure file failsafe header

    Date: 08/05/06 (PHP Community)    Keywords: html

    Below is a rough draft failsafe code I wrote to prevent me or one of the other programmers from putting critical files into
    the doc_root of the HTML server.   After this is where all the DB wrapper functions and the embedded username's and passwords to them.




    //Are we on the local test server?
    if($_SERVER['SERVER_NAME'] != "localhost" && $_SERVER['SERVER_ADDR'] != "127.0.0.1")
    {
                 //not local, then are we on the remote?
                 if($_SERVER['SERVER_NAME'] == 'www.myDomain.org' || 
                    $_SERVER['SERVER_NAME'] == 'myDomain.org' ||
                    $_SERVER['SERVER_NAME'] == 'myServer.com')
                {
                             //Were on the remote, are we where were supposed to be?
                            if(dirname(__FILE__) != "/home/digita23/secureScripts/")
                            {
                                     //NO, kill the script
                                     //TODO insert mail alarm code
                                     //TODO make a proper error msg
                                     die("UNSECURE SCRIPT - please move this file to the secureScript directory"); 
                             }
                 }
                 else
                 {
                            //WTF mate?
                            //TODO insert mail alarm code
                            //TODO make a proper error msg
                           die("UNSECURE SCRIPT - Unable to identify server");
                  }
    }

    Source: http://community.livejournal.com/php/479894.html

« Read more || Test for the existence of a... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home