From 0606ca1f5af67cd6a90fa695c8a33478a04d7a7f Mon Sep 17 00:00:00 2001 From: thomppj Date: Sun, 23 Dec 2001 06:40:16 +0000 Subject: [PATCH] Fixed silly, nasty, bug... git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1887 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mime.php | 2 +- functions/plugin.php | 80 +++++++++++--------------- src/read_body.php | 132 ++++++++++++++++++++----------------------- 3 files changed, 95 insertions(+), 119 deletions(-) diff --git a/functions/mime.php b/functions/mime.php index 357bfc4f..b5a6310d 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -628,7 +628,7 @@ class msg_header { } else { $body = formatAttachments ($message, -1, $message->header->mailbox, $id); } - return( $body ); + return ($body); } // A recursive function that returns a list of attachments with links diff --git a/functions/plugin.php b/functions/plugin.php index 392359fc..b5f4e4f5 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -3,7 +3,7 @@ /** * plugin.php * - * Copyright (c) 1999-2001 The SquirrelMail Development Team + * Copyright (c) 1999-2002 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This file provides the framework for a plugin architecture. @@ -13,65 +13,49 @@ * $Id$ */ -/*****************************************************************/ -/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ -/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ -/*** + Base level indent should begin at left margin, as ***/ -/*** the first line of the function definition below. ***/ -/*** + All identation should consist of four space blocks ***/ -/*** + Tab characters are evil. ***/ -/*** + all comments should use "slash-star ... star-slash" ***/ -/*** style -- no pound characters, no slash-slash style ***/ -/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ -/*** ALWAYS USE { AND } CHARACTERS!!! ***/ -/*** + Please use ' instead of ", when possible. Note " ***/ -/*** should always be used in _( ) function calls. ***/ -/*** Thank you for your help making the SM code more readable. ***/ -/*****************************************************************/ - global $squirrelmail_plugin_hooks; $squirrelmail_plugin_hooks = array(); - // This function adds a plugin - function use_plugin ($name) { - - if (file_exists("../plugins/$name/setup.php")) { - include_once("../plugins/$name/setup.php"); - $function = "squirrelmail_plugin_init_$name"; - if (function_exists($function)) { - $function(); - } +/* This function adds a plugin. */ +function use_plugin ($name) { + if (file_exists("../plugins/$name/setup.php")) { + include_once("../plugins/$name/setup.php"); + $function = "squirrelmail_plugin_init_$name"; + if (function_exists($function)) { + $function(); } - } +} - // This function executes a hook - function do_hook ($name) { - global $squirrelmail_plugin_hooks; - $data = func_get_args(); +/* This function executes a hook. */ +function do_hook ($name) { + global $squirrelmail_plugin_hooks; + $data = func_get_args(); - if (isset($squirrelmail_plugin_hooks[$name]) - && is_array($squirrelmail_plugin_hooks[$name])) { - foreach ($squirrelmail_plugin_hooks[$name] as $function) { - // Add something to set correct gettext domain for plugin - if (function_exists($function)) { - $function($data); - } + if (isset($squirrelmail_plugin_hooks[$name]) + && is_array($squirrelmail_plugin_hooks[$name])) { + foreach ($squirrelmail_plugin_hooks[$name] as $function) { + /* Add something to set correct gettext domain for plugin. */ + if (function_exists($function)) { + $function($data); } } - - // Variable-length argument lists have a slight problem when - // passing values by reference. Pity. This is a workaround. - return $Data; } - /* -------------------- MAIN --------------------- */ + /* Variable-length argument lists have a slight problem when */ + /* passing values by reference. Pity. This is a workaround. */ + return $data; +} - // On startup, register all plugins configured for use - if (isset($plugins) && is_array($plugins)) { - foreach ($plugins as $name) { - use_plugin($name); - } +/*************************************/ +/*** MAIN PLUGIN LOADING CODE HERE ***/ +/*************************************/ + +/* On startup, register all plugins configured for use. */ +if (isset($plugins) && is_array($plugins)) { + foreach ($plugins as $name) { + use_plugin($name); } +} ?> diff --git a/src/read_body.php b/src/read_body.php index 6e02591c..c2edcfa1 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -34,68 +34,6 @@ require_once('../functions/mime.php'); require_once('../functions/date.php'); require_once('../functions/url_parser.php'); - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - sqimap_mailbox_select($imapConnection, $mailbox); - do_hook('html_top'); - displayPageHeader($color, $mailbox); - - if (isset($view_hdr)) { - fputs ($imapConnection, sqimap_session_id() . " FETCH $passed_id BODY[HEADER]\r\n"); - $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true, $a, $b); - - echo '
' . - '' . "\n" . - "
" . _("Viewing Full Header") . ' - '; - if (isset($where) && isset($what)) { - // Got here from a search - echo "'; - } else { - echo ""; - } - echo ''._("View message") . "
\n" . - "\n" . - '
'; - - $cnum = 0; - for ($i=1; $i < count($read); $i++) { - $line = htmlspecialchars($read[$i]); - if (eregi("^>", $line)) { - $second[$i] = $line; - $first[$i] = ' '; - $cnum++; - } else if (eregi("^[ |\t]", $line)) { - $second[$i] = $line; - $first[$i] = ''; - } else if (eregi("^([^:]+):(.+)", $line, $regs)) { - $first[$i] = $regs[1] . ':'; - $second[$i] = $regs[2]; - $cnum++; - } else { - $second[$i] = trim($line); - $first[$i] = ''; - } - } - for ($i=0; $i < count($second); $i = $j) { - if (isset($first[$i])) { - $f = $first[$i]; - } - if (isset($second[$i])) { - $s = nl2br($second[$i]); - } - $j = $i + 1; - while (($first[$j] == '') && ($j < count($first))) { - $s .= '    ' . nl2br($second[$j]); - $j++; - } - parseEmail($s); - if (isset($f)) echo "$f$s"; - } - echo "
\n"; - echo ''; - sqimap_logout($imapConnection); - exit; - } - /** * Given an IMAP message id number, this will look it up in the cached * and sorted msgs array and return the index. Used for finding the next @@ -219,16 +157,70 @@ require_once('../functions/url_parser.php'); /*** Main of read_boby.php ***/ /*****************************/ - if (isset($msgs)) { - $currentArrayIndex = $passed_id; -/*** START OF COMMENTED OUT CODE - PHILIPPE, CAN THIS BE REMOVED? - for ($i=0; $i < count($msgs); $i++) { - if ($msgs[$i]["ID"] == $passed_id) { - $currentArrayIndex = $i; - break; + $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + sqimap_mailbox_select($imapConnection, $mailbox); + do_hook('html_top'); + displayPageHeader($color, $mailbox); + + if (isset($view_hdr)) { + fputs ($imapConnection, sqimap_session_id() . " FETCH $passed_id BODY[HEADER]\r\n"); + $read = sqimap_read_data ($imapConnection, sqimap_session_id(), true, $a, $b); + + echo '
' . + '' . "\n" . + "
" . _("Viewing Full Header") . ' - '; + if (isset($where) && isset($what)) { + // Got here from a search + echo "'; + } else { + echo ""; } + echo ''._("View message") . "
\n" . + "\n" . + '
'; + + $cnum = 0; + for ($i=1; $i < count($read); $i++) { + $line = htmlspecialchars($read[$i]); + if (eregi("^>", $line)) { + $second[$i] = $line; + $first[$i] = ' '; + $cnum++; + } else if (eregi("^[ |\t]", $line)) { + $second[$i] = $line; + $first[$i] = ''; + } else if (eregi("^([^:]+):(.+)", $line, $regs)) { + $first[$i] = $regs[1] . ':'; + $second[$i] = $regs[2]; + $cnum++; + } else { + $second[$i] = trim($line); + $first[$i] = ''; + } + } + for ($i=0; $i < count($second); $i = $j) { + if (isset($first[$i])) { + $f = $first[$i]; + } + if (isset($second[$i])) { + $s = nl2br($second[$i]); + } + $j = $i + 1; + while (($first[$j] == '') && ($j < count($first))) { + $s .= '    ' . nl2br($second[$j]); + $j++; + } + parseEmail($s); + if (isset($f)) echo "$f$s"; + } + echo "
\n"; + echo ''; + sqimap_logout($imapConnection); + exit; } -*** END OF COMMENTED OUT CODE */ + + if (isset($msgs)) { + $currentArrayIndex = $passed_id; } else { $currentArrayIndex = -1; } -- 2.25.1