~ubuntu-branches/ubuntu/hardy/squirrelmail/hardy-updates

« back to all changes in this revision

Viewing changes to config/conf.pl

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2005-02-06 21:41:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050206214151-z4n1o8mnttgzuj0y
Tags: 2:1.4.4-3
* Move default_pref config file from /var to /etc, as per Debian policy
  (Closes: #293281)
* [JvW] (finally) override two lintian warnings about nonstandard
  permissions that are intentional (Closes: #293366)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env perl
2
2
# conf.pl
3
3
#
4
 
# Copyright (c) 1999-2003 The SquirrelMail Project Team 
 
4
# Copyright (c) 1999-2005 The SquirrelMail Project Team
5
5
# Licensed under the GNU GPL. For full terms see COPYING.
6
6
#
7
7
# A simple configure script to configure SquirrelMail
8
8
#
9
 
# $Id: conf.pl,v 1.175 2003/12/26 09:13:37 tokul Exp $
 
9
# $Id: conf.pl,v 1.154.2.18 2005/01/02 23:50:00 kink Exp $
10
10
############################################################              
11
11
$conf_pl_version = "1.4.0";
12
12
 
171
171
        $options[1] =~ s/[\'|\"];\s*$//;
172
172
        $options[1] =~ s/;$//;
173
173
        $options[1] =~ s/^[\'|\"]//;
 
174
        # de-escape escaped strings
 
175
        $options[1] =~ s/\\'/'/g;
 
176
        $options[1] =~ s/\\\\/\\/g;
174
177
 
175
178
        if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) {
176
179
            $sub = $options[0];
269
272
    }
270
273
}
271
274
close FILE;
272
 
if ( lc($useSendmail) ne "true" ) {
273
 
    $useSendmail = "false";
274
 
}
275
 
if ( !$sendmail_path ) {
276
 
    $sendmail_path = "/usr/sbin/sendmail";
277
 
}
278
 
if ( !$pop_before_smtp ) {
279
 
    $pop_before_smtp = "false";
280
 
}
281
 
if ( !$default_unseen_notify ) {
282
 
    $default_unseen_notify = 2;
283
 
}
284
 
if ( !$default_unseen_type ) {
285
 
    $default_unseen_type = 1;
286
 
}
287
 
if ( !$config_use_color ) {
288
 
    $config_use_color = 0;
289
 
}
290
 
if ( !$invert_time ) {
291
 
    $invert_time = "false";
292
 
}
293
 
if ( !$force_username_lowercase ) {
294
 
    $force_username_lowercase = "false";
295
 
}
296
 
if ( !$optional_delimiter ) {
297
 
    $optional_delimiter = "detect";
298
 
}
299
 
if ( !$auto_create_special ) {
300
 
    $auto_create_special = "false";
301
 
}
302
 
if ( !$default_use_priority ) {
303
 
    $default_use_priority = "true";
304
 
}
305
 
if ( !$hide_sm_attributions ) {
306
 
    $hide_sm_attributions = "false";
307
 
}
308
 
if ( !$default_use_mdn ) {
309
 
    $default_use_mdn = "true";
310
 
}
311
 
if ( !$delete_folder ) {
312
 
    $delete_folder = "false";
313
 
}
314
 
if ( !$noselect_fix_enable ) {
315
 
    $noselect_fix_enable = "false";
316
 
}
317
 
if ( !$frame_top ) {
318
 
    $frame_top = "_top";
319
 
}
320
 
 
321
 
if ( !$provider_uri ) {
322
 
    $provider_uri = "http://www.squirrelmail.org/";
323
 
}
324
 
 
325
 
if ( !$provider_name ) {
326
 
    $provider_name = "SquirrelMail";
327
 
}
328
 
 
329
 
if ( !$edit_identity ) {
330
 
    $edit_identity = "true";
331
 
}
332
 
if ( !$edit_name ) {
333
 
    $edit_name = "true";
334
 
}
335
 
if ( !$allow_thread_sort ) {
336
 
    $allow_thread_sort = 'false';
337
 
}
338
 
if ( !$allow_server_sort ) {
339
 
    $allow_server_sort = 'false';
340
 
}
341
 
if ( !$no_list_for_subscribe ) {
342
 
    $no_list_for_subscribe = 'false';
343
 
}
344
 
if ( !$allow_charset_search ) {
345
 
    $allow_charset_search = 'true';
346
 
}
347
 
if ( !$prefs_user_field ) {
348
 
    $prefs_user_field = 'user';
349
 
}
350
 
if ( !$prefs_key_field ) {
351
 
    $prefs_key_field = 'prefkey';
352
 
}
353
 
if ( !$addrbook_global_table ) {
354
 
    $addrbook_global_table = 'global_abook';
355
 
}
356
 
if ( !$addrbook_global_writeable ) {
357
 
    $addrbook_global_writeable = 'false';
358
 
}
359
 
if ( !$addrbook_global_listing ) {
360
 
    $addrbook_global_listing = 'false';
361
 
}
362
 
if ( !$prefs_val_field ) {
363
 
    $prefs_val_field = 'prefval';
364
 
}
365
 
 
366
 
if ( !$use_smtp_tls) {
367
 
        $use_smtp_tls= 'false';
368
 
}
369
 
 
370
 
if ( !$smtp_auth_mech ) {
371
 
        $smtp_auth_mech = 'none';
372
 
}
373
 
 
374
 
if ( !$use_imap_tls ) {
375
 
    $use_imap_tls = 'false';
376
 
}
377
 
 
378
 
if ( !$imap_auth_mech ) {
379
 
    $imap_auth_mech = 'login';
380
 
}
381
 
 
382
 
if (!$session_name ) {
383
 
        $session_name = 'SQMSESSID';
384
 
}
385
 
 
386
 
if (!$show_alternative_names ) {
387
 
        $show_alternative_names = 'false';
388
 
}
389
 
 
390
 
if (!$available_languages ) {
391
 
        $available_languages = 'all';
392
 
}
393
 
 
394
 
if (!$agresive_decoding ) {
395
 
        $agresive_decoding = 'false';
396
 
}
397
 
 
398
 
if (!$advanced_tree ) {
399
 
        $advanced_tree = 'false';
400
 
}
401
 
 
402
 
if (!$oldway ) {
403
 
        $oldway = 'false';
404
 
}
405
 
 
406
 
if (!$use_php_recode ) {
407
 
        $use_php_recode = 'false';
408
 
}
409
 
 
410
 
if (!$use_php_iconv ) {
411
 
        $use_php_iconv = 'false';
412
 
}
 
275
 
 
276
# Default values used when option is missing
 
277
$useSendmail = "false"                 if ( lc($useSendmail) ne "true" );
 
278
$sendmail_path = "/usr/sbin/sendmail"  if ( !$sendmail_path );
 
279
$pop_before_smtp = "false"             if ( !$pop_before_smtp ) ;
 
280
$default_unseen_notify = 2             if ( !$default_unseen_notify );
 
281
$default_unseen_type = 1               if ( !$default_unseen_type );
 
282
$config_use_color = 0                  if ( !$config_use_color );
 
283
$invert_time = "false"                 if ( !$invert_time );
 
284
$force_username_lowercase = "false"    if ( !$force_username_lowercase );
 
285
$optional_delimiter = "detect"         if ( !$optional_delimiter );
 
286
$auto_create_special = "false"         if ( !$auto_create_special );
 
287
$default_use_priority = "true"         if ( !$default_use_priority );
 
288
$hide_sm_attributions = "false"        if ( !$hide_sm_attributions );
 
289
$default_use_mdn = "true"              if ( !$default_use_mdn );
 
290
$delete_folder = "false"               if ( !$delete_folder );
 
291
$noselect_fix_enable = "false"         if ( !$noselect_fix_enable );
 
292
$frame_top = "_top"                    if ( !$frame_top );
 
293
 
 
294
$provider_uri = "http://www.squirrelmail.org/" if ( !$provider_uri );
 
295
$provider_name = "SquirrelMail"        if ( !$provider_name );
 
296
 
 
297
$edit_identity = "true"                if ( !$edit_identity );
 
298
$edit_name = "true"                    if ( !$edit_name );
 
299
$allow_thread_sort = 'false'           if ( !$allow_thread_sort ) ;
 
300
$allow_server_sort = 'false'           if ( !$allow_server_sort );
 
301
$uid_support = 'true'                  if ( !$uid_support );
 
302
$no_list_for_subscribe = 'false'       if ( !$no_list_for_subscribe );
 
303
$allow_charset_search = 'true'         if ( !$allow_charset_search );
 
304
 
 
305
$prefs_user_field = 'user'             if ( !$prefs_user_field );
 
306
$prefs_key_field = 'prefkey'           if ( !$prefs_key_field );
 
307
$prefs_val_field = 'prefval'           if ( !$prefs_val_field );
 
308
 
 
309
$use_smtp_tls= 'false'                 if ( !$use_smtp_tls);
 
310
$smtp_auth_mech = 'none'               if ( !$smtp_auth_mech );
 
311
 
 
312
$use_imap_tls = 'false'                if ( !$use_imap_tls );
 
313
$imap_auth_mech = 'login'              if ( !$imap_auth_mech );
 
314
 
 
315
$session_name = 'SQMSESSID'            if (!$session_name );
 
316
 
 
317
$default_use_javascript_addr_book = 'false' if (! $default_use_javascript_addr_book);
 
318
 
 
319
# Added in 1.4.4
 
320
$lossy_encoding = 'false'               if ( !$lossy_encoding );
 
321
$addrbook_global_table = 'global_abook' if ( !$addrbook_global_table );
 
322
$addrbook_global_writeable = 'false'    if ( !$addrbook_global_writeable );
 
323
$addrbook_global_listing = 'false'      if ( !$addrbook_global_listing );
 
324
$abook_global_file = ''                 if ( !$abook_global_file);
 
325
$abook_global_file_writeable = 'false'  if ( !$abook_global_file_writeable);
413
326
 
414
327
if ( $ARGV[0] eq '--install-plugin' ) {
415
328
    print "Activating plugin " . $ARGV[1] . "\n";
453
366
        print "3.  Folder Defaults\n";
454
367
        print "4.  General Options\n";
455
368
        print "5.  Themes\n";
456
 
        print "6.  Address Books (LDAP)\n";
 
369
        print "6.  Address Books\n";
457
370
        print "7.  Message of the Day (MOTD)\n";
458
371
        print "8.  Plugins\n";
459
372
        print "9.  Database\n";
460
 
        print "10. Language settings\n"; 
461
 
        print "11. Tweaks\n"; 
 
373
        print "10. Languages\n";
462
374
        print "\n";
463
375
        print "D.  Set pre-defined settings for specific IMAP servers\n";
464
376
        print "\n";
571
483
        print "6.  Allow use of priority       : $WHT$default_use_priority$NRM\n";
572
484
        print "7.  Hide SM attributions        : $WHT$hide_sm_attributions$NRM\n";
573
485
        print "8.  Allow use of receipts       : $WHT$default_use_mdn$NRM\n";
574
 
        print "9. Allow editing of identity   : $WHT$edit_identity$NRM/$WHT$edit_name$NRM\n";
 
486
        print "9.  Allow editing of identity   : $WHT$edit_identity$NRM/$WHT$edit_name$NRM\n";
575
487
        print "10. Allow server thread sort    : $WHT$allow_thread_sort$NRM\n";
576
488
        print "11. Allow server-side sorting   : $WHT$allow_server_sort$NRM\n";
577
489
        print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
578
 
        print "13. PHP session name            : $WHT$session_name$NRM\n";
 
490
        print "13. Enable UID support          : $WHT$uid_support$NRM\n";
 
491
        print "14. PHP session name            : $WHT$session_name$NRM\n";
579
492
        print "\n";
580
493
        print "R   Return to Main Menu\n";
581
494
    } elsif ( $menu == 5 ) {
591
504
        print "\n";
592
505
        print "R   Return to Main Menu\n";
593
506
    } elsif ( $menu == 6 ) {
594
 
        print $WHT. "Address Books (LDAP)\n" . $NRM;
595
 
        print "1.  Change Servers\n";
 
507
        print $WHT. "Address Books\n" . $NRM;
 
508
        print "1.  Change LDAP Servers\n";
596
509
        for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
597
510
            print "    >  $ldap_host[$count]\n";
598
511
        }
599
 
        print
600
 
          "2.  Use Javascript Address Book Search  : $WHT$default_use_javascript_addr_book$NRM\n";
 
512
        print "2.  Use Javascript Address Book Search          : $WHT$default_use_javascript_addr_book$NRM\n";
 
513
        print "3.  Global file address book                    : $WHT$abook_global_file$NRM\n";
 
514
        print "4.  Allow writing into global file address book : $WHT$abook_global_file_writeable$NRM\n";
601
515
        print "\n";
602
516
        print "R   Return to Main Menu\n";
603
517
    } elsif ( $menu == 7 ) {
661
575
        print "\n";
662
576
        print "R   Return to Main Menu\n";
663
577
    } elsif ( $menu == 10 ) {
664
 
        print $WHT. "Language settings\n" . $NRM;
665
 
        print "1.  Default Language                : $WHT$squirrelmail_default_language$NRM\n";
666
 
        print "2.  Default Charset                 : $WHT$default_charset$NRM\n";
667
 
        print "3.  Show alternative language names : $WHT$show_alternative_names$NRM\n";
668
 
        print "4.  Available languages             : $WHT$available_languages$NRM\n";
669
 
        print "5.  Use agresive decoding           : $WHT$agresive_decoding$NRM\n";
670
 
        print "\n";
671
 
        print "R   Return to Main Menu\n";
672
 
    } elsif ( $menu == 11 ) {
673
 
        print $WHT. "Interface tweaks\n" . $NRM;
674
 
        print "1.  Advanced tree            : $WHT$advanced_tree$NRM\n";
675
 
        print "2.  Oldway                   : $WHT$oldway$NRM\n";
676
 
        print "\n";
677
 
        print $WHT. "PHP tweaks\n" . $NRM;
678
 
        print "3.  Use php recode functions : $WHT$use_php_recode$NRM\n";
679
 
        print "4.  Use php iconv functions  : $WHT$use_php_iconv$NRM\n";
680
 
        print "\n";
 
578
        print $WHT. "Language preferences\n" . $NRM;
 
579
        print "1.  Default Language       : $WHT$squirrelmail_default_language$NRM\n";
 
580
        print "2.  Default Charset        : $WHT$default_charset$NRM\n";
 
581
        print "3.  Enable lossy encoding  : $WHT$lossy_encoding$NRM\n";
 
582
        print "\n";
681
583
        print "R   Return to Main Menu\n";
682
584
    }
683
585
    if ( $config_use_color == 1 ) {
684
 
        print "C.  Turn color off\n";
 
586
        print "C   Turn color off\n";
685
587
    } else {
686
 
        print "C.  Turn color on\n";
 
588
        print "C   Turn color on\n";
687
589
    }
688
590
    print "S   Save data\n";
689
591
    print "Q   Quit\n";
725
627
    } else {
726
628
        $saved = 0;
727
629
        if ( $menu == 0 ) {
728
 
            if ( ( $command > 0 ) && ( $command < 12 ) ) {
 
630
            if ( ( $command > 0 ) && ( $command < 11 ) ) {
729
631
                $menu = $command;
730
632
            }
731
633
        } elsif ( $menu == 1 ) {
732
634
            if    ( $command == 1 ) { $org_name                      = command1(); }
733
635
            elsif ( $command == 2 ) { $org_logo                      = command2(); }
734
 
            elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height)  = command2a(); }
735
 
            elsif ( $command == 4 ) { $org_title                     = command3(); }
736
 
            elsif ( $command == 5 ) { $signout_page                  = command4(); }
 
636
            elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height)  = command3(); }
 
637
            elsif ( $command == 4 ) { $org_title                     = command4(); }
 
638
            elsif ( $command == 5 ) { $signout_page                  = command5(); }
737
639
            elsif ( $command == 6 ) { $frame_top                     = command6(); }
738
640
            elsif ( $command == 7 ) { $provider_uri                  = command7(); }
739
641
            elsif ( $command == 8 ) { $provider_name                 = command8(); }
783
685
            elsif ( $command == 17 ) { $delete_folder                  = command215(); }
784
686
            elsif ( $command == 18 ) { $noselect_fix_enable            = command216(); }
785
687
        } elsif ( $menu == 4 ) {
786
 
            if    ( $command == 1 )  { $data_dir                 = command33a(); }
787
 
            elsif ( $command == 2 )  { $attachment_dir           = command33b(); }
788
 
            elsif ( $command == 3 )  { $dir_hash_level           = command33c(); }
789
 
            elsif ( $command == 4 )  { $default_left_size        = command35(); }
790
 
            elsif ( $command == 5 )  { $force_username_lowercase = command36(); }
791
 
            elsif ( $command == 6 )  { $default_use_priority     = command37(); }
792
 
            elsif ( $command == 7 )  { $hide_sm_attributions     = command38(); }
793
 
            elsif ( $command == 8 )  { $default_use_mdn          = command39(); }
794
 
            elsif ( $command == 9 ) { $edit_identity            = command310(); }
795
 
            elsif ( $command == 10 ) { $allow_thread_sort        = command312(); }
796
 
            elsif ( $command == 11 ) { $allow_server_sort        = command313(); }
797
 
            elsif ( $command == 12 ) { $allow_charset_search     = command314(); }
798
 
                        elsif ( $command == 13 ) { $session_name             = command316(); }
 
688
            if    ( $command == 1 )  { $data_dir                 = command31(); }
 
689
            elsif ( $command == 2 )  { $attachment_dir           = command32(); }
 
690
            elsif ( $command == 3 )  { $dir_hash_level           = command33(); }
 
691
            elsif ( $command == 4 )  { $default_left_size        = command34(); }
 
692
            elsif ( $command == 5 )  { $force_username_lowercase = command35(); }
 
693
            elsif ( $command == 6 )  { $default_use_priority     = command36(); }
 
694
            elsif ( $command == 7 )  { $hide_sm_attributions     = command37(); }
 
695
            elsif ( $command == 8 )  { $default_use_mdn          = command38(); }
 
696
            elsif ( $command == 9 )  { $edit_identity            = command39(); }
 
697
            elsif ( $command == 10 ) { $allow_thread_sort        = command310(); }
 
698
            elsif ( $command == 11 ) { $allow_server_sort        = command311(); }
 
699
            elsif ( $command == 12 ) { $allow_charset_search     = command312(); }
 
700
            elsif ( $command == 13 ) { $uid_support              = command313(); }
 
701
            elsif ( $command == 14 ) { $session_name             = command314(); }
799
702
        } elsif ( $menu == 5 ) {
800
703
            if ( $command == 1 ) { command41(); }
801
704
            elsif ( $command == 2 ) { $theme_css = command42(); }
802
705
        } elsif ( $menu == 6 ) {
803
706
            if    ( $command == 1 ) { command61(); }
804
707
            elsif ( $command == 2 ) { command62(); }
 
708
            elsif ( $command == 3 ) { $abook_global_file=command63(); }
 
709
            elsif ( $command == 4 ) { command64(); }
805
710
        } elsif ( $menu == 7 ) {
806
711
            if ( $command == 1 ) { $motd = command71(); }
807
712
        } elsif ( $menu == 8 ) {
820
725
            elsif ( $command == 11 ) { $addrbook_global_listing  = command911(); }
821
726
        } elsif ( $menu == 10 ) {
822
727
            if    ( $command == 1 ) { $squirrelmail_default_language = commandA1(); }
823
 
            elsif ( $command == 2 ) { $default_charset               = commandA2(); }
824
 
            elsif ( $command == 3 ) { $show_alternative_names        = commandA3(); }
825
 
            elsif ( $command == 4 ) { $available_languages           = commandA4(); }
826
 
            elsif ( $command == 5 ) { $agresive_decoding             = commandA5(); }
827
 
        } elsif ( $menu == 11 ) {
828
 
            if    ( $command == 1 ) { $advanced_tree  = commandB1(); }
829
 
            elsif ( $command == 2 ) { $oldway         = commandB2(); }
830
 
            elsif ( $command == 3 ) { $use_php_recode = commandB3(); }
831
 
            elsif ( $command == 4 ) { $use_php_iconv  = commandB4(); }
 
728
            elsif ( $command == 2 ) { $default_charset  = commandA2(); }
 
729
            elsif ( $command == 3 ) { $lossy_encoding   = commandA3(); }
832
730
        }
833
731
    }
834
732
}
835
733
 
 
734
# we exit here
 
735
print "\nExiting conf.pl.\n".
 
736
    "You might want to test your configuration by browsing to\n".
 
737
    "http://your-squirrelmail-location/src/configtest.php\n".
 
738
    "Happy SquirrelMailing!\n\n";
 
739
 
 
740
 
836
741
####################################################################################
837
 
 
 
742
#### Organization preferences ####
838
743
# org_name
839
744
sub command1 {
840
745
    print "We have tried to make the name SquirrelMail as transparent as\n";
853
758
        $new_org_name = $org_name;
854
759
    } else {
855
760
        $new_org_name =~ s/[\r|\n]//g;
856
 
        $new_org_name =~ s/\"/&quot;/g;
 
761
        $new_org_name =~ s/\"/&quot;/g;
857
762
    }
858
763
    return $new_org_name;
859
764
}
868
773
    print "    to use the default logo, use ../images/sm_logo.png\n";
869
774
    print "  - To specify a logo defined outside the SquirrelMail source tree\n";
870
775
    print "    use the absolute URL the webserver would use to include the file\n";
871
 
    print "    e.g. http://some.host.com/images/mylogo.gif or /images/mylogo.jpg\n";
 
776
    print "    e.g. http://www.example.com/images/mylogo.gif or /images/mylogo.jpg\n";
872
777
    print "\n";
873
778
    print "[$WHT$org_logo$NRM]: $WHT";
874
779
    $new_org_logo = <STDIN>;
881
786
}
882
787
 
883
788
# org_logo_width
884
 
sub command2a {
 
789
sub command3 {
885
790
    print "Your organization's logo is an image that will be displayed at\n";
886
791
    print "different times throughout SquirrelMail.  Width\n";
887
792
    print "and Height of your logo image.  Use '0' to disable.\n";
897
802
        $new_org_logo_height = <STDIN>;
898
803
        $new_org_logo_height =~ tr/0-9//cd;  # only want digits!
899
804
        if( $new_org_logo_height eq '' ) {
900
 
                $new_org_logo_height = $org_logo_height;
901
 
        }
 
805
            $new_org_logo_height = $org_logo_height;
 
806
        }
902
807
    } else {
903
808
        $new_org_logo_height = 0;
904
809
    }
906
811
}
907
812
 
908
813
# org_title
909
 
sub command3 {
 
814
sub command4 {
910
815
    print "A title is what is displayed at the top of the browser window in\n";
911
816
    print "the titlebar.  Usually this will end up looking something like:\n";
912
817
    print "\"Netscape: $org_title\"\n";
923
828
        $new_org_title = $org_title;
924
829
    } else {
925
830
        $new_org_title =~ s/[\r|\n]//g;
926
 
        $new_org_title =~ s/\"/\'/g;
 
831
        $new_org_title =~ s/\"/\'/g;
927
832
    }
928
833
    return $new_org_title;
929
834
}
930
835
 
931
836
# signout_page
932
 
sub command4 {
 
837
sub command5 {
933
838
    print "When users click the Sign Out button they will be logged out and\n";
934
839
    print "then sent to signout_page.  If signout_page is left empty,\n";
935
840
    print "(hit space and then return) they will be taken, as normal,\n";
995
900
}
996
901
 
997
902
####################################################################################
998
 
 
 
903
#### Server settings ####
999
904
# domain
1000
905
sub command11 {
1001
906
    print "The domain name is the suffix at the end of all email addresses.  If\n";
1002
 
    print "for example, your email address is jdoe\@myorg.com, then your domain\n";
1003
 
    print "would be myorg.com.\n";
 
907
    print "for example, your email address is jdoe\@example.com, then your domain\n";
 
908
    print "would be example.com.\n";
1004
909
    print "\n";
1005
910
    print "[$WHT$domain$NRM]: $WHT";
1006
911
    $new_domain = <STDIN>;
1107
1012
# authenticated server 
1108
1013
sub command18 {
1109
1014
    return;
1110
 
        # This sub disabled by tassium - it has been replaced with smtp_auth_mech
 
1015
    # This sub disabled by tassium - it has been replaced with smtp_auth_mech
1111
1016
    print "Do you wish to use an authenticated SMTP server?  Your server must\n";
1112
1017
    print "support this in order for SquirrelMail to work with it.  We implemented\n";
1113
1018
    print "it according to RFC 2554.\n";
1149
1054
    print "these servers.  If you would like to use them, please select your\n";
1150
1055
    print "IMAP server.  If you do not wish to use these work-arounds, you can\n";
1151
1056
    print "set this to \"other\", and none will be used.\n";
1152
 
    print "    cyrus      = Cyrus IMAP server\n";
1153
 
    print "    uw         = University of Washington's IMAP server\n";
1154
 
    print "    exchange   = Microsoft Exchange IMAP server\n";
1155
 
    print "    courier    = Courier IMAP server\n";
1156
 
    print "    macosx     = Mac OS X Mailserver\n";
1157
 
    print "    other      = Not one of the above servers\n";
 
1057
    print "    cyrus       = Cyrus IMAP server\n";
 
1058
    print "    uw          = University of Washington's IMAP server\n";
 
1059
    print "    exchange    = Microsoft Exchange IMAP server\n";
 
1060
    print "    courier     = Courier IMAP server\n";
 
1061
    print "    macosx      = Mac OS X Mailserver\n";
 
1062
    print "    hmailserver = hMailServer\n";
 
1063
    print "    other       = Not one of the above servers\n";
1158
1064
    print "[$WHT$imap_server_type$NRM]: $WHT";
1159
1065
    $new_imap_server_type = <STDIN>;
1160
1066
 
1208
1114
    return $new_optional_delimiter;
1209
1115
}
1210
1116
# IMAP authentication type
1211
 
# Possible values: login, plain, cram-md5, digest-md5
 
1117
# Possible values: login, cram-md5, digest-md5
1212
1118
# Now offers to detect supported mechs, assuming server & port are set correctly
1213
1119
 
1214
1120
sub command112a {
1215
1121
    if ($use_imap_tls =~ /^true\b/i) {
1216
1122
        print "Auto-detection of login methods is unavailable when using TLS.\n";
1217
1123
    } else {
1218
 
        print "If you have already set the hostname and port number, I can try to\n";
1219
 
        print "detect the mechanisms your IMAP server supports.\n";
1220
 
        print "I will try to detect CRAM-MD5 and DIGEST-MD5 support.  I can't test\n";
1221
 
        print "for \"login\" or \"plain\" without knowing a username and password.\n";
1222
 
        print "Auto-detecting is optional - you can safely say \"n\" here.\n";
1223
 
        print "\nTry to detect supported mechanisms? [y/N]: ";
1224
 
        $inval=<STDIN>;
1225
 
        chomp($inval);
1226
 
        if ($inval =~ /^y\b/i) {
1227
 
          # Yes, let's try to detect.
1228
 
          print "Trying to detect IMAP capabilities...\n";
1229
 
          my $host = $imapServerAddress . ':'. $imapPort;
1230
 
          print "CRAM-MD5:\t";
1231
 
          my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5');
1232
 
          if (defined($tmp)) {
1233
 
                  if ($tmp eq 'YES') {
1234
 
                        print "$WHT SUPPORTED$NRM\n";
1235
 
                  } else {
1236
 
                    print "$WHT NOT SUPPORTED$NRM\n";
1237
 
                  }
 
1124
        print "If you have already set the hostname and port number, I can try to\n";
 
1125
        print "detect the mechanisms your IMAP server supports.\n";
 
1126
        print "I will try to detect CRAM-MD5 and DIGEST-MD5 support.  I can't test\n";
 
1127
        print "for \"login\" without knowing a username and password.\n";
 
1128
        print "Auto-detecting is optional - you can safely say \"n\" here.\n";
 
1129
        print "\nTry to detect supported mechanisms? [y/N]: ";
 
1130
        $inval=<STDIN>;
 
1131
        chomp($inval);
 
1132
        if ($inval =~ /^y\b/i) {
 
1133
          # Yes, let's try to detect.
 
1134
          print "Trying to detect IMAP capabilities...\n";
 
1135
          my $host = $imapServerAddress . ':'. $imapPort;
 
1136
          print "CRAM-MD5:\t";
 
1137
          my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5');
 
1138
          if (defined($tmp)) {
 
1139
              if ($tmp eq 'YES') {
 
1140
                  print "$WHT SUPPORTED$NRM\n";
 
1141
              } else {
 
1142
                print "$WHT NOT SUPPORTED$NRM\n";
 
1143
              }
1238
1144
          } else {
1239
 
            print $WHT . " ERROR DETECTING$NRM\n";
1240
 
          }
 
1145
            print $WHT . " ERROR DETECTING$NRM\n";
 
1146
          }
1241
1147
 
1242
 
          print "DIGEST-MD5:\t";
1243
 
          $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5');
1244
 
          if (defined($tmp)) {
1245
 
                if ($tmp eq 'YES') {
1246
 
                        print "$WHT SUPPORTED$NRM\n";
1247
 
                } else {
1248
 
                        print "$WHT NOT SUPPORTED$NRM\n";
1249
 
                }
1250
 
          } else {
1251
 
            print $WHT . " ERROR DETECTING$NRM\n";
1252
 
          }
1253
 
          
1254
 
        }
1255
 
    } 
1256
 
          print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
1257
 
          print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1258
 
      print $WHT . "plain" . $NRM . " - SASL PLAIN. If you need this, you already know it.\n";
1259
 
          print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
1260
 
          print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1261
 
          print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
1262
 
          print "If you don't understand or are unsure, you probably want \"login\"\n\n";
1263
 
          print "login, plain, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
 
1148
          print "DIGEST-MD5:\t";
 
1149
          $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5');
 
1150
          if (defined($tmp)) {
 
1151
              if ($tmp eq 'YES') {
 
1152
                print "$WHT SUPPORTED$NRM\n";
 
1153
            } else {
 
1154
                print "$WHT NOT SUPPORTED$NRM\n";
 
1155
            }
 
1156
          } else {
 
1157
            print $WHT . " ERROR DETECTING$NRM\n";
 
1158
          }
 
1159
      
 
1160
        } 
 
1161
    }
 
1162
      print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
 
1163
      print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
 
1164
      print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
 
1165
      print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
 
1166
      print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
 
1167
      print "If you don't understand or are unsure, you probably want \"login\"\n\n";
 
1168
      print "login, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
1264
1169
      $inval=<STDIN>;
1265
1170
      chomp($inval);
1266
 
      if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
 
1171
      if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i)) {
1267
1172
        return lc($inval);
1268
1173
      } else {
1269
1174
        # user entered garbage or default value so nothing needs to be set
1271
1176
      }
1272
1177
}
1273
1178
 
1274
 
        
 
1179
    
1275
1180
# SMTP authentication type
1276
1181
# Possible choices: none, plain, cram-md5, digest-md5
1277
1182
sub command112b {
1279
1184
        print "Auto-detection of login methods is unavailable when using TLS.\n";
1280
1185
    } else {
1281
1186
        print "If you have already set the hostname and port number, I can try to\n";
1282
 
        print "automatically detect some of the mechanisms your SMTP server supports.\n";
1283
 
        print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
 
1187
        print "automatically detect the mechanisms your SMTP server supports.\n";
 
1188
        print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
1284
1189
        print "\nTry to detect auth mechanisms? [y/N]: ";
1285
1190
        $inval=<STDIN>;
1286
1191
        chomp($inval);
1287
1192
        if ($inval =~ /^y\b/i) {
1288
 
                # Yes, let's try to detect.
1289
 
                print "Trying to detect supported methods (SMTP)...\n";
1290
 
                
1291
 
                # Special case!
1292
 
                # Check none by trying to relay to junk@microsoft.com
1293
 
                $host = $smtpServerAddress . ':' . $smtpPort;
1294
 
                use IO::Socket;
1295
 
                my $sock = IO::Socket::INET->new($host);
1296
 
                print "Testing none:\t\t$WHT";
1297
 
                if (!defined($sock)) {
1298
 
                        print " ERROR TESTING\n";
1299
 
                        close $sock;
1300
 
                } else {
1301
 
                        print $sock "mail from: tester\@squirrelmail.org\n";
1302
 
                        $got = <$sock>;  # Discard
1303
 
                        print $sock "rcpt to: junk\@microsoft.com\n";
1304
 
                        $got = <$sock>;  # This is the important line
1305
 
                        if ($got =~ /^250\b/) {  # SMTP will relay without auth
1306
 
                                print "SUPPORTED$NRM\n";
1307
 
                } else {
1308
 
                          print "NOT SUPPORTED$NRM\n";
1309
 
                }
1310
 
                        print $sock "rset\n";
1311
 
                        print $sock "quit\n";
1312
 
                        close $sock;
1313
 
                }
1314
 
                # Try login (SquirrelMail default)
1315
 
                print "Testing login:\t\t";
1316
 
                $tmp=detect_auth_support('SMTP',$host,'LOGIN');
1317
 
                if (defined($tmp)) {
1318
 
                if ($tmp eq 'YES') {
1319
 
                        print $WHT . "SUPPORTED$NRM\n";
1320
 
                } else {
1321
 
                        print $WHT . "NOT SUPPORTED$NRM\n";
1322
 
                }
1323
 
              } else {
1324
 
                          print $WHT . "ERROR DETECTING$NRM\n";
1325
 
                }
 
1193
            # Yes, let's try to detect.
 
1194
            print "Trying to detect supported methods (SMTP)...\n";
 
1195
        
 
1196
            # Special case!
 
1197
            # Check none by trying to relay to junk@microsoft.com
 
1198
            $host = $smtpServerAddress . ':' . $smtpPort;
 
1199
            use IO::Socket;
 
1200
            my $sock = IO::Socket::INET->new($host);
 
1201
            print "Testing none:\t\t$WHT";
 
1202
            if (!defined($sock)) {
 
1203
                print " ERROR TESTING\n";
 
1204
                close $sock;
 
1205
            } else {
 
1206
                print $sock "HELO $domain\r\n";
 
1207
                $got = <$sock>;  # Discard
 
1208
                print $sock "MAIL FROM:<tester\@squirrelmail.org>\r\n";
 
1209
                $got = <$sock>;  # Discard
 
1210
                print $sock "RCPT TO:<junk\@microsoft.com>\r\n";
 
1211
                $got = <$sock>;  # This is the important line
 
1212
                if ($got =~ /^250\b/) {  # SMTP will relay without auth
 
1213
                    print "SUPPORTED$NRM\n";
 
1214
                } else {
 
1215
                  print "NOT SUPPORTED$NRM\n";
 
1216
                }
 
1217
                print $sock "RSET\r\n";
 
1218
                print $sock "QUIT\r\n";
 
1219
                close $sock;
 
1220
            }
 
1221
            # Try login (SquirrelMail default)
 
1222
            print "Testing login:\t\t";
 
1223
            $tmp=detect_auth_support('SMTP',$host,'LOGIN');
 
1224
            if (defined($tmp)) {
 
1225
                if ($tmp eq 'YES') {
 
1226
                    print $WHT . "SUPPORTED$NRM\n";
 
1227
                } else {
 
1228
                    print $WHT . "NOT SUPPORTED$NRM\n";
 
1229
                }
 
1230
              } else {
 
1231
                  print $WHT . "ERROR DETECTING$NRM\n";
 
1232
              }
1326
1233
    
1327
 
                # Try CRAM-MD5
 
1234
            # Try CRAM-MD5
1328
1235
            print "Testing CRAM-MD5:\t";
1329
1236
            $tmp=detect_auth_support('SMTP',$host,'CRAM-MD5');
1330
1237
            if (defined($tmp)) {
1354
1261
    print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
1355
1262
    print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
1356
1263
    print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1357
 
    print $WHT . "plain" . $NRM . " - SASL PLAIN.  You already know it if you need this.\n";
1358
1264
    print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
1359
1265
    print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1360
1266
    print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
1367
1273
      return "none";
1368
1274
    }
1369
1275
    if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || 
1370
 
    ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
 
1276
    ($inval =~ /^login\b/i)) {
1371
1277
      return lc($inval);
1372
1278
    } else {
1373
1279
      # user entered garbage, or default value so nothing needs to be set
1374
 
          return $smtp_auth_mech;
 
1280
      return $smtp_auth_mech;
1375
1281
    }
1376
1282
}
1377
1283
 
1379
1285
# This sub is reused for IMAP and SMTP
1380
1286
# Args: service name, default value
1381
1287
sub command113 {
1382
 
        my($default_val,$service,$inval);
1383
 
        $service=$_[0];
1384
 
        $default_val=$_[1];
1385
 
        print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
1386
 
        print "If you're familiar with SSL, you get the idea.\n";
1387
 
        print "To use this feature, your " . $service . " server must offer TLS\n";
1388
 
        print "capability, plus PHP 4.3.x with OpenSSL support.\n";
1389
 
        print "\nIf your " . $service . " server is localhost, you can safely disable this.\n";
1390
 
        print "If it is remote, you may wish to seriously consider enabling this.\n";
 
1288
    my($default_val,$service,$inval);
 
1289
    $service=$_[0];
 
1290
    $default_val=$_[1];
 
1291
    print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
 
1292
    print "If you're familiar with SSL, you get the idea.\n";
 
1293
    print "To use this feature, your " . $service . " server must offer TLS\n";
 
1294
    print "capability, plus PHP 4.3.x with OpenSSL support.\n";
 
1295
    print "\nIf your " . $service . " server is localhost, you can safely disable this.\n";
 
1296
    print "If it is remote, you may wish to seriously consider enabling this.\n";
1391
1297
    print "Enable TLS (y/n) [$WHT";
1392
1298
    if ($default_val eq "true") {
1393
1299
      print "y";
1404
1310
 
1405
1311
}
1406
1312
 
1407
 
 
1408
 
# MOTD
 
1313
####################################################################################
 
1314
#### MOTD ####
1409
1315
sub command71 {
1410
1316
    print "\nYou can now create the welcome message that is displayed\n";
1411
1317
    print "every time a user logs on.  You can use HTML or just plain\n";
1412
1318
    print
1413
 
"text.  If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
 
1319
"text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
1414
1320
 
1415
1321
    $new_motd = "";
1416
1322
    do {
1429
1335
    return $new_motd;
1430
1336
}
1431
1337
 
1432
 
################# PLUGINS ###################
1433
 
 
 
1338
####################################################################################
 
1339
#### PLUGINS ####
1434
1340
sub command81 {
1435
1341
    $command =~ s/[\s|\n|\r]*//g;
1436
1342
    if ( $command > 0 ) {
1461
1367
    return @plugins;
1462
1368
}
1463
1369
 
1464
 
################# FOLDERS ###################
1465
 
 
 
1370
####################################################################################
 
1371
#### FOLDERS #####
1466
1372
# default_folder_prefix
1467
1373
sub command21 {
1468
1374
    print "Some IMAP servers (UW, for example) store mail and folders in\n";
1849
1755
 
1850
1756
# Automatically delete folders 
1851
1757
sub command215 {
1852
 
    if ( $imap_server_type eq "uw" ) {
1853
 
        print "UW IMAP servers will not allow folders containing mail to also contain folders.\n";
1854
 
        print "Deleting folders will bypass the trash folder and be immediately deleted\n\n";
 
1758
    if ( $imap_server_type == "courier" ) {
 
1759
        print "Courier(or Courier-IMAP) IMAP servers do not support ";
 
1760
        print "subfolders of Trash. \n";
 
1761
        print "Deleting folders will bypass the trash folder and ";
 
1762
        print "be immediately deleted.\n\n";
 
1763
        print "If this is not the correct value for your server,\n";
 
1764
        print "please use option D on the Main Menu to configure your server correctly.\n\n";
 
1765
        print "Press any key to continue...\n";
 
1766
        $new_delete = <STDIN>;
 
1767
        $delete_folder = "true";
 
1768
    } elsif ( $imap_server_type == "uw" ) {
 
1769
        print "UW IMAP servers will not allow folders containing";
 
1770
        print "mail to also contain folders.\n";
 
1771
        print "Deleting folders will bypass the trash folder and";
 
1772
        print "be immediately deleted\n\n";
1855
1773
        print "If this is not the correct value for your server,\n";
1856
1774
        print "please use option D on the Main Menu to configure your server correctly.\n\n";
1857
1775
        print "Press any key to continue...\n";
1858
1776
        $new_delete = <STDIN>;
1859
1777
        $delete_folder = "true";
1860
1778
    } else { 
1861
 
        if ( $imap_server_type eq "courier" ) {
1862
 
            print "Courier (or Courier-IMAP) IMAP servers may not support ";
1863
 
            print "subfolders of Trash. \n";
1864
 
            print "Specifically, if Courier is set to always move messages to Trash, \n";
1865
 
            print "Trash will be treated by Courier as a special folder that does not \n";
1866
 
            print "allow subfolders. \n\n";
1867
 
            print "Please verify your Courier configuration, and test folder deletion \n";
1868
 
            print "when changing this setting.\n\n";                                                             
1869
 
        }
1870
 
 
1871
 
        print "Are subfolders of the Trash supported by your IMAP server?\n";
1872
 
        print "If so, should deleted folders be sent to Trash?\n";
1873
 
        print "If not, say no (deleted folders should not be sent to Trash)\n\n";
1874
 
        # reversal of logic.
1875
 
        # question was: Should folders be automatically deleted instead of sent to trash..
1876
 
        # we've changed the question to make it more clear, 
1877
 
        # and are here handling that to avoid changing the answers.. 
 
1779
        print "Should folders selected for deletion bypass the Trash folder?\n\n";
1878
1780
        if ( lc($delete_folder) eq "true" ) {
 
1781
            $default_value = "y";
 
1782
        } else {
1879
1783
            $default_value = "n";
1880
 
        } else {
1881
 
            $default_value = "y";
1882
1784
        }
1883
 
        print "Send deleted folders to Trash? (y/n) [$WHT$default_value$NRM]: $WHT";
 
1785
        print "Auto delete folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1884
1786
        $new_delete = <STDIN>;
1885
1787
        if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
 
1788
            $delete_folder = "true";
 
1789
        } else {
1886
1790
            $delete_folder = "false";
1887
 
        } else {
1888
 
            $delete_folder = "true";
1889
1791
        }
1890
1792
    }
1891
1793
    return $delete_folder;
1912
1814
    }
1913
1815
    return $noselect_fix_enable;
1914
1816
}
1915
 
############# GENERAL OPTIONS #####################
1916
1817
 
 
1818
####################################################################################
 
1819
#### GENERAL OPTIONS ####
1917
1820
# Data directory
1918
 
sub command33a {
 
1821
sub command31 {
1919
1822
    print "Specify the location for your data directory.\n";
1920
1823
    print "The path name can be absolute or relative (to the config directory).\n";
1921
1824
    print "It doesn't matter.  Here are two examples:\n";
1923
1826
    print "  Relative:    ../data/\n";     
1924
1827
    print "Relative paths to directories outside of the SquirrelMail distribution\n";
1925
1828
    print "will be converted to their absolute path equivalents in config.php.\n\n";
1926
 
    print "Note: There are potential security risks with having a writeable directory\n";
 
1829
    print "Note: There are potential security risks with having a writable directory\n";
1927
1830
    print "under the web server's root directory (ex: /home/httpd/html).\n";
1928
1831
    print "For this reason, it is recommended to put the data directory\n";
1929
1832
    print "in an alternate location of your choice. \n";
1946
1849
}
1947
1850
 
1948
1851
# Attachment directory
1949
 
sub command33b {
 
1852
sub command32 {
1950
1853
    print "Path to directory used for storing attachments while a mail is\n";
1951
1854
    print "being sent. The path name can be absolute or relative (to the config directory).\n";
1952
1855
    print "It doesn't matter.  Here are two examples:\n";
1985
1888
    return $new_attachment_dir;
1986
1889
}
1987
1890
 
1988
 
sub command33c {
 
1891
sub command33 {
1989
1892
    print "The directory hash level setting allows you to configure the level\n";
1990
1893
    print "of hashing that Squirremail employs in your data and attachment\n";
1991
1894
    print "directories. This value must be an integer ranging from 0 to 4.\n";
2021
1924
    return $new_dir_hash_level;
2022
1925
}
2023
1926
 
2024
 
sub command35 {
 
1927
sub command34 {
2025
1928
    print "This is the default size (in pixels) of the left folder list.\n";
2026
 
    print "Default is 200, but you can set it to whatever you wish.  This\n";
 
1929
    print "Default is 150, but you can set it to whatever you wish.  This\n";
2027
1930
    print "is a user preference, so this will only show up as their default.\n";
2028
1931
    print "\n";
2029
1932
    print "[$WHT$default_left_size$NRM]: $WHT";
2036
1939
    return $new_default_left_size;
2037
1940
}
2038
1941
 
2039
 
sub command36 {
 
1942
sub command35 {
2040
1943
    print "Some IMAP servers only have lowercase letters in the usernames\n";
2041
1944
    print "but they still allow people with uppercase to log in.  This\n";
2042
1945
    print "causes a problem with the user's preference files.  This option\n";
2056
1959
    return "false";
2057
1960
}
2058
1961
 
2059
 
sub command37 {
 
1962
sub command36 {
2060
1963
    print "";
2061
1964
    print "\n";
2062
1965
 
2074
1977
    return "false";
2075
1978
}
2076
1979
 
2077
 
sub command38 {
 
1980
sub command37 {
2078
1981
    print "";
2079
1982
    print "\n";
2080
1983
 
2092
1995
    return "false";
2093
1996
}
2094
1997
 
2095
 
sub command39 {
 
1998
sub command38 {
2096
1999
    print "";
2097
2000
    print "\n";
2098
2001
 
2110
2013
    return "false";
2111
2014
}
2112
2015
 
2113
 
sub command310 {
 
2016
sub command39 {
2114
2017
    print "This allows you to prevent the editing of the user's name and ";
2115
2018
    print "email address. This is mainly useful when used with the ";
2116
2019
    print "retrieveuserdata plugin\n";
2128
2031
        $edit_name = "true";
2129
2032
    } else {
2130
2033
        $edit_identity = "false";
2131
 
        $edit_name = command311();
 
2034
        $edit_name = command39a();
2132
2035
    }
2133
2036
    return $edit_identity;
2134
2037
}
2135
2038
 
2136
 
sub command311 {
 
2039
sub command39a {
2137
2040
    print "As a follow-up, this option allows you to choose if the user ";
2138
2041
    print "can edit their full name even when you don't want them to ";
2139
2042
    print "change their username\n";
2154
2057
    return $edit_name;
2155
2058
}
2156
2059
 
2157
 
sub command312 {
 
2060
sub command310 {
2158
2061
    print "This option allows you to choose if users can use thread sorting\n";
2159
2062
    print "Your IMAP server must support the THREAD command for this to work\n";
2160
 
        print "PHP versions later than 4.0.3 recommended\n";
 
2063
    print "PHP versions later than 4.0.3 recommended\n";
2161
2064
    print "\n";
2162
2065
 
2163
2066
    if ( lc($allow_thread_sort) eq "true" ) {
2175
2078
    return $allow_thread_sort;
2176
2079
}
2177
2080
 
2178
 
sub command313 {
 
2081
sub command311 {
2179
2082
    print "This option allows you to choose if SM uses server-side sorting\n";
2180
2083
    print "Your IMAP server must support the SORT  command for this to work\n";
2181
2084
    print "\n";
2195
2098
    return $allow_server_sort;
2196
2099
}
2197
2100
 
2198
 
sub command314 {
 
2101
sub command312 {
2199
2102
    print "This option allows you to choose if SM uses charset search\n";
2200
2103
    print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
2201
2104
    print "\n";
2215
2118
    return $allow_charset_search;
2216
2119
}
2217
2120
 
2218
 
sub command315 {
2219
 
    ## OBSOLETE - UID support is now always enabled
2220
 
    return "true";
 
2121
sub command313 {
2221
2122
    print "This option allows you to enable unique identifier (UID) support.\n";
2222
2123
    print "\n";
2223
2124
 
2236
2137
    return $uid_support;
2237
2138
}
2238
2139
 
2239
 
sub command316 {
2240
 
        print "This option allows you to change the name of the PHP session used\n";
2241
 
        print "by SquirrelMail.  Unless you know what you are doing, you probably\n";
2242
 
        print "don't need or want to change this from the default of SQMSESSID.\n";
 
2140
sub command314 {
 
2141
    print "This option allows you to change the name of the PHP session used\n";
 
2142
    print "by SquirrelMail.  Unless you know what you are doing, you probably\n";
 
2143
    print "don't need or want to change this from the default of SQMSESSID.\n";
2243
2144
    print "[$WHT$session_name$NRM]: $WHT";
2244
2145
    $new_session_name = <STDIN>;
2245
 
        chomp($new_session_name);
 
2146
    chomp($new_session_name);
2246
2147
    if ( $new_session_name eq "" ) {
2247
2148
        $new_session_name = $session_name;
2248
2149
    }
2249
2150
    return $new_session_name;
2250
2151
}
2251
2152
 
2252
 
 
2253
 
 
 
2153
####################################################################################
 
2154
#### THEMES ####
2254
2155
sub command41 {
2255
2156
    print "\nDefine the themes that you wish to use.  If you have added ";
2256
2157
    print "a theme of your own, just follow the instructions (?) about how to add ";
2407
2308
    print "    to use the themes directory, use ../themes/css/newdefault.css\n";
2408
2309
    print "  - To specify a css file defined outside the SquirrelMail source tree\n";
2409
2310
    print "    use the absolute URL the webserver would use to include the file\n";
2410
 
    print "    e.g. http://some.host.com/css/mystyle.css or /css/mystyle.css\n";
 
2311
    print "    e.g. http://www.example.com/css/mystyle.css or /css/mystyle.css\n";
2411
2312
    print "\n";
2412
2313
    print "[$WHT$theme_css$NRM]: $WHT";
2413
2314
    $new_theme_css = <STDIN>;
2420
2321
    $new_theme_css =~ s/^\s*//;
2421
2322
    return $new_theme_css;
2422
2323
}
2423
 
 
 
2324
####################################################################################
 
2325
#### Address books ####
 
2326
# LDAP
2424
2327
sub command61 {
2425
2328
    print "You can now define different LDAP servers.\n";
2426
2329
    print "[ldap] command (?=help) > ";
2450
2353
                        print "      bindpw: $ldap_bindpw[$count]\n";
2451
2354
                    }
2452
2355
                }
2453
 
                if ( $ldap_protocol[$count] ) {
 
2356
        if ( $ldap_protocol[$count] ) {
2454
2357
                    print "    protocol: $ldap_protocol[$count]\n";
2455
2358
                }
2456
2359
 
2535
2438
                print "\n";
2536
2439
            }
2537
2440
 
2538
 
            print "You can specify bind protocol version here.\n";
 
2441
        print "You can specify bind protocol version here.\n";
2539
2442
            print "Default protocol version depends on your php ldap settings.\n";
2540
 
            print "Press ENTER for default.\n";
 
2443
        print "Press ENTER for default.\n";
2541
2444
            print "protocol: ";
2542
2445
            $name = <STDIN>;
2543
2446
            $name =~ s/[\r|\n]//g;
2587
2490
            @ldap_binddn  = @new_ldap_binddn;
2588
2491
            @ldap_bindpw  = @new_ldap_bindpw;
2589
2492
            @ldap_protocol = @new_ldap_protocol;
2590
 
 
2591
2493
        } elsif ( $input =~ /^\s*\?\s*/ ) {
2592
2494
            print ".-------------------------.\n";
2593
2495
            print "| +            (add host) |\n";
2602
2504
    }
2603
2505
}
2604
2506
 
 
2507
# Javascript or html address book
2605
2508
sub command62 {
2606
2509
    print "Some of our developers have come up with very good javascript interface\n";
2607
2510
    print "for searching through address books, however, our original goals said\n";
2629
2532
    return $default_use_javascript_addr_book;
2630
2533
}
2631
2534
 
 
2535
# global filebased address book
 
2536
sub command63 {
 
2537
    print "If you want to use global file address book, then you\n";
 
2538
    print "must set this option to a valid value. If option does\n";
 
2539
    print "not have path elements, system assumes that file is\n";
 
2540
    print "stored in data directory. If relative path is set, it is\n";
 
2541
    print "relative to main squirrelmail directory. If value is empty,\n";
 
2542
    print "address book is not enabled.\n";
 
2543
    print "\n";
 
2544
 
 
2545
    print "[$WHT$abook_global_file$NRM]: $WHT";
 
2546
    $new_abook_global_file = <STDIN>;
 
2547
    if ( $new_abook_global_file eq "\n" ) {
 
2548
        $new_abook_global_file = $abook_global_file;
 
2549
    } else {
 
2550
        $new_abook_global_file =~ s/[\r\n]//g;
 
2551
    }
 
2552
    return $new_abook_global_file;
 
2553
}
 
2554
 
 
2555
# writing into global filebased abook control
 
2556
sub command64 {
 
2557
    print "This setting controls writing into global file address\n";
 
2558
    print "book options. Address book file must be writeable by\n";
 
2559
    print "webserver's user, if you want to enable this option.\n";
 
2560
    print "\n";
 
2561
 
 
2562
    if ( lc($abook_global_file_writeable) eq 'true' ) {
 
2563
        $default_value = "y";
 
2564
    } else {
 
2565
        $abook_global_file_writeable = 'false';
 
2566
        $default_value               = "n";
 
2567
    }
 
2568
    print "Allow writing into global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
 
2569
    $new_show = <STDIN>;
 
2570
    if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
 
2571
        $abook_global_file_writeable = 'true';
 
2572
    } else {
 
2573
        $abook_global_file_writeable = 'false';
 
2574
    }
 
2575
    return $abook_global_file_writeable;
 
2576
}
 
2577
 
 
2578
####################################################################################
 
2579
#### Database ####
2632
2580
sub command91 {
2633
2581
    print "If you want to store your users address book details in a database then\n";
2634
2582
    print "you need to set this DSN to a valid value. The format for this is:\n";
2773
2721
    if ( $new_dsn eq "\n" ) {
2774
2722
        $new_dsn = "";
2775
2723
    } else {
2776
 
        $new_dsn =~ s/[\r|\n]//g;
 
2724
        $new_dsn =~ s/[\r\n]//g;
2777
2725
        $new_dsn =~ s/^\s+$//g;
2778
2726
    }
2779
2727
    return $new_dsn;
2781
2729
 
2782
2730
sub command99 {
2783
2731
    print "This is the name of the table you want to store the global address book\n";
2784
 
    print "data in, it defaults to 'global_address'\n";
 
2732
    print "data in. Default table name is 'global_abook'. Address book uses same\n";
 
2733
    print "database format as personal address book.\n";
2785
2734
    print "\n";
2786
2735
    print "[$WHT$addrbook_global_table$NRM]: $WHT";
2787
2736
    $new_table = <STDIN>;
2788
2737
    if ( $new_table eq "\n" ) {
2789
2738
        $new_table = $addrbook_global_table;
2790
2739
    } else {
2791
 
        $new_table =~ s/[\r|\n]//g;
 
2740
        $new_table =~ s/[\r\n]//g;
2792
2741
    }
2793
2742
    return $new_table;
2794
2743
}
2797
2746
    print "This option controls users\' ability to add or modify records stored \n";
2798
2747
    print "in global address book\n";
2799
2748
 
2800
 
    if ( lc($addrbook_global_writeable) eq "true" ) {
 
2749
    if ( lc($addrbook_global_writeable) eq 'true' ) {
2801
2750
        $default_value = "y";
2802
2751
    } else {
2803
2752
        $default_value = "n";
2805
2754
    print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
2806
2755
    $addrbook_global_writeable = <STDIN>;
2807
2756
    if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2808
 
        $addrbook_global_writeable = "true";
 
2757
        $addrbook_global_writeable = 'true';
2809
2758
    } else {
2810
 
        $addrbook_global_writeable = "false";
 
2759
        $addrbook_global_writeable = 'false';
2811
2760
    }
2812
2761
    return $addrbook_global_writeable;
2813
2762
}
2816
2765
    print "Enable this option if you want to see listing of addresses stored \n";
2817
2766
    print "in global address book\n";
2818
2767
 
2819
 
    if ( lc($addrbook_global_listing) eq "true" ) {
 
2768
    if ( lc($addrbook_global_listing) eq 'true' ) {
2820
2769
        $default_value = "y";
2821
2770
    } else {
2822
2771
        $default_value = "n";
2824
2773
    print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
2825
2774
    $addrbook_global_listing = <STDIN>;
2826
2775
    if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2827
 
        $addrbook_global_listing = "true";
 
2776
        $addrbook_global_listing = 'true';
2828
2777
    } else {
2829
 
        $addrbook_global_listing = "false";
 
2778
        $addrbook_global_listing = 'false';
2830
2779
    }
2831
2780
    return $addrbook_global_listing;
2832
2781
}
2833
2782
 
2834
2783
 
 
2784
####################################################################################
 
2785
#### Languages ####
2835
2786
# Default language
2836
2787
sub commandA1 {
2837
2788
    print "SquirrelMail attempts to set the language in many ways.  If it\n";
2839
2790
    print "language.  Please use the code for the desired language.\n";
2840
2791
    print "\n";
2841
2792
    print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
2842
 
    $new_squirrelmail_default_language = <STDIN>;
2843
 
    if ( $new_squirrelmail_default_language eq "\n" ) {
2844
 
        $new_squirrelmail_default_language = $squirrelmail_default_language;
 
2793
    $new_language = <STDIN>;
 
2794
    if ( $new_language eq "\n" ) {
 
2795
        $new_language = $squirrelmail_default_language;
2845
2796
    } else {
2846
 
        $new_squirrelmail_default_language =~ s/[\r|\n]//g;
2847
 
        $new_squirrelmail_default_language =~ s/^\s+$//g;
 
2797
        $new_language =~ s/[\r|\n]//g;
 
2798
        $new_language =~ s/^\s+$//g;
2848
2799
    }
2849
 
    return $new_squirrelmail_default_language;
 
2800
    return $new_language;
2850
2801
}
 
2802
 
2851
2803
# Default Charset
2852
2804
sub commandA2 {
2853
 
#    print "This option controls what character set is used when sending\n";
2854
 
#    print "mail and when sending HTML to the browser.  Do not set this\n";
2855
 
#    print "to US-ASCII, use ISO-8859-1 instead.  For cyrillic, it is best\n";
2856
 
#    print "to use KOI8-R, since this implementation is faster than most\n";
2857
 
#    print "of the alternatives\n";
2858
 
    print "This option is obsolate. Default charset depends on language\n";
2859
 
    print "you have selected in \"Default language\" option.\n";
 
2805
    print "This option controls what character set is used when sending\n";
 
2806
    print "mail and when sending HTML to the browser.\n";
 
2807
    print "\n";
 
2808
    print "This option is used only when default language is 'en_US'.\n";
2860
2809
    print "\n";
2861
2810
 
2862
2811
    print "[$WHT$default_charset$NRM]: $WHT";
2868
2817
    }
2869
2818
    return $new_default_charset;
2870
2819
}
2871
 
# Alternative language names
 
2820
 
 
2821
# Lossy encoding
2872
2822
sub commandA3 {
2873
 
    print "Enable this option if you want to see localized language names in\n";
2874
 
    print "language selection box. Note, that if don't limit list of available\n";
2875
 
    print "languages, this option can trigger installation of foreign language\n";
2876
 
    print "support modules in some browsers.\n";
2877
 
    print "\n";
2878
 
 
2879
 
    if ( lc($show_alternative_names) eq "true" ) {
2880
 
        $default_value = "y";
2881
 
    } else {
2882
 
        $default_value = "n";
2883
 
    }
2884
 
    print "Show alternative language names? (y/n) [$WHT$default_value$NRM]: $WHT";
2885
 
    $show_alternative_names = <STDIN>;
2886
 
    if ( ( $show_alternative_names =~ /^y\n/i ) || ( ( $show_alternative_names =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2887
 
        $show_alternative_names = "true";
2888
 
    } else {
2889
 
        $show_alternative_names = "false";
2890
 
    }
2891
 
    return $show_alternative_names;
2892
 
}
2893
 
# Available languages
2894
 
sub commandA4 {
2895
 
    print "This option allows to limit number of languages available in\n";
2896
 
    print "language selection box. You can enter as code of every language that\n";
2897
 
    print "you want to enable. Language codes should be separated by space. If you\n";
2898
 
    print "enter name unsupported by SquirrelMail, it will be ignored. If you enter\n";
2899
 
    print "special key \'all\' - all languages available in SquirrelMail will be\n";
2900
 
    print "listed. If you enter special key \'none\' - user won't be able to change";
2901
 
    print "language and interface will use language set it \"Default language\" option.\n";
2902
 
    print "\n";
2903
 
    print "Valid language names are:\n";
2904
 
    print " ar (Arabic), bg_BG (Bulgarian), ca_ES (Catalan), cy_GB (Welsh)\n";
2905
 
    print " cs_CZ (Chech), da_DK (Danish), de_DE (German), el_GR (Greek),\n";
2906
 
    print " en_US (English), es_ES (Spanish), et_EE (Estonian), fi_FI (Finnish),\n";
2907
 
    print " fo_FO (Faroese), fr_FR (French), he_IL (Hebrew), hr_HR (Croatian),\n";
2908
 
    print " hu_HU (Hungarian), id_ID (Indonesian), is_IS (Icelandic), it_IT (Italian),\n";
2909
 
    print " ja_JP (Japanese), ko_KR (Korean), lt_LT (Lithuanian), ms_MY (Malay),\n";
2910
 
    print " nl_NL (Dutch), nn_NO (Norwegian (Nynorsk)), no_NO (Norwegian (Bokmal)),\n";
2911
 
    print " pl_PL (Polish), pt_BR (Portuguese (Brazil)), pt_PT (Portuguese (Portugal)),\n";
2912
 
    print " ro_RO (Romanian), ru_RU (Russian), sk_SK (Slovak), sl_SI (Slovenian),\n";
2913
 
    print " sr_YU (Serbian), sv_SE (Swedish), th_TH (Thai), tr_TR (Turkish),\n";
2914
 
    print " zh_CN (Chinese Simplified), zh_TW (Chinese Traditional).\n";
2915
 
    print "\n";
2916
 
    print "[$WHT$available_languages$NRM]: $WHT";
2917
 
    $new_available_languages = <STDIN>;
2918
 
    if ( $new_available_languages eq "\n" ) {
2919
 
        $new_available_languages = $available_languages;
2920
 
    } else {
2921
 
        $new_available_languages =~ s/[\r|\n]//g;
2922
 
        $new_available_languages =~ s/^\s+$//g;
2923
 
    }
2924
 
    return $new_available_languages;
2925
 
}
2926
 
# Agresive decoding
2927
 
sub commandA5 {
2928
 
    print "Enable this option if you want to use CPU and memory intensive decoding\n";
2929
 
    print "functions. This option allows reading multibyte charset, that are used\n";
2930
 
    print "in Eastern Asia. SquirrelMail will try to use recode functions here,\n";
2931
 
    print "even when you have disabled use of recode in Tweaks section.\n";
2932
 
    print "\n";
2933
 
 
2934
 
    if ( lc($agresive_decoding) eq "true" ) {
2935
 
        $default_value = "y";
2936
 
    } else {
2937
 
        $default_value = "n";
2938
 
    }
2939
 
    print "Use agresive decoding? (y/n) [$WHT$default_value$NRM]: $WHT";
2940
 
    $agresive_decoding = <STDIN>;
2941
 
    if ( ( $agresive_decoding =~ /^y\n/i ) || ( ( $agresive_decoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2942
 
        $agresive_decoding = "true";
2943
 
    } else {
2944
 
        $agresive_decoding = "false";
2945
 
    }
2946
 
    return $agresive_decoding;
2947
 
}
2948
 
 
2949
 
# Advanced tree
2950
 
sub commandB1 {
2951
 
    print "Enable this option if you want to use DHTML based folder listing.\n";
2952
 
    print "Code is experimental, works only with some browsers and there might\n";
2953
 
    print "be some glitches.\n";
2954
 
    print "\n";
2955
 
 
2956
 
    if ( lc($advanced_tree) eq "true" ) {
2957
 
        $default_value = "y";
2958
 
    } else {
2959
 
        $default_value = "n";
2960
 
    }
2961
 
    print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2962
 
    $advanced_tree = <STDIN>;
2963
 
    if ( ( $advanced_tree =~ /^y\n/i ) || ( ( $advanced_tree =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2964
 
        $advanced_tree = "true";
2965
 
    } else {
2966
 
        $advanced_tree = "false";
2967
 
    }
2968
 
    return $advanced_tree;
2969
 
}
2970
 
# Oldway
2971
 
sub commandB2 {
2972
 
    print "Setting \$oldway to false causes left_main.php to use the new\n";
2973
 
    print "experimental way of getting the mailbox-tree.\n";
2974
 
    print "\n";
2975
 
 
2976
 
    if ( lc($oldway) eq "true" ) {
2977
 
        $default_value = "y";
2978
 
    } else {
2979
 
        $default_value = "n";
2980
 
    }
2981
 
    print "Use old way of folder list display? (y/n) [$WHT$default_value$NRM]: $WHT";
2982
 
    $oldway = <STDIN>;
2983
 
    if ( ( $oldway =~ /^y\n/i ) || ( ( $oldway =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2984
 
        $oldway = "true";
2985
 
    } else {
2986
 
        $oldway = "false";
2987
 
    }
2988
 
    return $oldway;
2989
 
}
2990
 
# php recode
2991
 
sub commandB3 {
2992
 
    print "Enable this option if you want to use php recode functions to read\n";
2993
 
    print "emails written in charset that differs from the one that is set in\n";
2994
 
    print "translation selected by user. Code is experimental, it might cause\n";
2995
 
    print "errors, if email contains charset unsupported by recode or if your\n";
2996
 
    print "php does not have recode support.\n";
2997
 
    print "\n";
2998
 
 
2999
 
    if ( lc($use_php_recode) eq "true" ) {
3000
 
        $default_value = "y";
3001
 
    } else {
3002
 
        $default_value = "n";
3003
 
    }
3004
 
    print "Use php recode functions? (y/n) [$WHT$default_value$NRM]: $WHT";
3005
 
    $use_php_recode = <STDIN>;
3006
 
    if ( ( $use_php_recode =~ /^y\n/i ) || ( ( $use_php_recode =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
3007
 
        $use_php_recode = "true";
3008
 
    } else {
3009
 
        $use_php_recode = "false";
3010
 
    }
3011
 
    return $use_php_recode;
3012
 
}
3013
 
# php iconv
3014
 
sub commandB4 {
3015
 
    print "Enable this option if you want to use php iconv functions to read\n";
3016
 
    print "emails written in charset that differs from the one that is set in\n";
3017
 
    print "translation selected by user. Code is experimental, it works only\n";
3018
 
    print "with translations that use utf-8 charset. Code might cause errors,\n";
3019
 
    print "if email contains charset unsupported by iconv or if your php does\n";
3020
 
    print "not have iconv support.\n";
3021
 
    print "\n";
3022
 
 
3023
 
    if ( lc($use_php_iconv) eq "true" ) {
3024
 
        $default_value = "y";
3025
 
    } else {
3026
 
        $default_value = "n";
3027
 
    }
3028
 
    print "Use php iconv functions? (y/n) [$WHT$default_value$NRM]: $WHT";
3029
 
    $use_php_iconv = <STDIN>;
3030
 
    if ( ( $use_php_iconv =~ /^y\n/i ) || ( ( $use_php_iconv =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
3031
 
        $use_php_iconv = "true";
3032
 
    } else {
3033
 
        $use_php_iconv = "false";
3034
 
    }
3035
 
    return $use_php_iconv;
3036
 
}
3037
 
 
 
2823
    print "Enable this option if you want to allow lossy charset encoding in message\n";
 
2824
    print "composition pages. This option allows charset conversions when output\n";
 
2825
    print "charset does not support all symbols used in original charset. Symbols\n";
 
2826
    print "unsupported by output charset will be replaced with question marks.\n";
 
2827
    print "\n";
 
2828
 
 
2829
    if ( lc($lossy_encoding) eq 'true' ) {
 
2830
        $default_value = "y";
 
2831
    } else {
 
2832
        $default_value = "n";
 
2833
    }
 
2834
    print "Enable lossy encoding? (y/n) [$WHT$default_value$NRM]: $WHT";
 
2835
    $lossy_encoding = <STDIN>;
 
2836
    if ( ( $lossy_encoding =~ /^y\n/i ) || ( ( $lossy_encoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
 
2837
        $lossy_encoding = 'true';
 
2838
    } else {
 
2839
        $lossy_encoding = 'false';
 
2840
    }
 
2841
    return $lossy_encoding;
 
2842
}
 
2843
 
 
2844
#### End of menu functions
 
2845
####################################################################################
3038
2846
 
3039
2847
sub save_data {
3040
2848
    $tab = "    ";
3048
2856
        print CF " */\n";
3049
2857
        print CF "\n";
3050
2858
        print CF "global \$version;\n";
3051
 
        
 
2859
    
3052
2860
        if ($print_config_version) {
3053
2861
            print CF "\$config_version = '$print_config_version';\n";
3054
2862
        }
3055
 
        # integer
 
2863
    # integer
3056
2864
        print CF "\$config_use_color = $config_use_color;\n";
3057
2865
        print CF "\n";
3058
 
        
3059
 
        # string
 
2866
    
 
2867
    # string
3060
2868
        print CF "\$org_name      = \"$org_name\";\n";
3061
2869
        # string
3062
 
        print CF "\$org_logo      = " . &change_to_SM_path($org_logo) . ";\n";
 
2870
    print CF "\$org_logo      = " . &change_to_SM_path($org_logo) . ";\n";
3063
2871
        $org_logo_width |= 0;
3064
2872
        $org_logo_height |= 0;
3065
 
        # string
 
2873
    # string
3066
2874
        print CF "\$org_logo_width  = '$org_logo_width';\n";
3067
2875
        # string
3068
 
        print CF "\$org_logo_height = '$org_logo_height';\n";
3069
 
        # string that can contain variables.
 
2876
    print CF "\$org_logo_height = '$org_logo_height';\n";
 
2877
    # string that can contain variables.
3070
2878
        print CF "\$org_title     = \"$org_title\";\n";
3071
 
        # string
 
2879
    # string
3072
2880
        print CF "\$signout_page  = " . &change_to_SM_path($signout_page) . ";\n";
3073
 
        # string
 
2881
    # string
3074
2882
        print CF "\$frame_top     = '$frame_top';\n";
3075
2883
        print CF "\n";
3076
2884
 
3080
2888
        print CF "\$provider_name     = '$provider_name';\n";
3081
2889
        print CF "\n";
3082
2890
 
3083
 
        # string that can contain variables
 
2891
    # string that can contain variables
3084
2892
        print CF "\$motd = \"$motd\";\n";
3085
2893
        print CF "\n";
3086
 
        
3087
 
        # string
 
2894
 
 
2895
    # Language preferences    
 
2896
    # string
3088
2897
        print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
3089
 
        # string
3090
 
        print CF "\$default_charset          = '$default_charset';\n";
3091
 
        # boolean
3092
 
        print CF "\$show_alternative_names   = $show_alternative_names;\n";
3093
 
        # string
3094
 
        print CF "\$available_languages   = '$available_languages';\n";
3095
 
        # boolean
3096
 
        print CF "\$agresive_decoding   = $agresive_decoding;\n";
 
2898
    # string
 
2899
        print CF "\$default_charset       = '$default_charset';\n";
 
2900
    # boolean
 
2901
        print CF "\$lossy_encoding        = $lossy_encoding;\n";
3097
2902
        print CF "\n";
3098
2903
 
3099
 
        # string or code
3100
 
        if ($domain =~ /^implode\(/) {
3101
 
                print CF "\$domain                 = $domain;\n";
3102
 
        } else {
3103
 
                print CF "\$domain                 = '$domain';\n";
3104
 
        }
3105
 
        # string
 
2904
    # Server settings
 
2905
        # string or code
 
2906
    if ($domain =~ /^(implode|trim)\(/) {
 
2907
        print CF "\$domain                 = $domain;\n";
 
2908
    } else {
 
2909
        print CF "\$domain                 = '$domain';\n";
 
2910
    }
 
2911
    # string
3106
2912
        print CF "\$imapServerAddress      = '$imapServerAddress';\n";
3107
 
        # integer
 
2913
    # integer
3108
2914
        print CF "\$imapPort               = $imapPort;\n";
3109
 
        # boolean
 
2915
    # boolean
3110
2916
        print CF "\$useSendmail            = $useSendmail;\n";
3111
 
        # string
 
2917
    # string
3112
2918
        print CF "\$smtpServerAddress      = '$smtpServerAddress';\n";
3113
 
        # integer
 
2919
    # integer
3114
2920
        print CF "\$smtpPort               = $smtpPort;\n";
3115
 
        # string
 
2921
    # string
3116
2922
        print CF "\$sendmail_path          = '$sendmail_path';\n";
3117
 
        # boolean
 
2923
    # boolean
3118
2924
#        print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
3119
 
        # boolean
 
2925
    # boolean
3120
2926
        print CF "\$pop_before_smtp        = $pop_before_smtp;\n";
3121
 
        # string
 
2927
    # string
3122
2928
        print CF "\$imap_server_type       = '$imap_server_type';\n";
3123
 
        # boolean
 
2929
    # boolean
3124
2930
        print CF "\$invert_time            = $invert_time;\n";
3125
 
        # string
 
2931
    # string
3126
2932
        print CF "\$optional_delimiter     = '$optional_delimiter';\n";
3127
2933
        print CF "\n";
3128
2934
 
3129
 
        # string
 
2935
    # string
3130
2936
        print CF "\$default_folder_prefix          = '$default_folder_prefix';\n";
3131
 
        # string
 
2937
    # string
3132
2938
        print CF "\$trash_folder                   = '$trash_folder';\n";
3133
 
        # string
 
2939
    # string
3134
2940
        print CF "\$sent_folder                    = '$sent_folder';\n";
3135
 
        # string
 
2941
    # string
3136
2942
        print CF "\$draft_folder                   = '$draft_folder';\n";
3137
 
        # boolean
 
2943
    # boolean
3138
2944
        print CF "\$default_move_to_trash          = $default_move_to_trash;\n";
3139
 
        # boolean
 
2945
    # boolean
3140
2946
        print CF "\$default_move_to_sent           = $default_move_to_sent;\n";
3141
 
        # boolean
 
2947
    # boolean
3142
2948
        print CF "\$default_save_as_draft          = $default_save_as_draft;\n";
3143
 
        # boolean
 
2949
    # boolean
3144
2950
        print CF "\$show_prefix_option             = $show_prefix_option;\n";
3145
 
        # boolean
 
2951
    # boolean
3146
2952
        print CF "\$list_special_folders_first     = $list_special_folders_first;\n";
3147
 
        # boolean
 
2953
    # boolean
3148
2954
        print CF "\$use_special_folder_color       = $use_special_folder_color;\n";
3149
 
        # boolean
 
2955
    # boolean
3150
2956
        print CF "\$auto_expunge                   = $auto_expunge;\n";
3151
 
        # boolean
 
2957
    # boolean
3152
2958
        print CF "\$default_sub_of_inbox           = $default_sub_of_inbox;\n";
3153
 
        # boolean
 
2959
    # boolean
3154
2960
        print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
3155
 
        # integer
 
2961
    # integer
3156
2962
        print CF "\$default_unseen_notify          = $default_unseen_notify;\n";
3157
 
        # integer
 
2963
    # integer
3158
2964
        print CF "\$default_unseen_type            = $default_unseen_type;\n";
3159
 
        # boolean
 
2965
    # boolean
3160
2966
        print CF "\$auto_create_special            = $auto_create_special;\n";
3161
 
        # boolean
 
2967
    # boolean
3162
2968
        print CF "\$delete_folder                  = $delete_folder;\n";
3163
2969
    # boolean
3164
2970
        print CF "\$noselect_fix_enable            = $noselect_fix_enable;\n";
3165
2971
 
3166
2972
        print CF "\n";
3167
2973
 
3168
 
        # string
 
2974
    # General options
 
2975
    # string
3169
2976
        print CF "\$data_dir                 = " . &change_to_SM_path($data_dir) . ";\n";
3170
 
        # string that can contain a variable
 
2977
    # string that can contain a variable
3171
2978
        print CF "\$attachment_dir           = " . &change_to_SM_path($attachment_dir) . ";\n";
3172
 
        # integer
 
2979
    # integer
3173
2980
        print CF "\$dir_hash_level           = $dir_hash_level;\n";
3174
 
        # string
 
2981
    # string
3175
2982
        print CF "\$default_left_size        = '$default_left_size';\n";
3176
 
        # boolean
 
2983
    # boolean
3177
2984
        print CF "\$force_username_lowercase = $force_username_lowercase;\n";
3178
 
        # boolean
 
2985
    # boolean
3179
2986
        print CF "\$default_use_priority     = $default_use_priority;\n";
3180
 
        # boolean
 
2987
    # boolean
3181
2988
        print CF "\$hide_sm_attributions     = $hide_sm_attributions;\n";
3182
 
        # boolean
 
2989
    # boolean
3183
2990
        print CF "\$default_use_mdn          = $default_use_mdn;\n";
3184
 
        # boolean
 
2991
    # boolean
3185
2992
        print CF "\$edit_identity            = $edit_identity;\n";
3186
 
        # boolean
 
2993
    # boolean
3187
2994
        print CF "\$edit_name                = $edit_name;\n";
3188
 
        # boolean
 
2995
    # boolean
3189
2996
        print CF "\$allow_thread_sort        = $allow_thread_sort;\n";
3190
 
        # boolean
 
2997
    # boolean
3191
2998
        print CF "\$allow_server_sort        = $allow_server_sort;\n";
3192
2999
        # boolean
3193
3000
        print CF "\$allow_charset_search     = $allow_charset_search;\n";
 
3001
        # boolean
 
3002
        print CF "\$uid_support              = $uid_support;\n";
3194
3003
        print CF "\n";
3195
 
        
3196
 
        # all plugins are strings
 
3004
    
 
3005
    # all plugins are strings
3197
3006
        for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
3198
3007
            print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
3199
3008
        }
3200
3009
        print CF "\n";
3201
3010
 
3202
 
        # strings
 
3011
    # strings
3203
3012
        print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
3204
 
        if ( $theme_default eq '' ) { $theme_default = '0'; }
 
3013
    if ( $theme_default eq '' ) { $theme_default = '0'; }
3205
3014
        print CF "\$theme_default = $theme_default;\n";
3206
3015
 
3207
3016
        for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
3208
3017
            print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
3209
 
            print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
 
3018
            # escape theme name so it can contain single quotes.
 
3019
            $esc_name =  $theme_name[$count];
 
3020
            $esc_name =~ s/\\/\\\\/g;
 
3021
            $esc_name =~ s/'/\\'/g;
 
3022
            print CF "\$theme[$count]['NAME'] = '$esc_name';\n";
3210
3023
        }
3211
3024
        print CF "\n";
3212
3025
 
3213
 
        if ( $default_use_javascript_addr_book ne "true" ) {
3214
 
            $default_use_javascript_addr_book = "false";
3215
 
        }
3216
 
 
3217
 
        # boolean
 
3026
        ## Address books
 
3027
        # boolean
3218
3028
        print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
3219
3029
        for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
3220
3030
            print CF "\$ldap_server[$count] = array(\n";
3221
 
            # string
 
3031
        # string
3222
3032
            print CF "    'host' => '$ldap_host[$count]',\n";
3223
 
            # string
 
3033
        # string
3224
3034
            print CF "    'base' => '$ldap_base[$count]'";
3225
3035
            if ( $ldap_name[$count] ) {
3226
3036
                print CF ",\n";
3227
 
                # string
 
3037
        # string
3228
3038
                print CF "    'name' => '$ldap_name[$count]'";
3229
3039
            }
3230
3040
            if ( $ldap_port[$count] ) {
3231
3041
                print CF ",\n";
3232
 
                # integer
 
3042
        # integer
3233
3043
                print CF "    'port' => $ldap_port[$count]";
3234
3044
            }
3235
3045
            if ( $ldap_charset[$count] ) {
3236
3046
                print CF ",\n";
3237
 
                # string
 
3047
        # string
3238
3048
                print CF "    'charset' => '$ldap_charset[$count]'";
3239
3049
            }
3240
3050
            if ( $ldap_maxrows[$count] ) {
3241
3051
                print CF ",\n";
3242
 
                # integer
 
3052
        # integer
3243
3053
                print CF "    'maxrows' => $ldap_maxrows[$count]";
3244
3054
            }
3245
3055
            if ( $ldap_binddn[$count] ) {
3254
3064
            }
3255
3065
            if ( $ldap_protocol[$count] ) {
3256
3066
                print CF ",\n";
3257
 
                # integer
 
3067
        # integer
3258
3068
                print CF "    'protocol' => $ldap_protocol[$count]";
3259
3069
            }
3260
3070
            print CF "\n";
3261
3071
            print CF ");\n";
3262
3072
            print CF "\n";
3263
3073
        }
 
3074
    # string
 
3075
        print CF "\$abook_global_file = '$abook_global_file';\n";
 
3076
    # boolean
 
3077
        print CF "\$abook_global_file_writeable = $abook_global_file_writeable;\n\n";
3264
3078
 
3265
 
        # string
 
3079
    ## Database
 
3080
    # string
3266
3081
        print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
3267
 
        # string
 
3082
    # string
3268
3083
        print CF "\$addrbook_table = '$addrbook_table';\n\n";
3269
 
        # string
 
3084
    # string
3270
3085
        print CF "\$prefs_dsn = '$prefs_dsn';\n";
3271
 
        # string
 
3086
    # string
3272
3087
        print CF "\$prefs_table = '$prefs_table';\n";
3273
 
        # string
 
3088
    # string
3274
3089
        print CF "\$prefs_user_field = '$prefs_user_field';\n";
3275
 
        # string
 
3090
    # string
3276
3091
        print CF "\$prefs_key_field = '$prefs_key_field';\n";
3277
 
        # string
3278
 
        print CF "\$prefs_val_field = '$prefs_val_field';\n\n";
3279
 
        # string
 
3092
    # string
 
3093
        print CF "\$prefs_val_field = '$prefs_val_field';\n";
 
3094
    # string
3280
3095
        print CF "\$addrbook_global_dsn = '$addrbook_global_dsn';\n";
3281
 
        # string
 
3096
    # string
3282
3097
        print CF "\$addrbook_global_table = '$addrbook_global_table';\n";
3283
 
        # boolean
3284
 
        print CF "\$addrbook_global_writeable = $addrbook_global_writeable;\n\n";
3285
 
        # boolean
 
3098
    # boolean
 
3099
        print CF "\$addrbook_global_writeable = $addrbook_global_writeable;\n";
 
3100
    # boolean
3286
3101
        print CF "\$addrbook_global_listing = $addrbook_global_listing;\n\n";
3287
 
        # boolean
3288
 
                print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
3289
 
 
3290
 
        # string
3291
 
                print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
3292
 
                print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
3293
 
        # boolean
3294
 
            print CF "\$use_imap_tls = $use_imap_tls;\n";
3295
 
                print CF "\$use_smtp_tls = $use_smtp_tls;\n";
3296
 
 
3297
 
                print CF "\$session_name = '$session_name';\n";
3298
 
 
3299
 
            print CF "\n";
3300
 
 
3301
 
        # boolean
3302
 
        print CF "\$advanced_tree = $advanced_tree;\n";
3303
 
        print CF "\n";
3304
 
        # boolean
3305
 
        print CF "\$oldway = $oldway;\n";
3306
 
        print CF "\n";
3307
 
        # boolean
3308
 
        print CF "\$use_php_recode = $use_php_recode;\n";
3309
 
        print CF "\n";
3310
 
        # boolean
3311
 
        print CF "\$use_php_iconv = $use_php_iconv;\n";
3312
 
        print CF "\n";
3313
 
 
3314
 
                print CF "\@include SM_PATH . 'config/config_local.php';\n";
 
3102
    # boolean
 
3103
        print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
 
3104
 
 
3105
    # string
 
3106
        print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
 
3107
        print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
 
3108
    # boolean
 
3109
        print CF "\$use_imap_tls = $use_imap_tls;\n";
 
3110
        print CF "\$use_smtp_tls = $use_smtp_tls;\n";
 
3111
 
 
3112
        print CF "\$session_name = '$session_name';\n";
 
3113
 
 
3114
        print CF "\n";
 
3115
        print CF "\@include SM_PATH . 'config/config_local.php';\n";
3315
3116
    
3316
 
                print CF "\n/**\n";
3317
 
            print CF " * Make sure there are no characters after the PHP closing\n";
3318
 
            print CF " * tag below (including newline characters and whitespace).\n";
3319
 
            print CF " * Otherwise, that character will cause the headers to be\n";
3320
 
            print CF " * sent and regular output to begin, which will majorly screw\n";
3321
 
            print CF " * things up when we try to send more headers later.\n";
3322
 
            print CF " */\n";
3323
 
            print CF "?>";
 
3117
        print CF "\n/**\n";
 
3118
        print CF " * Make sure there are no characters after the PHP closing\n";
 
3119
        print CF " * tag below (including newline characters and whitespace).\n";
 
3120
        print CF " * Otherwise, that character will cause the headers to be\n";
 
3121
        print CF " * sent and regular output to begin, which will majorly screw\n";
 
3122
        print CF " * things up when we try to send more headers later.\n";
 
3123
        print CF " */\n";
 
3124
        print CF "?>";
3324
3125
        
3325
 
                close CF;
 
3126
        close CF;
3326
3127
 
3327
 
            print "Data saved in config.php\n";
 
3128
        print "Data saved in config.php\n";
3328
3129
    } else {
3329
3130
        print "Error saving config.php: $!\n";
3330
3131
    }
3351
3152
    $continue = 0;
3352
3153
    while ( $continue != 1 ) {
3353
3154
        print "Please select your IMAP server:\n";
3354
 
        print "    cyrus      = Cyrus IMAP server\n";
3355
 
        print "    uw         = University of Washington's IMAP server\n";
3356
 
        print "    exchange   = Microsoft Exchange IMAP server\n";
3357
 
        print "    courier    = Courier IMAP server\n";
3358
 
        print "    macosx     = Mac OS X Mailserver\n";
3359
 
        print "    mercury32  = Mercury/32\n";
3360
 
        print "    quit       = Do not change anything\n";
 
3155
        print "    cyrus       = Cyrus IMAP server\n";
 
3156
        print "    uw          = University of Washington's IMAP server\n";
 
3157
        print "    exchange    = Microsoft Exchange IMAP server\n";
 
3158
        print "    courier     = Courier IMAP server\n";
 
3159
        print "    macosx      = Mac OS X Mailserver\n";
 
3160
        print "    hmailserver = hMailServer\n";
 
3161
        print "    quit        = Do not change anything\n";
3361
3162
        print "Command >> ";
3362
3163
        $server = <STDIN>;
3363
3164
        $server =~ s/[\r|\n]//g;
3374
3175
            $show_contain_subfolders_option = false;
3375
3176
            $optional_delimiter             = ".";
3376
3177
            $disp_default_folder_prefix     = "<none>";
3377
 
            $force_username_lowercase       = false;
3378
3178
 
3379
3179
            $continue = 1;
3380
3180
        } elsif ( $server eq "uw" ) {
3389
3189
            $optional_delimiter             = "/";
3390
3190
            $disp_default_folder_prefix     = $default_folder_prefix;
3391
3191
            $delete_folder                  = true;
3392
 
            $force_username_lowercase       = true;
3393
3192
            
3394
3193
            $continue = 1;
3395
3194
        } elsif ( $server eq "exchange" ) {
3403
3202
            $show_contain_subfolders_option = false;
3404
3203
            $optional_delimiter             = "detect";
3405
3204
            $disp_default_folder_prefix     = "<none>";
3406
 
            $force_username_lowercase       = true;
3407
3205
 
3408
3206
            $continue = 1;
3409
3207
        } elsif ( $server eq "courier" ) {
3418
3216
            $optional_delimiter             = ".";
3419
3217
            $disp_default_folder_prefix     = $default_folder_prefix;
3420
3218
            $delete_folder                  = true;
3421
 
            $force_username_lowercase       = false;
3422
3219
            
3423
3220
            $continue = 1;
3424
3221
        } elsif ( $server eq "macosx" ) {
3435
3232
            $disp_default_folder_prefix     = $default_folder_prefix;
3436
3233
 
3437
3234
            $continue = 1;
3438
 
        } elsif ( $server eq "mercury32" ) {
3439
 
            $imap_server_type               = "mercury32";
 
3235
        } elsif ( $server eq "hmailserver" ) {
 
3236
            $imap_server_type               = "hmailserver";
3440
3237
            $default_folder_prefix          = "";
3441
3238
            $trash_folder                   = "INBOX.Trash";
3442
3239
            $sent_folder                    = "INBOX.Sent";
3443
3240
            $draft_folder                   = "INBOX.Drafts";
3444
3241
            $show_prefix_option             = false;
3445
3242
            $default_sub_of_inbox           = true;
3446
 
            $show_contain_subfolders_option = true;
 
3243
            $show_contain_subfolders_option = false;
3447
3244
            $optional_delimiter             = "detect";
3448
 
            $delete_folder                  = true;
3449
 
            $force_username_lowercase       = true;
 
3245
            $allow_charset_search           = false;
 
3246
            $disp_default_folder_prefix     = $default_folder_prefix;
 
3247
            $delete_folder                  = false;
 
3248
            $force_username_lowercase       = false;
3450
3249
 
3451
3250
            $continue = 1;
3452
3251
        } elsif ( $server eq "quit" ) {
3467
3266
        print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
3468
3267
        print "            optional_delimiter = $optional_delimiter\n";
3469
3268
        print "                 delete_folder = $delete_folder\n";
3470
 
        print "      force_username_lowercase = $force_username_lowercase\n";
3471
3269
    }
3472
 
    print "\nPress enter to continue...";
 
3270
    print "\nPress any key to continue...";
3473
3271
    $tmp = <STDIN>;
3474
3272
}
3475
3273
 
3532
3330
        $new_path .= "\'";
3533
3331
    } else {
3534
3332
        # Last, it's a relative path without any leading '.'
3535
 
        # Prepend SM_PATH and config, since the paths are 
3536
 
        # relative to the config directory
 
3333
    # Prepend SM_PATH and config, since the paths are 
 
3334
    # relative to the config directory
3537
3335
        $new_path = "SM_PATH . \'config/" . $old_path . "\'";
3538
3336
    }
3539
3337
  return $new_path;
3562
3360
# Called by 'command112a' and 'command112b'
3563
3361
# ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
3564
3362
 
3565
 
        # Misc setup
3566
 
        use IO::Socket;
3567
 
        my $service = shift;
3568
 
        my $host = shift;
3569
 
        my $mech = shift;
3570
 
        # Sanity checks
3571
 
        if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
3572
 
          # Error - wrong # of args
3573
 
          print "BAD ARGS!\n";
3574
 
          return undef;
3575
 
        }
3576
 
        
3577
 
        if ($service eq 'SMTP') {
3578
 
                $cmd = "AUTH $mech\n";
3579
 
                $logout = "QUIT\n";
3580
 
        } elsif ($service eq 'IMAP') {
3581
 
                $cmd = "A01 AUTHENTICATE $mech\n";
3582
 
                $logout = "C01 LOGOUT\n";
3583
 
        } else {
3584
 
                # unknown service - whoops.
3585
 
                return undef;
3586
 
        }
 
3363
    # Misc setup
 
3364
    use IO::Socket;
 
3365
    my $service = shift;
 
3366
    my $host = shift;
 
3367
    my $mech = shift;
 
3368
    # Sanity checks
 
3369
    if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
 
3370
      # Error - wrong # of args
 
3371
      print "BAD ARGS!\n";
 
3372
      return undef;
 
3373
    }
 
3374
    
 
3375
    if ($service eq 'SMTP') {
 
3376
        $cmd = "AUTH $mech\r\n";
 
3377
        $logout = "QUIT\r\n";
 
3378
    } elsif ($service eq 'IMAP') {
 
3379
        $cmd = "A01 AUTHENTICATE $mech\n";
 
3380
        $logout = "C01 LOGOUT\n";
 
3381
    } else {
 
3382
        # unknown service - whoops.
 
3383
        return undef;
 
3384
    }
3587
3385
 
3588
 
        # Get this show on the road
 
3386
    # Get this show on the road
3589
3387
    my $sock=IO::Socket::INET->new($host);
3590
3388
    if (!defined($sock)) {
3591
3389
        # Connect failed
3592
3390
        return undef;
3593
3391
    }
3594
 
        my $discard = <$sock>; # Server greeting/banner - who cares..
3595
 
 
3596
 
        if ($service eq 'SMTP') {
3597
 
                # Say hello first..
3598
 
                print $sock "helo $domain\n";
3599
 
                $discard = <$sock>; # Yeah yeah, you're happy to see me..
3600
 
        }
3601
 
        print $sock $cmd;
3602
 
 
3603
 
        my $response = <$sock>;
3604
 
        chomp($response);
3605
 
        if (!defined($response)) {
3606
 
                return undef;
3607
 
        }
3608
 
 
3609
 
        # So at this point, we have a response, and it is (hopefully) valid.
3610
 
        if ($service eq 'SMTP') {
3611
 
                if (($response =~ /^535/) or ($response =~/^502/)) {
3612
 
                        # Not supported
3613
 
                        close $sock;
3614
 
                        return 'NO';
3615
 
                } elsif ($response =~ /^503/) {
3616
 
                        #Something went wrong
3617
 
                        return undef;
3618
 
                }
3619
 
        } elsif ($service eq 'IMAP') {
3620
 
                if ($response =~ /^A01/) {
3621
 
                        # Not supported
3622
 
                        close $sock;
3623
 
                        return 'NO';
3624
 
                }
3625
 
        } else {
3626
 
                # Unknown service - this shouldn't be able to happen.
3627
 
                close $sock;
3628
 
                return undef;
3629
 
        }
3630
 
 
3631
 
        # If it gets here, the mech is supported
3632
 
        print $sock "*\n";  # Attempt to cancel authentication
3633
 
        print $sock $logout; # Try to log out, but we don't really care if this fails
3634
 
        close $sock;
3635
 
        return 'YES';
 
3392
    my $discard = <$sock>; # Server greeting/banner - who cares..
 
3393
 
 
3394
    if ($service eq 'SMTP') {
 
3395
        # Say hello first..
 
3396
        print $sock "HELO $domain\r\n";
 
3397
        $discard = <$sock>; # Yeah yeah, you're happy to see me..
 
3398
    }
 
3399
    print $sock $cmd;
 
3400
 
 
3401
    my $response = <$sock>;
 
3402
    chomp($response);
 
3403
    if (!defined($response)) {
 
3404
        return undef;
 
3405
    }
 
3406
 
 
3407
    # So at this point, we have a response, and it is (hopefully) valid.
 
3408
    if ($service eq 'SMTP') {
 
3409
        if (($response =~ /^535/) or ($response =~/^502/)) {
 
3410
            # Not supported
 
3411
            print $sock $logout;
 
3412
            close $sock;
 
3413
            return 'NO';
 
3414
        } elsif ($response =~ /^503/) {
 
3415
            #Something went wrong
 
3416
            return undef;
 
3417
        }
 
3418
    } elsif ($service eq 'IMAP') {
 
3419
        if ($response =~ /^A01/) {
 
3420
            # Not supported
 
3421
            close $sock;
 
3422
            return 'NO';
 
3423
        }
 
3424
    } else {
 
3425
        # Unknown service - this shouldn't be able to happen.
 
3426
        close $sock;
 
3427
        return undef;
 
3428
    }
 
3429
 
 
3430
    # If it gets here, the mech is supported
 
3431
    print $sock "*\n";  # Attempt to cancel authentication
 
3432
    print $sock $logout; # Try to log out, but we don't really care if this fails
 
3433
    close $sock;
 
3434
    return 'YES';
3636
3435
}
3637
3436
 
3638
3437
sub clear_screen() {