Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Derek

By: a guest on Feb 2nd, 2011  |  syntax: PHP  |  size: 6.34 KB  |  hits: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.  
  3.                     init.php
  4.  
  5.  
  6.  
  7. <?php
  8.  
  9. /* TODO:
  10.  * Update @link
  11.  */
  12.  
  13.  
  14. /*
  15.  * =============================================================================
  16.  * Document:          init.php
  17.  * Created on:        Jan 31, 2011,
  18.  *                    at 8:53:58 PM
  19.  * Author:            Derek Maciel <derekamaciel@gmail.com>
  20.  * Short description:
  21.  *      -
  22.  *
  23.  * =============================================================================
  24.  *
  25.  * Long description:
  26.  *      - (optional)
  27.  *
  28.  * =============================================================================
  29.  *
  30.  *  This program is part of Novel CMS.
  31.  *
  32.  *  Novel CMS is free software: you can redistribute it and/or modify
  33.  *  it under the terms of the GNU General Public License as published by
  34.  *  the Free Software Foundation, either version 3 of the License, or
  35.  *  (at your option) any later version.
  36.  *
  37.  *  Novel CMS is distributed in the hope that it will be useful,
  38.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  39.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  40.  *  GNU General Public License for more details.
  41.  *
  42.  *  You should have received a copy of the GNU General Public License
  43.  *  along with Novel CMS, with a file name of "COPYING".  If not, see
  44.  *  <http://www.gnu.org/licenses/>.
  45.  *
  46.  * =============================================================================
  47.  *
  48.  * @project    Novel CMS
  49.  * @category   System Class
  50.  * @author     Derek Maciel <derekamaciel@gmail.com>
  51.  * @copyright  2011 Derek Maciel <derekamaciel@gmail.com>
  52.  * @license    http://www.gnu.org/licenses/gpl.html  GNU GPL, Ver. 3
  53.  * @version    1.0.0
  54.  * @link       http://pear.php.net/package/PackageName
  55.  *
  56.  * =============================================================================
  57.  */
  58.  
  59. //To prevent direct script access, users will have to have accessed init.php
  60. if (!defined('INIT')) define('INIT', TRUE);
  61.  
  62. //Load the global config:
  63. /*
  64.  * @TODO: A bug in PHP?! require() or die(); gives
  65.  *        "Failed opening required '1'"
  66.  *        Therefore, (require()) is needed.
  67.  */
  68.  
  69. class Main {
  70.  
  71. function __construct() {
  72. //Load the uri class
  73. (require(SYSTEMDIR.'uri.'.EXT))
  74. or die("The Novel CMS Initializer wasn't found! =( <br/>" .
  75.    "I was looking for <b>'uri.".EXT .
  76.    "'</b> in <b>'" . SYSTEMDIR . "'</b>, was this wrong?");
  77.  
  78. // Load the auth class
  79. (require(SYSTEMDIR.'auth.'.EXT))
  80. or die("The Novel CMS Initializer wasn't found! =( <br/>" .
  81.    "I was looking for <b>'auth.".EXT .
  82.    "'</b> in <b>'" . SYSTEMDIR . "'</b>, was this wrong?");
  83.  
  84. // Load the config class
  85. (require(SYSTEMDIR.'config.'.EXT))
  86. or die("The Novel CMS Initializer wasn't found! =( <br/>" .
  87.     "I was looking for <b>'config.".EXT .
  88.     "'</b> in <b>'" . SYSTEMDIR . "'</b>, was this wrong?");
  89.  
  90. // Load the error handling class
  91. (require(SYSTEMDIR.'errorhandling.'.EXT))
  92. or die("The Novel CMS Initializer wasn't found! =( <br/>" .
  93.     "I was looking for <b>'errorhandling.".EXT .
  94.     "'</b> in <b>'" . SYSTEMDIR . "'</b>, was this wrong?");
  95.  
  96. // Load the configuration files:
  97. $this->config = new Config;
  98.  
  99. // Load the rest:
  100. $this->uri = new Uri;
  101. $this->auth = new Auth;
  102. $this->errorhandling = new ErrorHandling;
  103.  
  104. $this->config->sanity();
  105.  
  106. }
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113.                      config.php
  114. <?php
  115.  
  116. /* TODO:
  117.  * Update @link
  118.  */
  119.  
  120.  
  121. /*
  122.  * =============================================================================
  123.  * Document:          config.php
  124.  * Created on:        Feb 1, 2011,
  125.  *                    at 8:40:45 PM
  126.  * Author:            Derek Maciel <derekamaciel@gmail.com>
  127.  * Short description:
  128.  *      Loads configuration files.
  129.  *
  130.  * =============================================================================
  131.  *
  132.  * Long description:
  133.  *      This class loads configuration files and is able to retrieve specific
  134.  *      configuration values. This is extensible--any configuration file for
  135.  *      any plugin is able to be loaded, as long as you know the name of the
  136.  *      file.
  137.  *
  138.  * =============================================================================
  139.  *
  140.  *  This program is part of Novel CMS.
  141.  *
  142.  *  Novel CMS is free software: you can redistribute it and/or modify
  143.  *  it under the terms of the GNU General Public License as published by
  144.  *  the Free Software Foundation, either version 3 of the License, or
  145.  *  (at your option) any later version.
  146.  *
  147.  *  Novel CMS is distributed in the hope that it will be useful,
  148.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  149.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  150.  *  GNU General Public License for more details.
  151.  *
  152.  *  You should have received a copy of the GNU General Public License
  153.  *  along with Novel CMS, with a file name of "COPYING".  If not, see
  154.  *  <http://www.gnu.org/licenses/>.
  155.  *
  156.  * =============================================================================
  157.  *
  158.  * @project    Novel CMS
  159.  * @category   System Class
  160.  * @author     Derek Maciel <derekamaciel@gmail.com>
  161.  * @copyright  2011 Derek Maciel <derekamaciel@gmail.com>
  162.  * @license    http://www.gnu.org/licenses/gpl.html  GNU GPL, Ver. 3
  163.  * @version    v1.0.0
  164.  * @link       http://pear.php.net/package/PackageName
  165.  *
  166.  * =============================================================================
  167.  */
  168.  
  169. /*
  170. * REPLACE THIS COMMENT WITH INCLUDES
  171. */
  172.  
  173. class Config extends Main
  174. {
  175.  
  176.     /*
  177.      * Function __construct
  178.      * @param datatype variable description
  179.      * @return datatype description
  180.      */
  181.    function __construct(/* $arg */) {
  182.        $this->load_global("config_global");
  183.    }
  184.  
  185.    /*
  186.     * Function load_global
  187.     * @param array $filename The name of the configuration file.
  188.     * @param boolean $throw  Whether to throw errors or not
  189.     * @return array          The configuration values as an array
  190.     */
  191.    public function load_global($filename="config", $throw = true) {
  192.  
  193.        (require(CONFIGDIR.$filename.".".EXT))
  194.        or die("'".$filename.".".EXT."' could not be found.");
  195.    }
  196.  
  197.    public static function sanity()
  198.    {
  199.        echo "Hello";
  200.    }
  201.  
  202.    /*
  203.     * Function load_plugin
  204.     * @param string $filename The name of the configuration file.
  205.     * @param bool $throw Whether to throw errors or not
  206.     * @return array The configuration values as an array
  207.     */
  208.    public function load_plugin($filename, $throw = true) {
  209.  
  210.    }
  211.  
  212. }