| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * left_main.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This is the code for the left bar. The left bar shows the folders |
| 10 | * available, and has cookie information. |
| 11 | * |
| 12 | * @version $Id$ |
| 13 | * @package squirrelmail |
| 14 | */ |
| 15 | |
| 16 | /** |
| 17 | * Path for SquirrelMail required files. |
| 18 | * @ignore |
| 19 | */ |
| 20 | define('SM_PATH','../'); |
| 21 | |
| 22 | /* SquirrelMail required files. */ |
| 23 | require_once(SM_PATH . 'include/validate.php'); |
| 24 | require_once(SM_PATH . 'functions/imap.php'); |
| 25 | require_once(SM_PATH . 'functions/plugin.php'); |
| 26 | require_once(SM_PATH . 'functions/page_header.php'); |
| 27 | require_once(SM_PATH . 'functions/html.php'); |
| 28 | require_once(SM_PATH . 'functions/date.php'); |
| 29 | |
| 30 | /* These constants are used for folder stuff. */ |
| 31 | define('SM_BOX_UNCOLLAPSED', 0); |
| 32 | define('SM_BOX_COLLAPSED', 1); |
| 33 | |
| 34 | /* --------------------- FUNCTIONS ------------------------- */ |
| 35 | |
| 36 | |
| 37 | /** |
| 38 | * Recursive function to output a tree of folders. |
| 39 | * It is called on a list of boxes and iterates over that tree. |
| 40 | * |
| 41 | * @since 1.3.0 |
| 42 | */ |
| 43 | function ListBoxes ($boxes, $j=0 ) { |
| 44 | global $data_dir, $username, $color, $unseen_notify, $unseen_type, |
| 45 | $move_to_trash, $trash_folder, $collapse_folders, $imapConnection, |
| 46 | $use_icons, $icon_theme, $use_special_folder_color; |
| 47 | |
| 48 | // stop condition |
| 49 | if (empty($boxes)) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | $pre = '<span style="white-space: nowrap;">'; |
| 54 | $end = ''; |
| 55 | $collapse = false; |
| 56 | $unseen_found = false; |
| 57 | $unseen = 0; |
| 58 | |
| 59 | $mailbox = $boxes->mailboxname_full; |
| 60 | $leader = '<tt>'; |
| 61 | $leader .= str_repeat(' ',$j); |
| 62 | $mailboxURL = urlencode($mailbox); |
| 63 | |
| 64 | /* get unseen/total messages information */ |
| 65 | /* Only need to display info when option is set */ |
| 66 | if (isset($unseen_notify) && ($unseen_notify > 1) && |
| 67 | (($boxes->unseen !== false) || ($boxes->total !== false))) { |
| 68 | |
| 69 | if ($boxes->unseen !== false) |
| 70 | $unseen = $boxes->unseen; |
| 71 | |
| 72 | /* |
| 73 | Should only display unseen info if the folder is inbox |
| 74 | or you set the option for all folders |
| 75 | */ |
| 76 | |
| 77 | if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) { |
| 78 | $unseen_string = $unseen; |
| 79 | |
| 80 | /* If users requests, display message count too */ |
| 81 | if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) { |
| 82 | $unseen_string .= '/' . $boxes->total; |
| 83 | } |
| 84 | |
| 85 | $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>"; |
| 86 | |
| 87 | /* |
| 88 | Finally allow the script to display the values by setting a boolean. |
| 89 | This can only occur if the unseen count is great than 0 (if you have |
| 90 | unseen count only), or you have the message count too. |
| 91 | */ |
| 92 | if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) { |
| 93 | $unseen_found = true; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | if (isset($boxes->mbxs[0]) && $collapse_folders) { |
| 99 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); |
| 100 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
| 101 | |
| 102 | $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?'; |
| 103 | if ($collapse) { |
| 104 | if ($use_icons && $icon_theme != 'none') { |
| 105 | $link .= "unfold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/plus.png" border="0" height="7" width="7" /> </tt>'; |
| 106 | } else { |
| 107 | $link .= "unfold=$mailboxURL\">$leader+ </tt>"; |
| 108 | } |
| 109 | } else { |
| 110 | if ($use_icons && $icon_theme != 'none') { |
| 111 | $link .= "fold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/minus.png" border="0" height="7" width="7" /> </tt>'; |
| 112 | } else { |
| 113 | $link .= "fold=$mailboxURL\">$leader- </tt>"; |
| 114 | } |
| 115 | } |
| 116 | $link .= '</a>'; |
| 117 | $pre .= $link; |
| 118 | } else { |
| 119 | $pre.= $leader . ' </tt>'; |
| 120 | } |
| 121 | |
| 122 | /* If there are unseen message, bold the line. */ |
| 123 | if (($move_to_trash) && ($mailbox == $trash_folder)) { |
| 124 | if (! isset($boxes->total)) { |
| 125 | $boxes->total = sqimap_status_messages($imapConnection, $mailbox); |
| 126 | } |
| 127 | $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
| 128 | if ($unseen > 0) { |
| 129 | $pre .= '<b>'; |
| 130 | $end .= '</b>'; |
| 131 | } |
| 132 | $end .= '</a>'; |
| 133 | if ($boxes->total > 0) { |
| 134 | /* Print unseen information. */ |
| 135 | if ($unseen_found) { |
| 136 | $end .= " <small>$unseen_string</small>"; |
| 137 | } |
| 138 | $end .= "\n\t<small>" . |
| 139 | ' [<a href="empty_trash.php">'._("Purge").'</a>]'. |
| 140 | '</small>'; |
| 141 | } |
| 142 | } else { |
| 143 | if (!$boxes->is_noselect) { |
| 144 | $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
| 145 | if ($unseen > 0) { |
| 146 | $pre .= '<b>'; |
| 147 | $end .= '</b>'; |
| 148 | } |
| 149 | $end .= '</a>'; |
| 150 | } |
| 151 | /* Print unseen information. */ |
| 152 | if ($unseen_found) { |
| 153 | $end .= " <small>$unseen_string</small>"; |
| 154 | } |
| 155 | |
| 156 | } |
| 157 | |
| 158 | $font = ''; |
| 159 | $fontend = ''; |
| 160 | if ($use_special_folder_color && $boxes->is_special) { |
| 161 | $font = "<font color=\"$color[11]\">"; |
| 162 | $fontend = "</font>"; |
| 163 | } elseif ( $boxes->is_noselect ) { |
| 164 | $font = "<font color=\"$color[15]\">"; |
| 165 | $fontend = '</font>'; |
| 166 | } |
| 167 | |
| 168 | // let plugins fiddle with end of line |
| 169 | $end .= concat_hook_function('left_main_after_each_folder', |
| 170 | array(isset($numMessages) ? $numMessages : '', |
| 171 | $boxes->mailboxname_full, $imapConnection)); |
| 172 | |
| 173 | $end .= '</span>'; |
| 174 | |
| 175 | if (!$boxes->is_root) { |
| 176 | echo "" . $pre .$font. |
| 177 | str_replace( |
| 178 | array(' ','<','>'), |
| 179 | array(' ','<','>'), |
| 180 | $boxes->mailboxname_sub) . |
| 181 | $fontend . $end. '<br />' . "\n"; |
| 182 | $j++; |
| 183 | } |
| 184 | |
| 185 | if (!$collapse || $boxes->is_root) { |
| 186 | for ($i = 0; $i <count($boxes->mbxs); $i++) { |
| 187 | ListBoxes($boxes->mbxs[$i],$j); |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { |
| 193 | global $data_dir, $username, $color, $unseen_notify, $unseen_type, |
| 194 | $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color; |
| 195 | |
| 196 | if (empty($boxes)) { |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | /* use_folder_images only works if the images exist in ../images */ |
| 201 | $use_folder_images = true; |
| 202 | |
| 203 | $pre = ''; |
| 204 | $end = ''; |
| 205 | $collapse = false; |
| 206 | $unseen_found = false; |
| 207 | $unseen = 0; |
| 208 | |
| 209 | $mailbox = $boxes->mailboxname_full; |
| 210 | $mailboxURL = urlencode($mailbox); |
| 211 | |
| 212 | /* get unseen/total messages information */ |
| 213 | /* Only need to display info when option is set */ |
| 214 | if (isset($unseen_notify) && ($unseen_notify > 1) && |
| 215 | (($boxes->unseen !== false) || ($boxes->total !== false))) { |
| 216 | |
| 217 | if ($boxes->unseen !== false) |
| 218 | $unseen = $boxes->unseen; |
| 219 | |
| 220 | /* |
| 221 | Should only display unseen info if the folder is inbox |
| 222 | or you set the option for all folders |
| 223 | */ |
| 224 | |
| 225 | if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) { |
| 226 | $unseen_string = $unseen; |
| 227 | |
| 228 | /* If users requests, display message count too */ |
| 229 | if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) { |
| 230 | $unseen_string .= '/' . $boxes->total; |
| 231 | } |
| 232 | |
| 233 | $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>"; |
| 234 | |
| 235 | /* |
| 236 | Finally allow the script to display the values by setting a boolean. |
| 237 | This can only occur if the unseen count is great than 0 (if you have |
| 238 | unseen count only), or you have the message count too. |
| 239 | */ |
| 240 | if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) { |
| 241 | $unseen_found = true; |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /* If there are unseen message, bold the line. */ |
| 247 | if ($unseen > 0) { $pre .= '<b>'; } |
| 248 | |
| 249 | /* color special boxes */ |
| 250 | if ($use_special_folder_color && $boxes->is_special) { |
| 251 | $pre .= "<font color=\"$color[11]\">"; |
| 252 | $end .= '</font>'; |
| 253 | } |
| 254 | |
| 255 | /* If there are unseen message, close bolding. */ |
| 256 | if ($unseen > 0) { $end .= '</b>'; } |
| 257 | |
| 258 | /* Print unseen information. */ |
| 259 | if ($unseen_found) { |
| 260 | $end .= " $unseen_string"; |
| 261 | } |
| 262 | |
| 263 | if (($move_to_trash) && ($mailbox == $trash_folder)) { |
| 264 | $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre; |
| 265 | $end .= '</a>'; |
| 266 | $end .= "\n<small>\n" . |
| 267 | ' [<a class="mbx_link" href="empty_trash.php">'._("Purge").'</a>]'. |
| 268 | '</small>'; |
| 269 | } else { |
| 270 | if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ |
| 271 | $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre; |
| 272 | $end .= '</a>'; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | // let plugins fiddle with end of line |
| 277 | global $imapConnection; |
| 278 | $end .= concat_hook_function('left_main_after_each_folder', |
| 279 | array(isset($numMessages) ? $numMessages : '', |
| 280 | $boxes->mailboxname_full, $imapConnection)); |
| 281 | |
| 282 | if (!$boxes->is_root) { |
| 283 | if ($use_folder_images) { |
| 284 | if ($boxes->is_inbox) { |
| 285 | $folder_img = '../images/inbox.png'; |
| 286 | } else if ($boxes->is_sent) { |
| 287 | $folder_img = '../images/senti.png'; |
| 288 | } else if ($boxes->is_trash) { |
| 289 | $folder_img = '../images/delitem.png'; |
| 290 | } else if ($boxes->is_draft) { |
| 291 | $folder_img = '../images/draft.png'; |
| 292 | } else if ($boxes->is_noinferiors) { |
| 293 | $folder_img = '../images/folder_noinf.png'; |
| 294 | } else { |
| 295 | $folder_img = '../images/folder.png'; |
| 296 | } |
| 297 | $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> '; |
| 298 | } else { |
| 299 | $folder_img = ''; |
| 300 | } |
| 301 | if (!isset($boxes->mbxs[0])) { |
| 302 | echo ' ' . html_tag( 'div', |
| 303 | '<tt>'. $pre . $folder_img . '</tt>' . |
| 304 | str_replace( array(' ','<','>'), |
| 305 | array(' ','<','>'), |
| 306 | $boxes->mailboxname_sub) . |
| 307 | $end, |
| 308 | 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n"; |
| 309 | } else { |
| 310 | /* get collapse information */ |
| 311 | if ($collapse_folders) { |
| 312 | $form_entry = $j.'F'; |
| 313 | if (isset($mbx) && isset($mbx[$form_entry])) { |
| 314 | $collapse = $mbx[$form_entry]; |
| 315 | setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full , |
| 316 | $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED); |
| 317 | } else { |
| 318 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); |
| 319 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
| 320 | } |
| 321 | $img_src = ($collapse ? '../images/plus.png' : '../images/minus.png'); |
| 322 | $collapse_link = '<a href="javascript:void(0)">' . |
| 323 | " <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>"; |
| 324 | } else { |
| 325 | $collapse_link=''; |
| 326 | } |
| 327 | echo ' ' . html_tag( 'div', |
| 328 | $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub . $end , |
| 329 | 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n"; |
| 330 | echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n"; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | $visible = ($collapse ? ' style="display:none"' : ' style="display:block"'); |
| 335 | if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */ |
| 336 | echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n"; |
| 337 | |
| 338 | if ($j !='ID.0000') { |
| 339 | $j = $j .'.0000'; |
| 340 | } |
| 341 | for ($i = 0; $i <count($boxes->mbxs); $i++) { |
| 342 | $j++; |
| 343 | ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j); |
| 344 | } |
| 345 | if (isset($boxes->mbxs[0]) && !$boxes->is_root) { |
| 346 | echo '</div>'."\n\n"; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | /* -------------------- MAIN ------------------------ */ |
| 354 | |
| 355 | /* get globals */ |
| 356 | sqgetGlobalVar('username', $username, SQ_SESSION); |
| 357 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
| 358 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
| 359 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
| 360 | |
| 361 | sqgetGlobalVar('fold', $fold, SQ_GET); |
| 362 | sqgetGlobalVar('unfold', $unfold, SQ_GET); |
| 363 | |
| 364 | /* end globals */ |
| 365 | |
| 366 | // open a connection on the imap port (143) |
| 367 | // why hide the output? |
| 368 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true); |
| 369 | |
| 370 | /** |
| 371 | * Using stristr since very old preferences may contain "None" and "none". |
| 372 | */ |
| 373 | if (!empty($left_refresh) && |
| 374 | !stristr($left_refresh, 'none')){ |
| 375 | $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" . |
| 376 | "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n". |
| 377 | "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n"; |
| 378 | } else { |
| 379 | $xtra = ''; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * $advanced_tree and is a boolean var which is default set to default |
| 384 | * SM behaviour. |
| 385 | * Setting $advanced tree to true causes SM to display a experimental |
| 386 | * mailbox-tree with dhtml behaviour. |
| 387 | * It only works on browsers which supports css and javascript. The used |
| 388 | * javascript is experimental and doesn't support all browsers. |
| 389 | * It has been tested on IE6 an Konquerer 3.0.0-2. |
| 390 | * It is now tested and working on: (please test and update this list) |
| 391 | * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7 |
| 392 | * XWindow: ? |
| 393 | * Mac: ? |
| 394 | * In the function ListAdvancedBoxes there is another var $use_folder_images. |
| 395 | * setting this to true is only usefull if the images exists in ../images. |
| 396 | * |
| 397 | * Feel free to experiment with the code and report bugs and enhancements |
| 398 | **/ |
| 399 | |
| 400 | /* set this to true if you want to see a nicer mailboxtree */ |
| 401 | if (empty($advanced_tree)) { |
| 402 | $advanced_tree=false; |
| 403 | } |
| 404 | |
| 405 | if ($advanced_tree) { |
| 406 | $xtra .= '<script language="Javascript" type="text/javascript">'."\n". |
| 407 | '<!--'."\n". |
| 408 | ' function preload() {'."\n". |
| 409 | ' if (document.images) {'."\n". |
| 410 | ' var treeImages = new Array;'."\n". |
| 411 | ' var arguments = preload.arguments;'."\n". |
| 412 | ' for (var i = 0; i<arguments.length; i++) {'."\n". |
| 413 | ' treeImages[i] = new Image();'."\n". |
| 414 | ' treeImages[i].src = arguments[i];'."\n". |
| 415 | ' }'."\n". |
| 416 | ' }'."\n". |
| 417 | ' }'."\n". |
| 418 | 'var vTreeImg;'."\n". |
| 419 | 'var vTreeDiv;'."\n". |
| 420 | 'var vTreeSrc;'."\n". |
| 421 | ' function fTreeTimeout() {'."\n". |
| 422 | ' if (vTreeDiv.readyState == "complete")'."\n". |
| 423 | ' vTreeImg.src = vTreeSrc;'."\n". |
| 424 | ' else'."\n". |
| 425 | ' setTimeout("fTreeTimeout()", 100);'."\n". |
| 426 | ' }'."\n". |
| 427 | ' function hidechilds(img) {'."\n". |
| 428 | ' id = img.id + ".0000";'."\n". |
| 429 | ' form_id = "mbx[" + img.id +"F]";'."\n". |
| 430 | ' if (document.all) { //IE, Opera7'."\n". |
| 431 | ' div = document.all[id];'."\n". |
| 432 | ' if (div) {'."\n". |
| 433 | ' if (div.style.display == "none") {'."\n". |
| 434 | ' vTreeSrc = "../images/minus.png";'."\n". |
| 435 | ' style = "block";'."\n". |
| 436 | ' value = 0;'."\n". |
| 437 | ' }'."\n". |
| 438 | ' else {'."\n". |
| 439 | ' vTreeSrc = "../images/plus.png";'."\n". |
| 440 | ' style = "none";'."\n". |
| 441 | ' value = 1;'."\n". |
| 442 | ' }'."\n". |
| 443 | ' vTreeImg = img;'."\n". |
| 444 | ' vTreeDiv = div;'."\n". |
| 445 | ' if (typeof vTreeDiv.readyState != "undefined") //IE'."\n". |
| 446 | ' setTimeout("fTreeTimeout()",100);'."\n". |
| 447 | ' else //Non IE'."\n". |
| 448 | ' vTreeImg.src = vTreeSrc;'."\n". |
| 449 | ' div.style.display = style;'."\n". |
| 450 | ' document.all[form_id].value = value;'."\n". |
| 451 | ' }'."\n". |
| 452 | ' }'."\n". |
| 453 | ' else if (document.getElementById) { //Gecko'."\n". |
| 454 | ' div = document.getElementById(id);'."\n". |
| 455 | ' if (div) {'."\n". |
| 456 | ' if (div.style.display == "none") {'."\n". |
| 457 | ' src = "../images/minus.png";'."\n". |
| 458 | ' style = "block";'."\n". |
| 459 | ' value = 0;'."\n". |
| 460 | ' }'."\n". |
| 461 | ' else {'."\n". |
| 462 | ' src = "../images/plus.png";'."\n". |
| 463 | ' style = "none";'."\n". |
| 464 | ' value = 1;'."\n". |
| 465 | ' }'."\n". |
| 466 | ' div.style.display = style;'."\n". |
| 467 | ' img.src = src;'."\n". |
| 468 | ' document.getElementById(form_id).value = value;'."\n". |
| 469 | ' }'."\n". |
| 470 | ' }'."\n". |
| 471 | ' }'."\n". |
| 472 | ' function buttonover(el,on) {'."\n". |
| 473 | ' if (!on) {'."\n". |
| 474 | "// el.style.borderColor=\"$color[9]\";}\n". |
| 475 | " el.style.background=\"$color[0]\";}\n". |
| 476 | ' else {'."\n". |
| 477 | " el.style.background=\"$color[9]\";}\n". |
| 478 | ' }'."\n". |
| 479 | ' function buttonclick(el,on) {'."\n". |
| 480 | ' if (!on) {'."\n". |
| 481 | ' el.style.border="groove";}'."\n". |
| 482 | ' else {'."\n". |
| 483 | ' el.style.border="ridge";}'."\n". |
| 484 | ' }'."\n". |
| 485 | ' function hideframe(hide) {'."\n". |
| 486 | ' left_size = "' . $left_size . '";'."\n". |
| 487 | ' if (document.all) {'."\n". |
| 488 | ' masterf = window.parent.document.all["fs1"];'."\n". |
| 489 | ' leftf = window.parent.document.all["left"];'."\n". |
| 490 | ' leftcontent = document.all["leftframe"];'."\n". |
| 491 | ' leftbutton = document.all["showf"];'."\n". |
| 492 | ' } else if (document.getElementById) {'."\n". |
| 493 | ' masterf = window.parent.document.getElementById("fs1");'."\n". |
| 494 | ' leftf = window.parent.document.getElementById("left");'."\n". |
| 495 | ' leftcontent = document.getElementById("leftframe");'."\n". |
| 496 | ' leftbutton = document.getElementById("showf");'."\n". |
| 497 | ' } else {'."\n". |
| 498 | ' return false;'."\n". |
| 499 | ' }'."\n". |
| 500 | ' if(hide) {'."\n". |
| 501 | ' new_col = calc_col("20");'."\n". |
| 502 | ' masterf.cols = new_col;'."\n". |
| 503 | ' document.body.scrollLeft=0;'."\n". |
| 504 | ' document.body.style.overflow="hidden";'."\n". |
| 505 | ' leftcontent.style.display = "none";'."\n". |
| 506 | ' leftbutton.style.display="block";'."\n". |
| 507 | ' } else {'."\n". |
| 508 | ' masterf.cols = calc_col(left_size);'."\n". |
| 509 | ' document.body.style.overflow="";'."\n". |
| 510 | ' leftbutton.style.display="none";'."\n". |
| 511 | ' leftcontent.style.display="block";'."\n". |
| 512 | ' }'."\n". |
| 513 | ' }'."\n". |
| 514 | ' function calc_col(c_w) {'."\n"; |
| 515 | |
| 516 | if ($location_of_bar == 'right') { |
| 517 | $xtra .= ' right=true;'; |
| 518 | } else { |
| 519 | $xtra .= ' right=false;'; |
| 520 | } |
| 521 | $xtra .= "\n"; |
| 522 | |
| 523 | $xtra .= 'if (right) {'."\n". |
| 524 | " new_col = '*,'+c_w;"."\n". |
| 525 | ' } else {'."\n". |
| 526 | " new_col = c_w+',*';"."\n". |
| 527 | ' }'."\n". |
| 528 | ' return new_col;'."\n". |
| 529 | ' }'."\n". |
| 530 | ' function resizeframe(direction) {'."\n". |
| 531 | ' if (document.all) {'."\n". |
| 532 | ' masterf = window.parent.document.all["fs1"];'."\n". |
| 533 | ' } else if (document.getElementById) {'."\n". |
| 534 | ' window.parent.document.getElementById("fs1");'."\n". |
| 535 | ' } else {'."\n". |
| 536 | ' return false;'."\n". |
| 537 | ' }'."\n"; |
| 538 | |
| 539 | if ($location_of_bar == 'right') { |
| 540 | $xtra .= ' colPat=/^\*,(\d+)$/;'; |
| 541 | } else { |
| 542 | $xtra .= ' colPat=/^(\d+),.*$/;'; |
| 543 | } |
| 544 | $xtra .= "\n"; |
| 545 | |
| 546 | $xtra .= 'old_col = masterf.cols;'."\n". |
| 547 | ' colPat.exec(old_col);'."\n". |
| 548 | ' if (direction) {'."\n". |
| 549 | ' new_col_width = parseInt(RegExp.$1) + 25;'."\n". |
| 550 | ' } else {'."\n". |
| 551 | ' if (parseInt(RegExp.$1) > 35) {'."\n". |
| 552 | ' new_col_width = parseInt(RegExp.$1) - 25;'."\n". |
| 553 | ' }'."\n". |
| 554 | ' }'."\n". |
| 555 | ' masterf.cols = calc_col(new_col_width);'."\n". |
| 556 | ' }'."\n". |
| 557 | '//-->'."\n". |
| 558 | '</script>'."\n"; |
| 559 | |
| 560 | /* style definitions */ |
| 561 | |
| 562 | $xtra .= '<style type="text/css">'."\n". |
| 563 | '<!--'."\n". |
| 564 | ' body {'."\n". |
| 565 | ' margin: 0px 0px 0px 0px;'."\n". |
| 566 | ' padding: 5px 5px 5px 5px;'."\n". |
| 567 | ' }'."\n". |
| 568 | ' .button {'."\n". |
| 569 | ' border:outset;'."\n". |
| 570 | " border-color: $color[9];\n". |
| 571 | " background:$color[0];\n". |
| 572 | " color:$color[6];\n". |
| 573 | ' width:99%;'."\n". |
| 574 | ' heigth:99%;'."\n". |
| 575 | ' }'."\n". |
| 576 | ' .mbx_par {'."\n". |
| 577 | ' font-size:1.0em;'."\n". |
| 578 | ' margin-left:4px;'."\n". |
| 579 | ' margin-right:0px;'."\n". |
| 580 | ' }'."\n". |
| 581 | ' a.mbx_link {'."\n". |
| 582 | ' text-decoration: none;'."\n". |
| 583 | " background-color: $color[0];\n". |
| 584 | ' display: inline;'."\n". |
| 585 | ' }'."\n". |
| 586 | ' a:hover.mbx_link {'."\n". |
| 587 | " background-color: $color[9];\n". |
| 588 | ' }'."\n". |
| 589 | ' a.mbx_link img {'."\n". |
| 590 | ' border-style: none;'."\n". |
| 591 | ' }'."\n". |
| 592 | ' .mbx_sub {'."\n". |
| 593 | ' padding-left:5px;'."\n". |
| 594 | ' padding-right:0px;'."\n". |
| 595 | ' margin-left:4px;'."\n". |
| 596 | ' margin-right:0px;'."\n". |
| 597 | ' font-size:0.9em;'."\n". |
| 598 | ' }'."\n". |
| 599 | ' .par_area {'."\n". |
| 600 | ' margin-top:0px;'."\n". |
| 601 | ' margin-left:4px;'."\n". |
| 602 | ' margin-right:0px;'."\n". |
| 603 | ' padding-left:10px;'."\n". |
| 604 | ' padding-bottom:5px;'."\n". |
| 605 | ' border-left: solid;'."\n". |
| 606 | ' border-left-width:0.1em;'."\n". |
| 607 | " border-left-color:$color[9];\n". |
| 608 | ' border-bottom: solid;'."\n". |
| 609 | ' border-bottom-width:0.1em;'."\n". |
| 610 | " border-bottom-color:$color[9];\n". |
| 611 | ' display: block;'."\n". |
| 612 | ' }'."\n". |
| 613 | ' .mailboxes {'."\n". |
| 614 | ' padding-bottom:3px;'."\n". |
| 615 | ' margin-right:4px;'."\n". |
| 616 | ' padding-right:4px;'."\n". |
| 617 | ' margin-left:4px;'."\n". |
| 618 | ' padding-left:4px;'."\n". |
| 619 | ' border: groove;'."\n". |
| 620 | ' border-width:0.1em;'."\n". |
| 621 | " border-color:$color[9];\n". |
| 622 | " background: $color[0];\n". |
| 623 | ' }'."\n". |
| 624 | '-->'."\n". |
| 625 | '</style>'."\n"; |
| 626 | } |
| 627 | |
| 628 | displayHtmlHeader( 'SquirrelMail', $xtra ); |
| 629 | sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION); |
| 630 | /* If requested and not yet complete, attempt to autocreate folders. */ |
| 631 | if ($auto_create_special && !isset($auto_create_done)) { |
| 632 | $autocreate = array($sent_folder, $trash_folder, $draft_folder); |
| 633 | foreach( $autocreate as $folder ) { |
| 634 | if (($folder != '') && ($folder != 'none')) { |
| 635 | if ( !sqimap_mailbox_exists($imapConnection, $folder)) { |
| 636 | sqimap_mailbox_create($imapConnection, $folder, ''); |
| 637 | } else { |
| 638 | // check for subscription is useless and expensive, just |
| 639 | // surpress the NO response. Unless we're on Mecury, which |
| 640 | // will just subscribe a folder again if it's already |
| 641 | // subscribed. |
| 642 | if ( strtolower($imap_server_type) != 'mercury32' || |
| 643 | !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) { |
| 644 | sqimap_subscribe($imapConnection, $folder, false); |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | /* Let the world know that autocreation is complete! Hurrah! */ |
| 651 | $auto_create_done = TRUE; |
| 652 | sqsession_register($auto_create_done, 'auto_create_done'); |
| 653 | } |
| 654 | |
| 655 | if ($advanced_tree) { |
| 656 | echo "\n<body" . |
| 657 | ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' . |
| 658 | " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n"; |
| 659 | } else { |
| 660 | echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n"; |
| 661 | } |
| 662 | |
| 663 | do_hook('left_main_before'); |
| 664 | if ($advanced_tree) { |
| 665 | /* nice future feature, needs layout !! volunteers? */ |
| 666 | $right_pos = $left_size - 20; |
| 667 | /* echo '<div style="position:absolute;top:0;border=solid;border-width:0.1em;border-color:blue;"><div id="hidef" style="width=20;font-size:12"><a href="javascript:hideframe(true)"><b><<</b></a></div>'; |
| 668 | echo '<div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>'; |
| 669 | echo '<div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>'; |
| 670 | echo '<div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>'; |
| 671 | echo '<div id="leftframe"><br /><br />';*/ |
| 672 | } |
| 673 | |
| 674 | echo "\n\n" . |
| 675 | '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n"; |
| 676 | |
| 677 | if ($date_format != 6) { |
| 678 | /* First, display the clock. */ |
| 679 | if ($hour_format == 1) { |
| 680 | $hr = 'H:i'; |
| 681 | if ($date_format == 4) { |
| 682 | $hr .= ':s'; |
| 683 | } |
| 684 | } else { |
| 685 | if ($date_format == 4) { |
| 686 | $hr = 'g:i:s a'; |
| 687 | } else { |
| 688 | $hr = 'g:i a'; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | switch( $date_format ) { |
| 693 | case 0: |
| 694 | $clk = date('Y-m-d '.$hr. ' T', time()); |
| 695 | break; |
| 696 | case 1: |
| 697 | $clk = date('m/d/y '.$hr, time()); |
| 698 | break; |
| 699 | case 2: |
| 700 | $clk = date('d/m/y '.$hr, time()); |
| 701 | break; |
| 702 | case 4: |
| 703 | case 5: |
| 704 | $clk = date($hr, time()); |
| 705 | break; |
| 706 | default: |
| 707 | $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() ); |
| 708 | } |
| 709 | $clk = str_replace(' ',' ',$clk); |
| 710 | |
| 711 | echo '<small><span style="white-space: nowrap;">' |
| 712 | . str_replace(' ', ' ', _("Last Refresh")) |
| 713 | . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n"; |
| 714 | } |
| 715 | |
| 716 | /* Next, display the refresh button. */ |
| 717 | echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'. |
| 718 | _("Check mail") . "</a>]</small></div></center><br />\n\n"; |
| 719 | |
| 720 | /* Lastly, display the folder list. */ |
| 721 | if ( $collapse_folders ) { |
| 722 | /* If directed, collapse or uncollapse a folder. */ |
| 723 | if (isset($fold)) { |
| 724 | setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED); |
| 725 | } else if (isset($unfold)) { |
| 726 | setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | /* Get unseen/total display prefs */ |
| 731 | $unseen_type = getPref( $data_dir , $username , 'unseen_type' ); |
| 732 | $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' ); |
| 733 | |
| 734 | if (empty($unseen_type)) { |
| 735 | if (!empty($default_unseen_type)) { |
| 736 | $unseen_type = $default_unseen_type; |
| 737 | } else { |
| 738 | $unseen_type = 1; |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | if (empty($unseen_notify)) { |
| 743 | if (!empty($default_unseen_notify)) { |
| 744 | $unseen_notify = $default_unseen_notify; |
| 745 | } else { |
| 746 | $unseen_notify = 0; |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | $boxes = sqimap_mailbox_tree($imapConnection); |
| 751 | if (isset($advanced_tree) && $advanced_tree) { |
| 752 | echo '<form name="collapse" action="left_main.php" method="post" ' . |
| 753 | 'enctype="multipart/form-data"'."\n"; |
| 754 | echo '<small>'; |
| 755 | echo '<button type="submit" class="button" onmouseover="buttonover(this,true)" onmouseout="buttonover(this,false)" onmousedown="buttonclick(this,true)" onmouseup="buttonclick(this,false)">'. _("Save folder tree") .'</button><br /><br />'; |
| 756 | echo '<div id="mailboxes" class="mailboxes">'."\n\n"; |
| 757 | sqgetGlobalVar('mbx', $mbx, SQ_POST); |
| 758 | if (!isset($mbx)) $mbx=NULL; |
| 759 | ListAdvancedBoxes($boxes, $mbx); |
| 760 | echo '</div>'; |
| 761 | echo '</small>'; |
| 762 | echo '</form>'."\n"; |
| 763 | } else { |
| 764 | ListBoxes($boxes); |
| 765 | } |
| 766 | |
| 767 | do_hook('left_main_after'); |
| 768 | sqimap_logout($imapConnection); |
| 769 | |
| 770 | ?> |
| 771 | </body></html> |