HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/lab.komma-mediadesign.nl/wwwroot/kms2013/kms/lib/Bootstrap.class.php
<?php
/**
 * Created by Komma.pro
 * User: mikevandersanden
 * Date: 17/9/13
 */

class Bootstrap
{
    public function __construct()
    {
        // Initialize the session
        Session::init();

        // Initialize translator
        $Translator = new Translator(URL_LANG);

        // Get Controller and method
        defined('URL_PAGE') ? $c = $Translator->convert(URL_PAGE) : $c = 'Dashboard';
        defined('URL_SUB') ? $m = $Translator->convert(URL_SUB) : $m = 'index';

        // Check if our gate is opened
        if( ! Login_Model::gateIsOpen())
        {
            // A list of controllers accessible outside the gate
            $outsideGate = array('login','forgot_pass','pass_activation','pass_updater');

            // If not in the list, show login form
            if( ! in_array($c,$outsideGate))
            {
                $c = 'Login';
                $m = 'index';
            }
        }
        // Load
        $this->load($c, $m);
    }

    /*
     * Load a controller
     * @param $c / controller
     * @param $m / method
     */
    private function load($name, $method)
    {
        // Controller file
        $file = DOCUMENT_ROOT . 'app/controllers/c_' . strtolower($name) . '.class.php';

        // Check if we need to load a basic page or the controller file
        $basicPage = $this->isBasicPage($name);
        if($basicPage)
        {
            require_once DOCUMENT_ROOT . 'app/controllers/c_basic_page.class.php';
        }
        else if(is_file($file))
        {
            //If the controller file exists require the file and create a new Controller object
            if( ! class_exists($name))
            {
                require_once $file;
            }
        }
        else
        {
            Functions::notFound();
        }

        //  Basic page -> Create a controller object and load the model
        if($basicPage)
        {
            $Controller = new Basic_Page($name);
            $Controller->loadModel('basic_page');
        }
        else
        {
            $Controller = new $name;
            $Controller->loadModel($name);
        }

        // Initialise the controller
        $Controller->init($name);

        // Call the method
        if(method_exists($Controller, $method))
        {
            $Controller->{$method}();
            return true;
        }

        // If nothing returned, header a 404
        Functions::notFound();
        return false;
    }

    /*
     * Check if a page is a basic page or an extension
     */
    private function isBasicPage($name)
    {
        global $Storage;
        $Storage->setTableName(TABLE_PREFIX . 'kms_pages');
        $Storage->addRule('name',$name);
        $Storage->addRule('extension',0);
        $result = $Storage->select();
        return ( ! empty($result));
    }
}