From: tokul Date: Sun, 22 May 2005 08:20:11 +0000 (+0000) Subject: adding index files in order to prevent directory listing. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=0f459286b465c21d7a7807098b34ae610a635a11;hp=09047d19fab2afd788d7ea6e493811393bf4c1a3 adding index files in order to prevent directory listing. adding some phpdoc blocks to mime classes. tagging possible programming errors git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9434 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/class/deliver/index.php b/class/deliver/index.php index c5e70db3..fd6dfdf7 100644 --- a/class/deliver/index.php +++ b/class/deliver/index.php @@ -1,3 +1,16 @@ \ No newline at end of file diff --git a/class/helper/index.php b/class/helper/index.php new file mode 100644 index 00000000..fd6dfdf7 --- /dev/null +++ b/class/helper/index.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/class/l10n/index.php b/class/l10n/index.php new file mode 100644 index 00000000..fd6dfdf7 --- /dev/null +++ b/class/l10n/index.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/class/mime.class.php b/class/mime.class.php index fc05bdb2..01fa8d48 100644 --- a/class/mime.class.php +++ b/class/mime.class.php @@ -6,10 +6,11 @@ * Copyright (c) 2003-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * This contains functions needed to handle mime messages. + * This file loads classes needed to handle mime messages. * * @version $Id$ * @package squirrelmail + * @subpackage mime */ /** @ignore */ diff --git a/class/mime/AddressStructure.class.php b/class/mime/AddressStructure.class.php index 0f9d3b8f..97ebb532 100644 --- a/class/mime/AddressStructure.class.php +++ b/class/mime/AddressStructure.class.php @@ -6,23 +6,54 @@ * Copyright (c) 2003-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * This contains functions needed to handle mime messages. + * This file contains functions needed to extract email address headers from + * mime messages. * * @version $Id$ * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ /** - * Undocumented class + * Class used to work with email address headers * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ class AddressStructure { - var $personal = '', - $adl = '', - $mailbox = '', - $host = '', - $group = ''; + /** + * Personal information + * @var string + */ + var $personal = ''; + /** + * @todo check use of this variable. var is not used in class. + * @var string + */ + var $adl = ''; + /** + * Mailbox name. + * @var string + */ + var $mailbox = ''; + /** + * Server address. + * @var string + */ + var $host = ''; + /** + * @todo check use of this variable. var is not used in class. + * @var string + */ + var $group = ''; + /** + * Return address information from mime headers. + * @param boolean $full return full address (true) or only email (false) + * @param boolean $encoded (since 1.4.0) return rfc2047 encoded address (true) or plain text (false). + * @return string + */ function getAddress($full = true, $encoded = false) { $result = ''; if (is_object($this)) { @@ -58,9 +89,14 @@ class AddressStructure { return $result; } + /** + * Shorter version of getAddress() function + * Returns full encoded address. + * @return string + * @since 1.4.0 + */ function getEncodedAddress() { return $this->getAddress(true, true); } } - ?> \ No newline at end of file diff --git a/class/mime/ContentType.class.php b/class/mime/ContentType.class.php index 9653b58f..d44c79f9 100644 --- a/class/mime/ContentType.class.php +++ b/class/mime/ContentType.class.php @@ -6,21 +6,46 @@ * Copyright (c) 2003-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * This contains functions needed to handle mime messages. + * This file contains functions needed to handle content type headers + * (rfc2045) in mime messages. * * @version $Id$ * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ /** - * Undocumented class + * Class that handles content-type headers + * Class was named content_type in 1.3.0 and 1.3.1. It is used internally + * by rfc822header class. * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ class ContentType { - var $type0 = 'text', - $type1 = 'plain', - $properties = ''; + /** + * Media type + * @var string + */ + var $type0 = 'text'; + /** + * Media subtype + * @var string + */ + var $type1 = 'plain'; + /** + * Auxiliary header information + * prepared with parseContentType() function in rfc822header class. + * @var array + */ + var $properties = ''; + /** + * Constructor function. + * Prepared type0 and type1 properties + * @param string $type content type string without auxiliary information + */ function ContentType($type) { $pos = strpos($type, '/'); if ($pos > 0) { diff --git a/class/mime/Disposition.class.php b/class/mime/Disposition.class.php index 7b3755d0..bf005697 100644 --- a/class/mime/Disposition.class.php +++ b/class/mime/Disposition.class.php @@ -6,22 +6,39 @@ * Copyright (c) 2003-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * This contains functions needed to handle mime messages. + * This file contains functions needed to handle content disposition headers + * in mime messages. * * @version $Id$ * @package squirrelmail + * @subpackage mime + * @since 1.3.2 + * @todo find rfc number */ /** - * Undocumented class + * Class that handles content disposition header * @package squirrelmail + * @subpackage mime + * @since 1.3.0 + * @todo FIXME: do we have to declare vars ($name and $properties)? */ class Disposition { + /** + * Constructor function + * @param string $name + */ function Disposition($name) { $this->name = $name; $this->properties = array(); } + /** + * Returns value of content disposition property + * @param string $par content disposition property name + * @return string + * @since 1.3.1 + */ function getProperty($par) { $value = strtolower($par); if (isset($this->properties[$par])) { diff --git a/class/mime/Language.class.php b/class/mime/Language.class.php index 9d78b61b..7aae1f52 100644 --- a/class/mime/Language.class.php +++ b/class/mime/Language.class.php @@ -11,6 +11,7 @@ * * @version $Id$ * @package squirrelmail + * @subpackage mime * @since 1.3.2 */ @@ -18,6 +19,7 @@ * Class that can be used to handle language properties in MIME headers. * * @package squirrelmail + * @subpackage mime * @since 1.3.0 */ class Language { diff --git a/class/mime/Message.class.php b/class/mime/Message.class.php index 0da1e5e4..de6530f4 100644 --- a/class/mime/Message.class.php +++ b/class/mime/Message.class.php @@ -10,6 +10,8 @@ * * @version $Id$ * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ /** @@ -20,6 +22,8 @@ * more objects of type message. See documentation in mime.txt for * a better description of how this works. * @package squirrelmail + * @subpackage mime + * @since 1.3.0 */ class Message { var $rfc822_header = '', @@ -39,14 +43,25 @@ class Message { $att_local_name = ''; /* location where the tempory attachment is stored. For future usage in smtp.php */ + /** + * @param mixed $ent entity id + */ function setEnt($ent) { $this->entity_id= $ent; } + /** + * @param mixed $msg + */ function addEntity ($msg) { $this->entities[] = $msg; } + /** + * Get file name used for mime part + * @return string file name + * @since 1.3.2 + */ function getFilename() { $filename = ''; $header = $this->header; @@ -85,12 +100,20 @@ class Message { return $filename; } - + /** + * Add header object to message object. + * WARNING: Unfinished code. Don't expect it to work in older sm versions. + * @param mixed $read array or string with message headers + * @todo FIXME: rfc822header->parseHeader() does not return rfc822header object + */ function addRFC822Header($read) { $header = new Rfc822Header(); $this->rfc822_header = $header->parseHeader($read); } + /** + * @param string $ent + */ function getEntity($ent) { $cur_ent = $this->entity_id; $msg = $this; @@ -133,10 +156,17 @@ class Message { return $msg; } + /** + * Set message body + * @param string $s message body + */ function setBody($s) { $this->body_part = $s; } + /** + * Clean message object + */ function clean_up() { $msg = $this; $msg->body_part = ''; @@ -146,6 +176,9 @@ class Message { } } + /** + * @return string + */ function getMailbox() { $msg = $this; while (is_object($msg->parent)) { @@ -164,7 +197,11 @@ class Message { * Question/Bugs: * * Ask for me (Marc Groot Koerkamp, stekkel@users.sourceforge.net) - * + * @param string $read + * @param integer $i + * @param mixed $sub_msg + * @return object Message object + * @todo define argument and return types */ function parseStructure($read, &$i, $sub_msg = '') { $msg = Message::parseBodyStructure($read, $i, $sub_msg); @@ -172,6 +209,13 @@ class Message { return $msg; } + /** + * @param object $msg + * @param mixed $init + * @param integer $i + * @todo document me + * @since 1.4.0 + */ function setEntIds(&$msg,$init=false,$i=0) { $iCnt = count($msg->entities); if ($init !==false) { @@ -201,6 +245,14 @@ class Message { } } + /** + * @param string $read + * @param integer $i + * @param mixed $sub_msg + * @return object Message object + * @todo document me + * @since 1.4.0 (code was part of parseStructure() in 1.3.x) + */ function parseBodyStructure($read, &$i, $sub_msg = '') { $arg_no = 0; $arg_a = array(); @@ -376,6 +428,11 @@ class Message { } /* for */ } /* parsestructure */ + /** + * @param string $read + * @param integer $i + * @return array + */ function parseProperties($read, &$i) { $properties = array(); $prop_name = ''; @@ -401,6 +458,12 @@ class Message { return $properties; } + /** + * @param string $read + * @param integer $i + * @param object $hdr MessageHeader object + * @return object MessageHeader object + */ function parseEnvelope($read, &$i, $hdr) { $arg_no = 0; $arg_a = array(); @@ -484,6 +547,12 @@ class Message { return $hdr; } + /** + * @param string $read + * @param integer $i + * @return string + * @todo document me + */ function parseLiteral($read, &$i) { $lit_cnt = ''; ++$i; @@ -504,6 +573,12 @@ class Message { return $s; } + /** + * @param string $read + * @param integer $i + * @return string + * @todo document me + */ function parseQuote($read, &$i) { $s = ''; $iPos = ++$i; @@ -523,6 +598,11 @@ class Message { return $s; } + /** + * @param string $read + * @param integer $i + * @return object AddressStructure object + */ function parseAddress($read, &$i) { $arg_a = array(); for (; $read{$i} != ')'; ++$i) { @@ -553,6 +633,11 @@ class Message { return $adr; } + /** + * @param string $read + * @param integer $i + * @param object Disposition object or empty string + */ function parseDisposition($read, &$i) { $arg_a = array(); for (; $read{$i} != ')'; ++$i) { @@ -574,6 +659,11 @@ class Message { return (is_object($disp) ? $disp : ''); } + /** + * @param string $read + * @param integer $i + * @return object Language object or empty string + */ function parseLanguage($read, &$i) { /* no idea how to process this one without examples */ $arg_a = array(); @@ -597,6 +687,12 @@ class Message { return (is_object($lang) ? $lang : ''); } + /** + * Parse message text enclosed in parenthesis + * @param string $read + * @param integer $i + * @return integer + */ function parseParenthesis($read, $i) { for (; $read{$i} != ')'; ++$i) { switch ($read{$i}) { @@ -609,8 +705,15 @@ class Message { return $i; } - /* Function to fill the message structure in case the */ - /* bodystructure is not available NOT FINISHED YET */ + /** + * Function to fill the message structure in case the + * bodystructure is not available + * NOT FINISHED YET + * @param string $read + * @param string $type0 message part type + * @param string $type1 message part subtype + * @return string + */ function parseMessage($read, $type0, $type1) { switch ($type0) { case 'message': @@ -678,6 +781,12 @@ class Message { } } + /** + * @param array $entity + * @param array $alt_order + * @param boolean $strict + * @return array + */ function findDisplayEntity($entity = array(), $alt_order = array('text/plain', 'text/html'), $strict=false) { $found = false; if ($this->type0 == 'multipart') { @@ -751,6 +860,10 @@ class Message { return $entity; } + /** + * @param array $alt_order + * @return array + */ function findAlternativeEntity($alt_order) { /* If we are dealing with alternative parts then we */ /* choose the best viewable message supported by SM. */ @@ -775,6 +888,9 @@ class Message { return $entity; } + /** + * @return array + */ function findRelatedEntity() { $msgs = array(); $related_type = $this->header->getParameter('type'); @@ -790,6 +906,11 @@ class Message { return $msgs; } + /** + * @param array $exclude_id + * @param array $result + * @return array + */ function getAttachments($exclude_id=array(), $result = array()) { /* if (($this->type0 == 'message') && @@ -829,10 +950,17 @@ class Message { return $result; } + /** + * Add attachment to message object + * @param string $type attachment type + * @param string $name attachment name + * @param string $location path to attachment + */ function initAttachment($type, $name, $location) { $attachment = new Message(); $mime_header = new MessageHeader(); $mime_header->setParameter('name', $name); + // FIXME: duplicate code. see ContentType class $pos = strpos($type, '/'); if ($pos > 0) { $mime_header->type0 = substr($type, 0, $pos); diff --git a/class/mime/MessageHeader.class.php b/class/mime/MessageHeader.class.php index e0b4fb36..51000744 100644 --- a/class/mime/MessageHeader.class.php +++ b/class/mime/MessageHeader.class.php @@ -6,20 +6,25 @@ * Copyright (c) 2003-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * This contains functions needed to handle mime messages. + * This file contains functions needed to handle headers in mime messages. * * @version $Id$ * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ /** - * Contains all variables available in a bodystructure + * Message header class + * Class contains all variables available in a bodystructure + * entity like described in rfc2060 + * It was called msg_header in 1.3.0 and 1.3.1. * @package squirrelmail + * @subpackage mime + * @since 1.3.2 + * @todo document vars */ class MessageHeader { - /** msg_header contains all variables available in a bodystructure **/ - /** entity like described in rfc2060 **/ - var $type0 = '', $type1 = '', $parameters = array(), @@ -31,21 +36,30 @@ class MessageHeader { $disposition = '', $language=''; - /* - * returns addres_list of supplied argument - * arguments: array('to', 'from', ...) or just a string like 'to'. - * result: string: address1, addres2, .... + /** + * Sets header variable + * @param string $var + * @param mixed $value */ - function setVar($var, $value) { $this->{$var} = $value; } + /** + * Gets parameter value from $parameters array + * @param string $p + * @return mixed + */ function getParameter($p) { $value = strtolower($p); return (isset($this->parameters[$p]) ? $this->parameters[$p] : ''); } + /** + * Sets parameter value in $parameters array + * @param string $parameter + * @param mixed $value + */ function setParameter($parameter, $value) { $this->parameters[strtolower($parameter)] = $value; } diff --git a/class/mime/Rfc822Header.class.php b/class/mime/Rfc822Header.class.php index 51141440..75073498 100644 --- a/class/mime/Rfc822Header.class.php +++ b/class/mime/Rfc822Header.class.php @@ -6,15 +6,23 @@ * Copyright (c) 2003-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * - * This contains functions needed to handle mime messages. + * This file contains functions needed to handle headers in mime messages. * * @version $Id$ * @package squirrelmail + * @subpackage mime + * @since 1.3.2 */ /** + * MIME header class * input: header_string or array + * You must call parseHeader() function after creating object in order to fill object's + * parameters. + * @todo FIXME: there is no constructor function and class should ignore all input args. * @package squirrelmail + * @subpackage mime + * @since 1.3.0 */ class Rfc822Header { var $date = -1, @@ -41,11 +49,15 @@ class Rfc822Header { $mlist = array(), $more_headers = array(); /* only needed for constructing headers in smtp.php */ + /** + * @param mixed $hdr string or array with message headers + */ function parseHeader($hdr) { if (is_array($hdr)) { $hdr = implode('', $hdr); } /* First we replace \r\n by \n and unfold the header */ + /* FIXME: unfolding header with multiple spaces "\n( +)" */ $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $hdr)); /* Now we can make a new header array with */ @@ -66,6 +78,10 @@ class Rfc822Header { } } + /** + * @param string $value + * @return string + */ function stripComments($value) { $result = ''; $cnt = strlen($value); @@ -108,6 +124,11 @@ class Rfc822Header { return $result; } + /** + * Parse header field according to field type + * @param string $field field name + * @param string $value field value + */ function parseField($field, $value) { $field = strtolower($field); switch($field) { @@ -227,6 +248,10 @@ class Rfc822Header { } } + /** + * @param string $address + * @return array + */ function getAddressTokens($address) { $aTokens = array(); $aSpecials = array('(' ,'<' ,',' ,';' ,':'); @@ -351,6 +376,14 @@ class Rfc822Header { } return $aTokens; } + + /** + * @param array $aStack + * @param array $aComment + * @param string $sEmail + * @param string $sGroup + * @return object AddressStructure object + */ function createAddressObject(&$aStack,&$aComment,&$sEmail,$sGroup='') { //$aStack=explode(' ',implode('',$aStack)); if (!$sEmail) { @@ -387,21 +420,8 @@ class Rfc822Header { return $oAddr; } - /* - * parseAddress: recursive function for parsing address strings and store - * them in an address stucture object. - * input: $address = string - * $ar = boolean (return array instead of only the - * first element) - * $addr_ar = array with parsed addresses // obsolete - * $group = string // obsolete - * $host = string (default domainname in case of - * addresses without a domainname) - * $lookup = callback function (for lookup address - * strings which are probably nicks - * (without @ ) ) - * output: array with addressstructure objects or only one - * address_structure object. + /** + * recursive function for parsing address strings and storing them in an address stucture object. * personal name: encoded: =?charset?Q|B?string?= * quoted: "string" * normal: string @@ -409,8 +429,14 @@ class Rfc822Header { * : mailbox@host * This function is also used for validating addresses returned from compose * That's also the reason that the function became a little bit huge + * @param string $address + * @param boolean $ar return array instead of only the first element + * @param array $addr_ar (obsolete) array with parsed addresses + * @param string $group (obsolete) + * @param string $host default domainname in case of addresses without a domainname + * @param string $lookup (since) callback function for lookup of address strings which are probably nicks (without @) + * @return mixed array with AddressStructure objects or only one address_structure object. */ - function parseAddress($address,$ar=false,$aAddress=array(),$sGroup='',$sHost='',$lookup=false) { $aTokens = $this->getAddressTokens($address); $sPersonal = $sEmail = $sGroup = ''; @@ -509,13 +535,15 @@ class Rfc822Header { /** * Normalise the different Priority headers into a uniform value, * namely that of the X-Priority header (1, 3, 5). Supports: - * Prioirty, X-Priority, Importance. + * Priority, X-Priority, Importance. * X-MS-Mail-Priority is not parsed because it always coincides * with one of the other headers. * * NOTE: this is actually a duplicate from the function in * functions/imap_messages. I'm not sure if it's ok here to call * that function? + * @param string $value literal priority name + * @return integer */ function parsePriority($value) { $value = strtolower(array_shift(split('/\w/',trim($value)))); @@ -531,6 +559,9 @@ class Rfc822Header { return 3; } + /** + * @param string $value content type header + */ function parseContentType($value) { $pos = strpos($value, ';'); $props = ''; @@ -551,7 +582,11 @@ class Rfc822Header { $this->content_type = $content_type; } - /* RFC2184 */ + /** + * RFC2184 + * @param array $aParameters + * @return array + */ function processParameters($aParameters) { $aResults = array(); $aCharset = array(); @@ -578,13 +613,21 @@ class Rfc822Header { $value = substr($value,strlen($charset)+1); $language = substr($value,0,strpos($value,"'")); $value = substr($value,strlen($charset)+1); - // FIX ME What's the status of charset decode with language information ???? + /* FIXME: What's the status of charset decode with language information ???? + * Maybe language information contains only ascii text and charset_decode() + * only runs htmlspecialchars() on it. If it contains 8bit information, you + * get html encoded text in charset used by selected translation. + */ $value = charset_decode($charset,$value); $aResults[$key] = $value; } return $aResults; } + /** + * @param string $value + * @return array + */ function parseProperties($value) { $propArray = explode(';', $value); $propResultArray = array(); @@ -603,6 +646,10 @@ class Rfc822Header { return $this->processParameters($propResultArray); } + /** + * Fills disposition object in rfc822Header object + * @param string $value + */ function parseDisposition($value) { $pos = strpos($value, ';'); $props = ''; @@ -618,6 +665,11 @@ class Rfc822Header { $this->disposition = $disp; } + /** + * Fills mlist array keys in rfc822Header object + * @param string $field + * @param string $value + */ function mlist($field, $value) { $res_a = array(); $value_a = explode(',', $value); @@ -635,11 +687,14 @@ class Rfc822Header { $this->mlist[$field] = $res_a; } - /* - * function to get the addres strings out of the header. - * Arguments: string or array of strings ! + /** + * function to get the address strings out of the header. * example1: header->getAddr_s('to'). * example2: header->getAddr_s(array('to', 'cc', 'bcc')) + * @param mixed $arr string or array of strings + * @param string $separator + * @param boolean $encoded (since 1.4.0) return encoded or plain text addresses + * @return string */ function getAddr_s($arr, $separator = ',',$encoded=false) { $s = ''; @@ -677,6 +732,13 @@ class Rfc822Header { return $s; } + /** + * function to get the array of addresses out of the header. + * @param mixed $arg string or array of strings + * @param array $excl_arr array of excluded email addresses + * @param array $arr array of added email addresses + * @return array + */ function getAddr_a($arg, $excl_arr = array(), $arr = array()) { if (is_array($arg)) { foreach($arg as $argument) { @@ -712,6 +774,12 @@ class Rfc822Header { return $arr; } + /** + * @param mixed $address array or string + * @param boolean $recurs + * @return mixed array, boolean + * @since 1.3.2 + */ function findAddress($address, $recurs = false) { $result = false; if (is_array($address)) { @@ -745,7 +813,7 @@ class Rfc822Header { } } } - foreach ($this->cc as $cc) { + foreach ($this->cc as $cc) { if ($cc->host == $srch_addr->host) { if ($cc->mailbox == $srch_addr->mailbox) { $results[] = $srch_addr; @@ -771,6 +839,12 @@ class Rfc822Header { return $result; } + /** + * @param string $type0 media type + * @param string $type1 media subtype + * @return array media properties + * @todo check use of media type arguments + */ function getContentType($type0, $type1) { $type0 = $this->content_type->type0; $type1 = $this->content_type->type1; diff --git a/class/mime/SMimeMessage.class.php b/class/mime/SMimeMessage.class.php index c97e737b..d531cceb 100644 --- a/class/mime/SMimeMessage.class.php +++ b/class/mime/SMimeMessage.class.php @@ -11,12 +11,14 @@ * @link http://www.ietf.org/html.charters/smime-charter.html * @version $Id$ * @package squirrelmail + * @subpackage mime * @since 1.3.2 */ /** * Unimplemented class. * @package squirrelmail + * @subpackage mime * @todo implement smime parsing */ class SMimeMessage { diff --git a/class/mime/index.php b/class/mime/index.php index c5e70db3..fd6dfdf7 100644 --- a/class/mime/index.php +++ b/class/mime/index.php @@ -1,3 +1,16 @@ \ No newline at end of file diff --git a/class/template/index.php b/class/template/index.php new file mode 100644 index 00000000..fd6dfdf7 --- /dev/null +++ b/class/template/index.php @@ -0,0 +1,16 @@ + \ No newline at end of file