type options from spamcop plugin.
- Removed trailing ?> from function scripts.
- Added checks for non-existent backend to AddressBook class.
+ - Make the base for the SquirrelMail URL configurable. Adds a new variable
+ config_base_location to config.php and a new option to conf.pl. This is
+ to prevent problems in installs where our heuristic doesn't work
+ correctly (#1521299, #1460675, #1110064, #1000850, #1113791).
Version 1.5.1 (branched on 2006-02-12)
--------------------------------------
$encode_header_key = '' if ( !$encode_header_key );
$hide_auth_header = 'false' if ( !$hide_auth_header );
$time_zone_type = '0' if ( !$time_zone_type );
+$config_location_base = '' if ( !$config_location_base );
$prefs_user_size = 128 if ( !$prefs_user_size );
$prefs_key_size = 64 if ( !$prefs_key_size );
$prefs_val_size = 65536 if ( !$prefs_val_size );
print "13. Allow advanced search : $WHT$allow_advanced_search$NRM\n";
print "14. PHP session name : $WHT$session_name$NRM\n";
print "15. Time zone configuration : $WHT$time_zone_type$NRM\n";
+ print "16. Location base : $WHT$config_location_base$NRM\n";
print "\n";
print "R Return to Main Menu\n";
} elsif ( $menu == 5 ) {
elsif ( $command == 13 ) { $allow_advanced_search = command316(); }
elsif ( $command == 14 ) { $session_name = command317(); }
elsif ( $command == 15 ) { $time_zone_type = command318(); }
+ elsif ( $command == 16 ) { $config_location_base = command319(); }
} elsif ( $menu == 5 ) {
if ( $command == 1 ) { $templateset_default = command_templates(); }
elsif ( $command == 2 ) { $theme_css = command42(); }
return $time_zone_type;
}
+# set the location base for redirects (since 1.5.2)
+sub command319 {
+ print "Here you can set the base part of the SquirrelMail URL.\n";
+ print "It is normally autodetected but if that fails, use this\n";
+ print "option to override.\n";
+ print "It should contain only the protocol and hostname/port parts\n";
+ print "of the URL; the full path will be appended automatically.\n\n";
+ print "Examples:\nhttp://webmail.example.org\nhttp://webmail.example.com:8080\nhttps://webmail.example.com:6691\n\n";
+ print "Do not add any path elements.\n";
+
+ print "URL base? [" .$WHT."autodetect$NRM]: $WHT";
+ $new_config_location_base = <STDIN>;
+ chomp($new_config_location_base);
+ $config_location_base = $new_config_location_base;
+
+ return $config_location_base;
+}
+
+
sub command41 {
print "\nDefine the themes that you wish to use. If you have added ";
# boolean
print CF "\$hide_auth_header = $hide_auth_header;\n";
# boolean
- print CF "\$disable_thread_sort = $disable_thread_sort;\n";
+ print CF "\$disable_thread_sort = $disable_thread_sort;\n";
# boolean
- print CF "\$disable_server_sort = $disable_server_sort;\n";
+ print CF "\$disable_server_sort = $disable_server_sort;\n";
# boolean
print CF "\$allow_charset_search = $allow_charset_search;\n";
# integer
# integer
print CF "\$time_zone_type = $time_zone_type;\n";
print CF "\n";
+ # string
+ print CF "\$config_location_base = '$config_location_base';\n";
+ print CF "\n";
# all plugins are strings
for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
*/
$time_zone_type = 0;
+/**
+ * Location base
+ *
+ * This is used to build the URL to the SquirrelMail location.
+ * It should contain only the protocol and hostname/port parts
+ * of the URL; the full path will be appended automatically.
+ *
+ * If not specified or empty, it will be autodetected.
+ *
+ * Examples:
+ * http://webmail.example.org
+ * http://webmail.example.com:8080
+ * https://webmail.example.com:6691
+ *
+ * To be clear: do not include any of the path elements, so if
+ * SquirrelMail is at http://www.example.net/web/mail/src/login.php, you
+ * write: http://www.example.net
+ *
+ * @global string $config_location_base;
+ * @since 1.5.2
+ */
+$config_location_base = '';
+
/*** Tweaks ***/
/**
* Iframe sandbox code control
*
* Determines the location to forward to, relative to your server.
* This is used in HTTP Location: redirects.
- * If this doesnt work correctly for you (although it should), you can
- * remove all this code except the last two lines, and have it return
- * the right URL for your site, something like:
*
- * http://www.example.com/squirrelmail/
+ * If set, it uses $config_location_base as the first part of the URL,
+ * specifically, the protocol, hostname and port parts. The path is
+ * always autodetected.
*
* @return string the base url for this SquirrelMail installation
* @since 1.0
*/
function get_location () {
- global $imap_server_type;
+ global $imap_server_type, $config_location_base;
/* Get the path, handle virtual directories */
if(strpos(php_self(), '?')) {
$path = php_self();
}
$path = substr($path, 0, strrpos($path, '/'));
+
+ // proto+host+port are already set in config:
+ if ( !empty($config_location_base) ) {
+ return $config_location_base . $path ;
+ }
+ // we computed it before, get it from the session:
if ( sqgetGlobalVar('sq_base_url', $full_url, SQ_SESSION) ) {
return $full_url . $path;
}
+ // else: autodetect
/* Check if this is a HTTPS or regular HTTP request. */
$proto = 'http://';
}
}
- /* this is a workaround for the weird macosx caching that
- causes Apache to return 16080 as the port number, which causes
- SM to bail */
+ /* this is a workaround for the weird macosx caching that
+ * causes Apache to return 16080 as the port number, which causes
+ * SM to bail */
- if ($imap_server_type == 'macosx' && $port == ':16080') {
+ if ($imap_server_type == 'macosx' && $port == ':16080') {
$port = '';
- }
+ }
- /* Fallback is to omit the server name and use a relative */
- /* URI, although this is not RFC 2616 compliant. */
- $full_url = ($host ? $proto . $host . $port : '');
- sqsession_register($full_url, 'sq_base_url');
- return $full_url . $path;
+ /* Fallback is to omit the server name and use a relative */
+ /* URI, although this is not RFC 2616 compliant. */
+ $full_url = ($host ? $proto . $host . $port : '');
+ sqsession_register($full_url, 'sq_base_url');
+ return $full_url . $path;
}
echo $IND . "Default language OK.<br />\n";
}
-echo $IND . "Base URL detected as: <tt>" . htmlspecialchars($test_location) . "</tt><br />\n";
+echo $IND . "Base URL detected as: <tt>" . htmlspecialchars($test_location) .
+ "</tt> (location base " . (empty($config_location_base) ? 'autodetected' : 'set to <tt>' .
+ htmlspecialchars($config_location_base)."</tt>") . ")<br />\n";
/* check minimal requirements for other security options */