ILIAS
trunk Revision v11.0_alpha-1831-g8615d53dadb
|
Public Member Functions | |
__construct (?string $address=null, ?string $default_domain=null, ?bool $nest_groups=null, ?bool $validate=null, ?int $limit=null) | |
Sets up the object. More... | |
parseAddressList (?string $address=null, ?string $default_domain=null, ?bool $nest_groups=null, ?bool $validate=null, ?int $limit=null) | |
Starts the whole process. More... | |
validateMailbox (string &$mailbox) | |
Function to validate a mailbox, which is: mailbox = addr-spec ; simple address / phrase route-addr ; name and route-addr. More... | |
approximateCount (string $data) | |
Returns an approximate count of how many addresses are in the given string. More... | |
isValidInetAddress (string $data, bool $strict=false) | |
This is a email validating function separate to the rest of the class. More... | |
Data Fields | |
string | $address = '' |
The address being parsed by the RFC822 object. More... | |
string | $default_domain = 'localhost' |
The default domain to use for unqualified addresses. More... | |
bool | $nestGroups = true |
Should we return a nested array showing groups, or flatten everything? More... | |
bool | $validate = true |
Whether or not to validate atoms for non-ascii characters. More... | |
array | $addresses = [] |
The array of raw addresses built up as we parse. More... | |
array | $structure = [] |
The final array of parsed address information that we build up. More... | |
string | $error = null |
The current error message, if any. More... | |
int | $index = null |
An internal counter/pointer. More... | |
int | $num_groups = 0 |
The number of groups that have been found in the address list. More... | |
bool | $mailRFC822 = true |
A variable so that we can tell whether or not we're inside a Mail_RFC822 object. More... | |
int | $limit = null |
A limit after which processing stops. More... | |
Protected Member Functions | |
_splitAddresses (string $address) | |
Splits an address into separate addresses. More... | |
_isGroup (string $address) | |
Checks for a group at the start of the string. More... | |
_splitCheck (array $parts, string $char) | |
A common function that will check an exploded string. More... | |
_hasUnclosedQuotes (string $string) | |
Checks if a string has unclosed quotes or not. More... | |
_hasUnclosedBrackets (string $string, string $chars) | |
Checks if a string has an unclosed brackets or not. More... | |
_hasUnclosedBracketsSub (string $string, int &$num, string $char) | |
Sub function that is used only by hasUnclosedBrackets(). More... | |
_validateAddress (array $address) | |
Function to begin checking the address. More... | |
_validatePhrase (string $phrase) | |
Function to validate a phrase. More... | |
_validateAtom (string $atom) | |
Function to validate an atom which from rfc822 is: atom = 1*<any CHAR except specials, SPACE and CTLs> More... | |
_validateQuotedString (string $qstring) | |
Function to validate quoted string, which is: quoted-string = <"> *(qtext/quoted-pair) <"> More... | |
_validateRouteAddr (string $route_addr) | |
This function validates a route-addr which is: route-addr = "<" [route] addr-spec ">". More... | |
_validateRoute (string $route) | |
Function to validate a route, which is: route = 1#("@" domain) ":". More... | |
_validateDomain (string $domain) | |
Function to validate a domain, though this is not quite what you expect of a strict internet domain. More... | |
_validateSubdomain (string $subdomain) | |
Function to validate a subdomain: subdomain = domain-ref / domain-literal. More... | |
_validateDliteral (string $dliteral) | |
Function to validate a domain literal: domain-literal = "[" *(dtext / quoted-pair) "]". More... | |
_validateAddrSpec (string $addr_spec) | |
Function to validate an addr-spec. More... | |
_validateLocalPart (string $local_part) | |
Function to validate the local part of an address: local-part = word *("." word) More... | |
Definition at line 74 of file RFC822.php.
Mail_RFC822::__construct | ( | ?string | $address = null , |
?string | $default_domain = null , |
||
?bool | $nest_groups = null , |
||
?bool | $validate = null , |
||
?int | $limit = null |
||
) |
Sets up the object.
The address must either be set here or when calling parseAddressList(). One or the other.
string | $address | The address(es) to validate. |
string | $default_domain | Default domain/host etc. If not supplied, will be set to localhost. |
bool | $nest_groups | Whether to return the structure with groups nested for easier viewing. |
bool | $validate | Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. |
Definition at line 154 of file RFC822.php.
References $address, $default_domain, $limit, and $validate.
|
protected |
Checks if a string has an unclosed brackets or not.
IMPORTANT: This function handles both angle brackets and square brackets;
string | $string | The string to check. |
string | $chars | The characters to check for. |
Definition at line 424 of file RFC822.php.
References _hasUnclosedBracketsSub().
Referenced by _splitCheck().
|
protected |
Sub function that is used only by hasUnclosedBrackets().
string | $string | The string to check. |
int | &$num | The number of occurences. |
string | $char | The character to count. |
Definition at line 448 of file RFC822.php.
References $parts, and _hasUnclosedQuotes().
Referenced by _hasUnclosedBrackets().
|
protected |
Checks if a string has unclosed quotes or not.
string | $string | The string to check. |
Definition at line 387 of file RFC822.php.
Referenced by _hasUnclosedBracketsSub(), and _splitCheck().
|
protected |
Checks for a group at the start of the string.
string | $address | The address to check. |
Definition at line 332 of file RFC822.php.
References $parts, and _splitCheck().
Referenced by _splitAddresses().
|
protected |
Splits an address into separate addresses.
string | $address | The addresses to split. |
Definition at line 264 of file RFC822.php.
References $address, $parts, _isGroup(), and _splitCheck().
Referenced by parseAddressList().
|
protected |
A common function that will check an exploded string.
array | $parts | The exloded string. |
string | $char | The char that was exploded on. |
Definition at line 356 of file RFC822.php.
References _hasUnclosedBrackets(), and _hasUnclosedQuotes().
Referenced by _isGroup(), _splitAddresses(), _validateAddress(), _validateAddrSpec(), _validateDomain(), _validateLocalPart(), _validatePhrase(), _validateRouteAddr(), and validateMailbox().
|
protected |
Function to begin checking the address.
array | $address | The address to validate. |
Definition at line 469 of file RFC822.php.
References $addresses, $parts, $structure, _splitCheck(), _validatePhrase(), and validateMailbox().
Referenced by parseAddressList().
|
protected |
Function to validate an addr-spec.
addr-spec = local-part "@" domain
string | $addr_spec | The string to check. |
Definition at line 875 of file RFC822.php.
References $default_domain, $parts, $validate, _splitCheck(), _validateDomain(), and _validateLocalPart().
Referenced by _validateRouteAddr(), and validateMailbox().
|
protected |
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.
string | $atom | The string to check. |
Definition at line 594 of file RFC822.php.
Referenced by _validatePhrase(), and _validateSubdomain().
|
protected |
Function to validate a domain literal: domain-literal = "[" *(dtext / quoted-pair) "]".
string | $dliteral | The string to check. |
Definition at line 861 of file RFC822.php.
Referenced by _validateSubdomain().
|
protected |
Function to validate a domain, though this is not quite what you expect of a strict internet domain.
domain = sub-domain *("." sub-domain)
string | $domain | The string to check. |
Definition at line 810 of file RFC822.php.
References _splitCheck(), and _validateSubdomain().
Referenced by _validateAddrSpec(), and _validateRoute().
|
protected |
Function to validate the local part of an address: local-part = word *("." word)
private
string | $local_part |
Definition at line 924 of file RFC822.php.
References $parts, _splitCheck(), and _validatePhrase().
Referenced by _validateAddrSpec().
|
protected |
Function to validate a phrase.
string | $phrase | The phrase to check. |
Definition at line 551 of file RFC822.php.
References $parts, _splitCheck(), _validateAtom(), and _validateQuotedString().
Referenced by _validateAddress(), _validateLocalPart(), and validateMailbox().
|
protected |
Function to validate quoted string, which is: quoted-string = <"> *(qtext/quoted-pair) <">
string | $qstring | The string to check |
Definition at line 629 of file RFC822.php.
Referenced by _validatePhrase().
|
protected |
Function to validate a route, which is: route = 1#("@" domain) ":".
string | $route | The string to check. |
Definition at line 786 of file RFC822.php.
References _validateDomain().
Referenced by _validateRouteAddr().
|
protected |
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.
string | $route_addr | The string to check. |
Definition at line 737 of file RFC822.php.
References $parts, _splitCheck(), _validateAddrSpec(), and _validateRoute().
Referenced by validateMailbox().
|
protected |
Function to validate a subdomain: subdomain = domain-ref / domain-literal.
string | $subdomain | The string to check. |
Definition at line 840 of file RFC822.php.
References _validateAtom(), and _validateDliteral().
Referenced by _validateDomain().
Mail_RFC822::approximateCount | ( | string | $data | ) |
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().
string | $data | Addresses to count |
Definition at line 973 of file RFC822.php.
Mail_RFC822::isValidInetAddress | ( | string | $data, |
bool | $strict = false |
||
) |
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.
string | $data | Address to check |
bool | $strict | Optional stricter mode |
Definition at line 991 of file RFC822.php.
Mail_RFC822::parseAddressList | ( | ?string | $address = null , |
?string | $default_domain = null , |
||
?bool | $nest_groups = null , |
||
?bool | $validate = null , |
||
?int | $limit = null |
||
) |
Starts the whole process.
The address must either be set here or when creating the object. One or the other.
string | $address | The address(es) to validate. |
string | $default_domain | Default domain/host etc. |
bool | $nest_groups | Whether to return the structure with groups nested for easier viewing. |
bool | $validate | Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. |
Definition at line 189 of file RFC822.php.
References $address, $default_domain, $limit, $structure, $valid, $validate, _splitAddresses(), _validateAddress(), and null.
Mail_RFC822::validateMailbox | ( | string & | $mailbox | ) |
Function to validate a mailbox, which is: mailbox = addr-spec ; simple address / phrase route-addr ; name and route-addr.
string | &$mailbox | The string to check. |
Definition at line 646 of file RFC822.php.
References $comment, $comments, $parts, _splitCheck(), _validateAddrSpec(), _validatePhrase(), and _validateRouteAddr().
Referenced by _validateAddress().
string Mail_RFC822::$address = '' |
The address being parsed by the RFC822 object.
Definition at line 80 of file RFC822.php.
Referenced by __construct(), _splitAddresses(), and parseAddressList().
array Mail_RFC822::$addresses = [] |
The array of raw addresses built up as we parse.
Definition at line 104 of file RFC822.php.
Referenced by _validateAddress().
string Mail_RFC822::$default_domain = 'localhost' |
The default domain to use for unqualified addresses.
Definition at line 86 of file RFC822.php.
Referenced by __construct(), _validateAddrSpec(), and parseAddressList().
string Mail_RFC822::$error = null |
The current error message, if any.
Definition at line 116 of file RFC822.php.
int Mail_RFC822::$index = null |
An internal counter/pointer.
Definition at line 122 of file RFC822.php.
int Mail_RFC822::$limit = null |
A limit after which processing stops.
Definition at line 142 of file RFC822.php.
Referenced by __construct(), and parseAddressList().
bool Mail_RFC822::$mailRFC822 = true |
A variable so that we can tell whether or not we're inside a Mail_RFC822 object.
Definition at line 136 of file RFC822.php.
bool Mail_RFC822::$nestGroups = true |
Should we return a nested array showing groups, or flatten everything?
Definition at line 92 of file RFC822.php.
int Mail_RFC822::$num_groups = 0 |
The number of groups that have been found in the address list.
public
Definition at line 129 of file RFC822.php.
array Mail_RFC822::$structure = [] |
The final array of parsed address information that we build up.
Definition at line 110 of file RFC822.php.
Referenced by _validateAddress(), and parseAddressList().
bool Mail_RFC822::$validate = true |
Whether or not to validate atoms for non-ascii characters.
Definition at line 98 of file RFC822.php.
Referenced by __construct(), _validateAddrSpec(), and parseAddressList().