phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.validator.inc.php, 1.2.4.4, 1


From: Dave Hall <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.validator.inc.php, 1.2.4.4, 1.2.4.5
Date: Mon, 25 Aug 2003 21:39:22 -0400

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv22632

Modified Files:
      Tag: Version-0_9_16-branch
        class.validator.inc.php 
Log Message:
new GPL version

Index: class.validator.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.validator.inc.php,v
retrieving revision 1.2.4.4
retrieving revision 1.2.4.5
diff -C2 -r1.2.4.4 -r1.2.4.5
*** class.validator.inc.php     1 Aug 2003 22:33:14 -0000       1.2.4.4
--- class.validator.inc.php     26 Aug 2003 01:39:20 -0000      1.2.4.5
***************
*** 8,30 ****
    * http://www.phpgroupware.org/api                                          
* 
    * ------------------------------------------------------------------------ *
!   * This library is free software; you can redistribute it and/or modify it  *
!   * under the terms of the GNU Lesser General Public License as published by *
!   * the Free Software Foundation; either version 2.1 of the License,         *
!   * or any later version.                                                    *
!   * This library is distributed in the hope that it will be useful, but      *
!   * WITHOUT ANY WARRANTY; without even the implied warranty of               *
!   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
!   * See the GNU Lesser General Public License for more details.              *
!   * You should have received a copy of the GNU Lesser General Public License *
!   * along with this library; if not, write to the Free Software Foundation,  *
!   * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
    \**************************************************************************/
  
!       /* $Id$ */
  
!       /*
!       The code that used to be here was non-free code from 
www.thewebmasters.net
!       This file has been stubbed and will soon be removed from phpGW 
!       */
  
        class validator
--- 8,20 ----
    * http://www.phpgroupware.org/api                                          
* 
    * ------------------------------------------------------------------------ *
!   *  This program is Free Software; you can redistribute it and/or modify it *
!   *  under the terms of the GNU General Public License as published by the   *
!   *  Free Software Foundation; either version 2 of the License, or (at your  *
!   *  option) any later version.                                              *
    \**************************************************************************/
  
!  /* $Id$ */
  
!   //NOTE This class still needs to be documented and the stubbed methods 
fixed!
  
        class validator
***************
*** 117,133 ****
                }
  
!               function is_email ($Address='')
                {
!                       $this->nonfree_call();
!               }
! 
!               function is_url ($Url='')
!               {
!                       $this->nonfree_call();
!               }
! 
!               function url_responds ($Url='')
!               {
!                       $this->nonfree_call();
                }
  
--- 107,185 ----
                }
  
!               function is_email ($address='')
                {
!                       list($user, $domain) = explode('@', $address);
!                       
!                       if(!($user && $domain))
!                       {
!                               return false;
!                       }
!                       
!                       if(!$this->has_space($user) && $this->is_host($domain))
!                       {
!                               return true;
!                       }
!               }
! 
!               function is_url ($url='')
!               {
!                       //echo "Checking $url<br>";
!                       $uris = array(
!                               'ftp'   => True,
!                               'https' => True,
!                               'http'  => True, 
!                               );
!                       $url_elements = parse_url($url);
!                       
!                       //echo '<pre>';
!                       //print_r($url_elements);
!                       //echo '</pre>';
! 
!                       if(!is_array($url_elements))
!                       {
!                               return false;
!                       }
! 
!                       //echo 'Scheme ' . $url_elements['scheme'];
!                       if(@$uris[$url_elements['scheme']])
!                       {
!                               //echo ' is valid<br>host ' . 
$url_elements['host'];
!                               if( eregi("[a-z]", $url_elements['host']) )
!                               {
!                                       //echo ' is name<br>';
!                                       return 
$this->is_hostname($url_elements['host']);
!                               }
!                               else
!                               {
!                                       //echo ' is ip<br>';
!                                       return 
$this->is_ipaddress($url_elements['host']);
!                               }
!                       }
!                       else
!                       {
!                               //echo ' is invalid<br>';
!                               return $false;
!                       }
!                       
!               }
! 
!               //the url may be valid, but this method can't test all types
!               function url_responds ($url='')
!               {
!                       if(!$this->is_url($url))
!                       {
!                               return false;
!                       }
! 
!                       address@hidden($url);
!                       if($fp)
!                       {
!                               fclose($fp);
!                               return true;
!                       }
!                       else
!                       {
!                               return false;
!                       }
                }
  
***************
*** 139,143 ****
                function is_hostname ($hostname='')
                {
!                       $this->nonfree_call();
                }
  
--- 191,214 ----
                function is_hostname ($hostname='')
                {
!                       //echo "Checking $hostname<br>";
!                       $segs = explode('.', $hostname);
!                       if(is_array($segs))
!                       {
!                               foreach($segs as $seg)
!                               {
!                                       //echo "Checking $seg<br>";
!                                       if(eregi("[a-z0-9\-]{0,62}",$seg))
!                                       {
!                                               $return = True; 
!                                       }
! 
!                                       if(!$return)
!                                       {
!                                               return False;
!                                       }
!                               }
!                               return True;
!                       }
!                       return False;
                }
  
***************
*** 149,163 ****
                function is_host ($hostname='', $type='ANY')
                {
!                       $this->nonfree_call();
!               }
! 
!               function is_ipaddress ($IP='')
!               {
!                       $this->nonfree_call();
!               }
! 
!               function ip_resolves ($IP='')
!               {
!                       $this->nonfree_call();
                }
  
--- 220,268 ----
                function is_host ($hostname='', $type='ANY')
                {
!                       if($this->is_hostname($hostname))
!                       {
!                               return checkdnsrr($hostname, $type);
!                       }
!                       else
!                       {
!                               return false;
!                       }
!                       
!               }
! 
!               function is_ipaddress ($ip='')
!               {
!                       if(strlen($ip) <= 15)
!                       {
!                               $segs = explode('.', $ip);
!                               if(count($segs) != 4)
!                               {
!                                       return false;
!                               }
!                               foreach($segs as $seg)
!                               {
!                                       if( ($seg < 0) || ($seg >= 255) )
!                                       {
!                                               return false;
!                                       }
!                               }
!                               return true;
!                       }
!                       else
!                       {
!                               return false;
!                       }
!               }
! 
!               function ip_resolves ($ip='')
!               {
!                       if($this->is_ipaddress($ip))
!                       {
!                               return !strcmp($hostname, gethostbyaddr($ip));
!                       }
!                       else
!                       {
!                               return false;
!                       }
                }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]