[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/system/pear/Mail/ -> RFC822.php (sommaire)

(pas de description)

Poids: 923 lignes (32 kb)
Inclus ou requis: 2 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Mail_RFC822:: (22 méthodes):
  Mail_RFC822()
  parseAddressList()
  _splitAddresses()
  _isGroup()
  _splitCheck()
  _hasUnclosedQuotes()
  _hasUnclosedBrackets()
  _hasUnclosedBracketsSub()
  _validateAddress()
  _validatePhrase()
  _validateAtom()
  _validateQuotedString()
  validateMailbox()
  _validateRouteAddr()
  _validateRoute()
  _validateDomain()
  _validateSubdomain()
  _validateDliteral()
  _validateAddrSpec()
  _validateLocalPart()
  approximateCount()
  isValidInetAddress()


Classe: Mail_RFC822  - X-Ref

RFC 822 Email address list validation Utility

What is it?

This class will take an address string, and parse it into it's consituent
parts, be that either addresses, groups, or combinations. Nested groups
are not supported. The structure it returns is pretty straight forward,
and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
print_r() to view the structure.

How do I use it?

$address_string = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
$structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true)
print_r($structure);

Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)   X-Ref
Sets up the object. The address must either be set here or when
calling parseAddressList(). One or the other.

param: string  $address         The address(es) to validate.
param: string  $default_domain  Default domain/host etc. If not supplied, will be set to localhost.
param: boolean $nest_groups     Whether to return the structure with groups nested for easier viewing.
param: boolean $validate        Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
return: object Mail_RFC822 A new Mail_RFC822 object.

parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)   X-Ref
Starts the whole process. The address must either be set here
or when creating the object. One or the other.

param: string  $address         The address(es) to validate.
param: string  $default_domain  Default domain/host etc.
param: boolean $nest_groups     Whether to return the structure with groups nested for easier viewing.
param: boolean $validate        Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
return: array A structured array of addresses.

_splitAddresses($address)   X-Ref
Splits an address into separate addresses.

param: string $address The addresses to split.
return: boolean Success or failure.

_isGroup($address)   X-Ref
Checks for a group at the start of the string.

param: string $address The address to check.
return: boolean Whether or not there is a group at the start of the string.

_splitCheck($parts, $char)   X-Ref
A common function that will check an exploded string.

param: array $parts The exloded string.
param: string $char  The char that was exploded on.
return: mixed False if the string contains unclosed quotes/brackets, or the string on success.

_hasUnclosedQuotes($string)   X-Ref
Checks if a string has an unclosed quotes or not.

param: string $string The string to check.
return: boolean True if there are unclosed quotes inside the string, false otherwise.

_hasUnclosedBrackets($string, $chars)   X-Ref
Checks if a string has an unclosed brackets or not. IMPORTANT:
This function handles both angle brackets and square brackets;

param: string $string The string to check.
param: string $chars  The characters to check for.
return: boolean True if there are unclosed brackets inside the string, false otherwise.

_hasUnclosedBracketsSub($string, &$num, $char)   X-Ref
Sub function that is used only by hasUnclosedBrackets().

param: string $string The string to check.
param: integer &$num    The number of occurences.
param: string $char   The character to count.
return: integer The number of occurences of $char in $string, adjusted for backslashes.

_validateAddress($address)   X-Ref
Function to begin checking the address.

param: string $address The address to validate.
return: mixed False on failure, or a structured array of address information on success.

_validatePhrase($phrase)   X-Ref
Function to validate a phrase.

param: string $phrase The phrase to check.
return: boolean Success or failure.

_validateAtom($atom)   X-Ref
Function to validate an atom which from rfc822 is:
atom = 1*<any CHAR except specials, SPACE and CTLs>

If validation ($this->validate) has been turned off, then
validateAtom() doesn't actually check anything. This is so that you
can split a list of addresses up before encoding personal names
(umlauts, etc.), for example.

param: string $atom The string to check.
return: boolean Success or failure.

_validateQuotedString($qstring)   X-Ref
Function to validate quoted string, which is:
quoted-string = <"> *(qtext/quoted-pair) <">

param: string $qstring The string to check
return: boolean Success or failure.

validateMailbox(&$mailbox)   X-Ref
Function to validate a mailbox, which is:
mailbox =   addr-spec         ; simple address
/ phrase route-addr ; name and route-addr

param: string &$mailbox The string to check.
return: boolean Success or failure.

_validateRouteAddr($route_addr)   X-Ref
This function validates a route-addr which is:
route-addr = "<" [route] addr-spec ">"

Angle brackets have already been removed at the point of
getting to this function.

param: string $route_addr The string to check.
return: mixed False on failure, or an array containing validated address/route information on success.

_validateRoute($route)   X-Ref
Function to validate a route, which is:
route = 1#("@" domain) ":"

param: string $route The string to check.
return: mixed False on failure, or the validated $route on success.

_validateDomain($domain)   X-Ref
Function to validate a domain, though this is not quite what
you expect of a strict internet domain.

domain = sub-domain *("." sub-domain)

param: string $domain The string to check.
return: mixed False on failure, or the validated domain on success.

_validateSubdomain($subdomain)   X-Ref
Function to validate a subdomain:
subdomain = domain-ref / domain-literal

param: string $subdomain The string to check.
return: boolean Success or failure.

_validateDliteral($dliteral)   X-Ref
Function to validate a domain literal:
domain-literal =  "[" *(dtext / quoted-pair) "]"

param: string $dliteral The string to check.
return: boolean Success or failure.

_validateAddrSpec($addr_spec)   X-Ref
Function to validate an addr-spec.

addr-spec = local-part "@" domain

param: string $addr_spec The string to check.
return: mixed False on failure, or the validated addr-spec on success.

_validateLocalPart($local_part)   X-Ref
Function to validate the local part of an address:
local-part = word *("." word)

param: string $local_part
return: mixed False on failure, or the validated local part on success.

approximateCount($data)   X-Ref
Returns an approximate count of how many addresses are in the
given string. This is APPROXIMATE as it only splits based on a
comma which has no preceding backslash. Could be useful as
large amounts of addresses will end up producing *large*
structures when used with parseAddressList().

param: string $data Addresses to count
return: int          Approximate count

isValidInetAddress($data, $strict = false)   X-Ref
This is a email validating function separate to the rest of the
class. It simply validates whether an email is of the common
internet form: <user>@<domain>. This can be sufficient for most
people. Optional stricter mode can be utilised which restricts
mailbox characters allowed to alphanumeric, full stop, hyphen
and underscore.

param: string  $data   Address to check
param: boolean $strict Optional stricter mode
return: mixed           False if it fails, an indexed array



Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics