| | |
| | | */ |
| | | function get_sequence_name($sequence) |
| | | { |
| | | global $CONFIG; |
| | | |
| | | // return table name if configured |
| | | $config_key = 'db_sequence_'.$sequence; |
| | | $opt = rcmail::get_instance()->config->get($config_key); |
| | | |
| | | if (strlen($CONFIG[$config_key])) |
| | | return $CONFIG[$config_key]; |
| | | if (!empty($opt)) |
| | | { |
| | | $db = &rcmail::get_instance()->db; |
| | | |
| | | if($db->db_provider=='pgsql') // just for sure |
| | | { |
| | | $db->db_handle->setOption('disable_smart_seqname', true); |
| | | $db->db_handle->setOption('seqname_format', '%s'); |
| | | } |
| | | |
| | | return $CONFIG[$opt]; |
| | | } |
| | | |
| | | return $sequence; |
| | | } |
| | | |
| | |
| | | { |
| | | return rcmail::get_instance()->gettext($p); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Load virtuser table in array |
| | | * |
| | | * @return array Virtuser table entries |
| | | */ |
| | | function rcmail_getvirtualfile() |
| | | { |
| | | global $CONFIG; |
| | | if (empty($CONFIG['virtuser_file']) || !is_file($CONFIG['virtuser_file'])) |
| | | return FALSE; |
| | | |
| | | // read file |
| | | $a_lines = file($CONFIG['virtuser_file']); |
| | | return $a_lines; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Find matches of the given pattern in virtuser table |
| | | * |
| | | * @param string Regular expression to search for |
| | | * @return array Matching entries |
| | | */ |
| | | function rcmail_findinvirtual($pattern) |
| | | { |
| | | $result = array(); |
| | | $virtual = rcmail_getvirtualfile(); |
| | | if ($virtual==FALSE) |
| | | return $result; |
| | | |
| | | // check each line for matches |
| | | foreach ($virtual as $line) |
| | | { |
| | | $line = trim($line); |
| | | if (empty($line) || $line{0}=='#') |
| | | continue; |
| | | |
| | | if (eregi($pattern, $line)) |
| | | $result[] = $line; |
| | | } |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') |
| | | { |
| | | $aliases['GB2312'] = 'GB18030'; |
| | | return iconv(($aliases[$from] ? $aliases[$from] : $from), ($aliases[$to] ? $aliases[$to] : $to) . "//IGNORE", $str); |
| | | $_iconv = iconv(($aliases[$from] ? $aliases[$from] : $from), ($aliases[$to] ? $aliases[$to] : $to) . "//IGNORE", $str); |
| | | if ($_iconv !== false) |
| | | { |
| | | return $_iconv; |
| | | } |
| | | } |
| | | |
| | | // settings for mbstring module (by Tadashi Jokagi) |
| | |
| | | |
| | | |
| | | /** |
| | | * Check if a specific template exists |
| | | * |
| | | * @param string Template name |
| | | * @return boolean True if template exists |
| | | */ |
| | | function template_exists($name) |
| | | { |
| | | global $CONFIG; |
| | | $skin_path = $CONFIG['skin_path']; |
| | | |
| | | // check template file |
| | | return is_file("$skin_path/templates/$name.html"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create a HTML table based on the given data |
| | | * |
| | | * @param array Named table attributes |
| | |
| | | */ |
| | | function rcube_table_output($attrib, $table_data, $a_show_cols, $id_col) |
| | | { |
| | | global $DB; |
| | | global $RCMAIL; |
| | | |
| | | // allow the following attributes to be added to the <table> tag |
| | | $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); |
| | | |
| | | $table = '<table' . $attrib_str . ">\n"; |
| | | $table = new html_table(/*array('cols' => count($a_show_cols))*/); |
| | | |
| | | // add table title |
| | | $table .= "<thead><tr>\n"; |
| | | |
| | | // add table header |
| | | foreach ($a_show_cols as $col) |
| | | $table .= '<td class="'.$col.'">' . Q(rcube_label($col)) . "</td>\n"; |
| | | |
| | | $table .= "</tr></thead>\n<tbody>\n"; |
| | | $table->add_header($col, Q(rcube_label($col))); |
| | | |
| | | $c = 0; |
| | | if (!is_array($table_data)) |
| | | { |
| | | $db = $RCMAIL->get_dbh(); |
| | | while ($table_data && ($sql_arr = $db->fetch_assoc($table_data))) |
| | | { |
| | | while ($table_data && ($sql_arr = $DB->fetch_assoc($table_data))) |
| | | { |
| | | $zebra_class = $c%2 ? 'even' : 'odd'; |
| | | |
| | | $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $sql_arr[$id_col]); |
| | | $zebra_class = $c % 2 ? 'even' : 'odd'; |
| | | $table->add_row(array('id' => 'rcmrow' . $sql_arr[$id_col], 'class' => "contact $zebra_class")); |
| | | |
| | | // format each col |
| | | foreach ($a_show_cols as $col) |
| | | { |
| | | $cont = Q($sql_arr[$col]); |
| | | $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; |
| | | } |
| | | |
| | | $table .= "</tr>\n"; |
| | | $table->add($col, Q($sql_arr[$col])); |
| | | |
| | | $c++; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | { |
| | | foreach ($table_data as $row_data) |
| | | { |
| | | $zebra_class = $c%2 ? 'even' : 'odd'; |
| | | |
| | | $table .= sprintf('<tr id="rcmrow%d" class="contact '.$zebra_class.'">'."\n", $row_data[$id_col]); |
| | | { |
| | | $zebra_class = $c % 2 ? 'even' : 'odd'; |
| | | $table->add_row(array('id' => 'rcmrow' . $row_data[$id_col], 'class' => "contact $zebra_class")); |
| | | |
| | | // format each col |
| | | foreach ($a_show_cols as $col) |
| | | { |
| | | $cont = Q($row_data[$col]); |
| | | $table .= '<td class="'.$col.'">' . $cont . "</td>\n"; |
| | | } |
| | | |
| | | $table .= "</tr>\n"; |
| | | $table->add($col, Q($row_data[$col])); |
| | | |
| | | $c++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // complete message table |
| | | $table .= "</tbody></table>\n"; |
| | | |
| | | return $table; |
| | | return $table->show($attrib); |
| | | } |
| | | |
| | | |
| | |
| | | $out = $input->show($value); |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return the mail domain configured for the given host |
| | | * |
| | | * @param string IMAP host |
| | | * @return string Resolved SMTP host |
| | | */ |
| | | function rcmail_mail_domain($host) |
| | | { |
| | | global $CONFIG; |
| | | |
| | | $domain = $host; |
| | | if (is_array($CONFIG['mail_domain'])) |
| | | { |
| | | if (isset($CONFIG['mail_domain'][$host])) |
| | | $domain = $CONFIG['mail_domain'][$host]; |
| | | } |
| | | else if (!empty($CONFIG['mail_domain'])) |
| | | $domain = $CONFIG['mail_domain']; |
| | | |
| | | return $domain; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | return $styles; |
| | | } |
| | | |
| | | /** |
| | | * Try to autodetect operating system and find the correct line endings |
| | | * |
| | | * @return string The appropriate mail header delimiter |
| | | */ |
| | | function rcmail_header_delm() |
| | | { |
| | | global $CONFIG; |
| | | |
| | | // use the configured delimiter for headers |
| | | if (!empty($CONFIG['mail_header_delimiter'])) |
| | | return $CONFIG['mail_header_delimiter']; |
| | | else if (strtolower(substr(PHP_OS, 0, 3)=='win')) |
| | | return "\r\n"; |
| | | else if (strtolower(substr(PHP_OS, 0, 3)=='mac')) |
| | | return "\r\n"; |
| | | else |
| | | return "\n"; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | $class_name = 'junk'; |
| | | |
| | | $js_name = htmlspecialchars(JQ($folder['id'])); |
| | | $out .= sprintf('<li id="rcmli%s" class="mailbox %s %s%s%s"><a href="%s"'. |
| | | $out .= sprintf('<li id="rcmli%s" class="mailbox %s %s%s"><a href="%s"'. |
| | | ' onclick="return %s.command(\'list\',\'%s\',this)"'. |
| | | ' onmouseover="return %s.focus_folder(\'%s\')"' . |
| | | ' onmouseout="return %s.unfocus_folder(\'%s\')"' . |
| | |
| | | $folder_id, |
| | | $class_name, |
| | | $zebra_class, |
| | | $unread_count ? ' unread' : '', |
| | | $folder['id']==$mbox_name ? ' selected' : '', |
| | | Q(rcmail_url('', array('_mbox' => $folder['id']))), |
| | | JS_OBJECT_NAME, |