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/SBogers64/klimroosbudel.nl/wwwroot/kms/lib/general/functions.class.php
<?php
/**
 * functions.class.php
 * Created by Komma Mediadesign.
 * Author: mike
 * Date: 3/20/13
 */
class Functions
{
    /*
     * @property array errors
     * If a functions returns an error, it will be saved in this value.
     * You can access this array by calling Functions::getErrors();
     */
    private $_errors = [];

    public function __construct()
    {
    }

    /**
     * Converts string into url string.
     *
     * @param string
     * @return string
     */
    public function encodeUrl($input)
    {
        // Remove whitespace
        $output = trim($input);

        // Lowercase
        $output = strtolower($output);

        // Replace &amp; with "en" or "and"
        TABLE_PREFIX == 'en_' ? $output = str_replace('&amp;', 'and', $output) : $output = str_replace('&amp;', 'en', $output);

        // Replace special letters with normal letters
        $output = preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i', '\\1', $output);

        // Remove html entities
        $pattern = '#(&)([a-z]*)([;$])#';
        $output = preg_replace($pattern, '', $output);

        // Remove all special characters
        $output = preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $output);

        // Remove ( )
        $output = str_replace('(', '', $output);
        $output = str_replace(')', '', $output);
        $output = str_replace('.', '', $output);

        // Replace spaces with a dash
        $output = str_replace(' ', '-', $output);

        // Replace multiple dashes with one dash
        $output = preg_replace('/-{2,}/', '-', $output);

        return $output;
    }

    /*
     * Headers a 404 error
     */
    public function notFound()
    {
        header('HTTP/1.0 404 Not Found');
        header('location:'.SITE_ROOT.'404/');
        exit;
    }

    /*
     * Redirect to a page
     */
    public function redirect($url)
    {
        header('location:'.$url);
        exit;
    }

    /*
     * Returns the errors in an array
     */
    public function getErrors()
    {
        return $this->_errors;
    }

    /*
     * Get Welcome (time)
     */
    public function getGoodDay()
    {
        $currentTime = date('G');
        $goodDay = '';
        if ($currentTime >= 0 && $currentTime < 6) {
            $goodDay = 'good_night';
        } elseif ($currentTime >= 6 && $currentTime < 12) {
            $goodDay = 'good_morning';
        } elseif ($currentTime >= 12 && $currentTime < 18) {
            $goodDay = 'good_afternoon';
        } elseif ($currentTime >= 18 && $currentTime < 24) {
            $goodDay = 'good_evening';
        }

        return $goodDay;
    }

    /*
     * Return a camelCase string
     */
    public function camelCase($label)
    {
        $label = str_replace('-', ' ', $label);
        $label = str_replace('_', ' ', $label);
        $words = explode(' ', $label);

        $output = '';
        foreach ($words as $i => $word) {
            $word = strtolower($word);
            if ($i != 0) {
                $word = ucfirst($word);
            }
            $output .= $word;
        }

        return $output;
    }

    /*
     * Check if a string can be an e-mail address.
     */
    public function checkMail($email)
    {
        // First, we check that there's one @ symbol, and that the lengths are right
        if (! preg_match('/^[^@]{1,64}@[^@]{1,255}$/', $email)) {
            // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
            return false;
        }
        // Split it into sections to make life easier
        $email_array = explode('@', $email);
        $local_array = explode('.', $email_array[0]);
        for ($i = 0; $i < count($local_array); $i++) {
            if (! preg_match("/^(([A-Za-z0-9!#$%&'*+\/=?^_`{|}~-][A-Za-z0-9!#$%&'*+\/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) {
                return false;
            }
        }
        if (! preg_match("/^\[?[0-9\.]+\]?$/", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
            $domain_array = explode('.', $email_array[1]);
            if (count($domain_array) < 2) {
                return false; // Not enough parts to domain
            }
            for ($i = 0; $i < count($domain_array); $i++) {
                if (! preg_match('/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$/', $domain_array[$i])) {
                    return false;
                }
            }
        }

        return true;
    }

    /*
     * Print
     */
    public function print_array($array)
    {
        if ($_SERVER['REMOTE_ADDR'] == '212.61.130.133') {
            echo '<pre>';
            print_r($array);
            echo '</pre>';
        }
    }
}