Changeset 1532 in subversion
- Timestamp:
- Jun 14, 2008 8:23:08 AM (5 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 10 edited
-
index.php (modified) (6 diffs)
-
program/include/html.php (modified) (4 diffs)
-
program/include/iniset.php (modified) (1 diff)
-
program/include/main.inc (modified) (4 diffs)
-
program/include/rcube_config.php (modified) (1 diff)
-
program/include/rcube_json_output.php (modified) (2 diffs)
-
program/include/rcube_template.php (modified) (3 diffs)
-
program/include/rcube_user.php (modified) (4 diffs)
-
program/steps/mail/func.inc (modified) (3 diffs)
-
program/steps/mail/sendmail.inc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/index.php
r1483 r1532 3 3 +-------------------------------------------------------------------------+ 4 4 | RoundCube Webmail IMAP Client | 5 | Version 0. 1-20080506|5 | Version 0.2-20080614 | 6 6 | | 7 7 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | … … 33 33 // define global vars 34 34 $OUTPUT_TYPE = 'html'; 35 36 // init application and start session with requested task 37 $RCMAIL = rcmail::get_instance(); 38 39 // init output class 40 $OUTPUT = !empty($_REQUEST['_remote']) ? $RCMAIL->init_json() : $RCMAIL->load_gui(!empty($_REQUEST['_framed'])); 35 41 36 42 // set output buffering … … 47 53 } 48 54 49 50 // init application and start session with requested task51 $RCMAIL = rcmail::get_instance();52 53 // init output class54 $OUTPUT = (!empty($_GET['_remote']) || !empty($_POST['_remote'])) ? $RCMAIL->init_json() : $RCMAIL->load_gui((!empty($_GET['_framed']) || !empty($_POST['_framed'])));55 56 57 55 // check DB connections and exit on failure 58 56 if ($err_str = $DB->is_error()) { … … 128 126 129 127 130 // not logged in -> set task to 'login 128 // check client X-header to verify request origin 129 if ($OUTPUT->ajax_call) { 130 if ($RCMAIL->config->get('devel_mode') && !rc_request_header('X-RoundCube-Referer')) { 131 header('HTTP/1.1 404 Not Found'); 132 die("Invalid Request"); 133 } 134 } 135 136 137 // not logged in -> show login page 131 138 if (empty($RCMAIL->user->ID)) { 139 132 140 if ($OUTPUT->ajax_call) 133 141 $OUTPUT->remote_response("setTimeout(\"location.href='\"+this.env.comm_path+\"'\", 2000);"); 134 142 135 $RCMAIL->set_task('login');136 }137 138 139 // check client X-header to verify request origin140 if ($OUTPUT->ajax_call) {141 if (empty($CONFIG['devel_mode']) && !rc_request_header('X-RoundCube-Referer')) {142 header('HTTP/1.1 404 Not Found');143 die("Invalid Request");144 }145 }146 147 148 // not logged in -> show login page149 if (empty($RCMAIL->user->ID)) {150 143 // check if installer is still active 151 if ($ CONFIG['enable_installer']&& is_readable('./installer/index.php')) {144 if ($RCMAIL->config->get('enable_installer') && is_readable('./installer/index.php')) { 152 145 $OUTPUT->add_footer(html::div(array('style' => "background:#ef9398; border:2px solid #dc5757; padding:0.5em; margin:2em auto; width:50em"), 153 146 html::tag('h2', array('style' => "margin-top:0.2em"), "Installer script is still accessible") . … … 161 154 162 155 $OUTPUT->set_env('task', 'login'); 163 $OUTPUT->task = 'login';164 156 $OUTPUT->send('login'); 165 exit;166 157 } 167 158 … … 170 161 if ($RCMAIL->action=='keep-alive') { 171 162 $OUTPUT->reset(); 172 $OUTPUT->send(''); 173 exit; 163 $OUTPUT->send(); 174 164 } 175 165 -
trunk/roundcubemail/program/include/html.php
r1504 r1532 572 572 * @param string Cell content 573 573 */ 574 p rivatefunction add_header($attr, $cont)574 public function add_header($attr, $cont) 575 575 { 576 576 if (is_string($attr)) … … 588 588 * @param array Row attributes 589 589 */ 590 p rivatefunction add_row($attr = array())590 public function add_row($attr = array()) 591 591 { 592 592 $this->rowindex++; … … 613 613 $rowcontent = ''; 614 614 foreach ($this->header as $c => $col) { 615 $rowcontent .= self::tag('t h', $col->attrib, $col->content);615 $rowcontent .= self::tag('td', $col->attrib, $col->content); 616 616 } 617 617 $thead = self::tag('thead', null, self::tag('tr', null, $rowcontent)); … … 625 625 626 626 if ($r < $this->rowindex || count($row->cells)) { 627 $tbody .= self::tag('tr', $row s->attrib, $rowcontent);627 $tbody .= self::tag('tr', $row->attrib, $rowcontent); 628 628 } 629 629 } -
trunk/roundcubemail/program/include/iniset.php
r1344 r1532 23 23 24 24 // application constants 25 define('RCMAIL_VERSION', '0. 1-trunk');25 define('RCMAIL_VERSION', '0.2-trunk'); 26 26 define('RCMAIL_CHARSET', 'UTF-8'); 27 27 define('JS_OBJECT_NAME', 'rcmail'); -
trunk/roundcubemail/program/include/main.inc
r1459 r1532 103 103 return rcmail::get_instance()->gettext($p); 104 104 } 105 106 107 /**108 * Load virtuser table in array109 *110 * @return array Virtuser table entries111 */112 function rcmail_getvirtualfile()113 {114 global $CONFIG;115 if (empty($CONFIG['virtuser_file']) || !is_file($CONFIG['virtuser_file']))116 return FALSE;117 118 // read file119 $a_lines = file($CONFIG['virtuser_file']);120 return $a_lines;121 }122 123 124 /**125 * Find matches of the given pattern in virtuser table126 *127 * @param string Regular expression to search for128 * @return array Matching entries129 */130 function rcmail_findinvirtual($pattern)131 {132 $result = array();133 $virtual = rcmail_getvirtualfile();134 if ($virtual==FALSE)135 return $result;136 137 // check each line for matches138 foreach ($virtual as $line)139 {140 $line = trim($line);141 if (empty($line) || $line{0}=='#')142 continue;143 144 if (eregi($pattern, $line))145 $result[] = $line;146 }147 148 return $result;149 }150 105 151 106 … … 575 530 function rcube_table_output($attrib, $table_data, $a_show_cols, $id_col) 576 531 { 577 global $DB; 578 579 // allow the following attributes to be added to the <table> tag 580 $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 581 582 $table = '<table' . $attrib_str . ">\n"; 532 global $RCMAIL; 533 534 $table = new html_table(/*array('cols' => count($a_show_cols))*/); 583 535 584 // add table title 585 $table .= "<thead><tr>\n"; 586 536 // add table header 587 537 foreach ($a_show_cols as $col) 588 $table .= '<td class="'.$col.'">' . Q(rcube_label($col)) . "</td>\n"; 589 590 $table .= "</tr></thead>\n<tbody>\n"; 538 $table->add_header($col, Q(rcube_label($col))); 591 539 592 540 $c = 0; 593 541 if (!is_array($table_data)) 594 {595 while ($table_data && ($sql_arr = $DB->fetch_assoc($table_data)))596 {597 $zebra_class = $c%2 ? 'even' : 'odd';598 599 $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $sql_arr[$id_col]);542 { 543 $db = $RCMAIL->get_dbh(); 544 while ($table_data && ($sql_arr = $db->fetch_assoc($table_data))) 545 { 546 $zebra_class = $c % 2 ? 'even' : 'odd'; 547 $table->add_row(array('id' => 'rcmrow' . $sql_arr[$id_col], 'class' => "contact $zebra_class")); 600 548 601 549 // format each col 602 550 foreach ($a_show_cols as $col) 603 { 604 $cont = Q($sql_arr[$col]); 605 $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; 606 } 607 608 $table .= "</tr>\n"; 551 $table->add($col, Q($sql_arr[$col])); 552 609 553 $c++; 610 }611 }554 } 555 } 612 556 else 613 {557 { 614 558 foreach ($table_data as $row_data) 615 { 616 $zebra_class = $c%2 ? 'even' : 'odd'; 617 618 $table .= sprintf('<tr id="rcmrow%s" class="contact '.$zebra_class.'">'."\n", $row_data[$id_col]); 559 { 560 $zebra_class = $c % 2 ? 'even' : 'odd'; 561 $table->add_row(array('id' => 'rcmrow' . $row_data[$id_col], 'class' => "contact $zebra_class")); 619 562 620 563 // format each col 621 564 foreach ($a_show_cols as $col) 622 { 623 $cont = Q($row_data[$col]); 624 $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; 625 } 626 627 $table .= "</tr>\n"; 565 $table->add($col, Q($row_data[$col])); 566 628 567 $c++; 629 } 630 } 631 632 // complete message table 633 $table .= "</tbody></table>\n"; 634 635 return $table; 568 } 569 } 570 571 return $table->show($attrib); 636 572 } 637 573 … … 671 607 672 608 return $out; 673 }674 675 676 /**677 * Return the mail domain configured for the given host678 *679 * @param string IMAP host680 * @return string Resolved SMTP host681 */682 function rcmail_mail_domain($host)683 {684 global $CONFIG;685 686 $domain = $host;687 if (is_array($CONFIG['mail_domain']))688 {689 if (isset($CONFIG['mail_domain'][$host]))690 $domain = $CONFIG['mail_domain'][$host];691 }692 else if (!empty($CONFIG['mail_domain']))693 $domain = $CONFIG['mail_domain'];694 695 return $domain;696 609 } 697 610 … … 744 657 return $styles; 745 658 } 746 747 /**748 * Try to autodetect operating system and find the correct line endings749 *750 * @return string The appropriate mail header delimiter751 */752 function rcmail_header_delm()753 {754 global $CONFIG;755 756 // use the configured delimiter for headers757 if (!empty($CONFIG['mail_header_delimiter']))758 return $CONFIG['mail_header_delimiter'];759 else if (strtolower(substr(PHP_OS, 0, 3)=='win'))760 return "\r\n";761 else if (strtolower(substr(PHP_OS, 0, 3)=='mac'))762 return "\r\n";763 else764 return "\n";765 }766 659 767 660 -
trunk/roundcubemail/program/include/rcube_config.php
r1392 r1532 178 178 179 179 180 /** 181 * Try to autodetect operating system and find the correct line endings 182 * 183 * @return string The appropriate mail header delimiter 184 */ 185 public function header_delimiter() 186 { 187 // use the configured delimiter for headers 188 if (!empty($this->prop['mail_header_delimiter'])) 189 return $this->prop['mail_header_delimiter']; 190 else if (strtolower(substr(PHP_OS, 0, 3) == 'win')) 191 return "\r\n"; 192 else if (strtolower(substr(PHP_OS, 0, 3) == 'mac')) 193 return "\r\n"; 194 else 195 return "\n"; 196 } 197 198 199 200 /** 201 * Return the mail domain configured for the given host 202 * 203 * @param string IMAP host 204 * @return string Resolved SMTP host 205 */ 206 public function mail_domain($host) 207 { 208 $domain = $host; 209 210 if (is_array($this->prop['mail_domain'])) { 211 if (isset($this->prop['mail_domain'][$host])) 212 $domain = $this->prop['mail_domain'][$host]; 213 } 214 else if (!empty($this->prop['mail_domain'])) 215 $domain = $this->prop['mail_domain']; 216 217 return $domain; 218 } 219 220 180 221 } 181 222 -
trunk/roundcubemail/program/include/rcube_json_output.php
r1358 r1532 35 35 private $commands = array(); 36 36 37 public $task = '';38 37 public $ajax_call = true; 39 38 … … 44 43 public function __construct($task) 45 44 { 46 $this->task = $task;47 45 $this->config = rcmail::get_instance()->config; 48 46 } -
trunk/roundcubemail/program/include/rcube_template.php
r1503 r1532 33 33 var $app; 34 34 var $config; 35 var $task = '';36 35 var $framed = false; 37 36 var $pagetitle = ''; … … 57 56 58 57 //$this->framed = $framed; 59 $this-> task = $task;58 $this->set_env('task', $task); 60 59 61 60 // add common javascripts … … 543 542 } 544 543 if ($object=='pagetitle') { 545 $task = $this-> task;544 $task = $this->env['task']; 546 545 $title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : ''; 547 546 -
trunk/roundcubemail/program/include/rcube_user.php
r1452 r1532 363 363 if ($user_id = $dbh->insert_id(get_sequence_name('users'))) 364 364 { 365 $mail_domain = rcmail_mail_domain($host);365 $mail_domain = $rcmail->config->mail_domain($host); 366 366 367 367 if ($user_email=='') … … 421 421 { 422 422 $user = $email; 423 $r = rcmail_findinvirtual("^$email");423 $r = self::findinvirtual("^$email"); 424 424 425 425 for ($i=0; $i<count($r); $i++) … … 447 447 { 448 448 $email = ""; 449 $r = rcmail_findinvirtual("$user$");449 $r = self::findinvirtual("$user$"); 450 450 451 451 for ($i=0; $i<count($r); $i++) … … 462 462 return $email; 463 463 } 464 465 466 /** 467 * Find matches of the given pattern in virtuser table 468 * 469 * @param string Regular expression to search for 470 * @return array Matching entries 471 */ 472 private static function findinvirtual($pattern) 473 { 474 $result = array(); 475 $virtual = null; 476 477 if ($virtuser_file = rcmail::get_instance()->config->get('virtuser_file')) 478 $virtual = file($virtuser_file); 479 480 if (empty($virtual)) 481 return $result; 482 483 // check each line for matches 484 foreach ($virtual as $line) 485 { 486 $line = trim($line); 487 if (empty($line) || $line{0}=='#') 488 continue; 489 490 if (eregi($pattern, $line)) 491 $result[] = $line; 492 } 493 494 return $result; 495 } 496 464 497 465 498 } -
trunk/roundcubemail/program/steps/mail/func.inc
r1494 r1532 1041 1041 function rcmail_send_mdn($uid) 1042 1042 { 1043 global $ CONFIG, $USER, $IMAP;1043 global $RCMAIL, $IMAP; 1044 1044 1045 1045 $message = new rcube_message($uid); … … 1047 1047 if ($message->headers->mdn_to && !$message->headers->mdn_sent) 1048 1048 { 1049 $identity = $ USER->get_identity();1049 $identity = $RCMAIL->user->get_identity(); 1050 1050 $sender = format_email_recipient($identity['email'], $identity['name']); 1051 1051 $recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to)); 1052 1052 $mailto = $recipient['mailto']; 1053 1053 1054 $compose = new rcube_mail_mime( rcmail_header_delm());1054 $compose = new rcube_mail_mime($RCMAIL->config->header_delimiter()); 1055 1055 $compose->setParam(array( 1056 1056 'text_encoding' => 'quoted-printable', … … 1068 1068 'To' => $message->headers->mdn_to, 1069 1069 'Subject' => rcube_label('receiptread') . ': ' . $message->subject, 1070 'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), rcmail_mail_domain($_SESSION['imap_host'])),1070 'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])), 1071 1071 'X-Sender' => $identity['email'], 1072 1072 'Content-Type' => 'multipart/report; report-type=disposition-notification', 1073 1073 ); 1074 1074 1075 if ( !empty($CONFIG['useragent']))1076 $headers['User-Agent'] = $ CONFIG['useragent'];1075 if ($agent = $RCMAIL->config->get('useragent')) 1076 $headers['User-Agent'] = $agent; 1077 1077 1078 1078 $body = rcube_label("yourmessage") . "\r\n\r\n" . 1079 1079 "\t" . rcube_label("to") . ': ' . rcube_imap::decode_mime_string($message->headers->to, $message->headers->charset) . "\r\n" . 1080 1080 "\t" . rcube_label("subject") . ': ' . $message->subject . "\r\n" . 1081 "\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $ CONFIG['date_long']) . "\r\n" .1081 "\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $RCMAIL->config->get('date_long')) . "\r\n" . 1082 1082 "\r\n" . rcube_label("receiptnote") . "\r\n"; 1083 1083 1084 $ua = !empty($CONFIG['useragent']) ? $CONFIG['useragent'] : "RoundCube Webmail (Version ".RCMAIL_VERSION.")";1084 $ua = $RCMAIL->config->get('useragent', "RoundCube Webmail (Version ".RCMAIL_VERSION.")"); 1085 1085 $report = "Reporting-UA: $ua\r\n"; 1086 1086 -
trunk/roundcubemail/program/steps/mail/sendmail.inc
r1344 r1532 114 114 $olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST); 115 115 116 $message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), rcmail_mail_domain($_SESSION['imap_host']));116 $message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])); 117 117 $savedraft = !empty($_POST['_draft']) ? TRUE : FALSE; 118 118 … … 208 208 if ($CONFIG['http_received_header']) 209 209 { 210 $nldlm = rcmail_header_delm() . "\t";210 $nldlm = $RCMAIL->config->header_delimiter() . "\t"; 211 211 $headers['Received'] = wordwrap('from ' . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? 212 212 gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']).' ['.$_SERVER['HTTP_X_FORWARDED_FOR'].']'.$nldlm.' via ' : '') . … … 233 233 234 234 // create extended PEAR::Mail_mime instance 235 $MAIL_MIME = new rcube_mail_mime( rcmail_header_delm());235 $MAIL_MIME = new rcube_mail_mime($RCMAIL->config->header_delimiter()); 236 236 237 237 // For HTML-formatted messages, construct the MIME message with both
Note: See TracChangeset
for help on using the changeset viewer.
