/**
  *  This checks if the specified text is a valid HTTP url. It should start with http:// and it should have at
  *  least one dot in there.
  *
  *  @param $val     	The value to test.
  *  @param $opts    	(not required)
  *	@param $formelement	(not required)
  */
 function httpurl($val, $opts = array(), $formelement = null)
 {
     // Return true if empty
     if (empty($val)) {
         return true;
     }
     // Convert to lowercase and trim
     $val = strtolower(trim($val));
     // Check lenght
     if (strlen($val) > 255) {
         return false;
     }
     // Add http:// if needed
     if (substr($val, 0, 7) != 'http://' && substr($val, 0, 8) != 'https://') {
         $val = 'http://' . $val;
     }
     // Compute expression
     $expression = '/^(https?:\\/\\/)' . '?(([0-9a-z_!~*\'().&=+$%-]+:)?[0-9a-z_!~*\'().&=+$%-]+@)?' . '(([0-9]{1,3}\\.){3}[0-9]{1,3}' . '|' . '([0-9a-z_!~*\'()-]+\\.)*' . '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\.' . '[a-z]{2,6}' . '|' . 'localhost)' . '(:[0-9]{1,5})?' . '((\\/?)|' . '(\\/[0-9a-z_!~*\'().;?:@&=+$,%#-]+)+\\/?)$/';
     return YDValidateRules::regex($val, $expression);
 }
 /**
  *	This rule checks if a file upload had the filename based on a regular expression.
  *
  *	@param $val		The value to test.
  *	@param $opts	The regex to which the filename should match.
  */
 function filename($val, $opts)
 {
     return YDValidateRules::regex($val['name'], $opts);
 }