ACC SHELL

Path : /srv/www/vhosts/ambfinance/admin/library/TF/
File Upload :
Current File : /srv/www/vhosts/ambfinance/admin/library/TF/Functions.php

<?php
class TF_Functions
{
    
    private function __construct ()
    {}
    /**
     * addElementToStringArray
     */
    public static function addElementToStringArray (&$resource, $val, $delimiter = ",")
    {
        if (! is_string($resource)) {
            throw new TF_Exception("Špatný formát textového pole!", 500);
        }
        $arr = explode($delimiter, $resource);
        $arr[] = $val;
        $resource = implode($delimiter, $arr);
    } /* of addElementToStringArray -------------------------------------*/
    private static function cs_utf2ascii ($s)
    {
        static $tbl = array(":" => "-" , "\"" => "-" , "'" => "-" , "(" => "-" , ")" => "-" , "=" => "-" , ";" => "-" ,
            "°" => "-" , "*" => "-" , "/" => "-" , "+" => "-" , "&" => "-" , "@" => "-" , "?" => "-" ,
            " " => "-" , "!" => "-" , "." => "-" , "," => "-" , "%" => "-" , "_" => "-" , "ˇ" => "-" ,
            "´" => "-" , "¨" => "-" , "\xc3\xa1" => "a" , "\xc3\xa4" => "a" , "\xc4\x8d" => "c" ,
            "\xc4\x8f" => "d" , "\xc3\xa9" => "e" , "\xc4\x9b" => "e" , "\xc3\xad" => "i" , "\xc4\xbe" => "l" ,
            "\xc4\xba" => "l" , "\xc5\x88" => "n" , "\xc3\xb3" => "o" , "\xc3\xb6" => "o" , "\xc5\x91" => "o" ,
            "\xc3\xb4" => "o" , "\xc5\x99" => "r" , "\xc5\x95" => "r" , "\xc5\xa1" => "s" , "\xc5\xa5" => "t" ,
            "\xc3\xba" => "u" , "\xc5\xaf" => "u" , "\xc3\xbc" => "u" , "\xc5\xb1" => "u" , "\xc3\xbd" => "y" ,
            "\xc5\xbe" => "z" , "\xc3\x81" => "A" , "\xc3\x84" => "A" , "\xc4\x8c" => "C" , "\xc4\x8e" => "D" ,
            "\xc3\x89" => "E" , "\xc4\x9a" => "E" , "\xc3\x8d" => "I" , "\xc4\xbd" => "L" , "\xc4\xb9" => "L" ,
            "\xc5\x87" => "N" , "\xc3\x93" => "O" , "\xc3\x96" => "O" , "\xc5\x90" => "O" , "\xc3\x94" => "O" ,
            "\xc5\x98" => "R" , "\xc5\x94" => "R" , "\xc5\xa0" => "S" , "\xc5\xa4" => "T" , "\xc3\x9a" => "U" ,
            "\xc5\xae" => "U" , "\xc3\x9c" => "U" , "\xc5\xb0" => "U" , "\xc3\x9d" => "Y" , "\xc5\xbd" => "Z");
        return strtr($s, $tbl);
    }
    /**
     * setParamToUrl
     * @return anchor href
     * @param key $_GET key to add
     * @param val coresponding value
     * @author Tomáš Fejfar
     */
    public static function setParamToUrl ($key, $val)
    {
        $get = $_GET;
        $get[$key] = $val;
        foreach ($get as $key => $val) {
            $arr[] = "$key=$val";
        }
        if(isset($_SERVER["REWRITE_URI"])){
        	$uri = $_SERVER["REWRITE_URI"];
        } else {
        	$uri = '';
        }
        return $uri . "?" . implode("&", $arr);
    } /* of setParamToUrl -------------------------------------*/
    /**
     * friendlyUrl
     */
    public static function friendlyUrl ($nadpis)
    {
        return preg_replace("/[-]{2,}/", "-", trim(strtolower(self::cs_utf2ascii($nadpis)), "-"));
    } //of friendlyUrl
    /**
     * arrToObj
     */
    public static function arrToObj ($array, $recursive = false)
    {
        if (is_array($array)) {
            $obj = new stdClass();
            foreach ($array as $key => $val) {
                if(is_array($val)){
                    $val = self::arrToObj($val);
                }
                $obj->$key = $val;
            }
            return $obj;
        } else {
            return $array;
        }
    } /* of arrToObj -------------------------------------*/
    /**
     * objToArr
     */
    public static function objToArr ($object)
    {
        if(is_array($object)){
            return $object;
        }
        return get_object_vars($object);
    } /* of objToArr -------------------------------------*/
    /**
     * dateMysqlToHuman
     */
    public static function dateMysqlToHuman ($date)
    {
        $arr = explode('-', $date);
        if (checkdate($arr[1], $arr[2], $arr[0])) {
            return implode('.', array_reverse($arr));
        } else {
            throw new TF_Exception('Neplatný formát MySQL datumu "'.$date.'". Měl by být RRRR-MM-DD. ');
        }
    } /* of dateMysqlToHuman -------------------------------------*/
    /**
     * dateHumanToMysql
     */
    public static function dateHumanToMysql ($date)
    {
        $arr = explode('.', $date);
        if (checkdate($arr[1], $arr[0], $arr[2])) {
            return implode('-', array_reverse($arr));
        } else {
            throw new TF_Exception('Neplatný formát datumu "'.$date.'". Použijte DD.MM.RRRR');
        }
    } /* of dateHumanToMysql -------------------------------------*/

    /**
    * injects element to array
    */
    public static function injectToArray($element,$position,&$array)
    {
    	$i = count($array);
    	while($i > $position){
    		$array[$i] = $array[$i-1];
    		unset($array[$i-1]);
    		$i--;
    	}
    	$array[$position] = $element;
    	TF_Debug::logSimple($array);
    	return true;
    }
    
    public static function moneyRound($price){
    	$rounded = round( $price );
    	return $rounded;
		 //return number_format( $rounded, 2, ',', ' ');
    }
}

ACC SHELL 2018