ini_set('session.use_cookies','1');
}
+/**
+ * Initialize seed of random number generator.
+ * We use a number of things to randomize input: current time in ms,
+ * info about the remote client, info about the current process, the
+ * randomness of uniqid and stat of the current file.
+ *
+ * We seed this here only once per init, not only to save cycles
+ * but also to make the result of mt_rand more random (it now also
+ * depends on the number of times mt_rand was called before in this
+ * execution.
+ */
+$seed = microtime() . $_SERVER['REMOTE_PORT'] . $_SERVER['REMOTE_ADDR'] . getmypid();
+
+if (function_exists('getrusage')) {
+ /* Avoid warnings with Win32 */
+ $dat = @getrusage();
+ if (isset($dat) && is_array($dat)) { $seed .= implode('', $dat); }
+}
+
+if(!empty($_SERVER['UNIQUE_ID'])) {
+ $seed .= $_SERVER['UNIQUE_ID'];
+}
+
+$seed .= uniqid(mt_rand(),TRUE);
+$seed .= implode( '', stat( __FILE__) );
+
+/** PHP 4.2 and up don't require seeding, but their used seed algorithm
+ * is of questionable quality, so we keep doing it ourselves. */
+mt_srand(hexdec(md5($seed)));
/**
* calculate SM_PATH and calculate the base_uri
* the current user is NOT that user, turn them
* back on
*/
-sqgetGlobalVar('username',$username,SQ_SESSION);
+sqgetGlobalVar('username', $username, SQ_SESSION);
if ($disable_plugins && !empty($disable_plugins_user)
&& $username != $disable_plugins_user) {
$disable_plugins = false;
* Do something special for some pages. This is based on the PAGE_NAME constant
* set at the top of every page.
*/
+$set_up_langage_after_template_setup = FALSE;
switch (PAGE_NAME) {
case 'style':
// reset template file cache
//
$sTemplateID = Template::get_default_template_set();
- Template::cache_template_file_hierarchy(TRUE);
+ Template::cache_template_file_hierarchy($sTemplateID, TRUE);
/**
* Make sure icon variables are setup for the login page.
/*
* $sTemplateID is not initialized when a user is not logged in, so we
* will use the config file defaults here. If the neccesary variables
- * are net set, force a default value.
+ * are not set, force a default value.
*/
- $sTemplateID = Template::get_default_template_set();
+ if (PAGE_NAME == 'squirrelmail_rpc') {
+ $sTemplateID = Template::get_rpc_template_set();
+ } else {
+ $sTemplateID = Template::get_default_template_set();
+ }
$oTemplate = Template::construct_template($sTemplateID);
set_up_language($squirrelmail_language, true);
*/
require(SM_PATH . 'include/load_prefs.php');
-// i do not understand the frames language cookie story
/**
* We'll need this to later have a noframes version
*
if ($my_language != $squirrelmail_language) {
sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
}
-// /dont understand
- /**
- * Set up the language.
- */
- $err=set_up_language(getPref($data_dir, $username, 'language'));
-
- // Japanese translation used without mbstring support
- if ($err==2) {
- $sError = "<p>Your administrator needs to have PHP installed with the multibyte string extension enabled (using configure option --enable-mbstring).</p>\n"
- . "<p>This system has assumed that you accidently switched to Japanese and has reverted your language preference to English.</p>\n"
- . "<p>Please refresh this page in order to continue using your webmail.</p>\n";
- error_box($sError);
- }
+ $set_up_langage_after_template_setup = TRUE;
$timeZone = getPref($data_dir, $username, 'timezone');
* so we shouldn't change it here.
*/
if (!isset($sTemplateID)) {
- $sTemplateID = Template::get_default_template_set();
+ if (PAGE_NAME == 'squirrelmail_rpc') {
+ $sTemplateID = Template::get_rpc_template_set();
+ } else {
+ $sTemplateID = Template::get_default_template_set();
+ }
$icon_theme_path = !$use_icons ? NULL : Template::calculate_template_images_directory($sTemplateID);
}
$nbsp = $oTemplate->fetch('non_breaking_space.tpl');
$br = $oTemplate->fetch('line_break.tpl');
+
+/**
+ * Set up the language.
+ *
+ * This code block corresponds to the *default* block of the switch
+ * statement above, but the language cannot be set up until after the
+ * template is instantiated, so we set $set_up_langage_after_template_setup
+ * above and do the linguistic stuff now.
+ */
+if ($set_up_langage_after_template_setup) {
+ $err=set_up_language(getPref($data_dir, $username, 'language'));
+
+ // Japanese translation used without mbstring support
+ if ($err==2) {
+ $sError = "<p>Your administrator needs to have PHP installed with the multibyte string extension enabled (using configure option --enable-mbstring).</p>\n"
+ . "<p>This system has assumed that you accidently switched to Japanese and has reverted your language preference to English.</p>\n"
+ . "<p>Please refresh this page in order to continue using your webmail.</p>\n";
+ error_box($sError);
+ }
+}
+
+
/**
* Initialize our custom error handler object
*/
$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
+
/**
* Activate custom error handling
*/