<?php
if(!function_exists('is_folder_writable')) {
	// check for correct permissions
	function is_folder_writable($path) {
    		// extended check for open_basedir/safemod restrictions. $path must contain trailing slash to work!!!
    		$fp = @fopen ($path."check.tmp", "a");
    		if ($fp===false) {
        		return false;
			}
    		fclose($fp);
    		@unlink($path."check.tmp");
    		return true;
	}
}

if(!function_exists('utf8_cleantext')) {
	function utf8_cleantext($string) {
		$string = html_entity_decode($string);
    	$string = str_replace("Ã¤","ä",$string);
        $string = str_replace("Ã„","Ä",$string);
        $string = str_replace("Ã¶","ö",$string);
        $string = str_replace("Ã–","Ö",$string);
        $string = str_replace("Ã¼","ü",$string);
        $string = str_replace("Ãœ","Ü",$string);
        $string = str_replace("ÃŸ","ß",$string);
        $string = str_replace("Â´","´",$string);
        $string = str_replace("Ã‰","É",$string);
        $string = str_replace("Ã©","é",$string);
        $string = str_replace("Â©","©",$string);
        $string = str_replace("Â®","®",$string);
		$string = str_replace('"',"",$string);
		$string = str_replace("&quot;","",$string);
		return $string;
    }
}
if(!function_exists('string2js')) {
	function string2js($string) {
        $bad_characters = array("Ã„", "Ã–", "Ãœ", 'Ã¤"', "Ã¶", "Ã¼", "ÃŸ", "\r", "\n");
	    $safe_characters = array('\u00c4','\u00d6','\u00dc','\u00e4','\u00f6','\u00fc','\u00df','<br />','');
		$string= str_replace($bad_characters, $safe_characters, $string);
	return $string;
    }
}

?>