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/SBogers36/mecurity-ramkraakbeveiliging.nl/wwwroot/mvc/models/m_siteTemplate.php
<?php

/**
 * Mecurity
 *
 * Created By: Komma Mediadesign
 * Author: Mike van der Sanden
 * March 2013
 *
 */

include DOCUMENT_ROOT.'models/m_languageHandler.php';

class SiteTemplate
{

    /*
     * @property mixed data
     */
    private $_data;

    /*
     * @property array lang
     * Language property, set in Template, accessible from every file.
     */
    public $lang = array();

    public function __construct()
    {
        $this->_data = array();
    }


    /*

        SETTER / GETTER

    */


    /**
     * Sets data for later use by the view
     *
     * @access public
     * @param string $name
     * @param string $value
     * @return void
     */
    public function setData($name,$value)
    {
        $this->_data[$name] = $value;
    }

    /**
     * Retrieves data based on provided name for access by view
     *
     * @access public
     * @param string $name
     * @param bool $echo
     * @return mixed
     */
    public function getData($name, $echo=TRUE)
    {
        if(isset($this->_data[$name]))
        {
            if($echo)
            {
                echo $this->_data[$name];
            }
            else{
                return $this->_data[$name];
            }
        }
        return FALSE;
    }


    /*

        LOAD / REDIRECT

    */


    /**
     * Loads specified url
     *
     * @access public
     * @param string
     * @return void
     */
    public function load($url)
    {
        include $url;
    }

    /**
     * Redirects to specified url
     *
     * @access public
     * @params string
     * @return null
     */
    public function redirect($url)
    {
        header('location:'.$url);
        exit;
    }

    /**
     * Redirects to specified url
     *
     * @access public
     * @params string
     * @return null
     */
    public function notFound()
    {
        header("HTTP/1.0 404 Not Found");
        header('location:'.SITE_ROOT.'404');
        exit;
    }


    /*

        Convert Data

    */


    /**
     * Converts string into url string.
     *
     * @access public
     * @param string
     * @return string
     */
    public function encodeUrl($input)
    {
        $output = trim($input);
        $output = str_replace(' ','-',$output);
        //remove these characters
        $forbidden = array("'", '"', '\\', '/', ';', ';', '|', '>', '<', '[', ']', '!','?', '@', '#', '$', '%', '^', '&', '*', '(', ')','+','=','{','}','`', '~', '.', ',');
        foreach($forbidden as $key => $value){
            $output = str_replace($value, '', $output);
        }
        $output = str_replace('--','-',$output);
        $output = strtolower($output);

        return $output;
    }

    /**
     * Encodes string into a valid Database name
     *
     * @access public
     * @param string
     * @return string
     */
    public function encodeDbName($input)
    {
        $input = $this->encodeUrl($input);
        $words = explode('-',$input);

        $dbName = '';
        foreach($words as $key => $word)
        {
            if($key > 0)
            {
                $word = ucfirst($word);
            }
            $dbName .= $word;
        }
        return $dbName;
    }
}