+sub command_templates {
+ print "\nDefine the template sets (skins) that you wish to use. If you have added\n";
+ print "a template set of your own, just follow the instructions (?) about\n";
+ print "how to add them. You can also change the default template.\n";
+
+ print "\n Available Templates:\n";
+
+ $count = 0;
+ while ( $count <= $#templateset_name ) {
+ if ( $templateset_id[$count] eq $templateset_default ) {
+ print " d";
+ } else {
+ print " ";
+ }
+ if ( $templateset_id[$count] eq $templateset_fallback ) {
+ print "f";
+ } else {
+ print " ";
+ }
+ if ( $templateset_id[$count] eq $rpc_templateset ) {
+ print "r ";
+ } else {
+ print " ";
+ }
+ if ( $count < 10 ) {
+ print " ";
+ }
+ if ( $count < 100 ) {
+ print " ";
+ }
+ $name = $templateset_name[$count];
+
+ # present RPC template sets differently
+ #
+ if ( $templateset_id[$count] =~ /_rpc$/ ) {
+ $name = $name . " (not shown in user interface; used for RPC interface only)";
+ } else {
+
+ $num_spaces = 35 - length($name);
+ for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
+ $name = $name . " ";
+ }
+ $name = $name . "($templateset_id[$count])";
+
+ }
+
+ print " $count. $name\n";
+
+ $count++;
+ }
+ print "\n d = default template set\n"
+ . " f = fallback template set\n"
+ . " r = RPC template set\n\n";
+
+ $menu_text = ".-------------------------------------.\n"
+ . "| t (detect template set) |\n"
+ . "| + (add template set) |\n"
+ . "| - N (remove template set) |\n"
+ . "| m N (mark default template set) |\n"
+ . "| f N (set fallback template set) |\n"
+ . "| r N (set RPC template set) |\n"
+ . "| l (list template sets/skins) |\n"
+ . "| d (done) |\n"
+ . "|-------------------------------------|\n"
+ . "| where N is a template set number |\n"
+ . "`-------------------------------------'\n";
+ print "\n";
+ print $menu_text;
+ print "\n[template set] command (?=help) > ";
+
+ $input = <STDIN>;
+ $input =~ s/[\r\n]//g;
+ while ( $input ne "d" ) {
+
+ # list template sets
+ #
+ if ( $input =~ /^\s*l\s*/i ) {
+ $count = 0;
+ while ( $count <= $#templateset_name ) {
+ if ( $templateset_id[$count] eq $templateset_default ) {
+ print " d";
+ } else {
+ print " ";
+ }
+ if ( $templateset_id[$count] eq $templateset_fallback ) {
+ print "f";
+ } else {
+ print " ";
+ }
+ if ( $templateset_id[$count] eq $rpc_templateset ) {
+ print "r ";
+ } else {
+ print " ";
+ }
+ if ( $count < 10 ) {
+ print " ";
+ }
+ if ( $count < 100 ) {
+ print " ";
+ }
+ $name = $templateset_name[$count];
+
+ # present RPC template sets differently
+ #
+ if ( $templateset_id[$count] =~ /_rpc$/ ) {
+ $name = $name . " (not shown in user interface; used for RPC interface only)";
+ } else {
+
+ $num_spaces = 35 - length($name);
+ for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
+ $name = $name . " ";
+ }
+ $name = $name . "($templateset_id[$count])";
+
+ }
+
+ print " $count. $name\n";
+
+ $count++;
+ }
+ print "\n d = default template set\n"
+ . " f = fallback template set\n"
+ . " r = RPC template set\n\n";
+
+ # mark default template set
+ #
+ } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
+ $old_def = $templateset_default;
+ $input =~ s/^\s*m\s*//;
+ $templateset_default = $templateset_id[$input];
+ if ( $templateset_default =~ /^\s*$/ ) {
+ print "Cannot set default template set to $input. That template set does not exist.\n";
+ $templateset_default = $old_def;
+ }
+ if ( $templateset_default =~ /_rpc$/ ) {
+ print "Cannot set default template set to $input. That template set is intended for the RPC interface only.\n";
+ $templateset_default = $old_def;
+ }
+
+ # set fallback template set
+ #
+ } elsif ( $input =~ /^\s*f\s*[0-9]+/i ) {
+ $old_def = $templateset_fallback;
+ $input =~ s/^\s*f\s*//;
+ $templateset_fallback = $templateset_id[$input];
+ if ( $templateset_fallback =~ /^\s*$/ ) {
+ print "Cannot set fallback template set to $input. That template set does not exist.\n";
+ $templateset_fallback = $old_def;
+ }
+ if ( $templateset_fallback =~ /_rpc$/ ) {
+ print "Cannot set fallback template set to $input. That template set is intended for the RPC interface only.\n";
+ $templateset_fallback = $old_def;
+ }
+
+ # set RPC template set
+ #
+ } elsif ( $input =~ /^\s*r\s*[0-9]+/i ) {
+ $old_def = $rpc_templateset;
+ $input =~ s/^\s*r\s*//;
+ $rpc_templateset = $templateset_id[$input];
+ if ( $rpc_templateset =~ /^\s*$/ ) {
+ print "Cannot set RPC template set to $input. That template set does not exist.\n";
+ $rpc_templateset = $old_def;
+ }
+ if ( $rpc_templateset !~ /_rpc$/ ) {
+ print "Cannot set fallback template set to $input. That template set is not intended for the RPC interface.\n";
+ $rpc_templateset = $old_def;
+ }
+
+ # add template set
+ #
+ } elsif ( $input =~ /^\s*\+/ ) {
+ print "\nWhat is the name of this template (as shown to your users): ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $templateset_name[ $#templateset_name + 1 ] = $name;
+ print "\n\nThe directory name should not contain any path information\n"
+ . "or slashes, and should be the name of the directory that the\n"
+ . "template set is found in within the SquirrelMail templates\n"
+ . "directory.\n\n";
+ print "What directory is this stored in (ex: default_advanced): ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $templateset_id[ $#templateset_id + 1 ] = $name;
+
+ # detect template sets
+ #
+ } elsif ( $input =~ /^\s*t\s*/i ) {
+ print "\nStarting detection...\n\n";
+ opendir( DIR, "../templates" );
+ @files = sort(readdir(DIR));
+ $cnt = 0;
+ while ( $cnt <= $#files ) {
+ if ( -d "../templates/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne ".svn" ) {
+ $filename = $files[$cnt];
+ $found = 0;
+ for ( $x = 0 ; $x <= $#templateset_id ; $x++ ) {
+ if ( $templateset_id[$x] eq $filename ) {
+ $found = 1;
+ last;
+ }
+ }
+ if ( $found != 1) {
+ print "** Found template set: $filename\n";
+ $def = $files[$cnt];
+
+ # no user-friendly names needed for RPC template sets
+ #
+ if ( $def =~ /_rpc$/ ) {
+ $nm = $def;
+ } else {
+ $def = lc($def);
+ $def =~ s/_/ /g;
+ #$def =~ s/(^\w+)/ucfirst $1/eg;
+ #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg;
+ $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg;
+ print " What is it's name (as shown to your users)? [$def]: ";
+ $nm = <STDIN>;
+ $nm =~ s/^\s+|\s+$|[\n\r]//g;
+ if ( $nm eq '' ) { $nm = $def; }
+ }
+ $templateset_id[ $#templateset_id + 1 ] = $filename;
+ $templateset_name[ $#templateset_name + 1 ] = $nm;
+ }
+ }
+ $cnt++;
+ }
+ print "\n";
+ for ( $cnt= 0 ; $cnt <= $#templateset_id ; ) {
+ $filename = $templateset_id[$cnt];
+ if ( !(-d change_to_rel_path('SM_PATH . \'templates/' . $filename)) ) {
+ print " Removing \"$filename\" (template set directory not found)\n";
+ if ( $templateset_default eq $filename ) { $templateset_default = 'default'; }
+ if ( $templateset_fallback eq $filename ) { $templateset_fallback = 'default'; }
+ if ( $rpc_templateset eq $filename ) { $rpc_templateset = 'default_rpc'; }
+ $offset = 0;
+ @new_templateset_name = ();
+ @new_templateset_id = ();
+ for ( $x = 0 ; $x < $#templateset_id ; $x++ ) {
+ if ( $templateset_id[$x] eq $filename ) {
+ $offset = 1;
+ }
+ if ( $offset == 1 ) {
+ $new_templateset_name[$x] = $templateset_name[ $x + 1 ];
+ $new_templateset_id[$x] = $templateset_id[ $x + 1 ];
+ } else {
+ $new_templateset_name[$x] = $templateset_name[$x];
+ $new_templateset_id[$x] = $templateset_id[$x];
+ }
+ }
+ @templateset_name = @new_templateset_name;
+ @templateset_id = @new_templateset_id;
+ } else { $cnt++; }
+ }
+ print "\nDetection complete!\n\n";
+
+ closedir DIR;
+
+ # remove template set
+ #
+ # undocumented functionality of removing last template set isn't that great
+ #} elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
+ } elsif ( $input =~ /^\s*-\s*[0-9]+/ ) {
+ if ( $input =~ /[0-9]+\s*$/ ) {
+ $rem_num = $input;
+ $rem_num =~ s/^\s*-\s*//g;
+ $rem_num =~ s/\s*$//;
+ } else {
+ $rem_num = $#templateset_name;
+ }
+ if ( $templateset_id[$rem_num] eq $templateset_default ) {
+ print "You cannot remove the default template set!\n";
+ } elsif ( $templateset_id[$rem_num] eq $templateset_fallback ) {
+ print "You cannot remove the fallback template set!\n";
+ } elsif ( $templateset_id[$rem_num] eq $rpc_templateset ) {
+ print "You cannot remove the RPC template set!\n";
+ } else {
+ $count = 0;
+ @new_templateset_name = ();
+ @new_templateset_id = ();
+ while ( $count <= $#templateset_name ) {
+ if ( $count != $rem_num ) {
+ @new_templateset_name = ( @new_templateset_name, $templateset_name[$count] );
+ @new_templateset_id = ( @new_templateset_id, $templateset_id[$count] );
+ }
+ $count++;
+ }
+ @templateset_name = @new_templateset_name;
+ @templateset_id = @new_templateset_id;
+ }
+
+ # help
+ #
+ } elsif ( $input =~ /^\s*\?\s*/ ) {
+ print $menu_text;
+
+ # command not understood
+ #
+ } else {
+ print "Command not understood\n";
+ }
+
+ print "[template set] command (?=help) > ";
+ $input = <STDIN>;
+ $input =~ s/[\r\n]//g;
+ }
+ return $templateset_default;
+}
+
+
+# sets default font size option
+sub command_default_fontsize {
+ print "Enter default font size [$WHT$$default_fontsize$NRM]: $WHT";
+ $new_size = <STDIN>;
+ if ( $new_size eq "\n" ) {
+ $new_size = $size;
+ } else {
+ $new_size =~ s/[\r\n]//g;
+ }
+ return $new_size;
+}
+
+# controls available fontsets
+sub command_fontsets {
+ # Greeting
+ print "You can control fontsets available to end users here.\n";
+ # set initial $input value
+ $input = 'l';
+ while ( $input ne "x" ) {
+ if ( $input =~ /^\s*a\s*/i ) {
+ # add new fontset
+ print "\nFontset name: ";
+ $name = <STDIN>;
+ if (! $fontsets{trim($name)}) {
+ print "Fontset string: ";
+ $value = <STDIN>;
+ $fontsets{trim($name)} = trim($value);
+ } else {
+ print "\nERROR: Such fontset already exists.\n";
+ }
+ } elsif ( $input =~ /^\s*e\s*/i ) {
+ # edit existing fontset
+ print "\nFontset name: ";
+ $name = <STDIN>;
+ if (! $fontsets{trim($name)}) {
+ print "\nERROR: No such fontset.\n";
+ } else {
+ print "Fontset string [$fontsets{trim($name)}]: ";
+ $value = <STDIN>;
+ $fontsets{trim($name)} = trim($value);
+ }
+ } elsif ( $input =~ /^\s*d\s*/ ) {
+ # delete existing fontset
+ print "\nFontset name: ";
+ $name = <STDIN>;
+ if (! $fontsets{trim($name)}) {
+ print "\nERROR: No such fontset.\n";
+ } else {
+ delete $fontsets{trim($name)};
+ }
+ } elsif ( $input =~ /^\s*l\s*/ ) {
+ # list fontsets
+ print "\nConfigured fontsets:\n";
+ while (($fontset_name, $fontset_string) = each(%fontsets)) {
+ print " $fontset_name = $fontset_string\n";
+ }
+ print "Default fontset: $default_fontset\n";
+ } elsif ( $input =~ /^\s*m\s*/ ) {
+ # set default fontset
+ print "\nSet default fontset [$default_fontset]: ";
+ $name = <STDIN>;
+ if (trim($name) ne '' and ! $fontsets{trim($name)}) {
+ print "\nERROR: No such fontset.\n";
+ } else {
+ $default_fontset = trim($name);
+ }
+ } else {
+ # print available commands on any other input
+ print "\nAvailable commands:\n";
+ print " a - Adds new fontset.\n";
+ print " d - Deletes existing fontset.\n";
+ print " e - Edits existing fontset.\n";
+ print " h or ? - Shows this help screen.\n";
+ print " l - Lists available fontsets.\n";
+ print " m - Sets default fontset.\n";
+ print " x - Exits fontset editor mode.\n";
+ }
+ print "\nCommand [fontsets] (a,d,e,h,?=help,l,m,x)> ";
+ $input = <STDIN>;
+ $input =~ s/[\r\n]//g;
+ }
+}
+
+sub command61 {
+ print "You can now define different LDAP servers.\n";
+ print "Please ensure proper permissions for config.php when including\n";
+ print "sensitive passwords.\n\n";
+ print "[ldap] command (?=help) > ";
+ $input = <STDIN>;
+ $input =~ s/[\r\n]//g;
+ while ( $input ne "d" ) {
+ if ( $input =~ /^\s*l\s*/i ) {
+ $count = 0;
+ while ( $count <= $#ldap_host ) {
+ print "$count. $ldap_host[$count]\n";
+ print " base: $ldap_base[$count]\n";
+ if ( $ldap_charset[$count] ) {
+ print " charset: $ldap_charset[$count]\n";
+ }
+ if ( $ldap_port[$count] ) {
+ print " port: $ldap_port[$count]\n";
+ }
+ if ( $ldap_name[$count] ) {
+ print " name: $ldap_name[$count]\n";
+ }
+ if ( $ldap_maxrows[$count] ) {
+ print " maxrows: $ldap_maxrows[$count]\n";
+ }
+ if ( $ldap_filter[$count] ) {
+ print " filter: $ldap_filter[$count]\n";
+ }
+ if ( $ldap_binddn[$count] ) {
+ print " binddn: $ldap_binddn[$count]\n";
+ if ( $ldap_bindpw[$count] ) {
+ print " bindpw: $ldap_bindpw[$count]\n";
+ }
+ }
+ if ( $ldap_protocol[$count] ) {
+ print " protocol: $ldap_protocol[$count]\n";
+ }
+ if ( $ldap_limit_scope[$count] ) {
+ print " limit_scope: $ldap_limit_scope[$count]\n";
+ }
+ if ( $ldap_listing[$count] ) {
+ print " listing: $ldap_listing[$count]\n";
+ }
+ if ( $ldap_writeable[$count] ) {
+ print " writeable: $ldap_writeable[$count]\n";
+ }
+ if ( $ldap_search_tree[$count] ) {
+ print " search_tree: $ldap_search_tree[$count]\n";
+ }
+ if ( $ldap_starttls[$count] ) {
+ print " starttls: $ldap_starttls[$count]\n";
+ }
+
+ print "\n";
+ $count++;
+ }
+ } elsif ( $input =~ /^\s*\+/ ) {
+ $sub = $#ldap_host + 1;
+
+ print "First, we need to have the hostname or the IP address where\n";
+ print "this LDAP server resides. Example: ldap.bigfoot.com\n";
+ print "\n";
+ print "You can use any URI compatible with your LDAP library. Please\n";
+ print "note that StartTLS option is not compatible with ldaps and\n";
+ print "ldapi URIs.\n";
+ print "hostname: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_host[$sub] = $name;
+
+ print "\n";
+
+ print "Next, we need the server root (base dn). For this, an empty\n";
+ print "string is allowed.\n";
+ print "Example: ou=member_directory,o=netcenter.com\n";
+ print "base: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_base[$sub] = $name;
+
+ print "\n";
+
+ print "This is the TCP/IP port number for the LDAP server. Default\n";
+ print "port is 389. This is optional. Press ENTER for default.\n";
+ print "port: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_port[$sub] = $name;
+
+ print "\n";
+
+ print "This is the charset for the server. Default is utf-8. This\n";
+ print "is also optional. Press ENTER for default.\n";
+ print "charset: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_charset[$sub] = $name;
+
+ print "\n";
+
+ print "This is the name for the server, used to tag the results of\n";
+ print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
+ print "name: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_name[$sub] = $name;
+
+ print "\n";
+
+ print "You can specify the maximum number of rows in the search result.\n";
+ print "Default value is equal to 250 rows. Press ENTER for default.\n";
+ print "maxrows: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_maxrows[$sub] = $name;
+
+
+ print "\n";
+
+ print "If your LDAP server does not like anonymous logins, you can specify bind DN.\n";
+ print "Default is none, anonymous bind. Press ENTER for default.\n";
+ print "binddn: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_binddn[$sub] = $name;
+
+ print "\n";
+
+ if ( $ldap_binddn[$sub] ne '' ) {
+
+ print "Now, please specify password for that DN.\n";
+ print "bindpw: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_bindpw[$sub] = $name;
+
+ print "\n";
+ }
+
+ print "You can specify bind protocol version here.\n";
+ print "Default protocol version depends on your php ldap settings.\n";
+ print "Press ENTER for default.\n";
+ print "protocol: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $ldap_protocol[$sub] = $name;
+
+ print "\n";
+
+ print "This configuration section allows to set some rarely used\n";
+ print "options and options specific to some LDAP implementations.\n";
+ print "\n";
+ print "Do you want to set advanced LDAP directory settings? (y/N):";
+ $ldap_advanced_settings = <STDIN>;
+ if ( $ldap_advanced_settings =~ /^y\n/i ) {
+ $ldap_advanced_settings = 'true';
+ } else {
+ $ldap_advanced_settings = 'false';
+ }
+
+ if ($ldap_advanced_settings eq 'true') {
+ print "\n";
+
+ print "You can control LDAP directory listing here. This option can\n";
+ print "be useful if you run small LDAP server and want to provide listing\n";
+ print "of all addresses stored in LDAP to users of webmail interface.\n";
+ print "Number of displayed entries is limited by maxrows setting.\n";
+ print "\n";
+ print "Don't enable this option for public LDAP directories.\n";
+ print "\n";
+ print "Allow listing of LDAP directory? (y/N):";
+ $name = <STDIN>;
+ if ( $name =~ /^y\n/i ) {
+ $name = 'true';
+ } else {
+ $name = 'false';
+ }
+ $ldap_listing[$sub] = $name;
+
+ print "\n";
+
+ print "You can control write access to LDAP address book here. This option can\n";
+ print "be useful if you run small LDAP server and want to provide writable\n";
+ print "shared address book stored in LDAP to users of webmail interface.\n";
+ print "\n";
+ print "Don't enable this option for public LDAP directories.\n";
+ print "\n";
+ print "Allow writing to LDAP directory? (y/N):";
+ $name = <STDIN>;
+ if ( $name =~ /^y\n/i ) {
+ $name = 'true';
+ } else {
+ $name = 'false';
+ }
+ $ldap_writeable[$sub] = $name;
+
+ print "\n";
+
+ print "You can specify an additional search filter.\n";
+ print "This could be something like \"(objectclass=posixAccount)\".\n";
+ print "No filtering is performed by default. Press ENTER for default.\n";
+ print "filter: ";
+ $name = <STDIN>;
+ $name =~ s/[\r|\n]//g;
+ $ldap_filter[$sub] = $name;
+
+ print "\n";
+
+ print "You can control search scope here.\n";
+ print "This option is specific to Microsoft ADS implementation.\n";
+ print "It requires use of v3 or newer LDAP protocol.\n";
+ print "Don't enable it, if you use other LDAP server.\n";
+ print "\n";
+ print "Limit ldap scope? (y/N):";
+ $name = <STDIN>;
+ if ( $name =~ /^y\n/i ) {
+ $name = 'true';
+ } else {
+ $name = 'false';
+ }
+ $ldap_limit_scope[$sub] = $name;
+
+ print "\n";
+
+ print "You can control ldap search type here.\n";
+ print "Addresses can be searched in entire LDAP subtree (default)\n";
+ print "or only first level entries are returned.\n";
+ print "\n";
+ print "Search entire LDAP subtree? (Y/n):";
+ $name = <STDIN>;
+ if ( $name =~ /^n\n/i ) {
+ $name = 'false';
+ } else {
+ $name = 'true';
+ }
+ $ldap_search_tree[$sub] = $name;
+
+ print "\n";
+
+ print "You can control use of StartTLS on LDAP connection here.\n";
+ print "This option requires use of v3 or newer LDAP protocol and php 4.2+.\n";
+ print "\n";
+ print "Use StartTLS? (y/N):";
+ $name = <STDIN>;
+ if ( $name =~ /^y\n/i ) {
+ $name = 'true';
+ } else {
+ $name = 'false';
+ }
+ $ldap_starttls[$sub] = $name;
+ }
+ print "\n";
+
+ } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
+ if ( $input =~ /[0-9]+\s*$/ ) {
+ $rem_num = $input;
+ $rem_num =~ s/^\s*-\s*//g;
+ $rem_num =~ s/\s*$//;
+ } else {
+ $rem_num = $#ldap_host;
+ }
+ $count = 0;
+ @new_ldap_host = ();
+ @new_ldap_base = ();
+ @new_ldap_port = ();
+ @new_ldap_name = ();
+ @new_ldap_charset = ();
+ @new_ldap_maxrows = ();
+ @new_ldap_filter = ();
+ @new_ldap_bindpw = ();
+ @new_ldap_binddn = ();
+ @new_ldap_protocol = ();
+ @new_ldap_limit_scope = ();
+ @new_ldap_listing = ();
+ @new_ldap_writeable = ();
+ @new_ldap_search_tree = ();
+ @new_ldap_starttls = ();
+
+ while ( $count <= $#ldap_host ) {
+ if ( $count != $rem_num ) {
+ @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
+ @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
+ @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
+ @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
+ @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
+ @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
+ @new_ldap_filter = ( @new_ldap_filter, $ldap_filter[$count] );
+ @new_ldap_binddn = ( @new_ldap_binddn, $ldap_binddn[$count] );
+ @new_ldap_bindpw = ( @new_ldap_bindpw, $ldap_bindpw[$count] );
+ @new_ldap_protocol = ( @new_ldap_protocol, $ldap_protocol[$count] );
+ @new_ldap_limit_scope = ( @new_ldap_limit_scope, $ldap_limit_scope[$count] );
+ @new_ldap_listing = ( @new_ldap_listing, $ldap_listing[$count] );
+ @new_ldap_writeable = ( @new_ldap_writeable, $ldap_writeable[$count] );
+ @new_ldap_search_tree = ( @new_ldap_search_tree, $ldap_search_tree[$count] );
+ @new_ldap_starttls = ( @new_ldap_starttls, $ldap_starttls[$count] );
+ }
+ $count++;
+ }
+ @ldap_host = @new_ldap_host;
+ @ldap_base = @new_ldap_base;
+ @ldap_port = @new_ldap_port;
+ @ldap_name = @new_ldap_name;
+ @ldap_charset = @new_ldap_charset;
+ @ldap_maxrows = @new_ldap_maxrows;
+ @ldap_filter = @new_ldap_filter;
+ @ldap_binddn = @new_ldap_binddn;
+ @ldap_bindpw = @new_ldap_bindpw;
+ @ldap_protocol = @new_ldap_protocol;
+ @ldap_limit_scope = @new_ldap_limit_scope;
+ @ldap_listing = @new_ldap_listing;
+ @ldap_writeable = @new_ldap_writeable;
+ @ldap_search_tree = @new_ldap_search_tree;
+ @ldap_starttls = @new_ldap_starttls;
+
+ } elsif ( $input =~ /^\s*\?\s*/ ) {
+ print ".-------------------------.\n";
+ print "| + (add host) |\n";
+ print "| - N (remove host) |\n";
+ print "| l (list hosts) |\n";
+ print "| d (done) |\n";
+ print "`-------------------------'\n";
+ }
+ print "[ldap] command (?=help) > ";
+ $input = <STDIN>;
+ $input =~ s/[\r\n]//g;
+ }
+}
+
+sub command62 {
+ print "Some of our developers have come up with very good javascript interface\n";
+ print "for searching through address books, however, our original goals said\n";
+ print "that we would be 100% HTML. In order to make it possible to use their\n";
+ print "interface, and yet stick with our goals, we have also written a plain\n";
+ print "HTML version of the search. Here, you can choose which version to use.\n";
+ print "\n";
+ print "This is just the default value. It is also a user option that each\n";
+ print "user can configure individually\n";
+ print "\n";
+
+ if ( lc($default_use_javascript_addr_book) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_use_javascript_addr_book = 'false';
+ $default_value = "n";
+ }
+ print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
+ $new_show = <STDIN>;
+ if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $default_use_javascript_addr_book = 'true';
+ } else {
+ $default_use_javascript_addr_book = 'false';
+ }
+ return $default_use_javascript_addr_book;
+}
+
+# global filebased address book
+sub command63 {
+ print "If you want to use global file address book, then you\n";
+ print "must set this option to a valid value. If option does\n";
+ print "not have path elements, system assumes that file is\n";
+ print "stored in data directory. If relative path is set, it is\n";
+ print "relative to main SquirrelMail directory. If value is empty,\n";
+ print "address book is not enabled.\n";
+ print "\n";
+
+ print "[$WHT$abook_global_file$NRM]: $WHT";
+ $new_abook_global_file = <STDIN>;
+ if ( $new_abook_global_file eq "\n" ) {
+ $new_abook_global_file = $abook_global_file;
+ } else {
+ $new_abook_global_file =~ s/[\r\n]//g;
+ }
+ return $new_abook_global_file;
+}
+
+# writing into global filebased abook control
+sub command64 {
+ print "This setting controls writing into global file address\n";
+ print "book options. Address book file must be writeable by\n";
+ print "webserver's user, if you want to enable this option.\n";
+ print "\n";
+
+ if ( lc($abook_global_file_writeable) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $abook_global_file_writeable = 'false';
+ $default_value = "n";
+ }
+ print "Allow writing into global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
+ $new_show = <STDIN>;
+ if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $abook_global_file_writeable = 'true';
+ } else {
+ $abook_global_file_writeable = 'false';
+ }
+ return $abook_global_file_writeable;
+}
+
+# listing of global filebased abook control
+sub command65 {
+ print "This setting controls listing of global file address\n";
+ print "book in addresses page.\n";
+ print "\n";
+
+ if ( lc($abook_global_file_listing) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $abook_global_file_listing = 'false';
+ $default_value = "n";
+ }
+ print "Allow listing of global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
+ $new_show = <STDIN>;
+ if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $abook_global_file_listing = 'true';
+ } else {
+ $abook_global_file_listing = 'false';
+ }
+ return $abook_global_file_listing;
+}
+
+# controls $abook_file_line_length setting
+sub command_abook_file_line_length {
+ print "This setting controls space allocated to file based address book records.\n";
+ print "End users will be unable to save address book entry, if total entry size \n";
+ print "(quoted address book fields + 4 delimiters + linefeed) exceeds allowed \n";
+ print "address book length size.\n";
+ print "\n";
+ print "Same setting is applied to personal and global file based address books.\n";
+ print "\n";
+ print "It is strongly recommended to keep default setting value. Change it only\n";
+ print "if you really want to store address book entries that are bigger than two\n";
+ print "kilobytes (2048).\n";
+ print "\n";
+
+ print "Enter allowed address book line length [$abook_file_line_length]: ";
+ my $tmp = <STDIN>;
+ $tmp = trim($tmp);
+ # value is not modified, if user hits Enter or enters space
+ if ($tmp ne '') {
+ # make sure that input is numeric
+ if ($tmp =~ /^\d+$/) {
+ $abook_file_line_length = $tmp;
+ } else {
+ print "If you want to change this setting, you must enter number.\n";
+ print "If you want to keep original setting - enter space.\n\n";
+ print "Press Enter to continue...";
+ $tmp = <STDIN>;
+ }
+ }
+}
+
+sub command91 {
+ print "If you want to store your users address book details in a database then\n";
+ print "you need to set this DSN to a valid value. The format for this is:\n";
+ print "mysql://user:pass\@hostname/dbname\n";
+ print "Where mysql can be one of the databases PHP supports, the most common\n";
+ print "of these are mysql, msql and pgsql.\n";
+ print "Please ensure proper permissions for config.php when including\n";
+ print "sensitive passwords.\n\n";
+ print "If the DSN is left empty (hit space and then return) the database\n";
+ print "related code for address books will not be used.\n";
+ print "\n";
+
+ if ( $addrbook_dsn eq "" ) {
+ $default_value = "Disabled";
+ } else {
+ $default_value = $addrbook_dsn;
+ }
+ print "[$WHT$addrbook_dsn$NRM]: $WHT";
+ $new_dsn = <STDIN>;
+ if ( $new_dsn eq "\n" ) {
+ $new_dsn = "";
+ } else {
+ $new_dsn =~ s/[\r\n]//g;
+ $new_dsn =~ s/^\s+$//g;
+ }
+ return $new_dsn;
+}
+
+sub command92 {
+ print "This is the name of the table you want to store the address book\n";
+ print "data in, it defaults to 'address'\n";
+ print "\n";
+ print "[$WHT$addrbook_table$NRM]: $WHT";
+ $new_table = <STDIN>;
+ if ( $new_table eq "\n" ) {
+ $new_table = $addrbook_table;
+ } else {
+ $new_table =~ s/[\r\n]//g;
+ }
+ return $new_table;
+}
+
+sub command93 {
+ print "If you want to store your users preferences in a database then\n";
+ print "you need to set this DSN to a valid value. The format for this is:\n";
+ print "mysql://user:pass\@hostname/dbname\n";
+ print "Where mysql can be one of the databases PHP supports, the most common\n";
+ print "of these are mysql, msql and pgsql.\n";
+ print "Please ensure proper permissions for config.php when including\n";
+ print "sensitive passwords.\n\n";
+ print "If the DSN is left empty (hit space and then return) the database\n";
+ print "related code for address books will not be used.\n";
+ print "\n";
+
+ if ( $prefs_dsn eq "" ) {
+ $default_value = "Disabled";
+ } else {
+ $default_value = $prefs_dsn;
+ }
+ print "[$WHT$prefs_dsn$NRM]: $WHT";
+ $new_dsn = <STDIN>;
+ if ( $new_dsn eq "\n" ) {
+ $new_dsn = "";
+ } else {
+ $new_dsn =~ s/[\r\n]//g;
+ $new_dsn =~ s/^\s+$//g;
+ }
+ return $new_dsn;
+}
+
+sub command94 {
+ print "This is the name of the table you want to store the preferences\n";
+ print "data in, it defaults to 'userprefs'\n";
+ print "\n";
+ print "[$WHT$prefs_table$NRM]: $WHT";
+ $new_table = <STDIN>;
+ if ( $new_table eq "\n" ) {
+ $new_table = $prefs_table;
+ } else {
+ $new_table =~ s/[\r\n]//g;
+ }
+ return $new_table;
+}
+
+sub command95 {
+ print "This is the name of the field in which you want to store the\n";
+ print "username of the person the prefs are for. It default to 'user'\n";
+ print "which clashes with a reserved keyword in PostgreSQL so this\n";
+ print "will need to be changed for that database at least\n";
+ print "\n";
+ print "[$WHT$prefs_user_field$NRM]: $WHT";
+ $new_field = <STDIN>;
+ if ( $new_field eq "\n" ) {
+ $new_field = $prefs_user_field;
+ } else {
+ $new_field =~ s/[\r\n]//g;
+ }
+ $prefs_user_size = db_pref_size($prefs_user_size);
+ return $new_field;
+}
+
+sub command96 {
+ print "This is the name of the field in which you want to store the\n";
+ print "preferences keyword. It defaults to 'prefkey'\n";
+ print "\n";
+ print "[$WHT$prefs_key_field$NRM]: $WHT";
+ $new_field = <STDIN>;
+ if ( $new_field eq "\n" ) {
+ $new_field = $prefs_key_field;
+ } else {
+ $new_field =~ s/[\r\n]//g;
+ }
+ $prefs_key_size = db_pref_size($prefs_key_size);
+ return $new_field;
+}
+
+sub command97 {
+ print "This is the name of the field in which you want to store the\n";
+ print "preferences value. It defaults to 'prefval'\n";
+ print "\n";
+ print "[$WHT$prefs_val_field$NRM]: $WHT";
+ $new_field = <STDIN>;
+ if ( $new_field eq "\n" ) {
+ $new_field = $prefs_val_field;
+ } else {
+ $new_field =~ s/[\r\n]//g;
+ }
+ $prefs_val_size = db_pref_size($prefs_val_size);
+ return $new_field;
+}
+
+# routine is used to set database field limits
+# it needs one argument
+sub db_pref_size() {
+ my ($size) = $_[0];
+ print "\nDatabase fields have size limits.\n";
+ print "\n";
+ print "What limit is set for this field? [$WHT$size$NRM]: $WHT";
+ $new_size = <STDIN>;
+ if ( $new_size eq "\n" ) {
+ $new_size = $size;
+ } else {
+ $new_size =~ s/[\r\n]//g;
+ }
+ return $new_size;
+}
+
+sub command98 {
+ print "If you want to store your global address book in a database then\n";
+ print "you need to set this DSN to a valid value. The format for this is:\n";
+ print "mysql://user:pass\@hostname/dbname\n";
+ print "Where mysql can be one of the databases PHP supports, the most common\n";
+ print "of these are mysql, msql and pgsql.\n";
+ print "Please ensure proper permissions for config.php when including\n";
+ print "sensitive passwords.\n\n";
+ print "If the DSN is left empty (hit space and then return) the database\n";
+ print "related code for global SQL address book will not be used.\n";
+ print "\n";
+
+ if ( $addrbook_global_dsn eq "" ) {
+ $default_value = "Disabled";
+ } else {
+ $default_value = $addrbook_global_dsn;
+ }
+ print "[$WHT$addrbook_global_dsn$NRM]: $WHT";
+ $new_dsn = <STDIN>;
+ if ( $new_dsn eq "\n" ) {
+ $new_dsn = "";
+ } else {
+ $new_dsn =~ s/[\r\n]//g;
+ $new_dsn =~ s/^\s+$//g;
+ }
+ return $new_dsn;
+}
+
+sub command99 {
+ print "This is the name of the table you want to store the global address book\n";
+ print "data in. Default table name is 'global_abook'. Address book uses same\n";
+ print "database format as personal address book.\n";
+ print "\n";
+ print "[$WHT$addrbook_global_table$NRM]: $WHT";
+ $new_table = <STDIN>;
+ if ( $new_table eq "\n" ) {
+ $new_table = $addrbook_global_table;
+ } else {
+ $new_table =~ s/[\r\n]//g;
+ }
+ return $new_table;
+}
+
+sub command910 {
+ print "This option controls users\' ability to add or modify records stored \n";
+ print "in global address book\n";
+
+ if ( lc($addrbook_global_writeable) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $addrbook_global_writeable = <STDIN>;
+ if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $addrbook_global_writeable = 'true';
+ } else {
+ $addrbook_global_writeable = 'false';
+ }
+ return $addrbook_global_writeable;
+}
+
+sub command911 {
+ print "Enable this option if you want to see listing of addresses stored \n";
+ print "in global address book\n";
+
+ if ( lc($addrbook_global_listing) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $addrbook_global_listing = <STDIN>;
+ if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $addrbook_global_listing = 'true';
+ } else {
+ $addrbook_global_listing = 'false';
+ }
+ return $addrbook_global_listing;
+}
+
+
+# Default language
+sub commandA1 {
+ print "SquirrelMail attempts to set the language in many ways. If it\n";
+ print "can not figure it out in another way, it will default to this\n";
+ print "language. Please use the code for the desired language.\n";
+ print "\n";
+ print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
+ $new_squirrelmail_default_language = <STDIN>;
+ if ( $new_squirrelmail_default_language eq "\n" ) {
+ $new_squirrelmail_default_language = $squirrelmail_default_language;
+ } else {
+ $new_squirrelmail_default_language =~ s/[\r\n]//g;
+ $new_squirrelmail_default_language =~ s/^\s+$//g;
+ }
+ return $new_squirrelmail_default_language;
+}
+# Default Charset
+sub commandA2 {
+ print "This option controls what character set is used when sending\n";
+ print "mail and when sending HTML to the browser. Option works only\n";
+ print "with US English (en_US) translation. Other translations use\n";
+ print "charsets that are set in translation settings.\n";
+ print "\n";
+
+ print "[$WHT$default_charset$NRM]: $WHT";
+ $new_default_charset = <STDIN>;
+ if ( $new_default_charset eq "\n" ) {
+ $new_default_charset = $default_charset;
+ } else {
+ $new_default_charset =~ s/[\r\n]//g;
+ }
+ return $new_default_charset;
+}
+# Alternative language names
+sub commandA3 {
+ print "Enable this option if you want to see localized language names in\n";
+ print "language selection box. Note, that this option can trigger\n";
+ print "installation of foreign language support modules in some browsers.\n";
+ print "\n";
+
+ if ( lc($show_alternative_names) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Show alternative language names? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $show_alternative_names = <STDIN>;
+ if ( ( $show_alternative_names =~ /^y\n/i ) || ( ( $show_alternative_names =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $show_alternative_names = 'true';
+ } else {
+ $show_alternative_names = 'false';
+ }
+ return $show_alternative_names;
+}
+
+# Aggressive decoding
+sub commandA4 {
+ print "Enable this option if you want to use CPU and memory intensive decoding\n";
+ print "functions. This option allows reading multibyte charset, that are used\n";
+ print "in Eastern Asia. SquirrelMail will try to use recode functions here,\n";
+ print "even when you have disabled use of recode in Tweaks section.\n";
+ print "\n";
+
+ if ( lc($aggressive_decoding) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Enable aggressive decoding? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $aggressive_decoding = <STDIN>;
+ if ( ( $aggressive_decoding =~ /^y\n/i ) || ( ( $aggressive_decoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $aggressive_decoding = 'true';
+ } else {
+ $aggressive_decoding = 'false';
+ }
+ return $aggressive_decoding;
+}
+
+# Lossy encoding
+sub commandA5 {
+ print "Enable this option if you want to allow lossy charset encoding in message\n";
+ print "composition pages. This option allows charset conversions when output\n";
+ print "charset does not support all symbols used in original charset. Symbols\n";
+ print "unsupported by output charset will be replaced with question marks.\n";
+ print "\n";
+
+ if ( lc($lossy_encoding) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Enable lossy encoding? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $lossy_encoding = <STDIN>;
+ if ( ( $lossy_encoding =~ /^y\n/i ) || ( ( $lossy_encoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $lossy_encoding = 'true';
+ } else {
+ $lossy_encoding = 'false';
+ }
+ return $lossy_encoding;
+}
+
+# display html emails in iframe
+sub commandB2 {
+ print "This option can enable html email rendering inside iframe.\n";
+ print "Inline frames are used in order to provide sandbox environment";
+ print "for html code included in html formated emails.";
+ print "Option is experimental and might have glitches in some parts of code.";
+ print "\n";
+
+ if ( lc($use_iframe) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Display html emails in iframe? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $use_iframe = <STDIN>;
+ if ( ( $use_iframe =~ /^y\n/i ) || ( ( $use_iframe =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $use_iframe = 'true';
+ } else {
+ $use_iframe = 'false';
+ }
+ return $use_iframe;
+}
+
+# ask user info
+sub command_ask_user_info {
+ print "New users need to supply their real name and email address to\n";
+ print "send out proper mails. When this option is enabled, a user that\n";
+ print "logs in for the first time will be redirected to the Personal\n";
+ print "Options screen and asked to supply their personal data.\n";
+ print "\n";
+
+ if ( lc($ask_user_info) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Ask user info? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $ask_user_info = <STDIN>;
+ if ( ( $ask_user_info =~ /^y\n/i ) || ( ( $ask_user_info =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $ask_user_info = 'true';
+ } else {
+ $ask_user_info = 'false';
+ }
+ return $ask_user_info;
+}
+
+# use icons
+sub commandB3 {
+ print "Enabling this option will cause icons to be used instead of text\n";
+ print "markers next to each message in mailbox lists that represent\n";
+ print "new, read, flagged, and deleted messages, as well as those that\n";
+ print "have been replied to and forwarded. Icons are also used next to\n";
+ print "(un)expanded folders in the folder list (Oldway = false). These\n";
+ print "icons are quite small, but will obviously be more of a resource\n";
+ print "drain than text markers.\n";
+ print "\n";
+
+ if ( lc($use_icons) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Use icons? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $use_icons = <STDIN>;
+ if ( ( $use_icons =~ /^y\n/i ) || ( ( $use_icons =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $use_icons = 'true';
+ } else {
+ $use_icons = 'false';
+ }
+ return $use_icons;
+}
+# php recode
+sub commandB4 {
+ print "Enable this option if you want to use php recode functions to read\n";
+ print "emails written in charset that differs from the one that is set in\n";
+ print "translation selected by user. Code is experimental, it might cause\n";
+ print "errors, if email contains charset unsupported by recode or if your\n";
+ print "php does not have recode support.\n";
+ print "\n";
+
+ if ( lc($use_php_recode) eq 'true' ) {
+ $default_value = "y";
+ } else {
+ $default_value = "n";
+ }
+ print "Use php recode functions? (y/n) [$WHT$default_value$NRM]: $WHT";
+ $use_php_recode = <STDIN>;
+ if ( ( $use_php_recode =~ /^y\n/i ) || ( ( $use_php_recode =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+ $use_php_recode = 'true';
+ } else {
+ $use_php_recode = 'false';
+ }
+ return $use_php_recode;
+}
+# php iconv
+sub commandB5 {
+ print "Enable this option if you want to use php iconv functions to read\n";
+ print "emails written in charset that differs from the one that is set in\n";
+ print "translation selected by user. Code is experimental, it works only\n";
+ print "with translations that use utf-8 charset. Code might cause errors,\n";
+ print "if email contains charset unsupported by iconv or if your php does\n";
+ print "not have iconv support.\n";