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/keystud.komma-mediadesign.nl/wwwroot/lib/ks_bootstrap.class.php
<?php
/**
 * bootstrap.class.php
 * Created by Komma Mediadesign.
 * Author: mike
 * Date: 7/24/13
 */

class Ks_Bootstrap extends Controller{

    public function __construct()
    {
        session_start();

        $definedLanguage = URL_LANG;

        /*
         * Convert URL_PAGE & URL_SUB to a controller and a method within a controller
         */
        $convertedController = '';
        $method = '';
        $LanguageHandler = new LanguageHandler();
        $LanguageHandler->set($definedLanguage);

        if(defined('URL_PAGE'))
        {
            $convertedController = $LanguageHandler->convert(URL_PAGE);
        }
        if(defined('URL_SUB'))
        {
            $method = $LanguageHandler->convert(URL_SUB);
        }

        /*
         * If URL_PAGE is not defined, call the homepage controller.
         */
        if(empty($convertedController))
        {
            require_once DOCUMENT_ROOT.'app/controllers/c_home.class.php';
            $Controller = new Ks_Home();
            $Controller->init();
            $Controller->index();
            return false;
        }

        $name = str_replace('-','_',$convertedController);
        $file = DOCUMENT_ROOT . 'app/controllers/c_' . strtolower($name) . '.class.php';

        /*
         * Check if the controller file exists.
         * If so, require the file and create a new Controller object
         */
        if(is_file($file))
        {
            require_once $file;
        }
        else
        {
            header("HTTP/1.0 404 Not Found");
            header('location:'.SITE_ROOT.'404/');
            exit;
        }

        /*
         * Catch 404
         */
        if($name == '404') $name = 'Page_Not_Found';

        $Controller = new $name;
        $Controller->loadModel($name);
        $Controller->init();

        /*
         * SUB -> If SUB exists as a method, call that method.
         * If no sub,
         */
        if( ! empty($method))
        {
            if(method_exists($Controller, $method))
            {
                $Controller->{$method}();
                return true;
            }
        }
        else
        {
            if(method_exists($Controller, 'index'))
            {
                $Controller->index();
                return true;
            }
        }
        $Controller->Functions->notFound();
        return false;
    }
}