Current File : /home/inlingua/www/sensoriumpsychologists.com/franchise_between/validate_functions.php |
<?php
class validate_functions
{
public function check_isset($to_check,$name)
{
if(!isset($to_check))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_empty($to_check,$name)
{
if($to_check=="")
{
echo("Error : ".$name." cannot be empty...(Error Code : 1)");
exit();
}
}
public function check_is_none($to_check,$name)
{
if($to_check=="none")
{
echo("Error : ".$name." must be selected...(Error Code : 1)");
exit();
}
}
public function check_isset_empty($to_check,$name)
{
if(!isset($to_check))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
if($to_check=="")
{
echo("Error : ".$name." cannot be empty...(Error Code : 2)");
exit();
}
}
public function check_is_num($to_check,$name)
{
if((filter_var($to_check, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^0-9]+/")))))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_is_num_decimal($to_check,$name)
{
if((filter_var($to_check, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^0-9.]+/")))))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_is_num_coma($to_check,$name)
{
if((filter_var($to_check, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^0-9,]+/")))))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_is_alpha_underscore($to_check,$name)
{
if((filter_var($to_check, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^a-zA-Z_]+/")))))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_length($to_check,$name,$length_allowed)
{
if(strlen($to_check)>$length_allowed)
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_is_alpha($to_check,$name)
{
if((filter_var($to_check, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^a-zA-Z]+/")))))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_is_alpha_num($to_check,$name)
{
if((filter_var($to_check, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^a-zA-Z0-9]+/")))))
{
echo("Error : ".$name." invalid...(Error Code : 1)");
exit();
}
}
public function check_convert_date_display_format($date_to_check,$string)//format 01-Jan-2015
{
$invoice_date_from=$date_to_check;
if($invoice_date_from=="")
{
$invoice_date_from="0000-00-00";
}
else
{
$invoice_date_from_postback=$invoice_date_from;
$invoice_date_from_array=explode("-",$invoice_date_from);
if(count($invoice_date_from_array)!=3)
{
echo("Error : Invalid '".$string."'...(Error Code : 4)");
exit();
}
if((strlen($invoice_date_from_array[0])!=2)||($invoice_date_from_array[0]=="")||($invoice_date_from_array[0]=="00"))
{
echo("Error : Invalid day in '".$string."'...(Error Code : 5)");
exit();
}
if((filter_var($invoice_date_from_array[0], FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^0-9]+/")))))
{
echo("Error : Invalid day in '".$string."'...(Error Code : 39)");
exit();
}
switch($invoice_date_from_array[1])
{
case 'Jan':$invoice_date_from_array[1]="01";break;
case 'Feb':$invoice_date_from_array[1]="02";break;
case 'Mar':$invoice_date_from_array[1]="03";break;
case 'Apr':$invoice_date_from_array[1]="04";break;
case 'May':$invoice_date_from_array[1]="05";break;
case 'Jun':$invoice_date_from_array[1]="06";break;
case 'Jul':$invoice_date_from_array[1]="07";break;
case 'Aug':$invoice_date_from_array[1]="08";break;
case 'Sep':$invoice_date_from_array[1]="09";break;
case 'Oct':$invoice_date_from_array[1]="10";break;
case 'Nov':$invoice_date_from_array[1]="11";break;
case 'Dec':$invoice_date_from_array[1]="12";break;
}
if((strlen($invoice_date_from_array[1])!=2)||($invoice_date_from_array[1]=="")||($invoice_date_from_array[1]=="00"))
{
echo("Error : Invalid month in '".$string."'...(Error Code : 6)");
exit();
}
if((filter_var($invoice_date_from_array[1], FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^0-9]+/")))))
{
echo("Error : Invalid month in '".$string."'...(Error Code : 40)");
exit();
}
if((strlen($invoice_date_from_array[2])!=4)||($invoice_date_from_array[2]=="")||($invoice_date_from_array[2]=="0000"))
{
echo("Error : Invalid year in '".$string."'...(Error Code : 7)");
exit();
}
if((filter_var($invoice_date_from_array[2], FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[^0-9]+/")))))
{
echo("Error : Invalid year in '".$string."'...(Error Code : 41)");
exit();
}
$invoice_date_from=$invoice_date_from_array[2]."-".$invoice_date_from_array[1]."-".$invoice_date_from_array[0];
}
return $invoice_date_from;
}
}
?>