NilSagor

ecom

Mar 2nd, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.52 KB | None | 0 0
  1. mysite/inc/autoload.php
  2. ------------------------------
  3.  
  4.     <?php
  5.  
  6.     require_once('_config.php');
  7.  
  8.     function __autoload($class_name){
  9.     $class=explode("_", $class_name);
  10.     $path=implode("/", $class).".php";
  11.     require_once($path);
  12.     }
  13.  
  14.     ?>
  15.  
  16. mysite/inc/_config.php
  17. ------------------------------
  18.    
  19.     <?php
  20.  
  21.     if (!isset($_SESSION)) {
  22.     session_start();
  23.     }
  24.  
  25.     // site domain name with http
  26.      defined("SITE_URL")
  27.         || define("SITE_URL","http://".$_SERVER['SERVER_NAME']);
  28.  
  29.      // directory separator
  30.     defined("DS")
  31.         || define("DS",DIRECTORY_SEPARATOR);
  32.  
  33.      // root path
  34.      defined("ROOT_PATH")
  35.         || define("ROOT_PATH",realpath(dirname(__FILE__).DS."..".DS));
  36.  
  37.      // class folder
  38.     defined("CLASSES_DIR")
  39.         || define("CLASSES_DIR", "classes");
  40.  
  41.     // pages folder
  42.     defined("PAGES_DIR")
  43.         || define("PAGES_DIR","pages");
  44.  
  45.      // module folder
  46.     defined("MOD_DIR")
  47.         || define("MOD_DIR", "mod");
  48.  
  49.     // inc folder
  50.     defined("INC_DIR")
  51.         || define("INC_DIR","inc");
  52.  
  53.     // template folder
  54.     defined("TEMPLATE_DIR")
  55.         || define("TEMPLATE_DIR","template");
  56.  
  57.     // catalogue images path
  58.     defined("CATALOGUE_PATH")
  59.     || define("CATALOGUE_PATH",ROOT_PATH.DS."media".DS."catalogue");
  60.  
  61.  
  62.     // add all above directories to the include path
  63.  
  64.      set_include_path(implode(PATH_SEPARATOR, array(
  65.     realpath(ROOT_PATH.DS.CLASSES_DIR),
  66.     realpath(ROOT_PATH.DS.PAGES_DIR),
  67.     realpath(ROOT_PATH.DS.MOD_DIR),
  68.     realpath(ROOT_PATH.DS.INC_DIR),
  69.     realpath(ROOT_PATH.DS.TEMPLATE_DIR),
  70.     get_include_path()
  71.         )));
  72.      ?>
  73.  
  74. mysite/classes/Url.php
  75. ------------------------------
  76.  
  77.     <?php
  78.     class Url {
  79.  
  80.     public static $_page = "page";
  81.     public static $_folder = PAGES_DIR;
  82.     public static $_params = array();
  83.    
  84.     public static function getParam($par) {
  85.         return isset($_GET[$par]) && $_GET[$par] != "" ?
  86.                 $_GET[$par] : null;
  87.     }
  88.    
  89.     public static function cPage() {
  90.         return isset($_GET[self::$_page]) ?
  91.                 $_GET[self::$_page] : 'index';
  92.     }
  93.    
  94.     public static function getPage() {
  95.         $page = self::$_folder.DS.self::cPage().".php";
  96.         $error = self::$_folder.DS."error.php";
  97.         return is_file($page) ? $page : $error;
  98.     }
  99. }
  100.  
  101.      ?>
  102.  
  103. mysite/classes/Core.php
  104. ------------------------------
  105.  
  106.     <?php
  107.  
  108.     class Core{
  109.         public function run(){
  110.             ob_start();
  111.             require_once(Url::getPage());
  112.             ob_get_flush();
  113.             }
  114.         }
  115.      ?>
  116.  
  117. mysite/pages/error.php
  118. ------------------------------
  119.  
  120. <?php require_once('_header.php'); ?>
  121.  
  122. <h1>Error</h1>
  123.  
  124. <?php require_once('_footer.php'); ?>
  125.  
  126.  
  127. mysite/index.php
  128. --------------------
  129.  
  130.     <?php
  131.  
  132.         require_once('inc/autoload.php');
  133.         require_once('_header.php');
  134.         require_once('_footer.php');
  135.  
  136.     ?>
  137. mysite/template/_header.php
  138. ------------------------------
  139.  
  140.     <!DOCTYPE html>
  141.     <html lang="en">
  142.     <head>
  143.         <meta charset="UTF-8">
  144.         <title>Document</title>
  145.         <link href="css/core.css" rel="stylesheet" type="text/css" />
  146.     </head>
  147.     <body>
  148.         <div id="header">
  149.             <div id="header_in">
  150.                 <h5><a href="">Business Name</a></h5>
  151.             </div>
  152.         </div>
  153.         <div id="outer">
  154.             <div id="wrapper">
  155.                 <div id="left">
  156.                     <h2>Categories</h2>
  157.                 <ul id="navigation">
  158.                     <li><a href="">link</a></li>
  159.                 </ul>
  160.             </div>
  161.             <div id="right">
  162.        
  163. mysite/template/_footer.php
  164. ------------------------------
  165.  
  166.             </div>
  167.                 <div class="cl">&#160;</div>
  168.             </div>
  169.         </div>
  170.         <div id="footer">
  171.             <div id="footer_in">
  172.                 &copy;<a href="">mysite.dev</a><?php echo date('Y');?>
  173.             </div>
  174.         </div>
  175.         <script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
  176.     </body>
  177.     </html>
Advertisement
Add Comment
Please, Sign In to add comment