# === SQL_DATE =================================================================
# Funkce pøeformátuje získaný datum z formuláøe do podoby potøebné pro MySQL
function db_date($datum){
list($den, $mesic, $rok) = explode(".", $datum);
$vystup=sprintf("%04s", $rok)."-".sprintf("%02s", $mesic)."-".sprintf("%02s", $den);
return $vystup;
}
?>
# === NL2OUT ===================================================================
# Odstranìní všech entrù z textu
function nl2out($text){
$text=ereg_replace("\r\n", " ", $text);
$text=ereg_replace("\n\r", " ", $text);
$text=ereg_replace("\r", " ", $text);
$text=ereg_replace("\n", " ", $text);
return $text;
}
?>
# === EMAILVALID ===============================================================
# testuje správnost syntaxe e-mail
# správnì = 1
# špatnì = 0
function emailvalid($email) {
list($local, $domain) = explode("@", $email);
$pattern_local = '^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$';
$pattern_domain = '^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$';
$match_local = eregi($pattern_local, $local);
$match_domain = eregi($pattern_domain, $domain);
if ($match_local && $match_domain) return 1;
else return 0;
}
?>
# === SQLDATE4USER =============================================================
# Upraví datum
# Funkce zobrazí sql datum v èeském formátu srozumitelnìjším pro uživatele
function sqldate4user($datum, $barva = false, $stav = 0){
$vystup="";
list ($rok, $mesic, $den) = explode ("-", $datum);
if (sprintf("%d", $den)) $vystup.= "$den.";
if (!sprintf("%d", $den) && sprintf("%d", $mesic)) $vystup.= "$mesic/";
elseif (sprintf("%d", $mesic)) $vystup.= "$mesic.";
if (sprintf("%d", $rok)) $vystup.= "$rok";
if ($barva && $stav != 3 && $stav != 5){
$mktime=mktime(0, 0, 0, $mesic, $den, $rok);
if ($mktime<=(time()+(3*24*3600)) && $mktime>=time()) $vystup="$vystup";
elseif($mktime