Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysite/inc/autoload.php
- ------------------------------
- <?php
- require_once('_config.php');
- function __autoload($class_name){
- $class=explode("_", $class_name);
- $path=implode("/", $class).".php";
- require_once($path);
- }
- ?>
- mysite/inc/_config.php
- ------------------------------
- <?php
- if (!isset($_SESSION)) {
- session_start();
- }
- // site domain name with http
- defined("SITE_URL")
- || define("SITE_URL","http://".$_SERVER['SERVER_NAME']);
- // directory separator
- defined("DS")
- || define("DS",DIRECTORY_SEPARATOR);
- // root path
- defined("ROOT_PATH")
- || define("ROOT_PATH",realpath(dirname(__FILE__).DS."..".DS));
- // class folder
- defined("CLASSES_DIR")
- || define("CLASSES_DIR", "classes");
- // pages folder
- defined("PAGES_DIR")
- || define("PAGES_DIR","pages");
- // module folder
- defined("MOD_DIR")
- || define("MOD_DIR", "mod");
- // inc folder
- defined("INC_DIR")
- || define("INC_DIR","inc");
- // template folder
- defined("TEMPLATE_DIR")
- || define("TEMPLATE_DIR","template");
- // catalogue images path
- defined("CATALOGUE_PATH")
- || define("CATALOGUE_PATH",ROOT_PATH.DS."media".DS."catalogue");
- // add all above directories to the include path
- set_include_path(implode(PATH_SEPARATOR, array(
- realpath(ROOT_PATH.DS.CLASSES_DIR),
- realpath(ROOT_PATH.DS.PAGES_DIR),
- realpath(ROOT_PATH.DS.MOD_DIR),
- realpath(ROOT_PATH.DS.INC_DIR),
- realpath(ROOT_PATH.DS.TEMPLATE_DIR),
- get_include_path()
- )));
- ?>
- mysite/classes/Url.php
- ------------------------------
- <?php
- class Url {
- public static $_page = "page";
- public static $_folder = PAGES_DIR;
- public static $_params = array();
- public static function getParam($par) {
- return isset($_GET[$par]) && $_GET[$par] != "" ?
- $_GET[$par] : null;
- }
- public static function cPage() {
- return isset($_GET[self::$_page]) ?
- $_GET[self::$_page] : 'index';
- }
- public static function getPage() {
- $page = self::$_folder.DS.self::cPage().".php";
- $error = self::$_folder.DS."error.php";
- return is_file($page) ? $page : $error;
- }
- }
- ?>
- mysite/classes/Core.php
- ------------------------------
- <?php
- class Core{
- public function run(){
- ob_start();
- require_once(Url::getPage());
- ob_get_flush();
- }
- }
- ?>
- mysite/pages/error.php
- ------------------------------
- <?php require_once('_header.php'); ?>
- <h1>Error</h1>
- <?php require_once('_footer.php'); ?>
- mysite/index.php
- --------------------
- <?php
- require_once('inc/autoload.php');
- require_once('_header.php');
- require_once('_footer.php');
- ?>
- mysite/template/_header.php
- ------------------------------
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <link href="css/core.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="header">
- <div id="header_in">
- <h5><a href="">Business Name</a></h5>
- </div>
- </div>
- <div id="outer">
- <div id="wrapper">
- <div id="left">
- <h2>Categories</h2>
- <ul id="navigation">
- <li><a href="">link</a></li>
- </ul>
- </div>
- <div id="right">
- mysite/template/_footer.php
- ------------------------------
- </div>
- <div class="cl"> </div>
- </div>
- </div>
- <div id="footer">
- <div id="footer_in">
- ©<a href="">mysite.dev</a><?php echo date('Y');?>
- </div>
- </div>
- <script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment