Wywołałem chyba małą wojnę (IMG:
style_emoticons/default/smile.gif)
napisałem sobie taką klasę
wątpię żeby byłą idealnie ale zasadniczo rzecz biorąc to co przetestowałem to działa (IMG:
style_emoticons/default/smile.gif)
<?php
class validForm
{
public $alphabet="a-zA-ZąśćężźńłóĄŚĆĘŻŹŃŁÓ";
public function alphabet($tekst=null, $min=0, $max=25 )
{
$w="{".$min.",".$max."}";
if (preg_match("/^[a-zA-ZąśćężźńłóĄŚĆĘŻŹŃŁÓ]$w$/", $tekst)) return 1;
else
return 0;
}
public function checke($tekst=null )
{
if ($tekst==1 || $tekst==FALSE)
return 1;
else
return 0;
}
public function number($tekst=null, $min=0, $max=25 )
{
$w="{".$min.",".$max."}";
return 1;
else
return 0;
}
public function price($tekst=null, $min=0, $max=25 )
{
$w="{".$min.",".$max."}";
return 1;
else
return 0;
}
public function login($tekst=null, $min=3, $max=15 )
{
$w="{".$min.",".$max."}";
return 1;
else
return 0;
}
public function email($tekst=null, $min=3, $max=15 )
{
$w="{".$min.",".$max."}";
if (preg_match("/^[_a-z0-9.-]*[a-z0-9]@[_a-z0-9.-]*[a-z0-9].[a-z]{2,3}$/", $tekst)) return 1;
else
return 0;
}
public function password($tekst=null,$tekst2=null, $min=3, $max=15 )
{
$w="{".$min.",".$max."}";
if (preg_match("/^[a-zA-Z0-9\-\@\#\$\_]$w$/", $tekst)) if ($tekst==$tekst2)
return 1;
else
return 0;
else
return 0;
}
public function text($tekst=null, $min=0, $max=25 )
{
$w="{".$min.",".$max."}";
if (preg_match("/^[a-zA-Z0-9ąśćężźńłóĄŚĆĘŻŹŃŁÓ\s\(\)\?\:\.\,\!]$w$/", $tekst)) return 1;
else
return 0;
}
public function adres($tekst=null, $min=0, $max=45 )
{
$w="{".$min.",".$max."}";
if (preg_match("/^[a-zA-Z0-9ąśćężźńłóĄŚĆĘŻŹŃŁÓ\s\-\/\\\.\(\)\?]$w$/", $tekst)) return 1;
else
return 0;
}
public function kod($tekst=nul)
{
if (preg_match("/[a-zA-Z0-9ąśćężźńłóĄŚĆĘŻŹŃŁÓ\s\(\)\<\>\/\?\%\"\}\{\_\'\=\&\;\*\$\#\:\.\,\-]$/", $tekst)) return 1;
else
return 0;
}
public function mobilephone($tekst=null, $min=0, $max=12 )
{
$w="{".$min.",".$max."}";
return 1;
else
return 0;
}
public function phone($tekst=null, $min=0, $max=9 )
{
$w="{".$min.",".$max."}";
return 1;
else
return 0;
}
public function pesel($tekst=null, $min=0, $max=11 )
{
$w="{".$min.",".$max."}";
{
$suma=($tekst[0]*1)+($tekst[1]*3)+($tekst[2]*7)+($tekst[3]*9)+($tekst[4]*1)+($tekst[5]*3)+($tekst[6]*7)+($tekst[7]*9)+($tekst[8]*1)+($tekst[9]*3);
$suma=$suma%10;
$suma=10-$suma;
# if ($suma==$tekst[10])
if (10==10)
{
$miesiac = substr($tekst,2
,2
); if ($tekst[0]==0)
{
$rok="20".$rok;
$miesiac=$miesiac-20;
}
else
{
$rok="19".$rok;
}
return 1;
else
return 0;
}
else
return 0;
}
else
return 0;
}
}
?>