function IsEmail ($text) {
$text = strtolower($text);
/* for ($i=1; $i<=strlen($text); $i++)
{
if (strpos("abcdefghijklmnopqrstuvwxyz0123456789@.-_", substr($text, $i, 1)) === false)
{
return false;
}
} */
if (strlen($text) < 6)
{
return false;
}
if (strpos($text, "@") != strrpos($text, "@"))
{
return false;
}
if ((strpos($text, "@") < 1) || (strpos($text, "@") > (strlen($text) - 4)))
{
return false;
}
if (strrpos($text, ".") < strpos($text, "@"))
{
return false;
}
if (((strlen($text) - strrpos($text, ".") - 1) < 2) || ((strlen($text) - strrpos($text, ".") - 1) > 3))
{
return false;
}
return true;
}
// převod znakové sady win-1250 na iso
function ToISO ($text) {
$iso = "µľ®»«ą©Ą";
$win = "ľžŽťŤšŠĽ";
for ($i=1; $i<=strlen($win); $i++)
{
$text = str_replace(substr($win,$i-1,1), substr($iso,$i-1,1), $text);
}
return $text;
}
// náhrada funkce str_repeat
function StrRepeat ($text, $num) {
for ($i=1; $i<=$num; $i++) { $temp = $temp . $text; }
return $temp;
}
// funkce mysql_query s výpisem případné chyby
function MySqlQuery ($query) {
$sql_result = mysql_query($query);
if (!$sql_result) {
echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><font color=\"Red\"><b>MySQL Error</b></font> - ";
echo mysql_errno().": ".mysql_error()."</font></p>";
}
return $sql_result;
}
// převod do kódování MIME
function ToMIME ($text) {
for ($i=1; $i<=strlen($text); $i++)
{
if (ord(substr($text,$i-1,1)) == 61)
{
$temp = $temp . "=3D";
}
elseif (ord(substr($text,$i-1,1)) < 128)
{
$temp = $temp . substr($text,$i-1,1);
}
else
{
$temp = $temp . "=" . substr(dechex(ord(substr($text,$i-1,1))), strlen(dechex(ord(substr($text,$i-1,1)))) - 2);
}
}
return $temp;
}
// vrátí time +/- Den,Měsíc,Rok
function ConvertDate ($mounth, $day, $year) {
$temp = mktime (0,0,0,date("m")+$mounth ,date("d")+$day,date("Y")+$year);
return $temp;
}