Frame structure

Go down

Frame structure

Post  cyberhunter on Sun May 25, 2008 10:39 pm

Code:

<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Frame page structure                                     //
// By PostalCyber                                     //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Set the error msg
$ERROR = "<h1><br>  ERROR 404</h1>
    <p>The page you were looking for dosn't exist.<br>
    We have a lot more work to do before the site is fully oparation.<br>
    Please be patiance while we are still underconstruction.<br>
    </p>
    <br><br><br><br><br><br><br><br><br>";

//The real header, put this on the first line of the pages that need to be loaded
$headerORG = "<?php //<!-- 546865204461726020486560602048657820706167652068656164657220737472697 --> ?>";

//Get my pages from the url
 $pag = $_GET['page'];

//Get rid of the non alfa chars in the page name
 $file = preg_replace("/\W/","", $pag);

//Set the .php
 $page = "$file.php";

//check if the file exists
  if (!file_exists($page)) {
         //echo "<b>$pag does not exist!</b><br>"; <= remove the comment when testing
   echo "$ERROR 00-01";
         die();}

//check if file is a file NOT a dir
  if (!is_file($page)) {
   //echo "<b>$pag isn't a file!</b><br>"; <= remove the comment when testing
   echo "$ERROR 00-02";
   die();}

//check if file is readable            
  if (!is_readable($page)) {
   //echo "<b>$pag isn't readable!</b><br>"; <= remove the comment when testing
   echo "$ERROR 00-03";
   die();}

//check size of file
 $Fsize = filesize($page);

   //Open file for reading
    ($Fopn = fopen("$page", "r")) or die ("$ERROR 00-04");

   //Get header
    $header = fgets($Fopn, 90); // <= change 90 with the lengt of the validation sting '$header'

   //Header test - Body output
    if("$header" == "$headerORG") {
      include("$page");
      }   
       else { die("$ERROR 00-05"); }

//Close file when done
 fclose($Fopn);
?>
avatar
cyberhunter
Info Cracker
Info Cracker

Posts : 201
Join date : 2008-03-12
Age : 34
Location : In your computer

View user profile http://www.infofreakz.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum