1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
|
<?php
// Begin includes/HordeCopyright.inc
/*
IMP: Copyright 1998, 1999 Charles J. Hagenbuch chuck@horde.org
You should have received a copy of the GNU Public
License along with this package; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
NOTE:
Please note that this file is autogenerated and is a collected library
of individual classes, functions, and other various code snippets.
If you would like to edit this library please edit the appropriate file
under the src/ subtree.
*/
// End includes/HordeCopyright.inc
// Begin defines/ImpActions.def
/* Define all of the actions */
define('NO_ACTION', 0);
define('DELETE_MESSAGES', 1);
define('UNDELETE_MESSAGES', 2);
define('MOVE_MESSAGES', 3);
define('COPY_MESSAGES', 4);
define('EXPUNGE_MAILBOX', 5);
define('IMP_LOGIN', 6);
define('REPLY', 7);
define('REPLY_ALL', 8);
define('FORWARD', 9);
define('DELETE_FOLDER', 10);
define('CREATE_FOLDER', 11);
define('RENAME_FOLDER', 12);
define('DOWNLOAD_ATTACH', 13);
define('VIEW_ATTACH', 14);
define('DELETE_ADDR', 15);
define('ADD_ADDR', 16);
define('UPDATE_ADDR', 17);
define('UPDATE_PREFS', 18);
define('SEND_MESSAGE', 19);
define('POSTPONE_MESSAGE', 20);
define('VIEW_SOURCE', 21);
define('SAVE_MESSAGE', 22);
define('SUBSCRIBE_FOLDER', 23);
define('UNSUBSCRIBE_FOLDER', 24);
define('BOUNCE_MESSAGE', 25);
define('BOUNCE_COMPOSE', 26);
define('ADD_ATTACHMENT', 28);
define('DELETE_ATTACHMENT', 29);
define('MAILTO', 30);
define('ADD_CONTACT', 31);
define('IMP_SIGNUP', 32);
define('COMPOSE', 33);
define('DRAFT', 34);
define('POSTPONE_DRAFT', 35);
define('HIDE_DELETED', 36);
define('CANCEL', 37);
define('PASSWD_INPUT', 38);
define('PASSWD_DISALLOW', 39);
define('PASSWD_CHANGE', 40);
define('ADD_CONTACT_OBJECT', 41);
/* MENU Modes */
define('IMPMENU_DORMANT', 100);
define('IMPMENU_MAIN', 200);
define('IMPMENU_BLANK', 999);
/* IMP CONFIGURATOR MODES */
define('IMPCFGMGR_WRITE_CONFIG', 800);
// End defines/ImpActions.def
// Begin objects/IMAPServer.object
class IMAPServer {
var $name;
var $server;
var $port;
var $folders;
var $from_server;
var $preferred;
function IMAPServer ($name, $server, $port=143, $folders='', $from_server='', $preferred='', $servtype='imap') {
$this->name = $name;
$this->server = $server;
$this->port = $port;
$this->servtype = $servtype;
$this->folders = $folders;
$this->preferred = $preferred;
$this->from_server = $from_server;
if (!$this->from_server)
$this->from_server = $this->server;
} // Constructor
function get_from () {
return $this->from_server;
}
} // End IMAPServer
// End objects/IMAPServer.object
// Begin objects/ImpDefaults.object
class ImpDefaults extends HordeDefaults {
/* Html Configuration */
/* Colors organized by general element. Hopefully, one should be able
* to set these, and have IMP follow them to create a whole new color scheme
*/
var $new_item_bg;
/* impmenu (sidebar) frame colors */
var $sidebar; /* HtmlDocument : configures the impmenu frame colors */
/* popups */
var $minimum_popups = false;
/* URL Configuraton */
var $root_url = ''; /* imp base url */
var $graphics_url = '/graphics'; /* imp specfic graphics */
/* Files Configuration */
var $include_dir = './templates'; /* the directory all of the includes live in */
/* IMAP Configuration */
var $server = 'localhost'; /* default IMAP server to connect to */
var $from_server = 'localhost'; /* messages are sent from this server by default */
var $port = '143'; /* default IMAPd port */
var $servtype = 'imap'; /* default type of server to connect to */
var $folders = ''; /* default directory to look in for mail folders */
var $personal_folders = ''; /* Cyrus personal folders */
var $sent_mail = 'sent-mail'; /* name of the directory sent-mail should be copied to */
var $postponed = 'drafts'; /* name of the directory unsent email should be copied to */
var $save_sent_mail = false; /* allow user to save sent email (true/false) */
var $use_imap_subscribe = true; /* subscribe folders via imap */
var $show_dotfiles = false; /* show dotfiles in folder list */
var $show_shared_hierarchy = false; /* show the UW-imap #shared/* folder hierarchy (not returned by a LIST * for some reason) */
var $show_public_hierarchy = false; /* show the UW-imap #public/* folder hierarchy (not returned by a LIST * for some reason) */
var $show_news_hierarchy = false; /* show the UW-imap #news/* folder hierarchy (not returned by a LIST * for some reason) */
var $to_domain = false;
/* Stylesheets */
var $use_css = true; /* use cascading stylesheets */
/* Imp Server Configuration */
var $user_change_server = false; // set false to force use of the default server
var $user_change_port = false; // set false to force use of the default port
var $user_change_servtype = false; // set false to force use of the default server type
var $user_change_folder = false; // set false to force use of the default folder dir
var $user_use_folders = true; // set false to only allow use of the INBOX
var $user_change_from = true; // allow user to change their from address
var $user_change_fullname = true; // allow user to change their fullname
var $user_change_language = true; // allow the user to set the language at login
var $use_server_list = false; // use server list dropdown
var $user_use_addressbook = false; // Address book on / off flag
var $menu_contacts_link = true; // Display the Contacts link
var $custom_from_hook = false; // if true, IMP will look for a function imp_expand_fromaddress() to use to expand ... from addresses! :)
/* Imp Client Configuration */
var $max_messages_page = 30; /* max number of messages to display in one page in mailbox.php3 */
/* Imp Debugging Configuration */
var $error_level = E_ALL; /* level of error_reporting() */
var $max_execution_time = 0; /* number to set exec time to for long operations */
/* Umask */
var $umask = 077;
/* LDAP Configuration */
var $use_ldap_search = true;
/* New mail configuration */
var $newmail_popup = true;
var $refresh_delay = 300;
/* Language configuration */
var $language = 'en';
/* Time/Date configuration */
var $date_format = '%Y-%m-%d';
var $time_format = '%I:%M %p';
var $compose_date_format = '%c';
/* Display text attachments inline */
var $text_parts_inline = true;
var $inline_in_parts_list = false;
var $text_inline_size = 0; // how big a part can be (in k) before we won't
// display it inline. 0 means no size limit.
/* New User stuff */
var $newuser_link = true;
/* Allow people to see the naked message? */
var $view_message_source = true;
/* Append configuration */
var $append_header = true;
var $append_trailer = false;
/* The string to prepend to wrapped lines. */
var $wrap_string = '+';
/* The string prefix quoted lines. */
var $quote_prefix = '> ';
/* Hide deleted messages by default? */
var $hide_deleted = false;
/* Actual table locations */
var $db_pref_table;
var $db_address_table;
/* sort order */
var $sort_crit = SORTARRIVAL;
var $sort_dir = 0;
/* syslog stats */
var $log_stats = false;
var $log_stats_facil = LOG_LOCAL4;
var $log_prio = LOG_NOTICE;
var $log_ident = 'IMP';
/* /var/log/secure (or /var/log/authlog) login/failure logging */
var $log_auth = true;
var $log_auth_facil = LOG_AUTH;
/* various mailbox attributes */
var $deleted_flag = 'd';
var $unread_flag = 'n';
var $answered_flag = 'a';
var $attachment_flag = 'f';
/* Password Options */
var $change_password = false; /* set to an url to have a change password link */
var $poppassd_server = '/dev/null';
var $poppassd_port = '0';
/* Constructor */
function ImpDefaults () {
$this->HordeDefaults();
$this->sidebar = new HtmlDocument;
$this->sidebar->logo = false;
$this->sidebar->logo_url = '';
$this->sidebar->local_site_logo = false;
$this->sidebar->local_site_logo_url = '';
}
} // End ImpDefaults
// End objects/ImpDefaults.object
// Begin objects/LDAPServer.object
class LDAPServer {
var $tag;
var $name;
var $server;
var $root;
var $sn;
var $attribs;
var $options;
var $org;
var $emailattr;
var $ldap_prefix;
function LDAPServer ($tag, $name, $server, $root, $sn, $attribs, $options, $org='', $prefix='', $emailattr='mail') {
$this->tag = $tag;
$this->name = $name;
$this->server = $server;
$this->root = $root;
$this->sn = $sn;
$this->attribs = $attribs;
$this->options = $options;
$this->emailattr = $emailattr;
if ($org && $prefix) $this->root = "o=$org, c=$prefix";
// add name/label to parameters?
} // Constructor
} // End LDAPServer
/* Function to decode a MIME-encoded string, returns the original string, if not MIME */
function decode_mime_string ($string) {
$pos = strpos($string, '=?');
if (!is_int($pos)) {
return $string;
}
// take out any spaces between multiple encoded words
$string = preg_replace('|\?=\s=\?|', '?==?', $string);
$preceding = substr($string, 0, $pos); // save any preceding text
$search = substr($string, $pos+2, 75); // the mime header spec says this is the longest a single encoded word can be
$d1 = strpos($search, '?');
if (!is_int($d1)) {
return $string;
}
$charset = substr($string, $pos+2, $d1);
$search = substr($search, $d1+1);
$d2 = strpos($search, '?');
if (!is_int($d2)) {
return $string;
}
$encoding = substr($search, 0, $d2);
$search = substr($search, $d2+1);
$end = strpos($search, '?=');
if (!is_int($end)) {
return $string;
}
$encoded_text = substr($search, 0, $end);
$rest = substr($string, (strlen($preceding . $charset . $encoding . $encoded_text)+6));
switch ($encoding) {
case 'Q':
case 'q':
$encoded_text = str_replace('_', '%20', $encoded_text);
$encoded_text = str_replace('=', '%', $encoded_text);
$decoded = urldecode($encoded_text);
if (strstr($charset, '1251')) {
$decoded = convert_cyr_string($decoded, 'w', 'k');
}
elseif (strstr($charset, '866')) {
$decoded = convert_cyr_string($decoded, 'a', 'k');
}
elseif (strstr($charset, '8859-5')) {
$decoded = convert_cyr_string($decoded, 'i', 'k');
}
elseif (stristr($charset, 'x-mac-cyrrilic')) {
$decoded = convert_cyr_string($decoded, 'm', 'k');
}
break;
case 'B':
case 'b':
$decoded = urldecode(base64_decode($encoded_text));
if (strtolower($charset) == 'windows-1251') {
$decoded = convert_cyr_string($decoded, 'w', 'k');
}
break;
default:
$decoded = '=?' . $charset . '?' . $encoding . '?' . $encoded_text . '?=';
break;
}
return $preceding . $decoded . decode_mime_string($rest);
} // decode_mime_string()
/* ignore IMAP subscription settings and get an old-style list */
function full_mailbox_list($header = false, $options = '') {
return mailbox_list ($header, $options, true, false);
}
function get_barefrom () {
/* format the bare (ie, just address@server.domain format) correctly */
global $default, $imp, $_barefrom;
if ($default->user_change_from || $default->use_db) {
if (empty($_barefrom))
$_barefrom = imp_get_from($imp->user, $imp->server);
}
if (empty($_barefrom)) {
if ($default->custom_from_hook && function_exists('imp_expand_fromaddress'))
$_barefrom = imp_expand_fromaddress($imp);
else
$_barefrom = $imp->user;
}
if (!strstr($_barefrom, '@')) { /* allow proper use of user@server usernames, and let imp_expand_fromaddress return full addresses */
$_barefrom .= '@' . $imp->from_server;
}
return $_barefrom;
}
/* obtain a list of mailboxes */
function mailbox_list ($header=false, $full_list=false, $abbrev=false, $inbox=true) {
global $imp, $default, $lang;
$options = '';
// choose a list command
if ($default->use_imap_subscribe && !$full_list) {
$listcmd = 'imap_listsubscribed';
} else {
$listcmd = 'imap_listmailbox';
}
$mboxes = array();
$mboxes = $listcmd($imp->stream, '{' . "$imp->server:$imp->port" . '}', "$imp->folders*");
if ($default->show_shared_hierarchy) {
$shared = $listcmd($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#shared/*');
if (is_array($shared)) {
while (list(,$sbox) = each($shared)) {
$mboxes[] = $sbox;
}
}
}
if ($default->show_public_hierarchy) {
$public = $listcmd($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#public/*');
if (is_array($public)) {
while (list(,$sbox) = each($public)) {
$mboxes[] = $sbox;
}
}
}
if ($default->show_news_hierarchy) {
$news = $listcmd($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#news/*');
if (is_array($news)) {
while (list(,$sbox) = each($news)) {
$mboxes[] = $sbox;
}
}
}
if (is_array($mboxes) && count($mboxes) > 0) {
sort($mboxes);
$mbox_seen = array();
/* for each folder, set the name the folder is displayed as */
while (list(,$mbox) = each($mboxes)) {
$mbox = @imap_utf7_decode($mbox);
/* Make sure this isn't a duplicate */
if (!isset($mbox_seen[$mbox])) {
$mbox_seen[$mbox] = true;
/* get rid of the server and folder crap so we have a clean label */
if (($default->show_shared_hierarchy && strstr($mbox, '#shared')) ||
($default->show_public_hierarchy && strstr($mbox, '#public')) ||
($default->show_news_hierarchy && strstr($mbox, '#news'))) {
$label = str_replace('{' . "$imp->server:$imp->port" . '}', '', $mbox);
$value = $label;
}
else {
$label = str_replace('{' . "$imp->server:$imp->port" . '}' . $imp->folders, '', $mbox);
$value = $imp->folders . $label;
}
if (strcmp('INBOX', $label) != 0) {
/* Check to see if we need to do special Cyrus labeling */
if (strlen($default->personal_folders) > 0) {
if (strcmp($default->personal_folders, substr($label, 0, strlen($default->personal_folders))) == 0) {
$label = substr($label, strlen($default->personal_folders));
}
}
if ($abbrev) {
if (strlen($label) > 16) {
$tmp = substr($label, 0, 8);
$tmp .= '...';
$tmp .= substr($label, -5, 5);
$label = $tmp;
}
}
/* Filter out dotfiles */
if (strlen($label) <= 0 || !isset($label[0]) || ($label[0] != '.') || $default->show_dotfiles) {
$options .= "<option value=\"$value\">$label</option>\n";
}
}
}
}
}
if ($inbox) $options = '<option value="INBOX">INBOX</option>' . $options;
if ($header) $options = '<option value="">' . $lang->imp->selected_messages . '</option>' . $options;
return $options;
}
/* diff the full mailbox list with the subscribed mailbox list */
function unsub_mailbox_list($header = false, $options = '') {
global $imp, $default, $lang;
if ($default->use_imap_subscribe) {
$sub_list = array();
$sub_list = @imap_listsubscribed($imp->stream, '{' . "$imp->server:$imp->port" . '}', "$imp->folders*");
if ($default->show_shared_hierarchy) {
$shared = @imap_listsubscribed($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#shared/*');
if (is_array($shared)) {
while (list(,$sbox) = each($shared)) {
$sublist[] = $sbox;
}
}
}
if ($default->show_public_hierarchy) {
$public = @imap_listsubscribed($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#public/*');
if (is_array($public)) {
while (list(,$sbox) = each($public)) {
$sublist[] = $sbox;
}
}
}
if ($default->show_news_hierarchy) {
$news = @imap_listsubscribed($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#news/*');
if (is_array($news)) {
while (list(,$sbox) = each($news)) {
$sublist[] = $sbox;
}
}
}
$full_list = array();
$full_list = @imap_listmailbox($imp->stream, '{' . "$imp->server:$imp->port" . '}', "$imp->folders*");
if ($default->show_shared_hierarchy) {
$shared = @imap_listmailbox($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#shared/*');
if (is_array($shared)) {
while (list(,$sbox) = each($shared)) {
$full_list[] = $sbox;
}
}
}
if ($default->show_public_hierarchy) {
$public = @imap_listmailbox($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#public/*');
if (is_array($public)) {
while (list(,$sbox) = each($public)) {
$full_list[] = $sbox;
}
}
}
if ($default->show_news_hierarchy) {
$news = @imap_listmailbox($imp->stream, '{' . "$imp->server:$imp->port" . '}', '#news/*');
if (is_array($news)) {
while (list(,$sbox) = each($news)) {
$full_list[] = $sbox;
}
}
}
if (!is_array($full_list)) $full_list = array();
if (!is_array($sub_list)) $sub_list = array();
$unsub_list = array();
/* step through lists to find unsub'ed folders */
while (list(,$fullbox) = each($full_list)) {
$match = false;
reset($sub_list);
while ((list(,$subbox) = each($sub_list)) && !$match) {
if ($fullbox == $subbox) {
$match = true;
}
}
if (!$match) {
$unsub_list[] = $fullbox;
}
}
if (count($unsub_list) > 0) {
sort($unsub_list);
$mbox_seen = array();
/* for each folder, set the name the folder is displayed as */
for ($i = 0; $i < count($unsub_list); $i++) {
$unsub_list[$i] = @imap_utf7_decode($unsub_list[$i]);
/* Make sure this isn't a duplicate */
if (!isset($mbox_seen[$unsub_list[$i]])) {
$mbox_seen[$unsub_list[$i]] = true;
/* get rid of the server and folder crap so we have a clean label */
if (($default->show_shared_hierarchy && strstr($unsub_list[$i], '#shared')) ||
($default->show_public_hierarchy && strstr($unsub_list[$i], '#public')) ||
($default->show_news_hierarchy && strstr($unsub_list[$i], '#news'))) {
$label = str_replace('{' . "$imp->server:$imp->port" . '}', '', $unsub_list[$i]);
$value = $label;
}
else {
$label = str_replace('{' . "$imp->server:$imp->port" . '}' . $imp->folders, '', $unsub_list[$i]);
$value = $imp->folders . $label;
}
if (strcmp('INBOX', $label) == 0) {
$Inbox = 1;
} else {
/* Check to see if we need to do special Cyrus labeling */
if (strlen($default->personal_folders) > 0) {
if (strcmp($default->personal_folders,
substr($label,0,strlen($default->personal_folders)))==0) {
$label = str_replace("$default->personal_folders",'', $label);
}
}
/* Filter out dotfiles */
if ((strlen($label) > 0) && ($label[0] != '.') || $default->show_dotfiles) {
$options .= "<option value=\"$value\">$label</option>\n";
}
}
}
}
}
if (empty($Inbox)) { $options = '<option value="INBOX">Inbox</option>' . $options; }
if ($header) { $options = '<option value="">' . $lang->imp->selected_messages . '</option>' . $options; }
}
return $options;
} // unsub_mailbox_list()
/* reload the specified frame */
function imp_reload_frame ($frame = '', $page = '') {
echo "<script language=\"JavaScript\">\n";
echo "<!-- Reload $frame to $page\n";
echo "if (parent.$frame) {\n";
echo "parent.$frame.location=\"$page\";\n";
echo "} else if (top.opener && top.opener.parent.$frame) {\n";
echo "top.opener.parent.$frame.location=\"$page\";\n";
echo '}' . "\n";
echo "//-->\n";
echo "</script>\n";
}
/* Define IMP_LIB */
define("IMP_LIB", 1);
/* Initialization */
$default = new ImpDefaults(); /* Create and initialize Defaults Object */
?>
|