# Perl since at least 5.003_7, and nobody sane runs anything
# before that, but just in case.
############################################################
-
+my $dir;
if ( eval q{require "File/Basename.pm"} ) {
- my $dir = File::Basename::dirname($0);
+ $dir = File::Basename::dirname($0);
chdir($dir);
}
exit;
}
+############################################################
+# If we got here, use Cwd to get the full directory path
+# (the Basename stuff above will sometimes return '.' as
+# the base directory, which is not helpful here).
+############################################################
+use Cwd;
+$dir = cwd();
+
############################################################
# First, lets read in the data already in there...
############################################################
# Read and parse the current configuration file
# (either config.php or config_default.php).
while ( $line = <FILE> ) {
- $line =~ s/^\s+//;
+ $line =~ s/^\s+//;
$line =~ s/^\$//;
$var = $line;
if ( -e "../themes" ) {
$options[1] =~ s/^\.\.\/config/\.\.\/themes/;
}
- $theme_path[$sub] = $options[1];
+ $theme_path[$sub] = &change_to_rel_path($options[1]);
} elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
$sub = $options[0];
$sub =~ s/\]\[['|"]NAME['|"]\]//;
$tmp =~ s/[\'|\"]\);\s*$//;
$charset = $tmp;
} elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
- $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i;
- $tmp =~ s/[\'|\"],?\s*$//;
- $tmp =~ s/[\'|\"]\);\s*$//;
+ $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i;
+ $tmp =~ s/[\'|\"]?,?\s*$//;
+ $tmp =~ s/[\'|\"]?\);\s*$//;
$port = $tmp;
} elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
- $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i;
- $tmp =~ s/[\'|\"],?\s*$//;
- $tmp =~ s/[\'|\"]\);\s*$//;
+ $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i;
+ $tmp =~ s/[\'|\"]?,?\s*$//;
+ $tmp =~ s/[\'|\"]?\);\s*$//;
$maxrows = $tmp;
} elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
$tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
$ldap_port[$sub] = $port;
$ldap_maxrows[$sub] = $maxrows;
$ldap_charset[$sub] = $charset;
+ } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
+ ${ $options[0] } = &change_to_rel_path($options[1]);
} else {
${ $options[0] } = $options[1];
}
if ( !$frame_top ) {
$frame_top = "_top";
}
+
+if ( !$provider_uri ) {
+ $provider_uri = "http://www.squirrelmail.org/";
+}
+
+if ( !$provider_name ) {
+ $provider_name = "SquirrelMail";
+}
+
if ( !$edit_identity ) {
$edit_identity = "true";
}
if ( !$allow_server_sort ) {
$allow_server_sort = 'false';
}
+if ( !$uid_support ) {
+ $uid_support = 'true';
+}
+if ( !$no_list_for_subscribe ) {
+ $no_list_for_subscribe = 'false';
+}
if ( !$allow_charset_search ) {
$allow_charset_search = 'true';
}
print "5. Signout Page : $WHT$signout_page$NRM\n";
print "6. Default Language : $WHT$squirrelmail_default_language$NRM\n";
print "7. Top Frame : $WHT$frame_top$NRM\n";
+ print "8. Provider link : $WHT$provider_uri$NRM\n";
+ print "9. Provider name : $WHT$provider_name$NRM\n";
+
print "\n";
print "R Return to Main Menu\n";
} elsif ( $menu == 2 ) {
print "13. Allow editing of name : $WHT$edit_name$NRM\n";
}
print "14. Allow server charset search : $WHT$allow_charset_search$NRM\n";
+ print "15. Enable UID support : $WHT$uid_support$NRM\n";
print "\n";
print "R Return to Main Menu\n";
} elsif ( $menu == 5 ) {
elsif ( $command == 5 ) { $signout_page = command4(); }
elsif ( $command == 6 ) { $squirrelmail_default_language = command5(); }
elsif ( $command == 7 ) { $frame_top = command6(); }
+ elsif ( $command == 8 ) { $provider_uri = command7(); }
+ elsif ( $command == 9 ) { $provider_name = command8(); }
+
} elsif ( $menu == 2 ) {
if ( $command == 1 ) { $domain = command11(); }
elsif ( $command == 2 ) { $imapServerAddress = command12(); }
elsif ( $command == 12 ) { $allow_server_sort = command313(); }
elsif ( $command == 13 ) { $edit_name = command311(); }
elsif ( $command == 14 ) { $allow_charset_search = command314(); }
+ elsif ( $command == 15 ) { $uid_support = command315(); }
} elsif ( $menu == 5 ) {
if ( $command == 1 ) { command41(); }
elsif ( $command == 2 ) { $theme_css = command42(); }
sub command2 {
print "Your organization's logo is an image that will be displayed at\n";
print "different times throughout SquirrelMail. This is asking for the\n";
- print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
- print "(../images/logo.jpg) path to your logo.\n";
+ print "literal (/usr/local/squirrelmail/images/logo.png) or relative\n";
+ print "(../images/logo.png) path to your logo.\n";
+ print "Relative paths to files outside the SquirrelMail distribution\n";
+ print "will be converted to their absolute path equivalents in config.php.\n";
print "\n";
print "[$WHT$org_logo$NRM]: $WHT";
$new_org_logo = <STDIN>;
return $new_frame_top;
}
+# Default link to provider
+sub command7 {
+ print "Here you can set the link on the right of the page.\n";
+ print "The default is 'http://www.squirrelmail.org/'\n";
+ print "\n";
+ print "[$WHT$provider_uri$NRM]: $WHT";
+ $new_provider_uri = <STDIN>;
+ if ( $new_provider_uri eq "\n" ) {
+ $new_provider_uri = 'http://www.squirrelmail.org/';
+ } else {
+ $new_provider_uri =~ s/[\r|\n]//g;
+ $new_provider_uri =~ s/^\s+$//g;
+ }
+ return $new_provider_uri;
+}
+
+sub command8 {
+ print "Here you can set the name of the link on the right of the page.\n";
+ print "The default is 'SquirrelMail/'\n";
+ print "\n";
+ print "[$WHT$provider_name$NRM]: $WHT";
+ $new_provider_name = <STDIN>;
+ if ( $new_provider_name eq "\n" ) {
+ $new_provider_name = 'SquirrelMail';
+ } else {
+ $new_provider_name =~ s/[\r|\n]//g;
+ $new_provider_name =~ s/^\s+$//g;
+ }
+ return $new_provider_name;
+}
+
####################################################################################
# domain
print "are two examples:\n";
print " Absolute: /usr/local/squirrelmail/data/\n";
print " Relative: ../data/\n";
+ print "Relative paths to directories outside of the SquirrelMail distribution\n";
+ print "will be converted to their absolute path equivalents in config.php.\n";
print "\n";
print "[$WHT$data_dir$NRM]: $WHT";
print " lying around there for too long.\n";
print " 3. It should probably be another directory than the data\n";
print " directory specified in option 3.\n";
+ print "Relative paths to directories outside of the SquirrelMail distribution\n";
+ print "will be converted to their absolute path equivalents in config.php.\n";
print "\n";
print "[$WHT$attachment_dir$NRM]: $WHT";
return $allow_charset_search;
}
+sub command315 {
+ print "This option allows you to enable unique identifier (UID) support.\n";
+ print "\n";
+
+ if ( lc($uid_support) eq "true" ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $uid_support = <STDIN>;
+ if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $uid_support = "true";
+ } else {
+ $uid_support = "false";
+ }
+ return $uid_support;
+}
+
sub command41 {
print "\nNow we will define the themes that you wish to use. If you have added\n";
print "\n";
print "To clear out an existing value, just type a space for the input.\n";
print "\n";
+ print "Relative links to files outside the SquirrelMail distribution\n";
+ print "will be converted to their absolute path equivalents in config.php.\n";
+ print "\n";
print "[$WHT$theme_css$NRM]: $WHT";
$new_theme_css = <STDIN>;
# string
print CF "\$org_name = \"$org_name\";\n";
# string
- print CF "\$org_logo = '$org_logo';\n";
+ print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n";
$org_logo_width |= 0;
$org_logo_height |= 0;
# string
# string that can contain variables.
print CF "\$org_title = \"$org_title\";\n";
# string
- print CF "\$signout_page = '$signout_page';\n";
+ print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n";
# string
print CF "\$frame_top = '$frame_top';\n";
print CF "\n";
+ print CF "\$provider_uri = '$provider_uri';\n";
+ print CF "\n";
+
+ print CF "\$provider_name = '$provider_name';\n";
+ print CF "\n";
+
# string that can contain variables
print CF "\$motd = \"$motd\";\n";
print CF "\n";
# string
print CF "\$default_charset = '$default_charset';\n";
# string
- print CF "\$data_dir = '$data_dir';\n";
+ print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n";
# string that can contain a variable
- print CF "\$attachment_dir = \"$attachment_dir\";\n";
+ print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n";
# integer
print CF "\$dir_hash_level = $dir_hash_level;\n";
# string
# boolean
print CF "\$allow_server_sort = $allow_server_sort;\n";
# boolean
- print CF "\$allow_charset_search = $allow_charset_search;\n";
+ print CF "\$allow_charset_search = $allow_charset_search;\n";
+ # boolean
+ print CF "\$uid_support = $uid_support;\n";
print CF "\n";
# all plugins are strings
print CF "\n";
# strings
- print CF "\$theme_css = '$theme_css';\n";
+ print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
+ if ( $theme_default eq '' ) { $theme_default = '0'; }
+ print CF "\$theme_default = $theme_default;\n";
+
for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
- print CF "\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
+ print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
}
print CF "\n";
print CF "\$prefs_key_field = '$prefs_key_field';\n";
# string
print CF "\$prefs_val_field = '$prefs_val_field';\n";
+ # boolean
+ print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
print CF "\n";
print CF "/**\n";
print "\nPress any key to continue...";
$tmp = <STDIN>;
}
+
+############################################################
+# This subroutine corrects relative paths to ensure they
+# will work within the SM space. If the path falls within
+# the SM directory tree, the SM_PATH variable will be
+# prepended to the path, if not, then the path will be
+# converted to an absolute path.
+############################################################
+sub change_to_SM_path() {
+ my ($old_path) = @_;
+ my $new_path = '';
+ my @rel_path;
+ my @abs_path;
+ my $subdir;
+
+ # If the path is absolute, don't bother.
+ return "\'" . $old_path . "\'" if ( $old_path eq '');
+ return "\'" . $old_path . "\'" if ( $old_path =~ /^\// );
+ return $old_path if ( $old_path =~ /^SM_PATH/ );
+
+ # For relative paths, split on '../'
+ @rel_path = split(/\.\.\//, $old_path);
+
+ if ( $#rel_path > 1 ) {
+ # more than two levels away. Make it absolute.
+ @abs_path = split(/\//, $dir);
+ foreach $subdir (@rel_path) {
+ if ($subdir eq '') {
+ pop @abs_path;
+ } else {
+ push @abs_path, $subdir;
+ }
+ }
+ foreach $subdir (@abs_path) {
+ $new_path .= $subdir . '/';
+ }
+ } elsif ( $#rel_path > 0 ) {
+ # it's within the SM tree, prepend SM_PATH
+ $new_path = $old_path;
+ $new_path =~ s/^\.\.\//SM_PATH . \'/;
+ $new_path .= '\'';
+ } else {
+ # Last, it's a relative path without any leading '.'
+ # Prepend SM_PATH (no substitution required)
+ $new_path = "SM_PATH . \'" . $old_path . "\'";
+ }
+
+ return $new_path;
+}
+
+sub change_to_rel_path() {
+ my ($old_path) = @_;
+ my $new_path = '';
+
+ return $old_path if ( $old_path eq '');
+ return $old_path if ( $old_path =~ /^\// );
+ return $old_path if ( $old_path =~ /^\.\./ );
+
+ if ( $old_path =~ /^SM_PATH/ ) {
+ $new_path = $old_path;
+ $new_path =~ s/^SM_PATH . \'/\.\.\//;
+ }
+
+ return $new_path;
+}