Example #1
0
 /**
  * Refresh values from the session
  */
 function refresh()
 {
     $this->wasSet = sqGetGlobalVar($this->name, $new_value, SQ_SESSION);
     if (!$this->wasSet) {
         return;
     }
     if ($new_value == NULL || $new_value == '') {
         $this->wasValid = $this->set(NULL, FALSE);
         return;
     }
     if ($this->base64) {
         $new_value = unserialize(base64_decode($new_value));
     }
     $this->wasValid = $this->set($new_value, FALSE);
 }
Example #2
0
 /**
  * Constructs a new checkbox object.
  *
  * @param string name The name of the checkbox.
  * @param bool checked The initial checkbox state.
  * @param string caption The caption to display by the checkbox.
  */
 function input_checkbox($name, &$form, $checked = FALSE, $caption = NULL)
 {
     $this->caption = $caption;
     $this->name = $name;
     $this->regex = NULL;
     $this->required = FALSE;
     $this->default = $checked;
     $this->wasSet = FALSE;
     $this->wasValid = FALSE;
     $this->default = $checked;
     if ($form->submitted()) {
         $this->wasSet = TRUE;
         $this->wasValid = TRUE;
         $this->checked = sqGetGlobalVar($name, $new_value, SQ_FORM);
     } else {
         $this->set($checked);
     }
     $this->value = $this->checked;
 }
Example #3
0
 /**
  * Constructs a new textarea object.
  *
  * @param string name The name of the textarea.
  * @param string regex The validation regular expression.
  * @param string value The initial contents value.
  * @param string caption The caption to display by the textarea.
  */
 function input_textarea($name, $regex = NULL, $value = NULL, $caption = NULL, $maxlength = FALSE)
 {
     $this->name = $name;
     $this->regex = $regex;
     $this->required = FALSE;
     $this->form = NULL;
     $this->caption = $caption;
     $this->maxlength = $maxlength;
     $this->default = $value;
     if (sqGetGlobalVar($name, $new_value, SQ_FORM)) {
         $this->wasSet = TRUE;
         $this->wasValid = $this->set($new_value);
     }
     // If either it wasn't set, or
     // Value was not null and it wasn't a string..
     // Then set to the default.
     if (!$this->wasSet || $value != NULL && !is_string($value)) {
         $this->value = $value;
     }
 }
Example #4
0
 function checkForJavascript($reset = FALSE)
 {
     global $data_dir, $username, $javascript_on, $javascript_setting;
     if (!$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION)) {
         return $javascript_on;
     }
     if (($reset || !isset($javascript_setting)) && (sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION) && $user_is_logged_in)) {
         $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
     }
     if (!sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results)) {
         $js_autodetect_results = SMPREF_JS_OFF;
     }
     if ($javascript_setting == SMPREF_JS_AUTODETECT) {
         $javascript_on = $js_autodetect_results;
     } else {
         $javascript_on = $javascript_setting;
     }
     sqsession_register($javascript_on, 'javascript_on');
     return $javascript_on;
 }
Example #5
0
/**
 * Create stylesheet links that will work for multiple browsers
 *
 * @param string  $uri       The URI to the linked stylesheet.
 * @param string  $name      The title of the stylesheet (optional; default empty).
 * @param boolean $alt       Whether or not this is an alternate 
 *                           stylesheet (optional; default TRUE).
 * @param string  $mtype     The target media display type (optional; default "screen").
 *
 * @return string The full text of the stylesheet link.
 *
 */
function create_css_link($uri, $name = '', $alt = TRUE, $mtype = 'screen')
{
    // FIXME: Add closing / to link and meta elements only after
    //        switching to xhtml 1.0 Transitional.
    //        It is not compatible with html 4.01 Transitional
    if (empty($uri)) {
        return '';
    }
    // set to lower case to avoid errors
    //
    sqGetGlobalVar('HTTP_USER_AGENT', $browser_user_agent, SQ_SERVER);
    $browser_user_agent = strtolower($browser_user_agent);
    if (stristr($browser_user_agent, "msie 4")) {
        $browser = 'msie4';
        $dom_browser = false;
        $is_IE = true;
    } elseif (stristr($browser_user_agent, "msie") && stristr($browser_user_agent, 'opera') === FALSE) {
        $browser = 'msie';
        $dom_browser = true;
        $is_IE = true;
    }
    if (strpos($uri, '-ie') !== false and !$is_IE) {
        //not IE, so don't render this sheet
        return;
    }
    if (strpos($uri, 'print') !== false) {
        $mtype = 'print';
    }
    $href = 'href="' . $uri . '" ';
    $media = 'media="' . $mtype . '" ';
    if (empty($name)) {
        $title = '';
        $rel = 'rel="stylesheet" ';
    } else {
        $title = 'title="' . $name . '" ';
        $rel = 'rel="' . ($alt ? 'alternate ' : '') . 'stylesheet" ';
    }
    return '<link ' . $media . $title . $rel . 'type="text/css" ' . $href . " />\n";
}
Example #6
0
 *
 * This page tests the decodeHeader function.
 *
 * @copyright &copy; 2006 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id$
 * @package plugins
 * @subpackage test
 */
define('SM_PATH', '../../');
include_once SM_PATH . 'include/validate.php';
include_once SM_PATH . 'functions/mime.php';
global $oTemplate, $color;
displayPageHeader($color, 'none');
$header = array("< &  Ã", '=?iso-8859-1?Q?=3C_&__=C3?=', '=?iso-8859-1?B?PCAmICDD?=', '=?utf-8?Q?=3C_&__=C3=80?=', '=?utf-8?B?PCAmICDDgA==?=');
if (sqGetGlobalVar('lossy', $lossy, SQ_GET)) {
    if ($lossy) {
        $lossy_encoding = true;
    } else {
        if ($default_charset == 'utf-8') {
            $default_charset = 'iso-8859-1';
        }
        $lossy_encoding = false;
    }
}
echo "<strong>decodeHeader() Test:</strong>\n";
if ($default_charset == 'utf-8' || $lossy_encoding) {
    echo '<p><a href="decodeheader.php?lossy=0">Test with lossy_encoding OFF</a></p>';
} else {
    echo '<p><a href="decodeheader.php?lossy=1">Test with lossy_encoding ON</a></p>';
}
Example #7
0
}
if (!sqGetGlobalVar('event_hour', $event_hour, SQ_POST) || !is_numeric($event_hour)) {
    unset($event_hour);
}
if (!sqGetGlobalVar('event_minute', $event_minute, SQ_POST) || !is_numeric($event_minute)) {
    unset($event_minute);
}
if (!sqGetGlobalVar('event_length', $event_length, SQ_POST) || !is_numeric($event_length)) {
    unset($event_length);
}
if (!sqGetGlobalVar('event_priority', $event_priority, SQ_POST) || !is_numeric($event_priority)) {
    unset($event_priority);
}
sqGetGlobalVar('event_title', $event_title, SQ_POST);
sqGetGlobalVar('event_text', $event_text, SQ_POST);
sqGetGlobalVar('send', $send, SQ_POST);
/* got 'em */
//main form to gather event info
function show_event_form()
{
    global $color, $editor_size, $year, $day, $month, $hour;
    echo "\n<form name=\"eventscreate\" action=\"event_create.php\" method=\"post\">\n" . "      <input type=\"hidden\" name=\"year\" value=\"{$year}\" />\n" . "      <input type=\"hidden\" name=\"month\" value=\"{$month}\" />\n" . "      <input type=\"hidden\" name=\"day\" value=\"{$day}\" />\n" . html_tag('tr') . html_tag('td', _("Start time:"), 'right', $color[4]) . "\n" . html_tag('td', '', 'left', $color[4]) . "\n" . "      <select name=\"event_hour\">\n";
    select_option_hour($hour);
    echo "      </select>\n" . "      &nbsp;:&nbsp;\n" . "      <select name=\"event_minute\">\n";
    select_option_minute("00");
    echo "      </select>\n" . "      </td></tr>\n" . html_tag('tr') . html_tag('td', _("Length:"), 'right', $color[4]) . "\n" . html_tag('td', '', 'left', $color[4]) . "\n" . "      <select name=\"event_length\">\n";
    select_option_length("0");
    echo "      </select>\n" . "      </td></tr>\n" . html_tag('tr') . html_tag('td', _("Priority:"), 'right', $color[4]) . "\n" . html_tag('td', '', 'left', $color[4]) . "\n" . "      <select name=\"event_priority\">\n";
    select_option_priority("0");
    echo "      </select>\n" . "      </td></tr>\n" . html_tag('tr') . html_tag('td', _("Title:"), 'right', $color[4]) . "\n" . html_tag('td', '', 'left', $color[4]) . "\n" . "      <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n" . "      </td></tr>\n" . html_tag('tr', html_tag('td', "<textarea name=\"event_text\" rows=\"5\" cols=\"{$editor_size}\"></textarea>", 'left', $color[4], 'colspan="2"')) . "\n" . html_tag('tr', html_tag('td', '<input type="submit" name="send" value="' . _("Set Event") . '" />', 'left', $color[4], 'colspan="2"')) . "\n";
    echo "</form>\n";
Example #8
0
/**
 * Saves the option value (this is the default save function
 * unless overridden by the user)
 *
 * @param object $option object that holds option name and new_value
 */
function save_option($option)
{
    // Can't save the pref if we don't have the username
    //
    if (!sqgetGlobalVar('username', $username, SQ_SESSION)) {
        return;
    }
    // if the widget is a selection list, make sure the new
    // value is actually in the selection list and is not an
    // injection attack
    //
    if ($option->type == SMOPT_TYPE_STRLIST && !array_key_exists($option->new_value, $option->possible_values)) {
        return;
    } else {
        if ($option->type != SMOPT_TYPE_TEXTAREA) {
            $option->new_value = str_replace(array("\r", "\n"), '', $option->new_value);
        }
    }
    global $data_dir;
    // edit lists: first add new elements to list, then
    // remove any selected ones (note that we must add
    // before deleting because the javascript that populates
    // the "add" textbox when selecting items in the list
    // (for deletion))
    //
    if ($option->type == SMOPT_TYPE_EDIT_LIST) {
        if (empty($option->possible_values)) {
            $option->possible_values = array();
        }
        if (!is_array($option->possible_values)) {
            $option->possible_values = array($option->possible_values);
        }
        // add element if given
        //
        if (isset($option->use_add_widget) && $option->use_add_widget && sqGetGlobalVar('add_' . $option->name, $new_element, SQ_POST)) {
            $new_element = trim($new_element);
            if (!empty($new_element) && !in_array($new_element, $option->possible_values)) {
                $option->possible_values[] = $new_element;
            }
        }
        // delete selected elements if needed
        //
        if (isset($option->use_delete_widget) && $option->use_delete_widget && is_array($option->new_value) && sqGetGlobalVar('delete_' . $option->name, $ignore, SQ_POST)) {
            $option->possible_values = array_diff($option->possible_values, $option->new_value);
        }
        // save full list (stored in "possible_values")
        //
        setPref($data_dir, $username, $option->name, serialize($option->possible_values));
        // associative edit lists are handled similar to
        // non-associative ones
        //
    } else {
        if ($option->type == SMOPT_TYPE_EDIT_LIST_ASSOCIATIVE) {
            if (empty($option->possible_values)) {
                $option->possible_values = array();
            }
            if (!is_array($option->possible_values)) {
                $option->possible_values = array($option->possible_values);
            }
            // add element if given
            //
            $new_element_key = '';
            $new_element_value = '';
            $retrieve_key = sqGetGlobalVar('add_' . $option->name . '_key', $new_element_key, SQ_POST);
            $retrieve_value = sqGetGlobalVar('add_' . $option->name . '_value', $new_element_value, SQ_POST);
            if (isset($option->use_add_widget) && $option->use_add_widget && ($retrieve_key || $retrieve_value)) {
                $new_element_key = trim($new_element_key);
                $new_element_value = trim($new_element_value);
                if ($option->poss_value_folders && empty($new_element_key)) {
                    $new_element_value = '';
                }
                if (!empty($new_element_key) || !empty($new_element_value)) {
                    if (empty($new_element_key)) {
                        $new_element_key = '0';
                    }
                    $option->possible_values[$new_element_key] = $new_element_value;
                }
            }
            // delete selected elements if needed
            //
            if (isset($option->use_delete_widget) && $option->use_delete_widget && is_array($option->new_value) && sqGetGlobalVar('delete_' . $option->name, $ignore, SQ_POST)) {
                if ($option->layout_type == SMOPT_EDIT_LIST_LAYOUT_SELECT) {
                    foreach ($option->new_value as $key) {
                        unset($option->possible_values[urldecode($key)]);
                    }
                } else {
                    $option->possible_values = array_diff($option->possible_values, $option->new_value);
                }
            }
            // save full list (stored in "possible_values")
            //
            setPref($data_dir, $username, $option->name, serialize($option->possible_values));
            // Certain option types need to be serialized because
            // they are not scalar
            //
        } else {
            if ($option->is_multiple_valued()) {
                setPref($data_dir, $username, $option->name, serialize($option->new_value));
            } else {
                if (($option->type == SMOPT_TYPE_BOOLEAN || $option->type == SMOPT_TYPE_BOOLEAN_CHECKBOX) && empty($option->new_value)) {
                    setPref($data_dir, $username, $option->name, SMPREF_OFF);
                } else {
                    if ($option->type == SMOPT_TYPE_INTEGER) {
                        $option->new_value = preg_replace('/[^0-9]/', '', $option->new_value);
                        setPref($data_dir, $username, $option->name, $option->new_value);
                    } else {
                        setPref($data_dir, $username, $option->name, $option->new_value);
                    }
                }
            }
        }
    }
    // if a checkbox or multi select is zeroed/cleared out, it
    // needs to have an empty value pushed into its "new_value" slot
    //
    if (($option->type == SMOPT_TYPE_STRLIST_MULTI || $option->type == SMOPT_TYPE_BOOLEAN_CHECKBOX) && is_null($option->new_value)) {
        $option->new_value = '';
    }
}
Example #9
0
File: i18n.php Project: jprice/EHCP
function set_up_language($sm_language, $do_search = false, $default = false)
{
    static $SetupAlready = 0;
    global $use_gettext, $languages, $squirrelmail_language, $squirrelmail_default_language, $default_charset, $sm_notAlias;
    if ($SetupAlready) {
        return;
    }
    $SetupAlready = TRUE;
    sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER);
    /**
     * detect preferred language from header when SquirrelMail asks for
     * it or when default language is set to empty string.
     */
    if (($do_search || empty($squirrelmail_default_language)) && !$sm_language && isset($accept_lang)) {
        $sm_language = substr($accept_lang, 0, 2);
    }
    /**
     * Use default language when it is not detected or when script
     * asks to use default language.
     */
    if ((!$sm_language || $default) && !empty($squirrelmail_default_language)) {
        $squirrelmail_language = $squirrelmail_default_language;
        $sm_language = $squirrelmail_default_language;
    }
    /** provide failsafe language when detection fails */
    if (!$sm_language) {
        $sm_language = 'en_US';
    }
    $sm_notAlias = $sm_language;
    /**
     * Catch removed translation
     * System reverts to English translation if user prefs contain translation
     * that is not available in $languages array
     */
    if (!isset($languages[$sm_notAlias])) {
        $sm_notAlias = "en_US";
    }
    while (isset($languages[$sm_notAlias]['ALIAS'])) {
        $sm_notAlias = $languages[$sm_notAlias]['ALIAS'];
    }
    if (isset($sm_language) && $use_gettext && $sm_language != '' && isset($languages[$sm_notAlias]['CHARSET'])) {
        bindtextdomain('squirrelmail', SM_PATH . 'locale/');
        textdomain('squirrelmail');
        if (function_exists('bind_textdomain_codeset')) {
            if ($sm_notAlias == 'ja_JP') {
                bind_textdomain_codeset("squirrelmail", 'EUC-JP');
            } else {
                bind_textdomain_codeset("squirrelmail", $languages[$sm_notAlias]['CHARSET']);
            }
        }
        // Use LOCALE key, if it is set.
        if (isset($languages[$sm_notAlias]['LOCALE'])) {
            $longlocale = $languages[$sm_notAlias]['LOCALE'];
        } else {
            $longlocale = $sm_notAlias;
        }
        // try setting locale
        $retlocale = sq_setlocale(LC_ALL, $longlocale);
        // check if locale is set and assign that locale to $longlocale
        // in order to use it in putenv calls.
        if (!is_bool($retlocale)) {
            $longlocale = $retlocale;
        } elseif (is_array($longlocale)) {
            // setting of all locales failed.
            // we need string instead of array used in LOCALE key.
            $longlocale = $sm_notAlias;
        }
        if (!(bool) ini_get('safe_mode') && getenv('LC_ALL') != $longlocale) {
            putenv("LC_ALL={$longlocale}");
            putenv("LANG={$longlocale}");
            putenv("LANGUAGE={$longlocale}");
            putenv("LC_NUMERIC=C");
            if ($sm_notAlias == 'tr_TR') {
                putenv("LC_CTYPE=C");
            }
        }
        // Workaround for plugins that use numbers with floating point
        // It might be removed if plugins use correct decimal delimiters
        // according to locale settings.
        setlocale(LC_NUMERIC, 'C');
        // Workaround for specific Turkish strtolower/strtoupper rules.
        // Many functions expect English conversion rules.
        if ($sm_notAlias == 'tr_TR') {
            setlocale(LC_CTYPE, 'C');
        }
        $squirrelmail_language = $sm_notAlias;
        if ($squirrelmail_language == 'ja_JP') {
            header('Content-Type: text/html; charset=EUC-JP');
            if (!function_exists('mb_internal_encoding')) {
                // don't display mbstring warning when user isn't logged
                // in because the user may not be using SM for Japanese;
                // also don't display on webmail page so user has the
                // chance to go back and revert their language setting
                // until admin can get their act together
                if (sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION) && $user_is_logged_in && PAGE_NAME != 'webmail') {
                    echo _("You need to have PHP installed with the multibyte string function enabled (using configure option --enable-mbstring).");
                    // Revert to English link has to be added.
                    // stop further execution in order not to get php errors on mb_internal_encoding().
                }
                return;
            }
            if (function_exists('mb_language')) {
                mb_language('Japanese');
            }
            mb_internal_encoding('EUC-JP');
            mb_http_output('pass');
        } elseif ($squirrelmail_language == 'en_US') {
            header('Content-Type: text/html; charset=' . $default_charset);
        } else {
            header('Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET']);
        }
        // mbstring.func_overload<>0 fix. See cvs HEAD comments.
        if ($squirrelmail_language != 'ja_JP' && function_exists('mb_internal_encoding') && check_php_version(4, 2, 0) && (int) ini_get('mbstring.func_overload') != 0) {
            mb_internal_encoding('pass');
        }
    }
}
Example #10
0
    unset($event_priority);
}
sqGetGlobalVar('confirmed', $confirmed, SQ_POST);
if (!sqGetGlobalVar('year', $year, SQ_FORM) || !is_numeric($year)) {
    unset($year);
}
if (!sqGetGlobalVar('month', $month, SQ_FORM) || !is_numeric($month)) {
    unset($month);
}
if (!sqGetGlobalVar('day', $day, SQ_FORM) || !is_numeric($day)) {
    unset($day);
}
if (!sqGetGlobalVar('hour', $hour, SQ_FORM) || !is_numeric($hour)) {
    unset($hour);
}
if (!sqGetGlobalVar('minute', $minute, SQ_FORM) || !is_numeric($minute)) {
    unset($minute);
}
/* got 'em */
/**
 * update event info
 * @return void
 * @access private
 */
function update_event_form()
{
    global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
    $tmparray = $calendardata["{$month}{$day}{$year}"]["{$hour}{$minute}"];
    $tab = '    ';
    echo "\n<form name=\"eventupdate\" action=\"event_edit.php\" method=\"post\">\n" . $tab . addHidden('year', $year) . $tab . addHidden('month', $month) . $tab . addHidden('day', $day) . $tab . addHidden('hour', $hour) . $tab . addHidden('minute', $minute) . $tab . addHidden('updated', 'yes') . html_tag('tr') . html_tag('td', _("Date:"), 'right', $color[4]) . "\n" . html_tag('td', '', 'left', $color[4]) . "      <select name=\"event_year\">\n";
    select_option_year($year);
Example #11
0
sqgetGlobalVar('smtoken', $submitted_token, SQ_POST, '');
sqgetGlobalVar('addaddr', $addaddr, SQ_POST);
sqgetGlobalVar('editaddr', $editaddr, SQ_POST);
sqgetGlobalVar('deladdr', $deladdr, SQ_POST);
sqgetGlobalVar('compose_to', $compose_to, SQ_POST);
sqgetGlobalVar('sel', $sel, SQ_POST);
sqgetGlobalVar('oldnick', $oldnick, SQ_POST);
sqgetGlobalVar('backend', $backend, SQ_POST);
sqgetGlobalVar('doedit', $doedit, SQ_POST);
$page_size = $abook_show_num;
if (!sqGetGlobalVar('page_number', $page_number, SQ_FORM)) {
    if (!sqGetGlobalVar('current_page_number', $page_number, SQ_FORM)) {
        $page_number = 1;
    }
}
if (!sqGetGlobalVar('show_all', $show_all, SQ_FORM)) {
    $show_all = 0;
}
/* Get sorting order */
$abook_sort_order = get_abook_sort();
// Create page header before addressbook_init in order to
// display error messages correctly, unless we might be
// redirecting the browser to the compose page.
//
if (empty($compose_to) || sizeof($sel) < 1) {
    displayPageHeader($color);
}
/* Open addressbook with error messages on.
 remote backends (LDAP) are enabled because they can be used. (list_addr function)
*/
$abook = addressbook_init(true, false);
Example #12
0
require_once SM_PATH . 'functions/strings.php';
require_once SM_PATH . 'functions/prefs.php';
require_once SM_PATH . 'functions/imap.php';
require_once SM_PATH . 'functions/plugin.php';
require_once SM_PATH . 'functions/constants.php';
require_once SM_PATH . 'functions/page_header.php';
header('Pragma: no-cache');
$location = get_location();
sqsession_is_active();
sqsession_unregister('user_is_logged_in');
sqsession_register($base_uri, 'base_uri');
/* get globals we me need */
sqGetGlobalVar('login_username', $login_username);
sqGetGlobalVar('secretkey', $secretkey);
sqGetGlobalVar('js_autodetect_results', $js_autodetect_results);
if (!sqGetGlobalVar('squirrelmail_language', $squirrelmail_language) || $squirrelmail_language == '') {
    $squirrelmail_language = $squirrelmail_default_language;
}
if (!sqgetGlobalVar('mailtodata', $mailtodata)) {
    $mailtodata = '';
}
/* end of get globals */
set_up_language($squirrelmail_language, true);
/* Refresh the language cookie. */
sqsetcookie('squirrelmail_language', $squirrelmail_language, time() + 2592000, $base_uri);
if (!isset($login_username)) {
    include_once SM_PATH . 'functions/display_messages.php';
    logout_error(_("You must be logged in to access this page."));
    exit;
}
if (!sqsession_is_registered('user_is_logged_in')) {
Example #13
0
<?php

/**
 * newmail.php
 *
 * Copyright (c) 1999-2006 The SquirrelMail Project Team
 * Licensed under the GNU GPL. For full terms see the file COPYING.        
 *
 * Displays all options relating to new mail sounds
 *
 * $Id: newmail.php 10633 2006-02-03 22:27:56Z jervfors $
 * @package plugins
 * @subpackage newmail
 */
/** @ignore */
define('SM_PATH', '../../');
/* SquirrelMail required files. */
require_once SM_PATH . 'include/validate.php';
require_once SM_PATH . 'include/load_prefs.php';
require_once SM_PATH . 'functions/page_header.php';
sqGetGlobalVar('numnew', $numnew, SQ_GET);
$numnew = (int) $numnew;
displayHtmlHeader(_("New Mail"), '', FALSE);
echo '<body bgcolor="' . $color[4] . '" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">' . "\n" . '<center>' . "\n" . html_tag('table', "\n" . html_tag('tr', "\n" . html_tag('td', '<b>' . _("SquirrelMail Notice:") . '</b>', 'center', $color[0])) . html_tag('tr', "\n" . html_tag('td', '<br /><big><font color="' . $color[2] . '">' . sprintf($numnew == 1 ? _("You have %s new message") : _("You have %s new messages"), $numnew) . '</font><br /></big><br />' . "\n" . '<form name="nm">' . "\n" . '<input type="button" name="bt" value="' . _("Close Window") . '" onClick="javascript:window.close();" />' . "\n" . '</form>', 'center')), '', '', 'width="100%" cellpadding="2" cellspacing="2" border="0"') . '</center>' . "<script language=javascript>\n" . "<!--\n" . "document.nm.bt.focus();\n" . "-->\n" . "</script>\n" . "</body></html>\n";
Example #14
0
/**
 * Javascript support detection function
 * @param boolean $reset recheck javascript support if set to true.
 * @return integer SMPREF_JS_ON or SMPREF_JS_OFF ({@see include/constants.php})
 * @since 1.5.1
 */
function checkForJavascript($reset = FALSE)
{
    global $data_dir, $username, $javascript_on, $javascript_setting;
    if (!$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION)) {
        return $javascript_on;
    }
    //FIXME: this isn't used anywhere else in this function; can we remove it?  why is it here?
    $user_is_logged_in = FALSE;
    if ($reset || !isset($javascript_setting)) {
        $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
    }
    if (!sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results)) {
        $js_autodetect_results = SMPREF_JS_OFF;
    }
    if ($javascript_setting == SMPREF_JS_AUTODETECT) {
        $javascript_on = $js_autodetect_results;
    } else {
        $javascript_on = $javascript_setting;
    }
    sqsession_register($javascript_on, 'javascript_on');
    return $javascript_on;
}
Example #15
0
if (!sqGetGlobalVar('dyear', $dyear, SQ_FORM) || !is_numeric($dyear)) {
    unset($dyear);
}
if (!sqGetGlobalVar('dmonth', $dmonth, SQ_FORM) || !is_numeric($dmonth)) {
    unset($dmonth);
}
if (!sqGetGlobalVar('dday', $dday, SQ_FORM) || !is_numeric($dday)) {
    unset($dday);
}
if (!sqGetGlobalVar('dhour', $dhour, SQ_FORM) || !is_numeric($dhour)) {
    unset($dhour);
}
if (!sqGetGlobalVar('dminute', $dminute, SQ_FORM) || !is_numeric($dminute)) {
    unset($dminute);
}
sqGetGlobalVar('confirmed', $confirmed, SQ_POST);
/* got 'em */
/**
 * Displays confirmation form when event is deleted
 * @return void
 */
function confirm_deletion()
{
    global $calself, $dyear, $dmonth, $dday, $dhour, $dminute, $calendardata, $color, $year, $month, $day;
    $tmparray = $calendardata["{$dmonth}{$dday}{$dyear}"]["{$dhour}{$dminute}"];
    echo html_tag('table', html_tag('tr', html_tag('th', _("Do you really want to delete this event?") . '<br />', '', $color[4], 'colspan="2"')) . html_tag('tr', html_tag('td', _("Date:"), 'right', $color[4]) . html_tag('td', date_intl(_("m/d/Y"), mktime(0, 0, 0, $dmonth, $dday, $dyear)), 'left', $color[4])) . html_tag('tr', html_tag('td', _("Time:"), 'right', $color[4]) . html_tag('td', date_intl(_("H:i"), mktime($dhour, $dminute, 0, $dmonth, $dday, $dyear)), 'left', $color[4])) . html_tag('tr', html_tag('td', _("Title:"), 'right', $color[4]) . html_tag('td', htmlspecialchars($tmparray['title']), 'left', $color[4])) . html_tag('tr', html_tag('td', _("Message:"), 'right', $color[4]) . html_tag('td', nl2br(htmlspecialchars($tmparray['message'])), 'left', $color[4])) . html_tag('tr', html_tag('td', "    <form name=\"delevent\" method=\"post\" action=\"{$calself}\">\n" . "       <input type=\"hidden\" name=\"dyear\" value=\"{$dyear}\" />\n" . "       <input type=\"hidden\" name=\"dmonth\" value=\"{$dmonth}\" />\n" . "       <input type=\"hidden\" name=\"dday\" value=\"{$dday}\" />\n" . "       <input type=\"hidden\" name=\"year\" value=\"{$year}\" />\n" . "       <input type=\"hidden\" name=\"month\" value=\"{$month}\" />\n" . "       <input type=\"hidden\" name=\"day\" value=\"{$day}\" />\n" . "       <input type=\"hidden\" name=\"dhour\" value=\"{$dhour}\" />\n" . "       <input type=\"hidden\" name=\"dminute\" value=\"{$dminute}\" />\n" . "       <input type=\"hidden\" name=\"confirmed\" value=\"yes\" />\n" . '       <input type="submit" value="' . _("Yes") . "\" />\n" . "    </form>\n", 'right', $color[4]) . html_tag('td', "    <form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n" . "       <input type=\"hidden\" name=\"year\" value=\"{$year}\" />\n" . "       <input type=\"hidden\" name=\"month\" value=\"{$month}\" />\n" . "       <input type=\"hidden\" name=\"day\" value=\"{$day}\" />\n" . '       <input type="submit" value="' . _("No") . "\" />\n" . "    </form>\n", 'left', $color[4])), '', $color[0], 'border="0" cellpadding="2" cellspacing="1"');
}
if ($month <= 0) {
    $month = date('m');
}
if ($year <= 0) {
Example #16
0
$theme = array();
$theme[0]['PATH'] = SM_PATH . 'themes/default_theme.php';
$theme[0]['NAME'] = 'Default';
$aTemplateSet = array();
$aTemplateSet[0]['ID'] = 'default';
$aTemplateSet[0]['NAME'] = 'Default';
/* load site configuration */
if (file_exists(SM_PATH . 'config/config.php')) {
    require SM_PATH . 'config/config.php';
}
/* load local configuration overrides */
if (file_exists(SM_PATH . 'config/config_local.php')) {
    require SM_PATH . 'config/config_local.php';
}
sqGetGlobalVar('REMOTE_ADDR', $client_ip, SQ_SERVER);
sqGetGlobalVar('SERVER_ADDR', $server_ip, SQ_SERVER);
/**
 * Include Compatibility plugin if available.
 */
if (!$disable_plugins && file_exists(SM_PATH . 'plugins/compatibility/functions.php')) {
    include_once SM_PATH . 'plugins/compatibility/functions.php';
}
/** Load plugins */
global $disable_plugins;
$squirrelmail_plugin_hooks = array();
if (!$disable_plugins && file_exists(SM_PATH . 'config/plugin_hooks.php')) {
    require SM_PATH . 'config/plugin_hooks.php';
}
/** Warning counter */
$warnings = 0;
/** indent */
Example #17
0
 /**
  * Constructs a new base object.
  *
  * @param string name The name of the form element.
  * @param string regex The validation regular expression.
  * @param string value The initial contents value.
  * @param bool  required is item required
  * @param constant method SQ_GET, SQ_POST, SQ_SESSION, etc.
  */
 function input_base($name, $regex = NULL, $value = NULL, $required = FALSE, $method = SQ_FORM)
 {
     $this->name = $name;
     $this->regex = $regex;
     $this->required = $required;
     $this->form = NULL;
     $this->default = $value;
     if (sqGetGlobalVar($name, $new_value, $method)) {
         $this->wasSet = TRUE;
         $this->wasValid = $this->set($new_value);
     }
     if (!$this->wasSet || !$this->wasValid) {
         $this->value = $value;
     }
 }
Example #18
0
define('SM_PATH', '../../');
/* SquirrelMail required files. */
include_once SM_PATH . 'include/validate.php';
/* date_intl() */
include_once SM_PATH . 'functions/date.php';
/* Calendar plugin required files. */
include_once SM_PATH . 'plugins/calendar/calendar_data.php';
include_once SM_PATH . 'plugins/calendar/functions.php';
/* get globals */
if (!sqGetGlobalVar('year', $year, SQ_FORM) || !is_numeric($year)) {
    unset($year);
}
if (!sqGetGlobalVar('month', $month, SQ_FORM) || !is_numeric($month)) {
    unset($month);
}
if (!sqGetGlobalVar('day', $day, SQ_FORM) || !is_numeric($day)) {
    unset($day);
}
/* got 'em */
/**
 * displays head of day calendar view
 * @return void
 * @access private
 */
function day_header()
{
    global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day, $prev_date, $next_month, $next_day, $next_year, $next_date;
    echo html_tag('tr', '', '', $color[0]) . "\n" . html_tag('td', '', 'left') . html_tag('table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"') . "\n" . html_tag('tr', html_tag('th', "<a href=\"day.php?year={$prev_year}&amp;month={$prev_month}&amp;day={$prev_day}\">&lt;&nbsp;" . date_intl('D', $prev_date) . "</a>", 'left') . html_tag('th', date_intl(_("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), '', '', 'width="75%"') . html_tag('th', "<a href=\"day.php?year={$next_year}&amp;month={$next_month}&amp;day={$next_day}\">" . date_intl('D', $next_date) . "&nbsp;&gt;</a>", 'right'));
}
/**
 * events for specific day  are inserted into "daily" array
Example #19
0
        error_box($string, $color);
        exit;
    }
}
do_hook('login_cookie');
/* Output the javascript onload function. */
$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . "  function squirrelmail_loginpage_onload() {\n" . "    var textElements = 0;\n" . "    for (i = 0; i < document.forms[0].elements.length; i++) {\n" . "      if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n" . "        textElements++;\n" . "        if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n" . "          document.forms[0].elements[i].focus();\n" . "          break;\n" . "        }\n" . "      }\n" . "    }\n" . "  }\n" . "// -->\n" . "</script>\n";
if (@file_exists($theme[$theme_default]['PATH'])) {
    @(include $theme[$theme_default]['PATH']);
}
displayHtmlHeader("{$org_name} - " . _("Login"), $header, FALSE);
echo "<body text=\"{$color['8']}\" bgcolor=\"{$color['4']}\" link=\"{$color['7']}\" vlink=\"{$color['7']}\" alink=\"{$color['7']}\" onLoad=\"squirrelmail_loginpage_onload()\">" . "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON . '\';">' . "\n";
$username_form_name = 'login_username';
$password_form_name = 'secretkey';
do_hook('login_top');
$loginname_value = sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '';
/* If they don't have a logo, don't bother.. */
if (isset($org_logo) && $org_logo) {
    /* Display width and height like good little people */
    $width_and_height = '';
    if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width > 0) {
        $width_and_height = " width=\"{$org_logo_width}\"";
    }
    if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height > 0) {
        $width_and_height .= " height=\"{$org_logo_height}\"";
    }
}
if (sqgetGlobalVar('mailto', $mailto)) {
    $rcptaddress = addHidden('mailto', $mailto);
} else {
    $rcptaddress = '';
Example #20
0
 /**
  * Has the form been cancelled?
  * Can be called statically. 
  * @return bool TRUE if the form has been cancelled
  */
 function cancelled()
 {
     if (sqGetGlobalVar('input_form_cancel', $new_value, SQ_FORM)) {
         return TRUE;
     }
     return FALSE;
 }
Example #21
0
 /**
  * Obtain template file hierarchy from cache.
  *
  * If the file hierarchy does not exist in session, it is
  * constructed and stored in session before being returned
  * to the caller.
  *
  * @param string  $template_set_id  The template set for which
  *                                  the cache should be built.
  *                                  This function will save more
  *                                  than one set's files, so it
  *                                  may be called multiple times
  *                                  with different values for this
  *                                  argument.  When regenerating,
  *                                  all set caches are dumped.
  * @param boolean $regenerate_cache When TRUE, the file hierarchy
  *                                  is reloaded and stored fresh
  *                                  (optional; default FALSE).
  * @param array   $additional_files Must be in same form as the
  *                                  files in the file hierarchy
  *                                  cache.  These are then added
  *                                  to the cache (optional; default
  *                                  empty - no additional files).
  *
  * @return array Template file hierarchy array, whose keys
  *               are all the template file names for the given
  *               template set ID (with path information relative
  *               to the template set's base directory, e.g.,
  *               "css/style.css") found in all parent template
  *               sets including the ultimate fall-back template
  *               set.  Array values are sub-arrays with the
  *               following key-value pairs:
  *
  *                 PATH    --  file path, relative to SM_PATH
  *                 SET_ID  --  the ID of the template set that this file belongs to
  *                 ENGINE  --  the engine needed to render this template file
  *
  * @static
  *
  */
 function cache_template_file_hierarchy($template_set_id, $regenerate_cache = FALSE, $additional_files = array())
 {
     sqGetGlobalVar('template_file_hierarchy', $template_file_hierarchy, SQ_SESSION, array());
     if ($regenerate_cache) {
         unset($template_file_hierarchy);
     }
     if (!empty($template_file_hierarchy[$template_set_id])) {
         // have to add additional files if given before returning
         //
         if (!empty($additional_files)) {
             $template_file_hierarchy[$template_set_id] = array_merge($template_file_hierarchy[$template_set_id], $additional_files);
             sqsession_register($template_file_hierarchy, 'template_file_hierarchy');
         }
         return $template_file_hierarchy[$template_set_id];
     }
     // nothing in cache apparently, so go build it now
     //
     $template_file_hierarchy[$template_set_id] = Template::catalog_template_files($template_set_id);
     // additional files, if any
     //
     if (!empty($additional_files)) {
         $template_file_hierarchy[$template_set_id] = array_merge($template_file_hierarchy[$template_set_id], $additional_files);
     }
     sqsession_register($template_file_hierarchy, 'template_file_hierarchy');
     return $template_file_hierarchy[$template_set_id];
 }
Example #22
0
if (sqGetGlobalVar('deletelist', $deletelist, SQ_FORM) && is_array($deletelist) && !empty($deletelist)) {
    // interface currently does not support multiple deletions at once
    // but we'll support it here anyway -- the index values of this
    // array are the only thing we care about and need to be the
    // index number of the list to be deleted
    //
    foreach (array_keys($deletelist) as $index) {
        unset($lists[$index]);
    }
    sort($lists);
    $temp_lists = array();
    foreach ($lists as $index => $list_addr) {
        $temp_lists[] = $index . '_' . $list_addr;
    }
    setPref($data_dir, $username, 'non_rfc_lists', implode(':', $temp_lists));
}
// add list?
//
if (sqGetGlobalVar('addlist', $ignore, SQ_FORM) && sqGetGlobalVar('newlist', $newlist, SQ_FORM)) {
    $lists[] = $newlist;
    sort($lists);
    $temp_lists = array();
    foreach ($lists as $index => $list_addr) {
        $temp_lists[] = $index . '_' . $list_addr;
    }
    setPref($data_dir, $username, 'non_rfc_lists', implode(':', $temp_lists));
}
displayPageHeader($color);
$oTemplate->assign('lists', $lists);
$oTemplate->display('plugins/listcommands/non_rfc_lists.tpl');
$oTemplate->display('footer.tpl');
Example #23
0
/** Get last search criteria from session or prefs
 * FIX ME, try to avoid globals
 */
function asearch_edit_last($index)
{
    if (sqGetGlobalVar(ASEARCH_CRITERIA, $criteria, SQ_SESSION)) {
        global $where_array, $mailbox_array, $what_array, $unop_array;
        global $biop_array, $exclude_array, $sub_array;
        $mailbox_array = $criteria[$index][0];
        $biop_array = $criteria[$index][1];
        $unop_array = $criteria[$index][2];
        $where_array = $criteria[$index][3];
        $what_array = $criteria[$index][4];
        $exclude_array = $criteria[$index][5];
        $sub_array = $criteria[$index][6];
        unset($criteria[$index]);
        //sqsession_unregister(ASEARCH_CRITERIA);
    } else {
        global $search_memory;
        if ($search_memory > 0) {
            asearch_edit_recent(0);
        }
    }
}
Example #24
0
 /**
  * function prepareRFC822_Header - prepares the RFC822 header string from Rfc822Header object(s)
  *
  * This function takes the Rfc822Header object(s) and formats them
  * into the RFC822Header string to send to the SMTP server as part
  * of the SMTP message.
  *
  * @param Rfc822Header  $rfc822_header
  * @param Rfc822Header  $reply_rfc822_header
  * @param integer      &$raw_length length of the message
  *
  * @return string $header
  */
 function prepareRFC822_Header(&$rfc822_header, $reply_rfc822_header, &$raw_length)
 {
     global $domain, $version, $username, $encode_header_key, $edit_identity, $hide_auth_header;
     if (!isset($hide_auth_header)) {
         $hide_auth_header = false;
     }
     /* if server var SERVER_NAME not available, use $domain */
     if (!sqGetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER)) {
         $SERVER_NAME = $domain;
     }
     sqGetGlobalVar('REMOTE_ADDR', $REMOTE_ADDR, SQ_SERVER);
     sqGetGlobalVar('REMOTE_PORT', $REMOTE_PORT, SQ_SERVER);
     sqGetGlobalVar('REMOTE_HOST', $REMOTE_HOST, SQ_SERVER);
     sqGetGlobalVar('HTTP_VIA', $HTTP_VIA, SQ_SERVER);
     sqGetGlobalVar('HTTP_X_FORWARDED_FOR', $HTTP_X_FORWARDED_FOR, SQ_SERVER);
     $rn = "\r\n";
     /* This creates an RFC 822 date */
     $date = date('D, j M Y H:i:s ', time()) . $this->timezone();
     /* Create a message-id */
     $message_id = 'MESSAGE ID GENERATION ERROR! PLEASE CONTACT SQUIRRELMAIL DEVELOPERS';
     if (empty($rfc822_header->message_id)) {
         $message_id = '<';
         /* user-specifc data to decrease collision chance */
         $seed_data = $username . '.';
         $seed_data .= !empty($REMOTE_PORT) ? $REMOTE_PORT . '.' : '';
         $seed_data .= !empty($REMOTE_ADDR) ? $REMOTE_ADDR . '.' : '';
         /* add the current time in milliseconds and randomness */
         $seed_data .= uniqid(mt_rand(), true);
         /* put it through one-way hash and add it to the ID */
         $message_id .= md5($seed_data) . '.squirrel@' . $SERVER_NAME . '>';
     }
     /* Make an RFC822 Received: line */
     if (isset($REMOTE_HOST)) {
         $received_from = "{$REMOTE_HOST} ([{$REMOTE_ADDR}])";
     } else {
         $received_from = $REMOTE_ADDR;
     }
     if (isset($HTTP_VIA) || isset($HTTP_X_FORWARDED_FOR)) {
         if (!isset($HTTP_X_FORWARDED_FOR) || $HTTP_X_FORWARDED_FOR == '') {
             $HTTP_X_FORWARDED_FOR = 'unknown';
         }
         $received_from .= " (proxying for {$HTTP_X_FORWARDED_FOR})";
     }
     $header = array();
     /**
      * SquirrelMail header
      *
      * This Received: header provides information that allows to track
      * user and machine that was used to send email. Don't remove it
      * unless you understand all possible forging issues or your
      * webmail installation does not prevent changes in user's email address.
      * See SquirrelMail bug tracker #847107 for more details about it.
      */
     // FIXME: The following headers may generate slightly differently between the message sent to the destination and that stored in the Sent folder because this code will be called before both actions.  This is not necessarily a big problem, but other headers such as Message-ID and Date are preserved between both actions
     if (isset($encode_header_key) && trim($encode_header_key) != '') {
         // use encoded headers, if encryption key is set and not empty
         $header[] = 'X-Squirrel-UserHash: ' . OneTimePadEncrypt($username, base64_encode($encode_header_key)) . $rn;
         $header[] = 'X-Squirrel-FromHash: ' . OneTimePadEncrypt($this->ip2hex($REMOTE_ADDR), base64_encode($encode_header_key)) . $rn;
         if (isset($HTTP_X_FORWARDED_FOR)) {
             $header[] = 'X-Squirrel-ProxyHash:' . OneTimePadEncrypt($this->ip2hex($HTTP_X_FORWARDED_FOR), base64_encode($encode_header_key)) . $rn;
         }
     } else {
         // use default received headers
         $header[] = "Received: from {$received_from}" . $rn;
         if ($edit_identity || !isset($hide_auth_header) || !$hide_auth_header) {
             $header[] = "        (SquirrelMail authenticated user {$username})" . $rn;
         }
         $header[] = "        by {$SERVER_NAME} with HTTP;" . $rn;
         $header[] = "        {$date}" . $rn;
     }
     /* Insert the rest of the header fields */
     if (!empty($rfc822_header->message_id)) {
         $header[] = 'Message-ID: ' . $rfc822_header->message_id . $rn;
     } else {
         $header[] = 'Message-ID: ' . $message_id . $rn;
         $rfc822_header->message_id = $message_id;
     }
     if (is_object($reply_rfc822_header) && isset($reply_rfc822_header->message_id) && $reply_rfc822_header->message_id) {
         //if ($reply_rfc822_header->message_id) {
         $rep_message_id = $reply_rfc822_header->message_id;
         $header[] = 'In-Reply-To: ' . $rep_message_id . $rn;
         $rfc822_header->in_reply_to = $rep_message_id;
         $references = $this->calculate_references($reply_rfc822_header);
         $header[] = 'References: ' . $references . $rn;
         $rfc822_header->references = $references;
     }
     if (!empty($rfc822_header->date) && $rfc822_header->date != -1) {
         $header[] = 'Date: ' . $rfc822_header->date . $rn;
     } else {
         $header[] = "Date: {$date}" . $rn;
         $rfc822_header->date = $date;
     }
     $header[] = 'Subject: ' . encodeHeader($rfc822_header->subject) . $rn;
     // folding address list [From|To|Cc|Bcc] happens by using ",$rn<space>"
     // as delimiter
     // Do not use foldLine for that.
     $header[] = 'From: ' . $rfc822_header->getAddr_s('from', ",{$rn} ", true) . $rn;
     // RFC2822 if from contains more then 1 address
     if (count($rfc822_header->from) > 1) {
         $header[] = 'Sender: ' . $rfc822_header->getAddr_s('sender', ',', true) . $rn;
     }
     if (count($rfc822_header->to)) {
         $header[] = 'To: ' . $rfc822_header->getAddr_s('to', ",{$rn} ", true) . $rn;
     }
     if (count($rfc822_header->cc)) {
         $header[] = 'Cc: ' . $rfc822_header->getAddr_s('cc', ",{$rn} ", true) . $rn;
     }
     if (count($rfc822_header->reply_to)) {
         $header[] = 'Reply-To: ' . $rfc822_header->getAddr_s('reply_to', ',', true) . $rn;
     }
     /* Sendmail should return true. Default = false */
     $bcc = $this->getBcc();
     if (count($rfc822_header->bcc)) {
         $s = 'Bcc: ' . $rfc822_header->getAddr_s('bcc', ",{$rn} ", true) . $rn;
         if (!$bcc) {
             $raw_length += strlen($s);
         } else {
             $header[] = $s;
         }
     }
     /* Identify SquirrelMail */
     $header[] = 'User-Agent: SquirrelMail/' . $version . $rn;
     /* Do the MIME-stuff */
     $header[] = 'MIME-Version: 1.0' . $rn;
     $contenttype = 'Content-Type: ' . $rfc822_header->content_type->type0 . '/' . $rfc822_header->content_type->type1;
     if (count($rfc822_header->content_type->properties)) {
         foreach ($rfc822_header->content_type->properties as $k => $v) {
             if ($k && $v) {
                 $contenttype .= ';' . $k . '=' . $v;
             }
         }
     }
     $header[] = $contenttype . $rn;
     if ($encoding = $rfc822_header->encoding) {
         $header[] = 'Content-Transfer-Encoding: ' . $encoding . $rn;
     }
     if ($rfc822_header->dnt) {
         $dnt = $rfc822_header->getAddr_s('dnt');
         /* Pegasus Mail */
         $header[] = 'X-Confirm-Reading-To: ' . $dnt . $rn;
         /* RFC 2298 */
         $header[] = 'Disposition-Notification-To: ' . $dnt . $rn;
     }
     if ($rfc822_header->priority) {
         switch ($rfc822_header->priority) {
             case 1:
                 $header[] = 'X-Priority: 1 (Highest)' . $rn;
                 $header[] = 'Importance: High' . $rn;
                 break;
             case 3:
                 $header[] = 'X-Priority: 3 (Normal)' . $rn;
                 $header[] = 'Importance: Normal' . $rn;
                 break;
             case 5:
                 $header[] = 'X-Priority: 5 (Lowest)' . $rn;
                 $header[] = 'Importance: Low' . $rn;
                 break;
             default:
                 break;
         }
     }
     /* Insert headers from the $more_headers array */
     if (count($rfc822_header->more_headers)) {
         reset($rfc822_header->more_headers);
         foreach ($rfc822_header->more_headers as $k => $v) {
             $header[] = $k . ': ' . $v . $rn;
         }
     }
     $cnt = count($header);
     $hdr_s = '';
     for ($i = 0; $i < $cnt; $i++) {
         $sKey = substr($header[$i], 0, strpos($header[$i], ':'));
         switch ($sKey) {
             case 'Message-ID':
             case 'In-Reply_To':
                 $hdr_s .= $header[$i];
                 break;
             case 'References':
                 $sRefs = substr($header[$i], 12);
                 $aRefs = explode(' ', $sRefs);
                 $sLine = 'References:';
                 foreach ($aRefs as $sReference) {
                     if (trim($sReference) == '') {
                         /* Don't add spaces. */
                     } elseif (strlen($sLine) + strlen($sReference) > 76) {
                         $hdr_s .= $sLine;
                         $sLine = $rn . '    ' . $sReference;
                     } else {
                         $sLine .= ' ' . $sReference;
                     }
                 }
                 $hdr_s .= $sLine;
                 break;
             case 'To':
             case 'Cc':
             case 'Bcc':
             case 'From':
                 $hdr_s .= $header[$i];
                 break;
             default:
                 $hdr_s .= $this->foldLine($header[$i], 78);
                 break;
         }
     }
     $header = $hdr_s;
     $header .= $rn;
     /* One blank line to separate header and body */
     $raw_length += strlen($header);
     return $header;
 }
define('PAGE_NAME', 'options_highlight');
/**
 * Include the SquirrelMail initialization file.
 */
require '../include/init.php';
// include_once(SM_PATH . 'functions/imap.php');
require_once SM_PATH . 'functions/forms.php';
/* get globals */
sqGetGlobalVar('action', $action);
sqGetGlobalVar('theid', $theid);
sqGetGlobalVar('identname', $identname);
sqGetGlobalVar('newcolor_choose', $newcolor_choose);
sqGetGlobalVar('newcolor_input', $newcolor_input);
sqGetGlobalVar('color_type', $color_type);
sqGetGlobalVar('match_type', $match_type);
sqGetGlobalVar('value', $value);
sqgetGlobalVar('smtoken', $submitted_token, SQ_FORM, '');
/* end of get globals */
function oh_opt($val, $sel, $tit)
{
    echo "<option value=\"{$val}\"";
    if ($sel) {
        echo ' selected="selected"';
    }
    echo ">{$tit}</option>\n";
}
if (!isset($action)) {
    $action = '';
}
if (!isset($message_highlight_list)) {
    $message_highlight_list = array();
Example #26
0
/**
 * This function saves the javascript detection option.
 */
function save_option_javascript_autodetect($option)
{
    global $data_dir, $username;
    sqGetGlobalVar('new_javascript_setting', $new_javascript_setting);
    // Set javascript either on or off.
    if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
        if ($option->new_value == SMPREF_JS_ON) {
            setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
        } else {
            setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
        }
    } else {
        setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
    }
}
Example #27
0
 function sqGetGlobalVarMultiple($name, &$value, $indicator_field, $search = SQ_INORDER, $fallback_no_suffix = TRUE, $default = NULL, $typecast = FALSE)
 {
     // Set arbitrary max limit -- should be much lower except on the
     // search results page, if there are many (50 or more?) mailboxes
     // shown, this may not be high enough.  Is there some way we should
     // automate this value?
     //
     $max_form_search = 100;
     for ($i = 1; $i <= $max_form_search; $i++) {
         if (sqGetGlobalVar($indicator_field . '_' . $i, $temp, $search)) {
             return sqGetGlobalVar($name . '_' . $i, $value, $search, $default, $typecast);
         }
     }
     // no indicator field found; just try without suffix if allowed
     //
     if ($fallback_no_suffix) {
         return sqGetGlobalVar($name, $value, $search, $default, $typecast);
     }
     // no dice, set default and return FALSE
     //
     if (!is_null($default)) {
         $value = $default;
     }
     return FALSE;
 }
Example #28
0
 * @copyright Copyright &copy; 2002 Marc Groot Koerkamp, The Netherlands
 * @copyright Copyright &copy; 2004-2009 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id: message_details_bottom.php 13549 2009-04-15 22:00:49Z jervfors $
 * @package plugins
 * @subpackage message_details
 */
/** @ignore */
define('SM_PATH', '../../');
/* SquirrelMail required files. */
require_once SM_PATH . 'include/validate.php';
require_once SM_PATH . 'functions/imap.php';
require_once SM_PATH . 'functions/mime.php';
global $color, $uid_support;
sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
if (!sqGetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM)) {
    $passed_ent_id = 0;
}
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
/**
 * Calculates id of MIME entity
 * @param string $entString
 * @param integer $direction
 * @return string
 * @access private
 */
function CalcEntity($entString, $direction)
{
 function prepareRFC822_Header($rfc822_header, $reply_rfc822_header, &$raw_length)
 {
     global $domain, $version, $username;
     /* if server var SERVER_NAME not available, use $domain */
     if (!sqGetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER)) {
         $SERVER_NAME = $domain;
     }
     sqGetGlobalVar('REMOTE_ADDR', $REMOTE_ADDR, SQ_SERVER);
     sqGetGlobalVar('REMOTE_PORT', $REMOTE_PORT, SQ_SERVER);
     sqGetGlobalVar('REMOTE_HOST', $REMOTE_HOST, SQ_SERVER);
     sqGetGlobalVar('HTTP_VIA', $HTTP_VIA, SQ_SERVER);
     sqGetGlobalVar('HTTP_X_FORWARDED_FOR', $HTTP_X_FORWARDED_FOR, SQ_SERVER);
     $rn = "\r\n";
     /* This creates an RFC 822 date */
     $date = date('D, j M Y H:i:s ', mktime()) . $this->timezone();
     /* Create a message-id */
     $message_id = '<' . $REMOTE_PORT . '.' . $REMOTE_ADDR . '.';
     $message_id .= time() . '.squirrel@' . $SERVER_NAME . '>';
     /* Make an RFC822 Received: line */
     if (isset($REMOTE_HOST)) {
         $received_from = "{$REMOTE_HOST} ([{$REMOTE_ADDR}])";
     } else {
         $received_from = $REMOTE_ADDR;
     }
     if (isset($HTTP_VIA) || isset($HTTP_X_FORWARDED_FOR)) {
         if (!isset($HTTP_X_FORWARDED_FOR) || $HTTP_X_FORWARDED_FOR == '') {
             $HTTP_X_FORWARDED_FOR = 'unknown';
         }
         $received_from .= " (proxying for {$HTTP_X_FORWARDED_FOR})";
     }
     $header = array();
     $header[] = "Received: from {$received_from}" . $rn;
     $header[] = "        (SquirrelMail authenticated user {$username})" . $rn;
     $header[] = "        by {$SERVER_NAME} with HTTP;" . $rn;
     $header[] = "        {$date}" . $rn;
     /* Insert the rest of the header fields */
     $header[] = 'Message-ID: ' . $message_id . $rn;
     if ($reply_rfc822_header->message_id) {
         $rep_message_id = $reply_rfc822_header->message_id;
         //	    $this->strip_crlf($message_id);
         $header[] = 'In-Reply-To: ' . $rep_message_id . $rn;
         $references = $this->calculate_references($reply_rfc822_header);
         $header[] = 'References: ' . $references . $rn;
     }
     $header[] = "Date: {$date}" . $rn;
     $header[] = 'Subject: ' . encodeHeader($rfc822_header->subject) . $rn;
     $header[] = 'From: ' . $rfc822_header->getAddr_s('from', ',', true) . $rn;
     /* RFC2822 if from contains more then 1 address */
     if (count($rfc822_header->from) > 1) {
         $header[] = 'Sender: ' . $rfc822_header->getAddr_s('sender', ',', true) . $rn;
     }
     if (count($rfc822_header->to)) {
         $header[] = 'To: ' . $rfc822_header->getAddr_s('to', ',', true) . $rn;
     }
     if (count($rfc822_header->cc)) {
         $header[] = 'Cc: ' . $rfc822_header->getAddr_s('cc', ',', true) . $rn;
     }
     if (count($rfc822_header->reply_to)) {
         $header[] = 'Reply-To: ' . $rfc822_header->getAddr_s('reply_to', ',', true) . $rn;
     }
     /* Sendmail should return true. Default = false */
     $bcc = $this->getBcc();
     if (count($rfc822_header->bcc)) {
         $s = 'Bcc: ' . $rfc822_header->getAddr_s('bcc', ',', true) . $rn;
         if (!$bcc) {
             $s = $this->foldLine($s, 78, str_pad('', 4));
             $raw_length += strlen($s);
         } else {
             $header[] = $s;
         }
     }
     /* Identify SquirrelMail */
     $header[] = 'User-Agent: SquirrelMail/' . $version . $rn;
     /* Do the MIME-stuff */
     $header[] = 'MIME-Version: 1.0' . $rn;
     $contenttype = 'Content-Type: ' . $rfc822_header->content_type->type0 . '/' . $rfc822_header->content_type->type1;
     if (count($rfc822_header->content_type->properties)) {
         foreach ($rfc822_header->content_type->properties as $k => $v) {
             if ($k && $v) {
                 $contenttype .= ';' . $k . '=' . $v;
             }
         }
     }
     $header[] = $contenttype . $rn;
     if ($rfc822_header->dnt) {
         $dnt = $rfc822_header->getAddr_s('dnt');
         /* Pegasus Mail */
         $header[] = 'X-Confirm-Reading-To: ' . $dnt . $rn;
         /* RFC 2298 */
         $header[] = 'Disposition-Notification-To: ' . $dnt . $rn;
     }
     if ($rfc822_header->priority) {
         $prio = $rfc822_header->priority;
         $header[] = 'X-Priority: ' . $prio . $rn;
         switch ($prio) {
             case 1:
                 $header[] = 'Importance: High' . $rn;
                 break;
             case 3:
                 $header[] = 'Importance: Normal' . $rn;
                 break;
             case 5:
                 $header[] = 'Importance: Low' . $rn;
                 break;
             default:
                 break;
         }
     }
     /* Insert headers from the $more_headers array */
     if (count($rfc822_header->more_headers)) {
         reset($rfc822_header->more_headers);
         foreach ($rfc822_header->more_headers as $k => $v) {
             $header[] = $k . ': ' . $v . $rn;
         }
     }
     $cnt = count($header);
     $hdr_s = '';
     for ($i = 0; $i < $cnt; $i++) {
         $hdr_s .= $this->foldLine($header[$i], 78, str_pad('', 4));
     }
     //	$debug = "Debug: <123456789012345678901234567890123456789012345678901234567890123456789>\r\n";
     //	$this->foldLine($debug, 78, str_pad('',4));
     $header = $hdr_s;
     $header .= $rn;
     /* One blank line to separate header and body */
     $raw_length += strlen($header);
     return $header;
 }
Example #30
0
            $string = _("The IMAP server is reporting that plain text logins are disabled.") . '<br />' . _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.") . '<br />';
            if (!$use_imap_tls) {
                $string .= _("Also, the use of TLS may allow SquirrelMail to login.") . '<br />';
            }
            $string .= _("Please contact your system administrator and report this error.");
            error_box($string);
            // display footer (closes html tags) and stop script execution
            $oTemplate->display('footer.tpl');
            exit;
        }
    }
}
$username_form_name = 'login_username';
$password_form_name = 'secretkey';
do_hook('login_cookie', $null);
$loginname_value = sqGetGlobalVar('loginname', $loginname) ? sm_encode_html_special_chars($loginname) : '';
//FIXME: should be part of the template, not the core!
/* Output the javascript onload function. */
$header = "<script type=\"text/javascript\">\n" . "<!--\n" . "  var alreadyFocused = false;\n" . "  function squirrelmail_loginpage_onload() {\n" . "    if (alreadyFocused) return;\n" . "    var textElements = 0; var i = 0;\n" . "    for (i = 0; i < document.login_form.elements.length; i++) {\n" . "      if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n" . "        textElements++;\n" . "        if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n" . "          document.login_form.elements[i].focus();\n" . "          break;\n" . "        }\n" . "      }\n" . "    }\n" . "  }\n" . "// -->\n" . "</script>\n";
if (@file_exists($theme[$theme_default]['PATH'])) {
    @(include $theme[$theme_default]['PATH']);
}
if (!isset($color) || !is_array($color)) {
    // Add default color theme, if theme loading fails
    $color = array();
    $color[0] = '#dcdcdc';
    /* light gray    TitleBar               */
    $color[1] = '#800000';
    /* red                                  */
    $color[2] = '#cc0000';
    /* light red     Warning/Error Messages */