+ print "What is the name of this template: ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $templateset_name[ $#templateset_name + 1 ] = $name;
+ print "Be sure to put ../templates/ before the dirname.\n";
+ print "What file is this stored in (ex: ../templates/default/): ";
+ $name = <STDIN>;
+ $name =~ s/[\r\n]//g;
+ $templateset_path[ $#templateset_path + 1 ] = $name;
+ } elsif ( $input =~ /^\s*t\s*/i ) {
+ print "\nStarting detection...\n\n";
+ opendir( DIR, "../templates" );
+ @files = readdir(DIR);
+ $cnt = 0;
+ $detected = 0;
+ while ( $cnt <= $#files ) {
+ if ( -d "../templates/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne "CVS" ) {
+ $filename = "../templates/" . $files[$cnt]. "/";
+ $found = 0;
+ for ( $x = 0 ; $x <= $#templateset_path ; $x++ ) {
+ if ( $templateset_path[$x] eq $filename ) {
+ $found = 1;
+ }
+ }
+ if ( $found != 1 && $detected == 0) {
+ $templateset_path[ $#templateset_path + 1 ] = $filename;
+ $templateset_name[ $#templateset_name + 1 ] = "Default template";
+ $aTemplateSet[ $#templateset_name + 1 ] = "Default template";
+ $aTemplateSet[ $#templateset_path + 1 ] = $filename;
+ } elsif ( $found != 1) {
+ print "** Found template set: $filename\n";
+ print " What is it's name? ";
+ $nm = <STDIN>;
+ $nm =~ s/[\n\r]//g;
+ $templateset_path[ $#templateset_path + 1 ] = $filename;
+ $templateset_name[ $#templateset_name + 1 ] = $nm;
+
+ $aTemplateSet[ $#templateset_name + 1 ] = $nm;
+ $aTemplateSet[ $#templateset_path + 1 ] = $filename;
+ }
+ $detected++;
+ }
+ $cnt++;
+ }
+ print "\n";
+ for ( $cnt = 0 ; $cnt <= $#templateset_path ; $cnt++ ) {
+ $filename = $templateset_path[$cnt];
+ if ( !(-d $filename) ) {
+ print " Removing $filename (file not found)\n";
+ $offset = 0;
+ @new_templateset_name = ();
+ @new_templateset_path = ();
+ for ( $x = 0 ; $x < $#templateset_path ; $x++ ) {
+ if ( $templateset_path[$x] eq $filename ) {
+ $offset = 1;
+ }
+ if ( $offset == 1 ) {
+ $new_templateset_name[$x] = $templateset_name[ $x + 1 ];
+ $new_theme_path[$x] = $templateset_path[ $x + 1 ];
+ } else {
+ $new_templateset_name[$x] = $templateset_name[$x];
+ $new_templateset_path[$x] = $templateset_path[$x];
+ }
+ }
+ @templateset_name = @new_templateset_name;
+ @templateset_path = @new_templateset_path;
+ }
+ }
+ print "\nDetection complete!\n\n";
+
+ closedir DIR;
+ } 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 ( $rem_num == $templateset_default ) {
+ print "You cannot remove the default template set!\n";
+ } else {
+ $count = 0;
+ @new_templateset_name = ();
+ @new_templateset_path = ();
+ while ( $count <= $#templateset_name ) {
+ if ( $count != $rem_num ) {
+ @new_templateset_name = ( @new_templateset_name, $templateset_name[$count] );
+ @new_templateset_path = ( @new_templateset_path, $templateset_path[$count] );
+ }
+ $count++;
+ }
+ @templateset_name = @new_templateset_name;
+ @templateset_path = @new_templateset_path;
+ if ( $templateset_default > $rem_num ) {
+ $templateset_default--;
+ }
+ }
+ } elsif ( $input =~ /^\s*\?\s*/ ) {
+ print ".--------------------------------.\n";
+ print "| t (detect templates set) |\n";
+ print "| + (add template set) |\n";
+ print "| - N (remove template set) |\n";
+ print "| m N (mark template set) |\n";
+ print "| l (list template set) |\n";
+ print "| d (done) |\n";
+ print "`--------------------------------'\n";
+ }
+ print "[template set] command (?=help) > ";
+ $input = <STDIN>;
+ $input =~ s/[\r\n]//g;
+ }
+ return $templateset_default;
+}
+
+
+# Theme - CSS file
+sub command42 {
+ print "You may specify a cascading style-sheet (CSS) file to be included\n";
+ print "on each html page generated by SquirrelMail. The CSS file is useful\n";
+ print "for specifying a site-wide font. If you're not familiar with CSS\n";
+ print "files, leave this blank.\n";
+ print "\n";
+ print "To clear out an existing value, just type a space for the input.\n";
+ print "\n";
+ print "Please be aware of the following: \n";
+ print " - Relative URLs are relative to the config dir\n";
+ print " to use the themes directory, use ../themes/css/newdefault.css\n";
+ print " - To specify a css file defined outside the SquirrelMail source tree\n";
+ print " use the absolute URL the webserver would use to include the file\n";
+ print " e.g. http://some.host.com/css/mystyle.css or /css/mystyle.css\n";
+ print "\n";
+ print "[$WHT$theme_css$NRM]: $WHT";
+ $new_theme_css = <STDIN>;
+
+ if ( $new_theme_css eq "\n" ) {
+ $new_theme_css = $theme_css;
+ } else {
+ $new_theme_css =~ s/[\r\n]//g;
+ }
+ $new_theme_css =~ s/^\s*//;
+ return $new_theme_css;
+}
+
+# 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 "[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_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;