Jump to content
MakeWebGames

Files Outside Root (Example)


gmoore
 Share

Recommended Posts

This is just incase you wanted to move files outside of root (libs in this example which I just did to my version):

config.php (Add)

 

// Core base directory
$webCoreDir="../core/";

 

index.php (Modify)

 

include "config/config.php";
include $webCoreDir . "libs/hooks.php";
include $webCoreDir . "libs/common.php";
include $webCoreDir . "libs/template.php";
include $webCoreDir . "libs/roles.php";

// Loads the include when needed to avoid loading all if not required
// It's also now possible to catch wrongly written class names
function __autoload ($className)
{
   global $webCoreDir;

   $classes = array("Database" => $webCoreDir . "libs/db.php", "UserStat" => $webCoreDir . "libs/stats.php", "Item" => $webCoreDir . "libs/items.php", "Ajax" => $webCoreDir . "libs/ajax.php");
   if (isset($classes[$className]))
       include $classes[$className];
   else
   {
       $bt = debug_backtrace();
       $f = array_shift($bt);
       engine_error_handling(0, "Class $className not defined", $f["file"], $f["line"], null);
   }
}

 

Then move the libs directory up and over to Core and it runs like a champ.

Directory Structure I use:

core

--lib

www

--(everything else)

Greg

Edited by gmoore
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...