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/tops.komma.pro/wwwroot/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();

        // Create a session for javascript output
        $_SESSION['js_output'] = '';

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

        // Get Controller and method
        defined('URL_PAGE') ? $c = $Translator->convert(URL_PAGE) : $c = 'Home';
        defined('URL_SUB') ? $m = $Translator->convert(URL_SUB) : $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
        {
           Fn::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
        Fn::notFound();
        return false;
    }

    /*
     * Check if a page is a basic page or an extension
     */
    private function isBasicPage($name)
    {
        $name = strtolower($name);

        // Check if page is a basic page
        $basicPages = array('company','filters', 'uses', 'installation', 'certificates', 'webshop', 'contact', 'disclaimer', 'terms', 'sitemap', 'page_not_found', 'offer');

        return in_array($name,$basicPages);
    }
}