+ $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 {