<?
// -------------- prints current date ---------------
function currentdate($mydate="nothing")
{
static $variable=0;
global $months;
       if ($mydate=="nothing")
       {
       $tmpM=date(m);
       $tmpD=date(d);
       $tmpY=date(Y);
       }
       else
       {
	$pat="-";
	$arr = split($pat,$mydate);	 //find all NECESSARY fields 
        $tmpY=(int) $arr[0]; //year
        $tmpM=(int) $arr[1]; //month
        $tmpD=(int) $arr[2]; //day
       }

echo "<table><tr>";
echo "<td><select name=day$variable>";
       for ($i=1;$i<=31;$i++)
        {
       if  ($i==$tmpD)
              echo "<option  value=\"$i\" selected>$i</option>";
       else
              echo "<option  value=\"$i\">$i</option>";
        }
echo "</select></td> ";
echo "<td><select name=month$variable>";
       for ($i=1;$i<=12;$i++)
       {
       if  ($i==$tmpM)       
        echo "<option  value=\"$i\" selected>$months[$i]</option>";
       else
        echo "<option  value=\"$i\" >$months[$i]</option>";
        }
echo "</select></td> ";


$y=date(Y);
echo "<td><select name=year$variable>";
       for ($i=$y;$i<$y+3;$i++)
       {
        if  ($i==$tmpY)   
          echo "<option  value=\"$i\" selected>$i</option>";
        else
          echo "<option  value=\"$i\" >$i</option>";
        }
echo "</select></td></tr></table>";
$variable++; 
// return $day."-".$month."-".$year;
}
// ------------- end printing current date ---------------

//**************   check if email/login or any data exist in DB ******************//
function check_if_exist($tocheck,$table,$fieldis)
{
         $num_rows=0;
	 $sql="SELECT * FROM $table WHERE $fieldis='$tocheck'";
	 $result = mysql_query($sql) or  die (mysql_error(). " : ".mysql_errno()); 
	 $num_rows=mysql_num_rows($result);
         return $num_rows; 

}//end of function
/*********************** end of emailvalidator() *************************/

function pricewithVAT($pricenoVAT)
{
       global $VAT;
       $priceVAT=$pricenoVAT/100*$VAT+$pricenoVAT;
       return round($priceVAT,2);
}

function pricewithoutVAT($priceVAT)
{
       global $VAT;
       $pricenoVAT=$priceVAT/(1+$VAT/100);
       return round($pricenoVAT,2);
}

//--------------- convert date to viewable status ---------/

function convert_date($date_to_convert,$param=0)
{
$pat="-";
$arr = split($pat,$date_to_convert);  //find all NECESSARY fields 
$newdate=$arr[2]."/".$arr[1]."/".$arr[0];
return $newdate;

}
//----------------- end of date convertion ----------/

//-------------- if You are authorized to enter ---------
function checkauth($dir)
{
global $login_ses;
global $url_ses;
if (! isset($login_ses) || $url_ses!=$dir)
 {
   echo "You are not authorized";
    exit;
 }
}
//------------------- end authorize me ------------

/********************* if we want to exit ***************/
if(isset ($exitme1) && $exitme1="exitme")
 {
   session_unset();
   session_destroy();
    if(isset ($to_go))
      {
	echo "<script language=javascript>location.href='$to_go';</script>";
	}
 }
/********************* end of exit ************************/

?>