Add phpdoc doc blocks to some files.
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 29 Oct 2003 09:35:51 +0000 (09:35 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 29 Oct 2003 09:35:51 +0000 (09:35 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6042 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/date.php
functions/global.php
functions/page_header.php
functions/plugin.php
functions/prefs.php
functions/strings.php
functions/tree.php
functions/url_parser.php

index 1c894d22ecf1f5b5e60b2566af64175220dc489b..ff5471983366d199c8d2935066d115fb6b606205 100644 (file)
 /** Load up some useful constants */
 require_once(SM_PATH . 'functions/constants.php');
 
 /** Load up some useful constants */
 require_once(SM_PATH . 'functions/constants.php');
 
-/** corrects a time stamp to be the local time */
+/**
+ * Corrects a time stamp to be the local time.
+ *
+ * @param int stamp the timestamp to adjust
+ * @param string tzc the timezone correction
+ * @return int the corrected timestamp
+ */
 function getGMTSeconds($stamp, $tzc) {
     /* date couldn't be parsed */
     if ($stamp == -1) {
 function getGMTSeconds($stamp, $tzc) {
     /* date couldn't be parsed */
     if ($stamp == -1) {
@@ -92,12 +98,15 @@ function getGMTSeconds($stamp, $tzc) {
 }
 
 /**
 }
 
 /**
-  Switch system has been intentionaly chosen for the
-  internationalization of month and day names. The reason
-  is to make sure that _("") strings will go into the
-  main po.
-**/
-
+ * Returns the (localized) string for a given day number.
+ * Switch system has been intentionaly chosen for the
+ * internationalization of month and day names. The reason
+ * is to make sure that _("") strings will go into the
+ * main po.
+ *
+ * @param int day_number the day number
+ * @return string the day in human readable form
+ */
 function getDayName( $day_number ) {
 
     switch( $day_number ) {
 function getDayName( $day_number ) {
 
     switch( $day_number ) {
@@ -128,6 +137,11 @@ function getDayName( $day_number ) {
     return( $ret );
 }
 
     return( $ret );
 }
 
+/**
+ * Like getDayName, but returns the short form
+ * @param int day_number the day number
+ * @return string the day in short human readable form
+ */
 function getDayAbrv( $day_number ) {
 
     switch( $day_number ) {
 function getDayAbrv( $day_number ) {
 
     switch( $day_number ) {
@@ -158,6 +172,13 @@ function getDayAbrv( $day_number ) {
     return( $ret );
 }
 
     return( $ret );
 }
 
+
+/**
+ * Returns the (localized) string for a given month number.
+ *
+ * @param string month_number the month number (01..12) 
+ * @return string the month name in human readable form
+ */
 function getMonthName( $month_number ) {
     switch( $month_number ) {
      case '01':
 function getMonthName( $month_number ) {
     switch( $month_number ) {
      case '01':
@@ -202,6 +223,13 @@ function getMonthName( $month_number ) {
     return( $ret );
 }
 
     return( $ret );
 }
 
+/**
+ * Returns the (localized) string for a given month number,
+ * short representation.
+ *
+ * @param string month_number the month number (01..12) 
+ * @return string the shortened month in human readable form
+ */
 function getMonthAbrv( $month_number ) {
     switch( $month_number ) {
      case '01':
 function getMonthAbrv( $month_number ) {
     switch( $month_number ) {
      case '01':
@@ -246,19 +274,35 @@ function getMonthAbrv( $month_number ) {
     return( $ret );
 }
 
     return( $ret );
 }
 
-
+/**
+ * Returns the localized representation of the date/time.
+ *
+ * @param string date_format The format for the date, like the input for the PHP date() function.
+ * @param int stamp the timestamp to convert
+ * @return string a full date representation
+ */
 function date_intl( $date_format, $stamp ) {
     $ret = str_replace( array('D','F','l','M'), array('$1','$2','$3','$4'), $date_format );
 function date_intl( $date_format, $stamp ) {
     $ret = str_replace( array('D','F','l','M'), array('$1','$2','$3','$4'), $date_format );
-    $ret = date('w#m#'. $ret, $stamp ); // to reduce the date calls we retrieve m and w in the same call
-    $aParts = explode('#',$ret);        // extract day and month in order to replace later by intl day and month
+    // to reduce the date calls we retrieve m and w in the same call
+    $ret = date('w#m#'. $ret, $stamp );
+    // extract day and month in order to replace later by intl day and month
+    $aParts = explode('#',$ret);        
     $ret = str_replace(array('$1','$4','$2','$3',), array(getDayAbrv($aParts[0]),
                                                           getMonthAbrv($aParts[1]),
                                                          getMonthName($aParts[1]),
                                                          getDayName($aParts[0])),
                                                          $aParts[2]);
     $ret = str_replace(array('$1','$4','$2','$3',), array(getDayAbrv($aParts[0]),
                                                           getMonthAbrv($aParts[1]),
                                                          getMonthName($aParts[1]),
                                                          getDayName($aParts[0])),
                                                          $aParts[2]);
- return( $ret );
   return( $ret );
 }
 
 }
 
+/**
+ * This returns a date of the format "Wed, Oct 29, 2003 9:52 am",
+ * or the same in 24H format (depending on the user's settings),
+ * and taking localization into accout.
+ *
+ * @param int stamp the timestamp
+ * @return string the long date string
+ */
 function getLongDateString( $stamp ) {
 
     global $hour_format;
 function getLongDateString( $stamp ) {
 
     global $hour_format;
@@ -277,6 +321,16 @@ function getLongDateString( $stamp ) {
 
 }
 
 
 }
 
+/**
+ * Returns a short representation of the date,
+ * taking timezones and localization into account.
+ * Depending on user's settings, this string can be
+ * of the form: "14:23" or "Jun 14, 2003" depending
+ * on whether the stamp is "today" or not.
+ *
+ * @param int stamp the timestamp
+ * @return string the date string
+ */
 function getDateString( $stamp ) {
 
     global $invert_time, $hour_format, $show_full_date;
 function getDateString( $stamp ) {
 
     global $invert_time, $hour_format, $show_full_date;
@@ -318,6 +372,12 @@ function getDateString( $stamp ) {
     return( date_intl( $date_format, $stamp ) );
 }
 
     return( date_intl( $date_format, $stamp ) );
 }
 
+/**
+ * Decodes a RFC 822 Date-header into a timestamp
+ *
+ * @param array dateParts the Date-header split by whitespace
+ * @return int the timestamp calculated from the header
+ */
 function getTimeStamp($dateParts) {
     /** $dateParts[0] == <day of week>   Mon, Tue, Wed
     ** $dateParts[1] == <day of month>  23
 function getTimeStamp($dateParts) {
     /** $dateParts[0] == <day of week>   Mon, Tue, Wed
     ** $dateParts[1] == <day of month>  23
index 6344ddcb7282ef22f7d595fedb75ee368803d294..3b06a8e37190db92a0f53ba9006b813779fa14fc 100644 (file)
@@ -80,6 +80,10 @@ $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
  * returns true if current php version is at mimimum a.b.c 
  * 
  * Called: check_php_version(4,1)
  * returns true if current php version is at mimimum a.b.c 
  * 
  * Called: check_php_version(4,1)
+ * @param int a major version number
+ * @param int b minor version number
+ * @param int c release number
+ * @return bool
  */
 function check_php_version ($a = '0', $b = '0', $c = '0')             
 {
  */
 function check_php_version ($a = '0', $b = '0', $c = '0')             
 {
@@ -97,6 +101,10 @@ function check_php_version ($a = '0', $b = '0', $c = '0')
  * constructed by us, as an array of 3 ints.
  *
  * Called: check_sm_version(1,3,3)
  * constructed by us, as an array of 3 ints.
  *
  * Called: check_sm_version(1,3,3)
+ * @param int a major version number
+ * @param int b minor version number
+ * @param int c release number
+ * @return bool
  */
 function check_sm_version($a = 0, $b = 0, $c = 0)
 {
  */
 function check_sm_version($a = 0, $b = 0, $c = 0)
 {
@@ -112,7 +120,11 @@ function check_sm_version($a = 0, $b = 0, $c = 0)
 }
 
 
 }
 
 
-/* recursively strip slashes from the values of an array */
+/**
+ * Recursively strip slashes from the values of an array.
+ * @param array array the array to strip, passed by reference
+ * @return void
+ */
 function sqstripslashes(&$array) {
     if(count($array) > 0) {
         foreach ($array as $index=>$value) {
 function sqstripslashes(&$array) {
     if(count($array) > 0) {
         foreach ($array as $index=>$value) {
@@ -126,6 +138,12 @@ function sqstripslashes(&$array) {
     }
 }
 
     }
 }
 
+/**
+ * Add a variable to the session.
+ * @param mixed $var the variable to register
+ * @param string $name the name to refer to this variable
+ * @return void
+ */
 function sqsession_register ($var, $name) {
 
     sqsession_is_active();
 function sqsession_register ($var, $name) {
 
     sqsession_is_active();
@@ -140,6 +158,11 @@ function sqsession_register ($var, $name) {
     session_register("$name");
 }
 
     session_register("$name");
 }
 
+/**
+ * Delete a variable from the session.
+ * @param string $name the name of the var to delete
+ * @return void
+ */
 function sqsession_unregister ($name) {
 
     sqsession_is_active();
 function sqsession_unregister ($name) {
 
     sqsession_is_active();
@@ -154,6 +177,12 @@ function sqsession_unregister ($name) {
     session_unregister("$name");
 }
 
     session_unregister("$name");
 }
 
+/**
+ * Checks to see if a variable has already been registered
+ * in the session.
+ * @param string $name the name of the var to check
+ * @return bool whether the var has been registered
+ */
 function sqsession_is_registered ($name) {
     $test_name = &$name;
     $result = false;
 function sqsession_is_registered ($name) {
     $test_name = &$name;
     $result = false;
@@ -196,8 +225,10 @@ define('SQ_FORM',6);
  *    sqgetGlobalVar('username',$username,SQ_SESSION);
  *  -- no quotes around last param!
  *
  *    sqgetGlobalVar('username',$username,SQ_SESSION);
  *  -- no quotes around last param!
  *
- * Returns FALSE if variable is not found.
- * Returns TRUE if it is.
+ * @param string name the name of the var to search
+ * @param mixed value the variable to return
+ * @param int search constant defining where to look
+ * @return bool whether variable is found.
  */
 function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) {
 
  */
 function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) {
 
@@ -260,6 +291,10 @@ function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) {
     return FALSE;
 }
 
     return FALSE;
 }
 
+/**
+ * Deletes an existing session, more advanced than the standard PHP
+ * session_destroy(), it explicitly deletes the cookies and global vars.
+ */
 function sqsession_destroy() {
 
     /*
 function sqsession_destroy() {
 
     /*
@@ -292,7 +327,7 @@ function sqsession_destroy() {
 
 }
 
 
 }
 
-/*
+/**
  * Function to verify a session has been started.  If it hasn't
  * start a session up.  php.net doesn't tell you that $_SESSION
  * (even though autoglobal), is not created unless a session is
  * Function to verify a session has been started.  If it hasn't
  * start a session up.  php.net doesn't tell you that $_SESSION
  * (even though autoglobal), is not created unless a session is
index ef044bcb0317e4c01a4f08d71fdecd942713576a..5aca335a65c778dfddb88579cdf1a8d30e45a952 100644 (file)
@@ -19,7 +19,13 @@ require_once(SM_PATH . 'functions/imap_mailbox.php');
 require_once(SM_PATH . 'functions/global.php');
 
 /**
 require_once(SM_PATH . 'functions/global.php');
 
 /**
- * Always set up the language before calling these functions
+ * Output a SquirrelMail page header, from <!doctype> to </head>
+ * Always set up the language before calling these functions.
+ *
+ * @param string title the page title, default SquirrelMail.
+ * @param string xtra extra HTML to insert into the header
+ * @param bool do_hook whether to execute hooks, default true
+ * @return void
  */
 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
     global $squirrelmail_language;
  */
 function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
     global $squirrelmail_language;
@@ -73,6 +79,13 @@ ECHO;
     $pageheader_sent = TRUE;
 }
 
     $pageheader_sent = TRUE;
 }
 
+/**
+ * Given a path to a SquirrelMail file, return a HTML link to it
+ *
+ * @param string path the SquirrelMail file to link to
+ * @param string text the link text
+ * @param string target the target frame for this link
+ */
 function makeInternalLink($path, $text, $target='') {
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
     if ($target != '') {
 function makeInternalLink($path, $text, $target='') {
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
     if ($target != '') {
@@ -84,10 +97,24 @@ function makeInternalLink($path, $text, $target='') {
     return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
 }
 
     return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
 }
 
+/**
+ * Same as makeInternalLink, but echoes it too
+ */
 function displayInternalLink($path, $text, $target='') {
     echo makeInternalLink($path, $text, $target);
 }
 
 function displayInternalLink($path, $text, $target='') {
     echo makeInternalLink($path, $text, $target);
 }
 
+/**
+ * Outputs a complete SquirrelMail page header, starting with <!doctype> and
+ * including the default menu bar. Uses displayHtmlHeader and takes
+ * JavaScript and locale settings into account.
+ *
+ * @param array color the array of theme colors
+ * @param string mailbox the current mailbox name to display
+ * @param string xtra extra html code to add
+ * @param bool session
+ * @return void
+ */
 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 
     global $hide_sm_attributions, $PHP_SELF, $frame_top,
 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 
     global $hide_sm_attributions, $PHP_SELF, $frame_top,
@@ -302,7 +329,14 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
         "</table><br>\n\n";
 }
 
         "</table><br>\n\n";
 }
 
-/* blatently copied/truncated/modified from the above function */
+/**
+ * Blatantly copied/truncated/modified from displayPageHeader.
+ * Outputs a page header specifically for the compose_in_new popup window
+ *
+ * @param array color the array of theme colors
+ * @param string mailbox the current mailbox name to display
+ * @return void
+ */
 function compose_Header($color, $mailbox) {
 
     global $javascript_on;
 function compose_Header($color, $mailbox) {
 
     global $javascript_on;
index 56315dc41d9cff76a791a4c8e5f0d01d0cc6105c..3004f8699e0d75659ea8d5b783ba84757839e3bd 100644 (file)
@@ -60,7 +60,13 @@ function do_hook ($name) {
     return $data;
 }
 
     return $data;
 }
 
-/* This function executes a hook. */
+/**
+ * This function executes a hook and allows for parameters to be passed.
+ *
+ * @param string name the name of the hook
+ * @param mixed param the parameters to pass to the hook function
+ * @return mixed the return value of the hook function
+ */
 function do_hook_function($name,$parm=NULL) {
     global $squirrelmail_plugin_hooks;
     $ret = '';
 function do_hook_function($name,$parm=NULL) {
     global $squirrelmail_plugin_hooks;
     $ret = '';
@@ -80,7 +86,14 @@ function do_hook_function($name,$parm=NULL) {
     return $ret;
 }
 
     return $ret;
 }
 
-/* This function executes a hook. */
+/**
+ * This function executes a hook, concatenating the results of each
+ * plugin that has the hook defined.
+ *
+ * @param string name the name of the hook
+ * @param mixed parm optional hook function parameters
+ * @return string a concatenation of the results of each plugin function
+ */
 function concat_hook_function($name,$parm=NULL) {
     global $squirrelmail_plugin_hooks;
     $ret = '';
 function concat_hook_function($name,$parm=NULL) {
     global $squirrelmail_plugin_hooks;
     $ret = '';
@@ -105,7 +118,14 @@ function concat_hook_function($name,$parm=NULL) {
  * false. If $priority is > 0, any one or more trues will override
  * any falses. If $priority < 0, then one or more falses will
  * override any trues.
  * false. If $priority is > 0, any one or more trues will override
  * any falses. If $priority < 0, then one or more falses will
  * override any trues.
- * Priority 0 means majority rules.  Ties will be broken with $tie */
+ * Priority 0 means majority rules.  Ties will be broken with $tie
+ *
+ * @param string name the hook name
+ * @param mixed parm the parameters for the hook function
+ * @param int priority
+ * @param bool tie
+ * @return bool the result of the function
+ */
 function boolean_hook_function($name,$parm=NULL,$priority=0,$tie=false) {
     global $squirrelmail_plugin_hooks;
     $yea = 0;
 function boolean_hook_function($name,$parm=NULL,$priority=0,$tie=false) {
     global $squirrelmail_plugin_hooks;
     $yea = 0;
@@ -149,6 +169,9 @@ function boolean_hook_function($name,$parm=NULL,$priority=0,$tie=false) {
  * This function checks whether the user's USER_AGENT is known to
  * be broken. If so, returns true and the plugin is invisible to the
  * offending browser.
  * This function checks whether the user's USER_AGENT is known to
  * be broken. If so, returns true and the plugin is invisible to the
  * offending browser.
+ * This function needs to have its name changed!
+ *
+ * @return bool whether this browser properly supports JavaScript
  */
 function soupNazi(){
 
  */
 function soupNazi(){
 
index 8521f39b01e043b3017cfd3836723f62d32db4f5..fa502cf40143d3c8933cbabe3d2084c108862a66 100644 (file)
@@ -39,6 +39,16 @@ if (isset($prefs_dsn) && !empty($prefs_dsn)) {
 
 /* Hashing functions */
 
 
 /* Hashing functions */
 
+/**
+ * Given a username and datafilename, this will return the path to the
+ * hashed location of that datafile.
+ *
+ * @param string username the username of the current user
+ * @param string dir the squirrelmail datadir
+ * @param string datafile the name of the file to open
+ * @param bool hash_seach default true
+ * @return string the hashed location of datafile
+ */
 function getHashedFile($username, $dir, $datafile, $hash_search = true) {
     global $dir_hash_level;
 
 function getHashedFile($username, $dir, $datafile, $hash_search = true) {
     global $dir_hash_level;
 
@@ -80,6 +90,15 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) {
     return ($result);
 }
 
     return ($result);
 }
 
+/**
+ * Helper function for getHashedFile, given a username returns the hashed
+ * dir for that username.
+ *
+ * @param string username the username of the current user
+ * @param string dir the squirrelmail datadir
+ * @param string hash_dirs default ''
+ * @return the path to the hash dir for username
+ */
 function getHashedDir($username, $dir, $hash_dirs = '') {
     global $dir_hash_level;
 
 function getHashedDir($username, $dir, $hash_dirs = '') {
     global $dir_hash_level;
 
@@ -111,6 +130,12 @@ function getHashedDir($username, $dir, $hash_dirs = '') {
     return ($real_hash_dir);
 }
 
     return ($real_hash_dir);
 }
 
+/**
+ * Helper function for getHashDir which does the actual hash calculation.
+ *
+ * @param string username the username to calculate the hash dir for
+ * @return array a list of hash dirs for this username
+ */
 function computeHashDirs($username) {
     /* Compute the hash for this user and extract the hash directories. */
     $hash = base_convert(crc32($username), 10, 16);
 function computeHashDirs($username) {
     /* Compute the hash for this user and extract the hash directories. */
     $hash = base_convert(crc32($username), 10, 16);
index 8f2cfa7c38a5ce0e270977998388a99ddc37754f..29def4c6689186cb838cfa43f8f9c8a6149fb186 100644 (file)
@@ -41,6 +41,10 @@ require_once(SM_PATH . 'functions/global.php');
  *
  * Specifically, &#039 comes up as 5 characters instead of 1.
  * This should not add newlines to the end of lines.
  *
  * Specifically, &#039 comes up as 5 characters instead of 1.
  * This should not add newlines to the end of lines.
+ *
+ * @param string line the line of text to wrap, by ref
+ * @param int wrap the maximum line lenth
+ * @return void
  */
 function sqWordWrap(&$line, $wrap) {
     global $languages, $squirrelmail_language;
  */
 function sqWordWrap(&$line, $wrap) {
     global $languages, $squirrelmail_language;
@@ -96,6 +100,8 @@ function sqWordWrap(&$line, $wrap) {
 
 /**
  * Does the opposite of sqWordWrap()
 
 /**
  * Does the opposite of sqWordWrap()
+ * @param string body the text to un-wordwrap
+ * @return void
  */
 function sqUnWordWrap(&$body) {
     global $squirrelmail_language;
  */
 function sqUnWordWrap(&$body) {
     global $squirrelmail_language;
@@ -135,6 +141,10 @@ function sqUnWordWrap(&$body) {
 /**
  * If $haystack is a full mailbox name and $needle is the mailbox
  * separator character, returns the last part of the mailbox name.
 /**
  * If $haystack is a full mailbox name and $needle is the mailbox
  * separator character, returns the last part of the mailbox name.
+ *
+ * @param string haystack full mailbox name to search
+ * @param string needle the mailbox separator character
+ * @return string the last part of the mailbox name
  */
 function readShortMailboxName($haystack, $needle) {
 
  */
 function readShortMailboxName($haystack, $needle) {
 
@@ -150,6 +160,12 @@ function readShortMailboxName($haystack, $needle) {
     return( $elem );
 }
 
     return( $elem );
 }
 
+/**
+ * Creates an URL for the page calling this function, using either the PHP global
+ * REQUEST_URI, or the PHP global PHP_SELF with QUERY_STRING added.
+ *
+ * @return string the complete url for this page
+ */
 function php_self () {
     if ( sqgetGlobalVar('REQUEST_URI', $req_uri, SQ_SERVER) && !empty($req_uri) ) {
       return $req_uri;
 function php_self () {
     if ( sqgetGlobalVar('REQUEST_URI', $req_uri, SQ_SERVER) && !empty($req_uri) ) {
       return $req_uri;
@@ -171,13 +187,15 @@ function php_self () {
 
 
 /**
 
 
 /**
- * This determines the location to forward to relative to your server.
+ * Determines the location to forward to, relative to your server.
+ * This is used in HTTP Location: redirects.
  * If this doesnt work correctly for you (although it should), you can
  * If this doesnt work correctly for you (although it should), you can
- * remove all this code except the last two lines, and change the header()
- * function to look something like this, customized to the location of
- * SquirrelMail on your server:
+ * remove all this code except the last two lines, and have it return
+ * the right URL for your site, something like:
+ *
+ *   http://www.example.com/squirrelmail/
  *
  *
- *   http://www.myhost.com/squirrelmail/src/login.php
+ * @return string the base url for this SquirrelMail installation
  */
 function get_location () {
 
  */
 function get_location () {
 
@@ -243,8 +261,13 @@ function get_location () {
 
 
 /**
 
 
 /**
- * These functions are used to encrypt the passowrd before it is
- * stored in a cookie.
+ * These functions are used to encrypt the password before it is
+ * stored in a cookie. The encryption key is generated by
+ * OneTimePadCreate();
+ *
+ * @param string string the (password)string to encrypt
+ * @param string epad the encryption key
+ * @return string the base64-encoded encrypted password
  */
 function OneTimePadEncrypt ($string, $epad) {
     $pad = base64_decode($epad);
  */
 function OneTimePadEncrypt ($string, $epad) {
     $pad = base64_decode($epad);
@@ -256,6 +279,14 @@ function OneTimePadEncrypt ($string, $epad) {
     return base64_encode($encrypted);
 }
 
     return base64_encode($encrypted);
 }
 
+/**
+ * Decrypt a password from the cookie, encrypted by OneTimePadEncrypt.
+ * This uses the encryption key that is stored in the session.
+ *
+ * @param string string the string to decrypt
+ * @param string epad the encryption key from the session
+ * @return string the decrypted password
+ */
 function OneTimePadDecrypt ($string, $epad) {
     $pad = base64_decode($epad);
     $encrypted = base64_decode ($string);
 function OneTimePadDecrypt ($string, $epad) {
     $pad = base64_decode($epad);
     $encrypted = base64_decode ($string);
@@ -272,6 +303,9 @@ function OneTimePadDecrypt ($string, $epad) {
  * Randomize the mt_rand() function.  Toss this in strings or integers
  * and it will seed the generator appropriately. With strings, it is
  * better to get them long. Use md5() to lengthen smaller strings.
  * Randomize the mt_rand() function.  Toss this in strings or integers
  * and it will seed the generator appropriately. With strings, it is
  * better to get them long. Use md5() to lengthen smaller strings.
+ *
+ * @param mixed val a value to seed the random number generator
+ * @return void
  */
 function sq_mt_seed($Val) {
     /* if mt_getrandmax() does not return a 2^n - 1 number,
  */
 function sq_mt_seed($Val) {
     /* if mt_getrandmax() does not return a 2^n - 1 number,
@@ -298,6 +332,8 @@ function sq_mt_seed($Val) {
  * This function initializes the random number generator fairly well.
  * It also only initializes it once, so you don't accidentally get
  * the same 'random' numbers twice in one session.
  * This function initializes the random number generator fairly well.
  * It also only initializes it once, so you don't accidentally get
  * the same 'random' numbers twice in one session.
+ *
+ * @return void
  */
 function sq_mt_randomize() {
     static $randomized;
  */
 function sq_mt_randomize() {
     static $randomized;
@@ -333,6 +369,13 @@ function sq_mt_randomize() {
     $randomized = 1;
 }
 
     $randomized = 1;
 }
 
+/**
+ * Creates an encryption key for encrypting the password stored in the cookie.
+ * The encryption key itself is stored in the session.
+ *
+ * @param int length optional, length of the string to generate
+ * @return string the encryption key
+ */
 function OneTimePadCreate ($length=100) {
     sq_mt_randomize();
 
 function OneTimePadCreate ($length=100) {
     sq_mt_randomize();
 
@@ -345,7 +388,10 @@ function OneTimePadCreate ($length=100) {
 }
 
 /**
 }
 
 /**
- *  Returns a string showing the size of the message/attachment.
+ * Returns a string showing the size of the message/attachment.
+ *
+ * @param int bytes the filesize in bytes
+ * @return string the filesize in human readable format
  */
 function show_readable_size($bytes) {
     $bytes /= 1024;
  */
 function show_readable_size($bytes) {
     $bytes /= 1024;
@@ -370,10 +416,14 @@ function show_readable_size($bytes) {
 /**
  * Generates a random string from the caracter set you pass in
  *
 /**
  * Generates a random string from the caracter set you pass in
  *
- * Flags:
- *   1 = add lowercase a-z to $chars
- *   2 = add uppercase A-Z to $chars
- *   4 = add numbers 0-9 to $chars
+ * @param int size the size of the string to generate
+ * @param string chars a string containing the characters to use
+ * @param int flags a flag to add a specific set to the characters to use:
+ *     Flags:
+ *       1 = add lowercase a-z to $chars
+ *       2 = add uppercase A-Z to $chars
+ *       4 = add numbers 0-9 to $chars
+ * @return string the random string
  */
 
 function GenerateRandomString($size, $chars, $flags = 0) {
  */
 
 function GenerateRandomString($size, $chars, $flags = 0) {
@@ -402,12 +452,18 @@ function GenerateRandomString($size, $chars, $flags = 0) {
     return $String;
 }
 
     return $String;
 }
 
+/**
+ * Escapes special characters for use in IMAP commands.
+ * @param string the string to escape
+ * @return string the escaped string
+ */
 function quoteimap($str) {
     return ereg_replace('(["\\])', '\\\\1', $str);
 }
 
 /**
 function quoteimap($str) {
     return ereg_replace('(["\\])', '\\\\1', $str);
 }
 
 /**
- * Trims every element in the array
+ * Trims every element in the array, ie. remove the first char of each element
+ * @param array array the array to trim
  */
 function TrimArray(&$array) {
     foreach ($array as $k => $v) {
  */
 function TrimArray(&$array) {
     foreach ($array as $k => $v) {
@@ -425,10 +481,13 @@ function TrimArray(&$array) {
     }
 }
 
     }
 }
 
-// Returns a link to the compose-page, taking in 
-// consideration the compose_in_new and javascript 
-// settings. 
-//
+/**
+ * Returns a link to the compose-page, taking in consideration
+ * the compose_in_new and javascript settings.
+ * @param string url the URL to the compose page
+ * @param string text the link text, default "Compose"
+ * @return string a link to the compose page
+ */
 function makeComposeLink($url, $text = null)
 {
     global $compose_new_win,$javascript_on;
 function makeComposeLink($url, $text = null)
 {
     global $compose_new_win,$javascript_on;
@@ -440,19 +499,15 @@ function makeComposeLink($url, $text = null)
 
     // if not using "compose in new window", make 
     // regular link and be done with it
 
     // if not using "compose in new window", make 
     // regular link and be done with it
-    //
     if($compose_new_win != '1') {
         return makeInternalLink($url, $text, 'right');
     }
 
 
     if($compose_new_win != '1') {
         return makeInternalLink($url, $text, 'right');
     }
 
 
-    //
     // build the compose in new window link...  
     // build the compose in new window link...  
-    //
 
 
     // if javascript is on, use onClick event to handle it
 
 
     // if javascript is on, use onClick event to handle it
-    // 
     if($javascript_on) {
         sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
         return '<a href="javascript:void(0)" onclick="comp_in_new(\''.$base_uri.$url.'\')">'. $text.'</a>';
     if($javascript_on) {
         sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
         return '<a href="javascript:void(0)" onclick="comp_in_new(\''.$base_uri.$url.'\')">'. $text.'</a>';
@@ -460,18 +515,19 @@ function makeComposeLink($url, $text = null)
 
 
     // otherwise, just open new window using regular HTML
 
 
     // otherwise, just open new window using regular HTML
-    //
     return makeInternalLink($url, $text, '_blank');
 
 }
 
 /**
     return makeInternalLink($url, $text, '_blank');
 
 }
 
 /**
-* sm_print_r($some_variable, [$some_other_variable [, ...]]);
-* Debugging function - does the same as print_r, but makes sure special
-* characters are converted to htmlentities first.  This will allow
-* values like <some@email.address> to be displayed.
-* The output is wrapped in <pre> and </pre> tags.
-*/
+ * sm_print_r($some_variable, [$some_other_variable [, ...]]);
+ * Debugging function - does the same as print_r, but makes sure special
+ * characters are converted to htmlentities first.  This will allow
+ * values like <some@email.address> to be displayed.
+ * The output is wrapped in <pre> and </pre> tags.
+ *
+ * @return void
+ */
 function sm_print_r() {
     ob_start();  // Buffer output
     foreach(func_get_args() as $var) {
 function sm_print_r() {
     ob_start();  // Buffer output
     foreach(func_get_args() as $var) {
index c35bc0e2eaa5da0fc46ea5b28a9ad30e32c01033..d051b172f4bb83475c8e252fd61cafd7d86b1405 100644 (file)
 require_once(SM_PATH . 'functions/imap.php');
 
 /**
 require_once(SM_PATH . 'functions/imap.php');
 
 /**
- * Recursive function to find the correct parent for a new node
+ * Recursive function to find the correct parent for a new node.
+ *
+ * @param mixed value the value to find a parent for
+ * @param int treeIndexToStart where to start the search, usually the root node (0)
+ * @param array tree the tree to search
+ * @return int the index of the parent
  */
  */
-
 function findParentForChild($value, $treeIndexToStart, $tree) {
     // is $value in $tree[$treeIndexToStart]['value']
     if ((isset($tree[$treeIndexToStart])) && (strstr($value, $tree[$treeIndexToStart]['value']))) {
 function findParentForChild($value, $treeIndexToStart, $tree) {
     // is $value in $tree[$treeIndexToStart]['value']
     if ((isset($tree[$treeIndexToStart])) && (strstr($value, $tree[$treeIndexToStart]['value']))) {
@@ -41,6 +45,13 @@ function findParentForChild($value, $treeIndexToStart, $tree) {
     }
 }
 
     }
 }
 
+/**
+ * Will insert a new value into the tree, based on a given comparison value.
+ *
+ * @param mixed comparisonValue the value to determine where the new element should be placed.
+ * @param mixed value the new node to insert
+ * @param array tree the tree to insert the node in, by ref
+ */
 function addChildNodeToTree($comparisonValue, $value, &$tree) {
     $parentNode = findParentForChild($comparisonValue, 0, $tree);
 
 function addChildNodeToTree($comparisonValue, $value, &$tree) {
     $parentNode = findParentForChild($comparisonValue, 0, $tree);
 
@@ -60,6 +71,14 @@ function addChildNodeToTree($comparisonValue, $value, &$tree) {
     }
 }
 
     }
 }
 
+/**
+ * Recursively walk the tree of trash mailboxes and delete all folders and messages
+ *
+ * @param int index the place in the tree to start, usually 0
+ * @param stream imap_stream the IMAP connection to send commands to
+ * @param array tree the tree to walk
+ * @return void
+ */
 function walkTreeInPreOrderEmptyTrash($index, $imap_stream, $tree) {
     global $trash_folder;
     if ($tree[$index]['doIHaveChildren']) {
 function walkTreeInPreOrderEmptyTrash($index, $imap_stream, $tree) {
     global $trash_folder;
     if ($tree[$index]['doIHaveChildren']) {
@@ -91,6 +110,14 @@ function walkTreeInPreOrderEmptyTrash($index, $imap_stream, $tree) {
 }
 
 
 }
 
 
+/**
+ * Recursively delete a tree of mail folders.
+ *
+ * @param int index the place in the tree to start, usually 0
+ * @param stream imap_stream the IMAP connection to send commands to
+ * @param array tree the tree to walk
+ * @return void
+ */
 function walkTreeInPreOrderDeleteFolders($index, $imap_stream, $tree) {
     if ($tree[$index]['doIHaveChildren']) {
         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
 function walkTreeInPreOrderDeleteFolders($index, $imap_stream, $tree) {
     if ($tree[$index]['doIHaveChildren']) {
         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
@@ -102,6 +129,9 @@ function walkTreeInPreOrderDeleteFolders($index, $imap_stream, $tree) {
     }
 }
 
     }
 }
 
+/**
+ * Recursively walk a tree of folders to create them under the trash folder.
+ */
 function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName) {
     global $trash_folder, $delimiter;
 
 function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName) {
     global $trash_folder, $delimiter;
 
@@ -131,6 +161,12 @@ function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tre
     }
 }
 
     }
 }
 
+/**
+ * Recursive function that outputs a tree In-Pre-Order.
+ * @param int index the node to start (usually 0)
+ * @param array tree the tree to walk
+ * @return void
+ */
 function simpleWalkTreePre($index, $tree) {
     if ($tree[$index]['doIHaveChildren']) {
         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
 function simpleWalkTreePre($index, $tree) {
     if ($tree[$index]['doIHaveChildren']) {
         for ($j = 0; $j < count($tree[$index]['subNodes']); $j++) {
index 02181fbe972eddafc01b8587556775dbc2c22649..eadebd37c9fbe2ba48c418d02fec63cf62baec47 100644 (file)
@@ -38,6 +38,12 @@ $Host_RegExp_Match = '(' . $IP_RegExp_Match .
 $Email_RegExp_Match = '[0-9a-z]([-_.+]?[0-9a-z])*(%' . $Host_RegExp_Match .
     ')?@' . $Host_RegExp_Match;
 
 $Email_RegExp_Match = '[0-9a-z]([-_.+]?[0-9a-z])*(%' . $Host_RegExp_Match .
     ')?@' . $Host_RegExp_Match;
 
+/**
+ * Parses a body and converts all found email addresses to clickable links.
+ *
+ * @param string body the body to process, by ref
+ * @return int the number of unique addresses found
+ */
 function parseEmail (&$body) {
     global $color, $Email_RegExp_Match;
     $sbody     = $body;
 function parseEmail (&$body) {
     global $color, $Email_RegExp_Match;
     $sbody     = $body;
@@ -77,6 +83,12 @@ $url_parser_poss_ends = array(' ', "\n", "\r", '<', '>', ".\r", ".\n",
     ']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r");
 
 
     ']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r");
 
 
+/**
+ * Parses a body and converts all found URLs to clickable links.
+ *
+ * @param string body the body to process, by ref
+ * @return void
+ */
 function parseUrl (&$body) {
     global $url_parser_poss_ends, $url_parser_url_tokens;;
     $start      = 0;
 function parseUrl (&$body) {
     global $url_parser_poss_ends, $url_parser_url_tokens;;
     $start      = 0;