conf.pl 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619
  1. #!/usr/bin/env perl
  2. # conf.pl
  3. # Luke Ehresman (luke@squirrelmail.org)
  4. #
  5. # A simple configure script to configure squirrelmail
  6. #
  7. # $Id$
  8. ############################################################
  9. $conf_pl_version = "1.2.0";
  10. ############################################################
  11. # Check what directory we're supposed to be running in, and
  12. # change there if necessary. File::Basename has been in
  13. # Perl since at least 5.003_7, and nobody sane runs anything
  14. # before that, but just in case.
  15. ############################################################
  16. if ( eval q{require "File/Basename.pm"} ) {
  17. my $dir = File::Basename::dirname($0);
  18. chdir($dir);
  19. }
  20. ############################################################
  21. # Some people try to run this as a CGI. That's wrong!
  22. ############################################################
  23. if ( defined( $ENV{'PATH_INFO'} )
  24. || defined( $ENV{'QUERY_STRING'} )
  25. || defined( $ENV{'REQUEST_METHOD'} ) ) {
  26. print "Content-Type: text/html\n\n";
  27. print "You must run this script from the command line.";
  28. exit;
  29. }
  30. ############################################################
  31. # First, lets read in the data already in there...
  32. ############################################################
  33. if ( -e "config.php" ) {
  34. open( FILE, "config.php" );
  35. while ( $line = <FILE> ) {
  36. $line =~ s/^\s+//;
  37. $line =~ s/^\$//;
  38. $var = $line;
  39. $var =~ s/=/EQUALS/;
  40. if ( $var =~ /^([a-z]|[A-Z])/ ) {
  41. @o = split ( /\s*EQUALS\s*/, $var );
  42. if ( $o[0] eq "config_version" ) {
  43. $o[1] =~ s/[\n|\r]//g;
  44. $o[1] =~ s/[\'|\"];\s*$//;
  45. $o[1] =~ s/;$//;
  46. $o[1] =~ s/^[\'|\"]//;
  47. $config_version = $o[1];
  48. close(FILE);
  49. }
  50. }
  51. }
  52. close(FILE);
  53. if ( $config_version ne $conf_pl_version ) {
  54. system "clear";
  55. print $WHT. "WARNING:\n" . $NRM;
  56. print " The file \"config/config.php\" was found, but it is for\n";
  57. print " an older version of SquirrelMail. It is possible to still\n";
  58. print " read the defaults from this file but be warned that many\n";
  59. print " preferences change between versions. It is recommended that\n";
  60. print " you start with a clean config.php for each upgrade that you\n";
  61. print " do. To do this, just move config/config.php out of the way.\n";
  62. print "\n";
  63. print "Continue loading with the old config.php [y/N]? ";
  64. $ctu = <STDIN>;
  65. if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
  66. exit;
  67. }
  68. print "\nDo you want me to stop warning you [y/N]? ";
  69. $ctu = <STDIN>;
  70. if ( $ctu =~ /^y\n/i ) {
  71. $print_config_version = $conf_pl_version;
  72. } else {
  73. $print_config_version = $config_version;
  74. }
  75. } else {
  76. $print_config_version = $config_version;
  77. }
  78. $config = 1;
  79. open( FILE, "config.php" );
  80. } elsif ( -e "config_default.php" ) {
  81. open( FILE, "config_default.php" );
  82. while ( $line = <FILE> ) {
  83. $line =~ s/^\s+//;
  84. $line =~ s/^\$//;
  85. $var = $line;
  86. $var =~ s/=/EQUALS/;
  87. if ( $var =~ /^([a-z]|[A-Z])/ ) {
  88. @o = split ( /\s*EQUALS\s*/, $var );
  89. if ( $o[0] eq "config_version" ) {
  90. $o[1] =~ s/[\n|\r]//g;
  91. $o[1] =~ s/[\'|\"];\s*$//;
  92. $o[1] =~ s/;$//;
  93. $o[1] =~ s/^[\'|\"]//;
  94. $config_version = $o[1];
  95. close(FILE);
  96. }
  97. }
  98. }
  99. close(FILE);
  100. if ( $config_version ne $conf_pl_version ) {
  101. system "clear";
  102. print $WHT. "WARNING:\n" . $NRM;
  103. print " You are trying to use a 'config_default.php' from an older\n";
  104. print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
  105. print " should get the 'config_default.php' that matches the version\n";
  106. print " of SquirrelMail that you are running. You can get this from\n";
  107. print " the SquirrelMail web page by going to the following URL:\n";
  108. print " http://www.squirrelmail.org.\n";
  109. print "\n";
  110. print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
  111. $ctu = <STDIN>;
  112. if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
  113. exit;
  114. }
  115. print "\nDo you want me to stop warning you [y/N]? ";
  116. $ctu = <STDIN>;
  117. if ( $ctu =~ /^y\n/i ) {
  118. $print_config_version = $conf_pl_version;
  119. } else {
  120. $print_config_version = $config_version;
  121. }
  122. } else {
  123. $print_config_version = $config_version;
  124. }
  125. $config = 2;
  126. open( FILE, "config_default.php" );
  127. } else {
  128. print "No configuration file found. Please get config_default.php\n";
  129. print "or config.php before running this again. This program needs\n";
  130. print "a default config file to get default values.\n";
  131. exit;
  132. }
  133. # Read and parse the current configuration file
  134. # (either config.php or config_default.php).
  135. while ( $line = <FILE> ) {
  136. $line =~ s/^\s+//;
  137. $line =~ s/^\$//;
  138. $var = $line;
  139. $var =~ s/=/EQUALS/;
  140. if ( $var =~ /^([a-z]|[A-Z])/ ) {
  141. @options = split ( /\s*EQUALS\s*/, $var );
  142. $options[1] =~ s/[\n|\r]//g;
  143. $options[1] =~ s/[\'|\"];\s*$//;
  144. $options[1] =~ s/;$//;
  145. $options[1] =~ s/^[\'|\"]//;
  146. if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) {
  147. $sub = $options[0];
  148. $sub =~ s/\]\[['|"]PATH['|"]\]//;
  149. $sub =~ s/.*\[//;
  150. if ( -e "../themes" ) {
  151. $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
  152. }
  153. $theme_path[$sub] = $options[1];
  154. } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
  155. $sub = $options[0];
  156. $sub =~ s/\]\[['|"]NAME['|"]\]//;
  157. $sub =~ s/.*\[//;
  158. $theme_name[$sub] = $options[1];
  159. } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) {
  160. $sub = $options[0];
  161. $sub =~ s/\]//;
  162. $sub =~ s/^plugins\[//;
  163. $plugins[$sub] = $options[1];
  164. } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
  165. $sub = $options[0];
  166. $sub =~ s/\]//;
  167. $sub =~ s/^ldap_server\[//;
  168. $continue = 0;
  169. while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) {
  170. if ( $tmp =~ /\);\s*$/ ) {
  171. $continue = 1;
  172. }
  173. if ( $tmp =~ /^\s*[\'|\"]host[\'|\"]/i ) {
  174. $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
  175. $tmp =~ s/[\'|\"],?\s*$//;
  176. $tmp =~ s/[\'|\"]\);\s*$//;
  177. $host = $tmp;
  178. } elsif ( $tmp =~ /^\s*[\'|\"]base[\'|\"]/i ) {
  179. $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
  180. $tmp =~ s/[\'|\"],?\s*$//;
  181. $tmp =~ s/[\'|\"]\);\s*$//;
  182. $base = $tmp;
  183. } elsif ( $tmp =~ /^\s*[\'|\"]charset[\'|\"]/i ) {
  184. $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
  185. $tmp =~ s/[\'|\"],?\s*$//;
  186. $tmp =~ s/[\'|\"]\);\s*$//;
  187. $charset = $tmp;
  188. } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
  189. $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i;
  190. $tmp =~ s/[\'|\"]?,?\s*$//;
  191. $tmp =~ s/[\'|\"]?\);\s*$//;
  192. $port = $tmp;
  193. } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
  194. $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i;
  195. $tmp =~ s/[\'|\"]?,?\s*$//;
  196. $tmp =~ s/[\'|\"]?\);\s*$//;
  197. $maxrows = $tmp;
  198. } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
  199. $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
  200. $tmp =~ s/[\'|\"],?\s*$//;
  201. $tmp =~ s/[\'|\"]\);\s*$//;
  202. $name = $tmp;
  203. }
  204. }
  205. $ldap_host[$sub] = $host;
  206. $ldap_base[$sub] = $base;
  207. $ldap_name[$sub] = $name;
  208. $ldap_port[$sub] = $port;
  209. $ldap_maxrows[$sub] = $maxrows;
  210. $ldap_charset[$sub] = $charset;
  211. } else {
  212. ${ $options[0] } = $options[1];
  213. }
  214. }
  215. }
  216. close FILE;
  217. if ( $useSendmail ne "true" ) {
  218. $useSendmail = "false";
  219. }
  220. if ( !$sendmail_path ) {
  221. $sendmail_path = "/usr/sbin/sendmail";
  222. }
  223. if ( !$pop_before_smtp ) {
  224. $pop_before_smtp = "false";
  225. }
  226. if ( !$default_unseen_notify ) {
  227. $default_unseen_notify = 2;
  228. }
  229. if ( !$default_unseen_type ) {
  230. $default_unseen_type = 1;
  231. }
  232. if ( !$config_use_color ) {
  233. $config_use_color = 0;
  234. }
  235. if ( !$invert_time ) {
  236. $invert_time = "false";
  237. }
  238. if ( !$force_username_lowercase ) {
  239. $force_username_lowercase = "false";
  240. }
  241. if ( !$optional_delimiter ) {
  242. $optional_delimiter = "detect";
  243. }
  244. if ( !$use_authenticated_smtp ) {
  245. $use_authenticated_smtp = "false";
  246. }
  247. if ( !$auto_create_special ) {
  248. $auto_create_special = "false";
  249. }
  250. if ( !$default_use_priority ) {
  251. $default_use_priority = "true";
  252. }
  253. if ( !$hide_sm_attributions ) {
  254. $hide_sm_attributions = "false";
  255. }
  256. if ( !$default_use_mdn ) {
  257. $default_use_mdn = "true";
  258. }
  259. if ( !$delete_folder ) {
  260. $delete_folder = "false";
  261. }
  262. if ( !$noselect_fix_enable ) {
  263. $noselect_fix_enable = "false";
  264. }
  265. if ( !$frame_top ) {
  266. $frame_top = "_top";
  267. }
  268. if ( !$edit_identity ) {
  269. $edit_identity = "true";
  270. }
  271. if ( !$edit_name ) {
  272. $edit_name = "true";
  273. }
  274. if ( !$allow_thread_sort ) {
  275. $allow_thread_sort = 'false';
  276. }
  277. if ( !$allow_server_sort ) {
  278. $allow_server_sort = 'false';
  279. }
  280. if ( !$uid_support ) {
  281. $uid_support = 'true';
  282. }
  283. if ( !$allow_charset_search ) {
  284. $allow_charset_search = 'true';
  285. }
  286. if ( !$prefs_user_field ) {
  287. $prefs_user_field = 'user';
  288. }
  289. if ( !$prefs_key_field ) {
  290. $prefs_key_field = 'prefkey';
  291. }
  292. if ( !$prefs_val_field ) {
  293. $prefs_val_field = 'prefval';
  294. }
  295. if ( $ARGV[0] eq '--install-plugin' ) {
  296. print "Activating plugin " . $ARGV[1] . "\n";
  297. push @plugins, $ARGV[1];
  298. save_data();
  299. exit(0);
  300. } elsif ( $ARGV[0] eq '--remove-plugin' ) {
  301. print "Removing plugin " . $ARGV[1] . "\n";
  302. foreach $plugin (@plugins) {
  303. if ( $plugin ne $ARGV[1] ) {
  304. push @newplugins, $plugin;
  305. }
  306. }
  307. @plugins = @newplugins;
  308. save_data();
  309. exit(0);
  310. }
  311. #####################################################################################
  312. if ( $config_use_color == 1 ) {
  313. $WHT = "\x1B[37;1m";
  314. $NRM = "\x1B[0m";
  315. } else {
  316. $WHT = "";
  317. $NRM = "";
  318. $config_use_color = 2;
  319. }
  320. while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
  321. system "clear";
  322. print $WHT. "SquirrelMail Configuration : " . $NRM;
  323. if ( $config == 1 ) { print "Read: config.php"; }
  324. elsif ( $config == 2 ) { print "Read: config_default.php"; }
  325. print " ($print_config_version)\n";
  326. print "---------------------------------------------------------\n";
  327. if ( $menu == 0 ) {
  328. print $WHT. "Main Menu --\n" . $NRM;
  329. print "1. Organization Preferences\n";
  330. print "2. Server Settings\n";
  331. print "3. Folder Defaults\n";
  332. print "4. General Options\n";
  333. print "5. Themes\n";
  334. print "6. Address Books (LDAP)\n";
  335. print "7. Message of the Day (MOTD)\n";
  336. print "8. Plugins\n";
  337. print "9. Database\n";
  338. print "\n";
  339. print "D. Set pre-defined settings for specific IMAP servers\n";
  340. print "\n";
  341. } elsif ( $menu == 1 ) {
  342. print $WHT. "Organization Preferences\n" . $NRM;
  343. print "1. Organization Name : $WHT$org_name$NRM\n";
  344. print "2. Organization Logo : $WHT$org_logo$NRM\n";
  345. print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
  346. print "4. Organization Title : $WHT$org_title$NRM\n";
  347. print "5. Signout Page : $WHT$signout_page$NRM\n";
  348. print "6. Default Language : $WHT$squirrelmail_default_language$NRM\n";
  349. print "7. Top Frame : $WHT$frame_top$NRM\n";
  350. print "\n";
  351. print "R Return to Main Menu\n";
  352. } elsif ( $menu == 2 ) {
  353. print $WHT. "Server Settings\n" . $NRM;
  354. print "1. Domain : $WHT$domain$NRM\n";
  355. print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
  356. print "3. IMAP Port : $WHT$imapPort$NRM\n";
  357. print "4. Use Sendmail/SMTP : $WHT";
  358. if ( lc($useSendmail) eq "true" ) {
  359. print "Sendmail";
  360. } else {
  361. print "SMTP";
  362. }
  363. print "$NRM\n";
  364. if ( lc($useSendmail) eq "true" ) {
  365. print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
  366. } else {
  367. print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
  368. print "7. SMTP Port : $WHT$smtpPort$NRM\n";
  369. print "8. Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
  370. print "9. POP Before SMTP : $WHT$pop_before_smtp$NRM\n";
  371. }
  372. print "10. Server : $WHT$imap_server_type$NRM\n";
  373. print "11. Invert Time : $WHT$invert_time$NRM\n";
  374. print "12. Delimiter : $WHT$optional_delimiter$NRM\n";
  375. print "\n";
  376. print "R Return to Main Menu\n";
  377. } elsif ( $menu == 3 ) {
  378. print $WHT. "Folder Defaults\n" . $NRM;
  379. print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
  380. print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
  381. print "3. Trash Folder : $WHT$trash_folder$NRM\n";
  382. print "4. Sent Folder : $WHT$sent_folder$NRM\n";
  383. print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
  384. print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
  385. print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
  386. print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
  387. print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
  388. print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
  389. print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
  390. print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
  391. print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
  392. print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
  393. print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
  394. print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
  395. print "17. Don't move folders into Trash : $WHT$delete_folder$NRM\n";
  396. print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
  397. print "\n";
  398. print "R Return to Main Menu\n";
  399. } elsif ( $menu == 4 ) {
  400. print $WHT. "General Options\n" . $NRM;
  401. print "1. Default Charset : $WHT$default_charset$NRM\n";
  402. print "2. Data Directory : $WHT$data_dir$NRM\n";
  403. print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
  404. print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
  405. print "5. Default Left Size : $WHT$default_left_size$NRM\n";
  406. print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
  407. print "7. Allow use of priority : $WHT$default_use_priority$NRM\n";
  408. print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
  409. print "9. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
  410. print "10. Allow editing of identity : $WHT$edit_identity$NRM\n";
  411. print "11. Allow server thread sort : $WHT$allow_thread_sort$NRM\n";
  412. print "12. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
  413. if ( lc($edit_identity) eq "false" ) {
  414. print "13. Allow editing of name : $WHT$edit_name$NRM\n";
  415. }
  416. print "14. Allow server charset search : $WHT$allow_charset_search$NRM\n";
  417. print "15. Enable UID support : $WHT$uid_support$NRM\n";
  418. print "\n";
  419. print "R Return to Main Menu\n";
  420. } elsif ( $menu == 5 ) {
  421. print $WHT. "Themes\n" . $NRM;
  422. print "1. Change Themes\n";
  423. for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
  424. print " > $theme_name[$count]\n";
  425. }
  426. print "2. CSS File : $WHT$theme_css$NRM\n";
  427. print "\n";
  428. print "R Return to Main Menu\n";
  429. } elsif ( $menu == 6 ) {
  430. print $WHT. "Address Books (LDAP)\n" . $NRM;
  431. print "1. Change Servers\n";
  432. for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
  433. print " > $ldap_host[$count]\n";
  434. }
  435. print
  436. "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
  437. print "\n";
  438. print "R Return to Main Menu\n";
  439. } elsif ( $menu == 7 ) {
  440. print $WHT. "Message of the Day (MOTD)\n" . $NRM;
  441. print "\n$motd\n";
  442. print "\n";
  443. print "1 Edit the MOTD\n";
  444. print "\n";
  445. print "R Return to Main Menu\n";
  446. } elsif ( $menu == 8 ) {
  447. print $WHT. "Plugins\n" . $NRM;
  448. print " Installed Plugins\n";
  449. $num = 0;
  450. for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
  451. $num = $count + 1;
  452. print " $num. $plugins[$count]\n";
  453. }
  454. print "\n Available Plugins:\n";
  455. opendir( DIR, "../plugins" );
  456. @files = readdir(DIR);
  457. $pos = 0;
  458. @unused_plugins = ();
  459. for ( $i = 0 ; $i <= $#files ; $i++ ) {
  460. if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
  461. $match = 0;
  462. for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
  463. if ( $plugins[$k] eq $files[$i] ) {
  464. $match = 1;
  465. }
  466. }
  467. if ( $match == 0 ) {
  468. $unused_plugins[$pos] = $files[$i];
  469. $pos++;
  470. }
  471. }
  472. }
  473. for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
  474. $num = $num + 1;
  475. print " $num. $unused_plugins[$i]\n";
  476. }
  477. closedir DIR;
  478. print "\n";
  479. print "A Sanitize all plugins for use with Squirrelmail 1.2\n";
  480. print "\n";
  481. print "R Return to Main Menu\n";
  482. } elsif ( $menu == 9 ) {
  483. print $WHT. "Database\n" . $NRM;
  484. print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
  485. print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
  486. print "\n";
  487. print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
  488. print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
  489. print "5. Field for username : $WHT$prefs_user_field$NRM\n";
  490. print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n";
  491. print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n";
  492. print "\n";
  493. print "R Return to Main Menu\n";
  494. }
  495. if ( $config_use_color == 1 ) {
  496. print "C. Turn color off\n";
  497. } else {
  498. print "C. Turn color on\n";
  499. }
  500. print "S Save data\n";
  501. print "Q Quit\n";
  502. print "\n";
  503. print "Command >> " . $WHT;
  504. $command = <STDIN>;
  505. $command =~ s/[\n|\r]//g;
  506. $command =~ tr/A-Z/a-z/;
  507. print "$NRM\n";
  508. # Read the commands they entered.
  509. if ( $command eq "r" ) {
  510. $menu = 0;
  511. } elsif ( $command eq "s" ) {
  512. save_data();
  513. print "Press enter to continue...";
  514. $tmp = <STDIN>;
  515. $saved = 1;
  516. } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
  517. print "You have not saved your data.\n";
  518. print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
  519. $save = <STDIN>;
  520. if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
  521. save_data();
  522. }
  523. } elsif ( $command eq "c" ) {
  524. if ( $config_use_color == 1 ) {
  525. $config_use_color = 2;
  526. $WHT = "";
  527. $NRM = "";
  528. } else {
  529. $config_use_color = 1;
  530. $WHT = "\x1B[37;1m";
  531. $NRM = "\x1B[0m";
  532. }
  533. } elsif ( $command eq "d" && $menu == 0 ) {
  534. set_defaults();
  535. } else {
  536. $saved = 0;
  537. if ( $menu == 0 ) {
  538. if ( ( $command > 0 ) && ( $command < 10 ) ) {
  539. $menu = $command;
  540. }
  541. } elsif ( $menu == 1 ) {
  542. if ( $command == 1 ) { $org_name = command1(); }
  543. elsif ( $command == 2 ) { $org_logo = command2(); }
  544. elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a(); }
  545. elsif ( $command == 4 ) { $org_title = command3(); }
  546. elsif ( $command == 5 ) { $signout_page = command4(); }
  547. elsif ( $command == 6 ) { $squirrelmail_default_language = command5(); }
  548. elsif ( $command == 7 ) { $frame_top = command6(); }
  549. } elsif ( $menu == 2 ) {
  550. if ( $command == 1 ) { $domain = command11(); }
  551. elsif ( $command == 2 ) { $imapServerAddress = command12(); }
  552. elsif ( $command == 3 ) { $imapPort = command13(); }
  553. elsif ( $command == 4 ) { $useSendmail = command14(); }
  554. elsif ( $command == 5 ) { $sendmail_path = command15(); }
  555. elsif ( $command == 6 ) { $smtpServerAddress = command16(); }
  556. elsif ( $command == 7 ) { $smtpPort = command17(); }
  557. elsif ( $command == 8 ) { $use_authenticated_smtp = command18(); }
  558. elsif ( $command == 9 ) { $pop_before_smtp = command18a(); }
  559. elsif ( $command == 10 ) { $imap_server_type = command19(); }
  560. elsif ( $command == 11 ) { $invert_time = command110(); }
  561. elsif ( $command == 12 ) { $optional_delimiter = command111(); }
  562. } elsif ( $menu == 3 ) {
  563. if ( $command == 1 ) { $default_folder_prefix = command21(); }
  564. elsif ( $command == 2 ) { $show_prefix_option = command22(); }
  565. elsif ( $command == 3 ) { $trash_folder = command23a(); }
  566. elsif ( $command == 4 ) { $sent_folder = command23b(); }
  567. elsif ( $command == 5 ) { $draft_folder = command23c(); }
  568. elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
  569. elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
  570. elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
  571. elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
  572. elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
  573. elsif ( $command == 11 ) { $auto_expunge = command29(); }
  574. elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
  575. elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
  576. elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
  577. elsif ( $command == 15 ) { $default_unseen_type = command213(); }
  578. elsif ( $command == 16 ) { $auto_create_special = command214(); }
  579. elsif ( $command == 17 ) { $delete_folder = command215(); }
  580. elsif ( $command == 18 ) { $noselect_fix_enable = command216(); }
  581. } elsif ( $menu == 4 ) {
  582. if ( $command == 1 ) { $default_charset = command31(); }
  583. elsif ( $command == 2 ) { $data_dir = command33a(); }
  584. elsif ( $command == 3 ) { $attachment_dir = command33b(); }
  585. elsif ( $command == 4 ) { $dir_hash_level = command33c(); }
  586. elsif ( $command == 5 ) { $default_left_size = command35(); }
  587. elsif ( $command == 6 ) { $force_username_lowercase = command36(); }
  588. elsif ( $command == 7 ) { $default_use_priority = command37(); }
  589. elsif ( $command == 8 ) { $hide_sm_attributions = command38(); }
  590. elsif ( $command == 9 ) { $default_use_mdn = command39(); }
  591. elsif ( $command == 10 ) { $edit_identity = command310(); }
  592. elsif ( $command == 11 ) { $allow_thread_sort = command312(); }
  593. elsif ( $command == 12 ) { $allow_server_sort = command313(); }
  594. elsif ( $command == 13 ) { $edit_name = command311(); }
  595. elsif ( $command == 14 ) { $allow_charset_search = command314(); }
  596. elsif ( $command == 15 ) { $uid_support = command315(); }
  597. } elsif ( $menu == 5 ) {
  598. if ( $command == 1 ) { command41(); }
  599. elsif ( $command == 2 ) { $theme_css = command42(); }
  600. } elsif ( $menu == 6 ) {
  601. if ( $command == 1 ) { command61(); }
  602. elsif ( $command == 2 ) { command62(); }
  603. } elsif ( $menu == 7 ) {
  604. if ( $command == 1 ) { $motd = command71(); }
  605. } elsif ( $menu == 8 ) {
  606. if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
  607. elsif ( $command eq "a" ) { command8s(); }
  608. } elsif ( $menu == 9 ) {
  609. if ( $command == 1 ) { $addrbook_dsn = command91(); }
  610. elsif ( $command == 2 ) { $addrbook_table = command92(); }
  611. elsif ( $command == 3 ) { $prefs_dsn = command93(); }
  612. elsif ( $command == 4 ) { $prefs_table = command94(); }
  613. elsif ( $command == 5 ) { $prefs_user_field = command95(); }
  614. elsif ( $command == 6 ) { $prefs_key_field = command96(); }
  615. elsif ( $command == 7 ) { $prefs_val_field = command97(); }
  616. }
  617. }
  618. }
  619. ####################################################################################
  620. # org_name
  621. sub command1 {
  622. print "We have tried to make the name SquirrelMail as transparent as\n";
  623. print "possible. If you set up an organization name, most places where\n";
  624. print "SquirrelMail would take credit will be credited to your organization.\n";
  625. print "\n";
  626. print "[$WHT$org_name$NRM]: $WHT";
  627. $new_org_name = <STDIN>;
  628. if ( $new_org_name eq "\n" ) {
  629. $new_org_name = $org_name;
  630. } else {
  631. $new_org_name =~ s/[\r|\n]//g;
  632. $new_org_name =~ s/\"/&quot;/g;
  633. }
  634. return $new_org_name;
  635. }
  636. # org_logo
  637. sub command2 {
  638. print "Your organization's logo is an image that will be displayed at\n";
  639. print "different times throughout SquirrelMail. This is asking for the\n";
  640. print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
  641. print "(../images/logo.jpg) path to your logo.\n";
  642. print "\n";
  643. print "[$WHT$org_logo$NRM]: $WHT";
  644. $new_org_logo = <STDIN>;
  645. if ( $new_org_logo eq "\n" ) {
  646. $new_org_logo = $org_logo;
  647. } else {
  648. $new_org_logo =~ s/[\r|\n]//g;
  649. }
  650. return $new_org_logo;
  651. }
  652. # org_logo_width
  653. sub command2a {
  654. print "Your organization's logo is an image that will be displayed at\n";
  655. print "different times throughout SquirrelMail. Width\n";
  656. print "and Height of your logo image. Use '0' to disable.\n";
  657. print "\n";
  658. print "Width: [$WHT$org_logo_width$NRM]: $WHT";
  659. $new_org_logo_width = <STDIN>;
  660. $new_org_logo_width =~ tr/0-9//cd; # only want digits!
  661. if ( $new_org_logo_width eq '' ) {
  662. $new_org_logo_width = $org_logo_width;
  663. }
  664. if ( $new_org_logo_width > 0 ) {
  665. print "Height: [$WHT$org_logo_height$NRM]: $WHT";
  666. $new_org_logo_height = <STDIN>;
  667. $new_org_logo_height =~ tr/0-9//cd; # only want digits!
  668. if( $new_org_logo_height eq '' ) {
  669. $new_org_logo_height = $org_logo_height;
  670. }
  671. } else {
  672. $new_org_logo_height = 0;
  673. }
  674. return ($new_org_logo_width, $new_org_logo_height);
  675. }
  676. # org_title
  677. sub command3 {
  678. print "A title is what is displayed at the top of the browser window in\n";
  679. print "the titlebar. Usually this will end up looking something like:\n";
  680. print "\"Netscape: $org_title\"\n";
  681. print "\n";
  682. print "[$WHT$org_title$NRM]: $WHT";
  683. $new_org_title = <STDIN>;
  684. if ( $new_org_title eq "\n" ) {
  685. $new_org_title = $org_title;
  686. } else {
  687. $new_org_title =~ s/[\r|\n]//g;
  688. $new_org_title =~ s/\"/\'/g;
  689. }
  690. return $new_org_title;
  691. }
  692. # signout_page
  693. sub command4 {
  694. print "When users click the Sign Out button they will be logged out and\n";
  695. print "then sent to signout_page. If signout_page is left empty,\n";
  696. print "(hit space and then return) they will be taken, as normal,\n";
  697. print "to the default and rather sparse SquirrelMail signout page.\n";
  698. print "\n";
  699. print "[$WHT$signout_page$NRM]: $WHT";
  700. $new_signout_page = <STDIN>;
  701. if ( $new_signout_page eq "\n" ) {
  702. $new_signout_page = $signout_page;
  703. } else {
  704. $new_signout_page =~ s/[\r|\n]//g;
  705. $new_signout_page =~ s/^\s+$//g;
  706. }
  707. return $new_signout_page;
  708. }
  709. # Default language
  710. sub command5 {
  711. print "SquirrelMail attempts to set the language in many ways. If it\n";
  712. print "can not figure it out in another way, it will default to this\n";
  713. print "language. Please use the code for the desired language.\n";
  714. print "\n";
  715. print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
  716. $new_signout_page = <STDIN>;
  717. if ( $new_signout_page eq "\n" ) {
  718. $new_signout_page = $squirrelmail_default_language;
  719. } else {
  720. $new_signout_page =~ s/[\r|\n]//g;
  721. $new_signout_page =~ s/^\s+$//g;
  722. }
  723. return $new_signout_page;
  724. }
  725. # Default top frame
  726. sub command6 {
  727. print "SquirrelMail defaults to using the whole of the browser window.\n";
  728. print "This allows you to keep it within a specified frame. The default\n";
  729. print "is '_top'\n";
  730. print "\n";
  731. print "[$WHT$frame_top$NRM]: $WHT";
  732. $new_frame_top = <STDIN>;
  733. if ( $new_frame_top eq "\n" ) {
  734. $new_frame_top = '_top';
  735. } else {
  736. $new_frame_top =~ s/[\r|\n]//g;
  737. $new_frame_top =~ s/^\s+$//g;
  738. }
  739. return $new_frame_top;
  740. }
  741. ####################################################################################
  742. # domain
  743. sub command11 {
  744. print "The domain name is the suffix at the end of all email addresses. If\n";
  745. print "for example, your email address is jdoe\@myorg.com, then your domain\n";
  746. print "would be myorg.com.\n";
  747. print "\n";
  748. print "[$WHT$domain$NRM]: $WHT";
  749. $new_domain = <STDIN>;
  750. if ( $new_domain eq "\n" ) {
  751. $new_domain = $domain;
  752. } else {
  753. $new_domain =~ s/[\r|\n]//g;
  754. }
  755. return $new_domain;
  756. }
  757. # imapServerAddress
  758. sub command12 {
  759. print "This is the address where your IMAP server resides.\n";
  760. print "[$WHT$imapServerAddress$NRM]: $WHT";
  761. $new_imapServerAddress = <STDIN>;
  762. if ( $new_imapServerAddress eq "\n" ) {
  763. $new_imapServerAddress = $imapServerAddress;
  764. } else {
  765. $new_imapServerAddress =~ s/[\r|\n]//g;
  766. }
  767. return $new_imapServerAddress;
  768. }
  769. # imapPort
  770. sub command13 {
  771. print "This is the port that your IMAP server is on. Usually this is 143.\n";
  772. print "[$WHT$imapPort$NRM]: $WHT";
  773. $new_imapPort = <STDIN>;
  774. if ( $new_imapPort eq "\n" ) {
  775. $new_imapPort = $imapPort;
  776. } else {
  777. $new_imapPort =~ s/[\r|\n]//g;
  778. }
  779. return $new_imapPort;
  780. }
  781. # useSendmail
  782. sub command14 {
  783. print "You now need to choose the method that you will use for sending\n";
  784. print "messages in SquirrelMail. You can either connect to an SMTP server\n";
  785. print "or use sendmail directly.\n";
  786. if ( lc($useSendmail) eq "true" ) {
  787. $default_value = "1";
  788. } else {
  789. $default_value = "2";
  790. }
  791. print "\n";
  792. print " 1. Sendmail\n";
  793. print " 2. SMTP\n";
  794. print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
  795. $use_sendmail = <STDIN>;
  796. if ( ( $use_sendmail =~ /^1\n/i )
  797. || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
  798. $useSendmail = "true";
  799. } else {
  800. $useSendmail = "false";
  801. }
  802. return $useSendmail;
  803. }
  804. # sendmail_path
  805. sub command15 {
  806. if ( $sendmail_path[0] !~ /./ ) {
  807. $sendmail_path = "/usr/sbin/sendmail";
  808. }
  809. print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
  810. print "[$WHT$sendmail_path$NRM]: $WHT";
  811. $new_sendmail_path = <STDIN>;
  812. if ( $new_sendmail_path eq "\n" ) {
  813. $new_sendmail_path = $sendmail_path;
  814. } else {
  815. $new_sendmail_path =~ s/[\r|\n]//g;
  816. }
  817. return $new_sendmail_path;
  818. }
  819. # smtpServerAddress
  820. sub command16 {
  821. print "This is the location of your SMTP server.\n";
  822. print "[$WHT$smtpServerAddress$NRM]: $WHT";
  823. $new_smtpServerAddress = <STDIN>;
  824. if ( $new_smtpServerAddress eq "\n" ) {
  825. $new_smtpServerAddress = $smtpServerAddress;
  826. } else {
  827. $new_smtpServerAddress =~ s/[\r|\n]//g;
  828. }
  829. return $new_smtpServerAddress;
  830. }
  831. # smtpPort
  832. sub command17 {
  833. print "This is the port to connect to for SMTP. Usually 25.\n";
  834. print "[$WHT$smtpPort$NRM]: $WHT";
  835. $new_smtpPort = <STDIN>;
  836. if ( $new_smtpPort eq "\n" ) {
  837. $new_smtpPort = $smtpPort;
  838. } else {
  839. $new_smtpPort =~ s/[\r|\n]//g;
  840. }
  841. return $new_smtpPort;
  842. }
  843. # authenticated server
  844. sub command18 {
  845. print "Do you wish to use an authenticated SMTP server? Your server must\n";
  846. print "support this in order for SquirrelMail to work with it. We implemented\n";
  847. print "it according to RFC 2554.\n";
  848. $YesNo = 'n';
  849. $YesNo = 'y' if ( lc($use_authenticated_smtp) eq "true" );
  850. print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
  851. $new_use_authenticated_smtp = <STDIN>;
  852. $new_use_authenticated_smtp =~ tr/yn//cd;
  853. return "true" if ( $new_use_authenticated_smtp eq "y" );
  854. return "false" if ( $new_use_authenticated_smtp eq "n" );
  855. return $use_authenticated_smtp;
  856. }
  857. # pop before SMTP
  858. sub command18a {
  859. print "Do you wish to use POP3 before SMTP? Your server must\n";
  860. print "support this in order for SquirrelMail to work with it.\n";
  861. $YesNo = 'n';
  862. $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" );
  863. print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
  864. $new_pop_before_smtp = <STDIN>;
  865. $new_pop_before_smtp =~ tr/yn//cd;
  866. return "true" if ( $new_pop_before_smtp eq "y" );
  867. return "false" if ( $new_pop_before_smtp eq "n" );
  868. return $pop_before_smtp;
  869. }
  870. # imap_server_type
  871. sub command19 {
  872. print "Each IMAP server has its own quirks. As much as we tried to stick\n";
  873. print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
  874. print "the same principles. We have made some work-arounds for some of\n";
  875. print "these servers. If you would like to use them, please select your\n";
  876. print "IMAP server. If you do not wish to use these work-arounds, you can\n";
  877. print "set this to \"other\", and none will be used.\n";
  878. print " cyrus = Cyrus IMAP server\n";
  879. print " uw = University of Washington's IMAP server\n";
  880. print " exchange = Microsoft Exchange IMAP server\n";
  881. print " courier = Courier IMAP server\n";
  882. print " macosx = Mac OS X Mailserver\n";
  883. print " other = Not one of the above servers\n";
  884. print "[$WHT$imap_server_type$NRM]: $WHT";
  885. $new_imap_server_type = <STDIN>;
  886. if ( $new_imap_server_type eq "\n" ) {
  887. $new_imap_server_type = $imap_server_type;
  888. } else {
  889. $new_imap_server_type =~ s/[\r|\n]//g;
  890. }
  891. return $new_imap_server_type;
  892. }
  893. # invert_time
  894. sub command110 {
  895. print "Sometimes the date of messages sent is messed up (off by a few hours\n";
  896. print "on some machines). Typically this happens if the system doesn't support\n";
  897. print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
  898. print "This most often occurs on Solaris 7 machines in the United States.\n";
  899. print "By default, this is off. It should be kept off unless problems surface\n";
  900. print "about the time that messages are sent.\n";
  901. print " no = Do NOT fix time -- almost always correct\n";
  902. print " yes = Fix the time for this system\n";
  903. $YesNo = 'n';
  904. $YesNo = 'y' if ( lc($invert_time) eq "true" );
  905. print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
  906. $new_invert_time = <STDIN>;
  907. $new_invert_time =~ tr/yn//cd;
  908. return "true" if ( $new_invert_time eq "y" );
  909. return "false" if ( $new_invert_time eq "n" );
  910. return $invert_time;
  911. }
  912. sub command111 {
  913. print "This is the delimiter that your IMAP server uses to distinguish between\n";
  914. print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
  915. print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
  916. print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
  917. print "but if you are sure you know what delimiter your server uses, you can\n";
  918. print "specify it here.\n";
  919. print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
  920. print "[$WHT$optional_delimiter$NRM]: $WHT";
  921. $new_optional_delimiter = <STDIN>;
  922. if ( $new_optional_delimiter eq "\n" ) {
  923. $new_optional_delimiter = $optional_delimiter;
  924. } else {
  925. $new_optional_delimiter =~ s/[\r|\n]//g;
  926. }
  927. return $new_optional_delimiter;
  928. }
  929. # MOTD
  930. sub command71 {
  931. print "\nYou can now create the welcome message that is displayed\n";
  932. print "every time a user logs on. You can use HTML or just plain\n";
  933. print
  934. "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
  935. $new_motd = "";
  936. do {
  937. print "] ";
  938. $line = <STDIN>;
  939. $line =~ s/[\r|\n]//g;
  940. if ( $line ne "@" ) {
  941. $line =~ s/ /\&nbsp;\&nbsp;/g;
  942. $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
  943. $line =~ s/$/ /;
  944. $line =~ s/\"/&quot;/g;
  945. $new_motd = $new_motd . $line;
  946. }
  947. } while ( $line ne "@" );
  948. return $new_motd;
  949. }
  950. ################# PLUGINS ###################
  951. sub command81 {
  952. $command =~ s/[\s|\n|\r]*//g;
  953. if ( $command > 0 ) {
  954. $command = $command - 1;
  955. if ( $command <= $#plugins ) {
  956. @newplugins = ();
  957. $ct = 0;
  958. while ( $ct <= $#plugins ) {
  959. if ( $ct != $command ) {
  960. @newplugins = ( @newplugins, $plugins[$ct] );
  961. }
  962. $ct++;
  963. }
  964. @plugins = @newplugins;
  965. } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
  966. $num = $command - $#plugins - 1;
  967. @newplugins = @plugins;
  968. $ct = 0;
  969. while ( $ct <= $#unused_plugins ) {
  970. if ( $ct == $num ) {
  971. @newplugins = ( @newplugins, $unused_plugins[$ct] );
  972. # sanitize the plugin
  973. $dir = $unused_plugins[$ct];
  974. if (-d "../plugins/$dir") {
  975. `./ri_once.pl ../plugins/$dir`;
  976. } else {
  977. print "Could not locate ../plugins/$dir\n" ;
  978. print "The plugin $dir could *not* be sanitized!\n" ;
  979. print "If you want to try to do this manually, please run\n" ;
  980. print "config/ri_once.pl with the full path to the $dir plugin.\n" ;
  981. }
  982. }
  983. $ct++;
  984. }
  985. @plugins = @newplugins;
  986. }
  987. }
  988. return @plugins;
  989. }
  990. sub command8s {
  991. print "This command will sanitize all plugins for use with\n";
  992. print "Squirrelmail 1.2. That is, it will rewrite some php-\n";
  993. print "constructs that are *incompatible* with the 1.2 design\n";
  994. print "into ones that are *compatible*\n";
  995. print "Do you wish to issue this command [y/N]? ";
  996. $ctu = <STDIN>;
  997. if ( $ctu =~ /^y\n/i ) {
  998. `./ri_once.pl ../plugins`;
  999. }
  1000. }
  1001. ################# FOLDERS ###################
  1002. # default_folder_prefix
  1003. sub command21 {
  1004. print "Some IMAP servers (UW, for example) store mail and folders in\n";
  1005. print "your user space in a separate subdirectory. This is where you\n";
  1006. print "specify what that directory is.\n";
  1007. print "\n";
  1008. print "EXAMPLE: mail/";
  1009. print "\n";
  1010. print "NOTE: If you use Cyrus, or some server that would not use this\n";
  1011. print " option, you must set this to 'none'.\n";
  1012. print "\n";
  1013. print "[$WHT$default_folder_prefix$NRM]: $WHT";
  1014. $new_default_folder_prefix = <STDIN>;
  1015. if ( $new_default_folder_prefix eq "\n" ) {
  1016. $new_default_folder_prefix = $default_folder_prefix;
  1017. } else {
  1018. $new_default_folder_prefix =~ s/[\r\n]//g;
  1019. }
  1020. if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
  1021. $new_default_folder_prefix = "";
  1022. } else {
  1023. # add the trailing delimiter only if we know what the server is.
  1024. if (($imap_server_type eq 'cyrus' and
  1025. $optional_delimiter eq 'detect') or
  1026. ($imap_server_type eq 'courier' and
  1027. $optional_delimiter eq 'detect')) {
  1028. $new_default_folder_prefix =~ s/\.*$/\./;
  1029. } elsif ($imap_server_type eq 'uw' and
  1030. $optional_delimiter eq 'detect') {
  1031. $new_default_folder_prefix =~ s/\/*$/\//;
  1032. }
  1033. }
  1034. return $new_default_folder_prefix;
  1035. }
  1036. # Show Folder Prefix
  1037. sub command22 {
  1038. print "It is possible to set up the default folder prefix as a user\n";
  1039. print "specific option, where each user can specify what their mail\n";
  1040. print "folder is. If you set this to false, they will never see the\n";
  1041. print "option, but if it is true, this option will appear in the\n";
  1042. print "'options' section.\n";
  1043. print "\n";
  1044. print "NOTE: You set the default folder prefix in option '1' of this\n";
  1045. print " section. That will be the default if the user doesn't\n";
  1046. print " specify anything different.\n";
  1047. print "\n";
  1048. if ( lc($show_prefix_option) eq "true" ) {
  1049. $default_value = "y";
  1050. } else {
  1051. $default_value = "n";
  1052. }
  1053. print "\n";
  1054. print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
  1055. $new_show = <STDIN>;
  1056. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1057. $show_prefix_option = "true";
  1058. } else {
  1059. $show_prefix_option = "false";
  1060. }
  1061. return $show_prefix_option;
  1062. }
  1063. # Trash Folder
  1064. sub command23a {
  1065. print "You can now specify where the default trash folder is located.\n";
  1066. print "On servers where you do not want this, you can set it to anything\n";
  1067. print "and set option 6 to false.\n";
  1068. print "\n";
  1069. print "This is relative to where the rest of your email is kept. You do\n";
  1070. print "not need to worry about their mail directory. If this folder\n";
  1071. print "would be ~/mail/trash on the filesystem, you only need to specify\n";
  1072. print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
  1073. print "\n";
  1074. print "[$WHT$trash_folder$NRM]: $WHT";
  1075. $new_trash_folder = <STDIN>;
  1076. if ( $new_trash_folder eq "\n" ) {
  1077. $new_trash_folder = $trash_folder;
  1078. } else {
  1079. $new_trash_folder =~ s/[\r|\n]//g;
  1080. }
  1081. return $new_trash_folder;
  1082. }
  1083. # Sent Folder
  1084. sub command23b {
  1085. print "This is where messages that are sent will be stored. SquirrelMail\n";
  1086. print "by default puts a copy of all outgoing messages in this folder.\n";
  1087. print "\n";
  1088. print "This is relative to where the rest of your email is kept. You do\n";
  1089. print "not need to worry about their mail directory. If this folder\n";
  1090. print "would be ~/mail/sent on the filesystem, you only need to specify\n";
  1091. print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
  1092. print "\n";
  1093. print "[$WHT$sent_folder$NRM]: $WHT";
  1094. $new_sent_folder = <STDIN>;
  1095. if ( $new_sent_folder eq "\n" ) {
  1096. $new_sent_folder = $sent_folder;
  1097. } else {
  1098. $new_sent_folder =~ s/[\r|\n]//g;
  1099. }
  1100. return $new_sent_folder;
  1101. }
  1102. # Draft Folder
  1103. sub command23c {
  1104. print "You can now specify where the default draft folder is located.\n";
  1105. print "On servers where you do not want this, you can set it to anything\n";
  1106. print "and set option 9 to false.\n";
  1107. print "\n";
  1108. print "This is relative to where the rest of your email is kept. You do\n";
  1109. print "not need to worry about their mail directory. If this folder\n";
  1110. print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
  1111. print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
  1112. print "\n";
  1113. print "[$WHT$draft_folder$NRM]: $WHT";
  1114. $new_draft_folder = <STDIN>;
  1115. if ( $new_draft_folder eq "\n" ) {
  1116. $new_draft_folder = $draft_folder;
  1117. } else {
  1118. $new_draft_folder =~ s/[\r|\n]//g;
  1119. }
  1120. return $new_draft_folder;
  1121. }
  1122. # default move to trash
  1123. sub command24a {
  1124. print "By default, should messages get moved to the trash folder? You\n";
  1125. print "can specify the default trash folder in option 3. If this is set\n";
  1126. print "to false, messages will get deleted immediately without moving\n";
  1127. print "to the trash folder.\n";
  1128. print "\n";
  1129. print "Trash folder is currently: $trash_folder\n";
  1130. print "\n";
  1131. if ( lc($default_move_to_trash) eq "true" ) {
  1132. $default_value = "y";
  1133. } else {
  1134. $default_value = "n";
  1135. }
  1136. print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
  1137. $new_show = <STDIN>;
  1138. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1139. $default_move_to_trash = "true";
  1140. } else {
  1141. $default_move_to_trash = "false";
  1142. }
  1143. return $default_move_to_trash;
  1144. }
  1145. # default move to sent
  1146. sub command24b {
  1147. print "By default, should messages get moved to the sent folder? You\n";
  1148. print "can specify the default sent folder in option 4. If this is set\n";
  1149. print "to false, messages will get sent and no copy will be made.\n";
  1150. print "\n";
  1151. print "Sent folder is currently: $sent_folder\n";
  1152. print "\n";
  1153. if ( lc($default_move_to_sent) eq "true" ) {
  1154. $default_value = "y";
  1155. } else {
  1156. $default_value = "n";
  1157. }
  1158. print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
  1159. $new_show = <STDIN>;
  1160. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1161. $default_move_to_sent = "true";
  1162. } else {
  1163. $default_move_to_sent = "false";
  1164. }
  1165. return $default_move_to_sent;
  1166. }
  1167. # default save as draft
  1168. sub command24c {
  1169. print "By default, should the save to draft option be shown? You can\n";
  1170. print "specify the default drafts folder in option 5. If this is set\n";
  1171. print "to false, users will not be shown the save to draft option.\n";
  1172. print "\n";
  1173. print "Drafts folder is currently: $draft_folder\n";
  1174. print "\n";
  1175. if ( lc($default_move_to_draft) eq "true" ) {
  1176. $default_value = "y";
  1177. } else {
  1178. $default_value = "n";
  1179. }
  1180. print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
  1181. $new_show = <STDIN>;
  1182. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1183. $default_save_as_draft = "true";
  1184. } else {
  1185. $default_save_as_draft = "false";
  1186. }
  1187. return $default_save_as_draft;
  1188. }
  1189. # List special folders first
  1190. sub command27 {
  1191. print "SquirrelMail has what we call 'special folders' that are not\n";
  1192. print "manipulated and viewed like normal folders. Some examples of\n";
  1193. print "these folders would be INBOX, Trash, Sent, etc. This option\n";
  1194. print "Simply asks if you want these folders listed first in the folder\n";
  1195. print "listing.\n";
  1196. print "\n";
  1197. if ( lc($list_special_folders_first) eq "true" ) {
  1198. $default_value = "y";
  1199. } else {
  1200. $default_value = "n";
  1201. }
  1202. print "\n";
  1203. print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
  1204. $new_show = <STDIN>;
  1205. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1206. $list_special_folders_first = "true";
  1207. } else {
  1208. $list_special_folders_first = "false";
  1209. }
  1210. return $list_special_folders_first;
  1211. }
  1212. # Show special folders color
  1213. sub command28 {
  1214. print "SquirrelMail has what we call 'special folders' that are not\n";
  1215. print "manipulated and viewed like normal folders. Some examples of\n";
  1216. print "these folders would be INBOX, Trash, Sent, etc. This option\n";
  1217. print "wants to know if we should display special folders in a\n";
  1218. print "color than the other folders.\n";
  1219. print "\n";
  1220. if ( lc($use_special_folder_color) eq "true" ) {
  1221. $default_value = "y";
  1222. } else {
  1223. $default_value = "n";
  1224. }
  1225. print "\n";
  1226. print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
  1227. $new_show = <STDIN>;
  1228. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1229. $use_special_folder_color = "true";
  1230. } else {
  1231. $use_special_folder_color = "false";
  1232. }
  1233. return $use_special_folder_color;
  1234. }
  1235. # Auto expunge
  1236. sub command29 {
  1237. print "The way that IMAP handles deleting messages is as follows. You\n";
  1238. print "mark the message as deleted, and then to 'really' delete it, you\n";
  1239. print "expunge it. This option asks if you want to just have messages\n";
  1240. print "marked as deleted, or if you want SquirrelMail to expunge the \n";
  1241. print "messages too.\n";
  1242. print "\n";
  1243. if ( lc($auto_expunge) eq "true" ) {
  1244. $default_value = "y";
  1245. } else {
  1246. $default_value = "n";
  1247. }
  1248. print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
  1249. $new_show = <STDIN>;
  1250. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1251. $auto_expunge = "true";
  1252. } else {
  1253. $auto_expunge = "false";
  1254. }
  1255. return $auto_expunge;
  1256. }
  1257. # Default sub of inbox
  1258. sub command210 {
  1259. print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
  1260. print "This can cause some confusion in folder creation for users when\n";
  1261. print "they try to create folders and don't put it as a subfolder of INBOX\n";
  1262. print "and get permission errors. This option asks if you want folders\n";
  1263. print "to be subfolders of INBOX by default.\n";
  1264. print "\n";
  1265. if ( lc($default_sub_of_inbox) eq "true" ) {
  1266. $default_value = "y";
  1267. } else {
  1268. $default_value = "n";
  1269. }
  1270. print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
  1271. $new_show = <STDIN>;
  1272. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1273. $default_sub_of_inbox = "true";
  1274. } else {
  1275. $default_sub_of_inbox = "false";
  1276. }
  1277. return $default_sub_of_inbox;
  1278. }
  1279. # Show contain subfolder option
  1280. sub command211 {
  1281. print "Some IMAP servers (UW) make it so that there are two types of\n";
  1282. print "folders. Those that contain messages, and those that contain\n";
  1283. print "subfolders. If this is the case for your server, set this to\n";
  1284. print "true, and it will ask the user whether the folder they are\n";
  1285. print "creating contains subfolders or messages.\n";
  1286. print "\n";
  1287. if ( lc($show_contain_subfolders_option) eq "true" ) {
  1288. $default_value = "y";
  1289. } else {
  1290. $default_value = "n";
  1291. }
  1292. print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
  1293. $new_show = <STDIN>;
  1294. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1295. $show_contain_subfolders_option = "true";
  1296. } else {
  1297. $show_contain_subfolders_option = "false";
  1298. }
  1299. return $show_contain_subfolders_option;
  1300. }
  1301. # Default Unseen Notify
  1302. sub command212 {
  1303. print "This option specifies where the users will receive notification\n";
  1304. print "about unseen messages by default. This is of course an option that\n";
  1305. print "can be changed on a user level.\n";
  1306. print " 1 = No notification\n";
  1307. print " 2 = Only on the INBOX\n";
  1308. print " 3 = On all folders\n";
  1309. print "\n";
  1310. print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
  1311. $new_show = <STDIN>;
  1312. if ( $new_show =~ /^[1|2|3]\n/i ) {
  1313. $default_unseen_notify = $new_show;
  1314. }
  1315. $default_unseen_notify =~ s/[\r|\n]//g;
  1316. return $default_unseen_notify;
  1317. }
  1318. # Default Unseen Type
  1319. sub command213 {
  1320. print "Here you can define the default way that unseen messages will be displayed\n";
  1321. print "to the user in the folder listing on the left side.\n";
  1322. print " 1 = Only unseen messages (4)\n";
  1323. print " 2 = Unseen and Total messages (4/27)\n";
  1324. print "\n";
  1325. print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
  1326. $new_show = <STDIN>;
  1327. if ( $new_show =~ /^[1|2]\n/i ) {
  1328. $default_unseen_type = $new_show;
  1329. }
  1330. $default_unseen_type =~ s/[\r|\n]//g;
  1331. return $default_unseen_type;
  1332. }
  1333. # Auto create special folders
  1334. sub command214 {
  1335. print "Would you like the Sent, Trash, and Drafts folders to be created\n";
  1336. print "automatically print for you when a user logs in? If the user\n";
  1337. print "accidentally deletes their special folders, this option will\n";
  1338. print "automatically create it again for them.\n";
  1339. print "\n";
  1340. if ( lc($auto_create_special) eq "true" ) {
  1341. $default_value = "y";
  1342. } else {
  1343. $default_value = "n";
  1344. }
  1345. print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
  1346. $new_show = <STDIN>;
  1347. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1348. $auto_create_special = "true";
  1349. } else {
  1350. $auto_create_special = "false";
  1351. }
  1352. return $auto_create_special;
  1353. }
  1354. # Auto create special folders
  1355. sub command215 {
  1356. print "Would you like to automatically completely delete any deleted\n";
  1357. print "folders? If not then they will be moved to the Trash folder\n";
  1358. print "and can be deleted from there\n";
  1359. print "\n";
  1360. if ( lc($delete_folder) eq "true" ) {
  1361. $default_value = "y";
  1362. } else {
  1363. $default_value = "n";
  1364. }
  1365. print "Auto delete folders? (y/n) [$WHT$default_value$NRM]: $WHT";
  1366. $new_delete = <STDIN>;
  1367. if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1368. $delete_folder = "true";
  1369. } else {
  1370. $delete_folder = "false";
  1371. }
  1372. return $delete_folder;
  1373. }
  1374. #noselect fix
  1375. sub command216 {
  1376. print "Some IMAP server allow subfolders to exist even if the parent\n";
  1377. print "folders do not. This fixes some problems with the folder list\n";
  1378. print "when this is the case, causing the /NoSelect folders to be displayed\n";
  1379. print "\n";
  1380. if ( lc($noselect_fix_enable) eq "true" ) {
  1381. $default_value = "y";
  1382. } else {
  1383. $default_value = "n";
  1384. }
  1385. print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
  1386. $noselect_fix_enable = <STDIN>;
  1387. if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1388. $noselect_fix_enable = "true";
  1389. } else {
  1390. $noselect_fix_enable = "false";
  1391. }
  1392. return $noselect_fix_enable;
  1393. }
  1394. ############# GENERAL OPTIONS #####################
  1395. # Default Charset
  1396. sub command31 {
  1397. print "This option controls what character set is used when sending\n";
  1398. print "mail and when sending HTML to the browser. Do not set this\n";
  1399. print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
  1400. print "to use KOI8-R, since this implementation is faster than most\n";
  1401. print "of the alternatives\n";
  1402. print "\n";
  1403. print "[$WHT$default_charset$NRM]: $WHT";
  1404. $new_default_charset = <STDIN>;
  1405. if ( $new_default_charset eq "\n" ) {
  1406. $new_default_charset = $default_charset;
  1407. } else {
  1408. $new_default_charset =~ s/[\r|\n]//g;
  1409. }
  1410. return $new_default_charset;
  1411. }
  1412. # Data directory
  1413. sub command33a {
  1414. print "It is a possible security hole to have a writable directory\n";
  1415. print "under the web server's root directory (ex: /home/httpd/html).\n";
  1416. print "For this reason, it is possible to put the data directory\n";
  1417. print "anywhere you would like. The path name can be absolute or\n";
  1418. print "relative (to the config directory). It doesn't matter. Here\n";
  1419. print "are two examples:\n";
  1420. print " Absolute: /usr/local/squirrelmail/data/\n";
  1421. print " Relative: ../data/\n";
  1422. print "\n";
  1423. print "[$WHT$data_dir$NRM]: $WHT";
  1424. $new_data_dir = <STDIN>;
  1425. if ( $new_data_dir eq "\n" ) {
  1426. $new_data_dir = $data_dir;
  1427. } else {
  1428. $new_data_dir =~ s/[\r|\n]//g;
  1429. }
  1430. if ( $new_data_dir =~ /^\s*$/ ) {
  1431. $new_data_dir = "";
  1432. } else {
  1433. $new_data_dir =~ s/\/*$//g;
  1434. $new_data_dir =~ s/$/\//g;
  1435. }
  1436. return $new_data_dir;
  1437. }
  1438. # Attachment directory
  1439. sub command33b {
  1440. print "Path to directory used for storing attachments while a mail is\n";
  1441. print "being sent. There are a few security considerations regarding this\n";
  1442. print "directory:\n";
  1443. print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
  1444. print " impossible for a random person with access to the webserver\n";
  1445. print " to list files in this directory. Confidential data might\n";
  1446. print " be laying around in there.\n";
  1447. print " 2. Since the webserver is not able to list the files in the\n";
  1448. print " content is also impossible for the webserver to delete files\n";
  1449. print " lying around there for too long.\n";
  1450. print " 3. It should probably be another directory than the data\n";
  1451. print " directory specified in option 3.\n";
  1452. print "\n";
  1453. print "[$WHT$attachment_dir$NRM]: $WHT";
  1454. $new_attachment_dir = <STDIN>;
  1455. if ( $new_attachment_dir eq "\n" ) {
  1456. $new_attachment_dir = $attachment_dir;
  1457. } else {
  1458. $new_attachment_dir =~ s/[\r|\n]//g;
  1459. }
  1460. if ( $new_attachment_dir =~ /^\s*$/ ) {
  1461. $new_attachment_dir = "";
  1462. } else {
  1463. $new_attachment_dir =~ s/\/*$//g;
  1464. $new_attachment_dir =~ s/$/\//g;
  1465. }
  1466. return $new_attachment_dir;
  1467. }
  1468. sub command33c {
  1469. print "The directory hash level setting allows you to configure the level\n";
  1470. print "of hashing that Squirremail employs in your data and attachment\n";
  1471. print "directories. This value must be an integer ranging from 0 to 4.\n";
  1472. print "When this value is set to 0, Squirrelmail will simply store all\n";
  1473. print "files as normal in the data and attachment directories. However,\n";
  1474. print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
  1475. print "used to organize the files in this directory. In short, the crc32\n";
  1476. print "value for a username will be computed. Then, up to the first 4\n";
  1477. print "digits of the hash, as set by this configuration value, will be\n";
  1478. print "used to directory hash the files for that user in the data and\n";
  1479. print "attachment directory. This allows for better performance on\n";
  1480. print "servers with larger numbers of users.\n";
  1481. print "\n";
  1482. print "[$WHT$dir_hash_level$NRM]: $WHT";
  1483. $new_dir_hash_level = <STDIN>;
  1484. if ( $new_dir_hash_level eq "\n" ) {
  1485. $new_dir_hash_level = $dir_hash_level;
  1486. } else {
  1487. $new_dir_hash_level =~ s/[\r|\n]//g;
  1488. }
  1489. if ( ( int($new_dir_hash_level) < 0 )
  1490. || ( int($new_dir_hash_level) > 4 )
  1491. || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
  1492. print "Invalid Directory Hash Level.\n";
  1493. print "Value must be an integer ranging from 0 to 4\n";
  1494. print "Hit enter to continue.\n";
  1495. $enter_key = <STDIN>;
  1496. $new_dir_hash_level = $dir_hash_level;
  1497. }
  1498. return $new_dir_hash_level;
  1499. }
  1500. sub command35 {
  1501. print "This is the default size (in pixels) of the left folder list.\n";
  1502. print "Default is 200, but you can set it to whatever you wish. This\n";
  1503. print "is a user preference, so this will only show up as their default.\n";
  1504. print "\n";
  1505. print "[$WHT$default_left_size$NRM]: $WHT";
  1506. $new_default_left_size = <STDIN>;
  1507. if ( $new_default_left_size eq "\n" ) {
  1508. $new_default_left_size = $default_left_size;
  1509. } else {
  1510. $new_default_left_size =~ s/[\r|\n]//g;
  1511. }
  1512. return $new_default_left_size;
  1513. }
  1514. sub command36 {
  1515. print "Some IMAP servers only have lowercase letters in the usernames\n";
  1516. print "but they still allow people with uppercase to log in. This\n";
  1517. print "causes a problem with the user's preference files. This option\n";
  1518. print "transparently changes all usernames to lowercase.";
  1519. print "\n";
  1520. if ( lc($force_username_lowercase) eq "true" ) {
  1521. $default_value = "y";
  1522. } else {
  1523. $default_value = "n";
  1524. }
  1525. print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
  1526. $new_show = <STDIN>;
  1527. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1528. return "true";
  1529. }
  1530. return "false";
  1531. }
  1532. sub command37 {
  1533. print "";
  1534. print "\n";
  1535. if ( lc($default_use_priority) eq "true" ) {
  1536. $default_value = "y";
  1537. } else {
  1538. $default_value = "n";
  1539. }
  1540. print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
  1541. $new_show = <STDIN>;
  1542. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1543. return "true";
  1544. }
  1545. return "false";
  1546. }
  1547. sub command38 {
  1548. print "";
  1549. print "\n";
  1550. if ( lc($default_hide_attribution) eq "true" ) {
  1551. $default_value = "y";
  1552. } else {
  1553. $default_value = "n";
  1554. }
  1555. print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
  1556. $new_show = <STDIN>;
  1557. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1558. return "true";
  1559. }
  1560. return "false";
  1561. }
  1562. sub command39 {
  1563. print "";
  1564. print "\n";
  1565. if ( lc($default_use_mdn) eq "true" ) {
  1566. $default_value = "y";
  1567. } else {
  1568. $default_value = "n";
  1569. }
  1570. print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
  1571. $new_show = <STDIN>;
  1572. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1573. return "true";
  1574. }
  1575. return "false";
  1576. }
  1577. sub command310 {
  1578. print "This allows you to prevent the editing of the users name and";
  1579. print "email address. This is mainly useful when used with the";
  1580. print "retrieveuserdata plugin\n";
  1581. print "\n";
  1582. if ( lc($edit_identity) eq "true" ) {
  1583. $default_value = "y";
  1584. } else {
  1585. $default_value = "n";
  1586. }
  1587. print "Allow editing? (y/n) [$WHT$default_value$NRM]: $WHT";
  1588. $new_edit = <STDIN>;
  1589. if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1590. $edit_identity = "true";
  1591. } else {
  1592. $edit_identity = "false";
  1593. }
  1594. return $edit_identity;
  1595. }
  1596. sub command311 {
  1597. print "This option allows you to choose if the user can edit their full name";
  1598. print "even when you don't want them to change their username\n";
  1599. print "\n";
  1600. if ( lc($edit_name) eq "true" ) {
  1601. $default_value = "y";
  1602. } else {
  1603. $default_value = "n";
  1604. }
  1605. print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
  1606. $new_edit = <STDIN>;
  1607. if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1608. $edit_name = "true";
  1609. } else {
  1610. $edit_name = "false";
  1611. }
  1612. return $edit_name;
  1613. }
  1614. sub command312 {
  1615. print "This option allows you to choose if users can use thread sorting\n";
  1616. print "Your IMAP server must support the THREAD command for this to work\n";
  1617. print "PHP versions later than 4.0.3 recommended\n";
  1618. print "\n";
  1619. if ( lc($allow_thread_sort) eq "true" ) {
  1620. $default_value = "y";
  1621. } else {
  1622. $default_value = "n";
  1623. }
  1624. print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
  1625. $allow_thread_sort = <STDIN>;
  1626. if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1627. $allow_thread_sort = "true";
  1628. } else {
  1629. $allow_thread_sort = "false";
  1630. }
  1631. return $allow_thread_sort;
  1632. }
  1633. sub command313 {
  1634. print "This option allows you to choose if SM uses server-side sorting\n";
  1635. print "Your IMAP server must support the SORT command for this to work\n";
  1636. print "\n";
  1637. if ( lc($allow_server_sort) eq "true" ) {
  1638. $default_value = "y";
  1639. } else {
  1640. $default_value = "n";
  1641. }
  1642. print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
  1643. $allow_server_sort = <STDIN>;
  1644. if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1645. $allow_server_sort = "true";
  1646. } else {
  1647. $allow_server_sort = "false";
  1648. }
  1649. return $allow_server_sort;
  1650. }
  1651. sub command314 {
  1652. print "This option allows you to choose if SM uses charset search\n";
  1653. print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
  1654. print "\n";
  1655. if ( lc($allow_charset_search) eq "true" ) {
  1656. $default_value = "y";
  1657. } else {
  1658. $default_value = "n";
  1659. }
  1660. print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
  1661. $allow_charset_search = <STDIN>;
  1662. if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1663. $allow_charset_search = "true";
  1664. } else {
  1665. $allow_charset_search = "false";
  1666. }
  1667. return $allow_charset_search;
  1668. }
  1669. sub command315 {
  1670. print "This option allows you to enable unique identifier (UID) support.\n";
  1671. print "\n";
  1672. if ( lc($uid_support) eq "true" ) {
  1673. $default_value = "y";
  1674. } else {
  1675. $default_value = "n";
  1676. }
  1677. print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT";
  1678. $uid_support = <STDIN>;
  1679. if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1680. $uid_support = "true";
  1681. } else {
  1682. $uid_support = "false";
  1683. }
  1684. return $uid_support;
  1685. }
  1686. sub command41 {
  1687. print "\nNow we will define the themes that you wish to use. If you have added\n";
  1688. print "a theme of your own, just follow the instructions (?) about how to add\n";
  1689. print "them. You can also change the default theme.\n";
  1690. print "[theme] command (?=help) > ";
  1691. $input = <STDIN>;
  1692. $input =~ s/[\r|\n]//g;
  1693. while ( $input ne "d" ) {
  1694. if ( $input =~ /^\s*l\s*/i ) {
  1695. $count = 0;
  1696. while ( $count <= $#theme_name ) {
  1697. if ( $count == $theme_default ) {
  1698. print " *";
  1699. } else {
  1700. print " ";
  1701. }
  1702. $name = $theme_name[$count];
  1703. $num_spaces = 25 - length($name);
  1704. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  1705. $name = $name . " ";
  1706. }
  1707. print " $count. $name";
  1708. print "($theme_path[$count])\n";
  1709. $count++;
  1710. }
  1711. } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
  1712. $old_def = $theme_default;
  1713. $theme_default = $input;
  1714. $theme_default =~ s/^\s*m\s*//;
  1715. if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
  1716. print "Cannot set default theme to $theme_default. That theme does not exist.\n";
  1717. $theme_default = $old_def;
  1718. }
  1719. } elsif ( $input =~ /^\s*\+/ ) {
  1720. print "What is the name of this theme: ";
  1721. $name = <STDIN>;
  1722. $name =~ s/[\r|\n]//g;
  1723. $theme_name[ $#theme_name + 1 ] = $name;
  1724. print "Be sure to put ../themes/ before the filename.\n";
  1725. print "What file is this stored in (ex: ../themes/default_theme.php): ";
  1726. $name = <STDIN>;
  1727. $name =~ s/[\r|\n]//g;
  1728. $theme_path[ $#theme_path + 1 ] = $name;
  1729. } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
  1730. if ( $input =~ /[0-9]+\s*$/ ) {
  1731. $rem_num = $input;
  1732. $rem_num =~ s/^\s*-\s*//g;
  1733. $rem_num =~ s/\s*$//;
  1734. } else {
  1735. $rem_num = $#theme_name;
  1736. }
  1737. if ( $rem_num == $theme_default ) {
  1738. print "You cannot remove the default theme!\n";
  1739. } else {
  1740. $count = 0;
  1741. @new_theme_name = ();
  1742. @new_theme_path = ();
  1743. while ( $count <= $#theme_name ) {
  1744. if ( $count != $rem_num ) {
  1745. @new_theme_name = ( @new_theme_name, $theme_name[$count] );
  1746. @new_theme_path = ( @new_theme_path, $theme_path[$count] );
  1747. }
  1748. $count++;
  1749. }
  1750. @theme_name = @new_theme_name;
  1751. @theme_path = @new_theme_path;
  1752. if ( $theme_default > $rem_num ) {
  1753. $theme_default--;
  1754. }
  1755. }
  1756. } elsif ( $input =~ /^\s*t\s*/i ) {
  1757. print "\nStarting detection...\n\n";
  1758. opendir( DIR, "../themes" );
  1759. @files = grep { /\.php$/i } readdir(DIR);
  1760. $cnt = 0;
  1761. while ( $cnt <= $#files ) {
  1762. $filename = "../themes/" . $files[$cnt];
  1763. if ( $filename ne "../themes/index.php" ) {
  1764. $found = 0;
  1765. for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
  1766. if ( $theme_path[$x] eq $filename ) {
  1767. $found = 1;
  1768. }
  1769. }
  1770. if ( $found != 1 ) {
  1771. print "** Found theme: $filename\n";
  1772. print " What is its name? ";
  1773. $nm = <STDIN>;
  1774. $nm =~ s/[\n|\r]//g;
  1775. $theme_name[ $#theme_name + 1 ] = $nm;
  1776. $theme_path[ $#theme_path + 1 ] = $filename;
  1777. }
  1778. }
  1779. $cnt++;
  1780. }
  1781. print "\n";
  1782. for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
  1783. $filename = $theme_path[$cnt];
  1784. if ( !( -e $filename ) ) {
  1785. print " Removing $filename (file not found)\n";
  1786. $offset = 0;
  1787. @new_theme_name = ();
  1788. @new_theme_path = ();
  1789. for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
  1790. if ( $theme_path[$x] eq $filename ) {
  1791. $offset = 1;
  1792. }
  1793. if ( $offset == 1 ) {
  1794. $new_theme_name[$x] = $theme_name[ $x + 1 ];
  1795. $new_theme_path[$x] = $theme_path[ $x + 1 ];
  1796. } else {
  1797. $new_theme_name[$x] = $theme_name[$x];
  1798. $new_theme_path[$x] = $theme_path[$x];
  1799. }
  1800. }
  1801. @theme_name = @new_theme_name;
  1802. @theme_path = @new_theme_path;
  1803. }
  1804. }
  1805. print "\nDetection complete!\n\n";
  1806. closedir DIR;
  1807. } elsif ( $input =~ /^\s*\?\s*/ ) {
  1808. print ".-------------------------.\n";
  1809. print "| t (detect themes) |\n";
  1810. print "| + (add theme) |\n";
  1811. print "| - N (remove theme) |\n";
  1812. print "| m N (mark default) |\n";
  1813. print "| l (list themes) |\n";
  1814. print "| d (done) |\n";
  1815. print "`-------------------------'\n";
  1816. }
  1817. print "[theme] command (?=help) > ";
  1818. $input = <STDIN>;
  1819. $input =~ s/[\r|\n]//g;
  1820. }
  1821. }
  1822. # Theme - CSS file
  1823. sub command42 {
  1824. print "You may specify a cascading style-sheet (CSS) file to be included\n";
  1825. print "on each html page generated by SquirrelMail. The CSS file is useful\n";
  1826. print "for specifying a site-wide font. If you're not familiar with CSS\n";
  1827. print "files, leave this blank.\n";
  1828. print "\n";
  1829. print "To clear out an existing value, just type a space for the input.\n";
  1830. print "\n";
  1831. print "[$WHT$theme_css$NRM]: $WHT";
  1832. $new_theme_css = <STDIN>;
  1833. if ( $new_theme_css eq "\n" ) {
  1834. $new_theme_css = $theme_css;
  1835. } else {
  1836. $new_theme_css =~ s/[\r|\n]//g;
  1837. }
  1838. $new_theme_css =~ s/^\s*//;
  1839. return $new_theme_css;
  1840. }
  1841. sub command61 {
  1842. print "You can now define different LDAP servers.\n";
  1843. print "[ldap] command (?=help) > ";
  1844. $input = <STDIN>;
  1845. $input =~ s/[\r|\n]//g;
  1846. while ( $input ne "d" ) {
  1847. if ( $input =~ /^\s*l\s*/i ) {
  1848. $count = 0;
  1849. while ( $count <= $#ldap_host ) {
  1850. print "$count. $ldap_host[$count]\n";
  1851. print " base: $ldap_base[$count]\n";
  1852. if ( $ldap_charset[$count] ) {
  1853. print " charset: $ldap_charset[$count]\n";
  1854. }
  1855. if ( $ldap_port[$count] ) {
  1856. print " port: $ldap_port[$count]\n";
  1857. }
  1858. if ( $ldap_name[$count] ) {
  1859. print " name: $ldap_name[$count]\n";
  1860. }
  1861. if ( $ldap_maxrows[$count] ) {
  1862. print " maxrows: $ldap_maxrows[$count]\n";
  1863. }
  1864. print "\n";
  1865. $count++;
  1866. }
  1867. } elsif ( $input =~ /^\s*\+/ ) {
  1868. $sub = $#ldap_host + 1;
  1869. print "First, we need to have the hostname or the IP address where\n";
  1870. print "this LDAP server resides. Example: ldap.bigfoot.com\n";
  1871. print "hostname: ";
  1872. $name = <STDIN>;
  1873. $name =~ s/[\r|\n]//g;
  1874. $ldap_host[$sub] = $name;
  1875. print "\n";
  1876. print "Next, we need the server root (base dn). For this, an empty\n";
  1877. print "string is allowed.\n";
  1878. print "Example: ou=member_directory,o=netcenter.com\n";
  1879. print "base: ";
  1880. $name = <STDIN>;
  1881. $name =~ s/[\r|\n]//g;
  1882. $ldap_base[$sub] = $name;
  1883. print "\n";
  1884. print "This is the TCP/IP port number for the LDAP server. Default\n";
  1885. print "port is 389. This is optional. Press ENTER for default.\n";
  1886. print "port: ";
  1887. $name = <STDIN>;
  1888. $name =~ s/[\r|\n]//g;
  1889. $ldap_port[$sub] = $name;
  1890. print "\n";
  1891. print "This is the charset for the server. Default is utf-8. This\n";
  1892. print "is also optional. Press ENTER for default.\n";
  1893. print "charset: ";
  1894. $name = <STDIN>;
  1895. $name =~ s/[\r|\n]//g;
  1896. $ldap_charset[$sub] = $name;
  1897. print "\n";
  1898. print "This is the name for the server, used to tag the results of\n";
  1899. print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
  1900. print "name: ";
  1901. $name = <STDIN>;
  1902. $name =~ s/[\r|\n]//g;
  1903. $ldap_name[$sub] = $name;
  1904. print "\n";
  1905. print "You can specify the maximum number of rows in the search result.\n";
  1906. print "Default is unlimited. Press ENTER for default.\n";
  1907. print "maxrows: ";
  1908. $name = <STDIN>;
  1909. $name =~ s/[\r|\n]//g;
  1910. $ldap_maxrows[$sub] = $name;
  1911. print "\n";
  1912. } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
  1913. if ( $input =~ /[0-9]+\s*$/ ) {
  1914. $rem_num = $input;
  1915. $rem_num =~ s/^\s*-\s*//g;
  1916. $rem_num =~ s/\s*$//;
  1917. } else {
  1918. $rem_num = $#ldap_host;
  1919. }
  1920. $count = 0;
  1921. @new_ldap_host = ();
  1922. @new_ldap_base = ();
  1923. @new_ldap_port = ();
  1924. @new_ldap_name = ();
  1925. @new_ldap_charset = ();
  1926. @new_ldap_maxrows = ();
  1927. while ( $count <= $#ldap_host ) {
  1928. if ( $count != $rem_num ) {
  1929. @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
  1930. @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
  1931. @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
  1932. @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
  1933. @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
  1934. @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
  1935. }
  1936. $count++;
  1937. }
  1938. @ldap_host = @new_ldap_host;
  1939. @ldap_base = @new_ldap_base;
  1940. @ldap_port = @new_ldap_port;
  1941. @ldap_name = @new_ldap_name;
  1942. @ldap_charset = @new_ldap_charset;
  1943. @ldap_maxrows = @new_ldap_maxrows;
  1944. } elsif ( $input =~ /^\s*\?\s*/ ) {
  1945. print ".-------------------------.\n";
  1946. print "| + (add host) |\n";
  1947. print "| - N (remove host) |\n";
  1948. print "| l (list hosts) |\n";
  1949. print "| d (done) |\n";
  1950. print "`-------------------------'\n";
  1951. }
  1952. print "[ldap] command (?=help) > ";
  1953. $input = <STDIN>;
  1954. $input =~ s/[\r|\n]//g;
  1955. }
  1956. }
  1957. sub command62 {
  1958. print "Some of our developers have come up with very good javascript interface\n";
  1959. print "for searching through address books, however, our original goals said\n";
  1960. print "that we would be 100% HTML. In order to make it possible to use their\n";
  1961. print "interface, and yet stick with our goals, we have also written a plain\n";
  1962. print "HTML version of the search. Here, you can choose which version to use.\n";
  1963. print "\n";
  1964. print "This is just the default value. It is also a user option that each\n";
  1965. print "user can configure individually\n";
  1966. print "\n";
  1967. if ( lc($default_use_javascript_addr_book) eq "true" ) {
  1968. $default_value = "y";
  1969. } else {
  1970. $default_use_javascript_addr_book = "false";
  1971. $default_value = "n";
  1972. }
  1973. print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
  1974. $new_show = <STDIN>;
  1975. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1976. $default_use_javascript_addr_book = "true";
  1977. } else {
  1978. $default_use_javascript_addr_book = "false";
  1979. }
  1980. return $default_use_javascript_addr_book;
  1981. }
  1982. sub command91 {
  1983. print "If you want to store your users address book details in a database then\n";
  1984. print "you need to set this DSN to a valid value. The format for this is:\n";
  1985. print "mysql://user:pass\@hostname/dbname\n";
  1986. print "Where mysql can be one of the databases PHP supports, the most common\n";
  1987. print "of these are mysql, msql and pgsql\n";
  1988. print "If the DSN is left empty (hit space and then return) the database\n";
  1989. print "related code for address books will not be used\n";
  1990. print "\n";
  1991. if ( $addrbook_dsn eq "" ) {
  1992. $default_value = "Disabled";
  1993. } else {
  1994. $default_value = $addrbook_dsn;
  1995. }
  1996. print "[$WHT$addrbook_dsn$NRM]: $WHT";
  1997. $new_dsn = <STDIN>;
  1998. if ( $new_dsn eq "\n" ) {
  1999. $new_dsn = "";
  2000. } else {
  2001. $new_dsn =~ s/[\r|\n]//g;
  2002. $new_dsn =~ s/^\s+$//g;
  2003. }
  2004. return $new_dsn;
  2005. }
  2006. sub command92 {
  2007. print "This is the name of the table you want to store the address book\n";
  2008. print "data in, it defaults to 'address'\n";
  2009. print "\n";
  2010. print "[$WHT$addrbook_table$NRM]: $WHT";
  2011. $new_table = <STDIN>;
  2012. if ( $new_table eq "\n" ) {
  2013. $new_table = $addrbook_table;
  2014. } else {
  2015. $new_table =~ s/[\r|\n]//g;
  2016. }
  2017. return $new_table;
  2018. }
  2019. sub command93 {
  2020. print "If you want to store your users preferences in a database then\n";
  2021. print "you need to set this DSN to a valid value. The format for this is:\n";
  2022. print "mysql://user:pass\@hostname/dbname\n";
  2023. print "Where mysql can be one of the databases PHP supports, the most common\n";
  2024. print "of these are mysql, msql and pgsql\n";
  2025. print "If the DSN is left empty (hit space and then return) the database\n";
  2026. print "related code for address books will not be used\n";
  2027. print "\n";
  2028. if ( $prefs_dsn eq "" ) {
  2029. $default_value = "Disabled";
  2030. } else {
  2031. $default_value = $prefs_dsn;
  2032. }
  2033. print "[$WHT$prefs_dsn$NRM]: $WHT";
  2034. $new_dsn = <STDIN>;
  2035. if ( $new_dsn eq "\n" ) {
  2036. $new_dsn = "";
  2037. } else {
  2038. $new_dsn =~ s/[\r|\n]//g;
  2039. $new_dsn =~ s/^\s+$//g;
  2040. }
  2041. return $new_dsn;
  2042. }
  2043. sub command94 {
  2044. print "This is the name of the table you want to store the preferences\n";
  2045. print "data in, it defaults to 'userprefs'\n";
  2046. print "\n";
  2047. print "[$WHT$prefs_table$NRM]: $WHT";
  2048. $new_table = <STDIN>;
  2049. if ( $new_table eq "\n" ) {
  2050. $new_table = $prefs_table;
  2051. } else {
  2052. $new_table =~ s/[\r|\n]//g;
  2053. }
  2054. return $new_table;
  2055. }
  2056. sub command95 {
  2057. print "This is the name of the field in which you want to store the\n";
  2058. print "username of the person the prefs are for. It default to 'user'\n";
  2059. print "which clashes with a reserved keyword in PostgreSQL so this\n";
  2060. print "will need to be changed for that database at least\n";
  2061. print "\n";
  2062. print "[$WHT$prefs_user_field$NRM]: $WHT";
  2063. $new_field = <STDIN>;
  2064. if ( $new_field eq "\n" ) {
  2065. $new_field = $prefs_user_field;
  2066. } else {
  2067. $new_field =~ s/[\r|\n]//g;
  2068. }
  2069. return $new_field;
  2070. }
  2071. sub command96 {
  2072. print "This is the name of the field in which you want to store the\n";
  2073. print "preferences keyword. It defaults to 'prefkey'\n";
  2074. print "\n";
  2075. print "[$WHT$prefs_key_field$NRM]: $WHT";
  2076. $new_field = <STDIN>;
  2077. if ( $new_field eq "\n" ) {
  2078. $new_field = $prefs_key_field;
  2079. } else {
  2080. $new_field =~ s/[\r|\n]//g;
  2081. }
  2082. return $new_field;
  2083. }
  2084. sub command97 {
  2085. print "This is the name of the field in which you want to store the\n";
  2086. print "preferences value. It defaults to 'prefval'\n";
  2087. print "\n";
  2088. print "[$WHT$prefs_val_field$NRM]: $WHT";
  2089. $new_field = <STDIN>;
  2090. if ( $new_field eq "\n" ) {
  2091. $new_field = $prefs_val_field;
  2092. } else {
  2093. $new_field =~ s/[\r|\n]//g;
  2094. }
  2095. return $new_field;
  2096. }
  2097. sub save_data {
  2098. $tab = " ";
  2099. if ( open( CF, ">config.php" ) ) {
  2100. print CF "<?php\n";
  2101. print CF "\n";
  2102. print CF "/**\n";
  2103. print CF " * SquirrelMail Configuration File\n";
  2104. print CF " * Created using the configure script, conf.pl\n";
  2105. print CF " */\n";
  2106. print CF "\n";
  2107. if ($print_config_version) {
  2108. print CF "\$config_version = '$print_config_version';\n";
  2109. }
  2110. # integer
  2111. print CF "\$config_use_color = $config_use_color;\n";
  2112. print CF "\n";
  2113. # string
  2114. print CF "\$org_name = \"$org_name\";\n";
  2115. # string
  2116. print CF "\$org_logo = '$org_logo';\n";
  2117. $org_logo_width |= 0;
  2118. $org_logo_height |= 0;
  2119. # string
  2120. print CF "\$org_logo_width = '$org_logo_width';\n";
  2121. # string
  2122. print CF "\$org_logo_height = '$org_logo_height';\n";
  2123. # string that can contain variables.
  2124. print CF "\$org_title = \"$org_title\";\n";
  2125. # string
  2126. print CF "\$signout_page = '$signout_page';\n";
  2127. # string
  2128. print CF "\$frame_top = '$frame_top';\n";
  2129. print CF "\n";
  2130. # string that can contain variables
  2131. print CF "\$motd = \"$motd\";\n";
  2132. print CF "\n";
  2133. # string
  2134. print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
  2135. print CF "\n";
  2136. # string
  2137. print CF "\$domain = '$domain';\n";
  2138. # string
  2139. print CF "\$imapServerAddress = '$imapServerAddress';\n";
  2140. # integer
  2141. print CF "\$imapPort = $imapPort;\n";
  2142. # boolean
  2143. print CF "\$useSendmail = $useSendmail;\n";
  2144. # string
  2145. print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
  2146. # integer
  2147. print CF "\$smtpPort = $smtpPort;\n";
  2148. # string
  2149. print CF "\$sendmail_path = '$sendmail_path';\n";
  2150. # boolean
  2151. print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
  2152. # boolean
  2153. print CF "\$pop_before_smtp = $pop_before_smtp;\n";
  2154. # string
  2155. print CF "\$imap_server_type = '$imap_server_type';\n";
  2156. # boolean
  2157. print CF "\$invert_time = $invert_time;\n";
  2158. # string
  2159. print CF "\$optional_delimiter = '$optional_delimiter';\n";
  2160. print CF "\n";
  2161. # string
  2162. print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
  2163. # string
  2164. print CF "\$trash_folder = '$trash_folder';\n";
  2165. # string
  2166. print CF "\$sent_folder = '$sent_folder';\n";
  2167. # string
  2168. print CF "\$draft_folder = '$draft_folder';\n";
  2169. # boolean
  2170. print CF "\$default_move_to_trash = $default_move_to_trash;\n";
  2171. # boolean
  2172. print CF "\$default_move_to_sent = $default_move_to_sent;\n";
  2173. # boolean
  2174. print CF "\$default_save_as_draft = $default_save_as_draft;\n";
  2175. # boolean
  2176. print CF "\$show_prefix_option = $show_prefix_option;\n";
  2177. # boolean
  2178. print CF "\$list_special_folders_first = $list_special_folders_first;\n";
  2179. # boolean
  2180. print CF "\$use_special_folder_color = $use_special_folder_color;\n";
  2181. # boolean
  2182. print CF "\$auto_expunge = $auto_expunge;\n";
  2183. # boolean
  2184. print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
  2185. # boolean
  2186. print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
  2187. # integer
  2188. print CF "\$default_unseen_notify = $default_unseen_notify;\n";
  2189. # integer
  2190. print CF "\$default_unseen_type = $default_unseen_type;\n";
  2191. # boolean
  2192. print CF "\$auto_create_special = $auto_create_special;\n";
  2193. # boolean
  2194. print CF "\$delete_folder = $delete_folder;\n";
  2195. # boolean
  2196. print CF "\$noselect_fix_enable = $noselect_fix_enable;\n";
  2197. print CF "\n";
  2198. # string
  2199. print CF "\$default_charset = '$default_charset';\n";
  2200. # string
  2201. print CF "\$data_dir = '$data_dir';\n";
  2202. # string that can contain a variable
  2203. print CF "\$attachment_dir = \"$attachment_dir\";\n";
  2204. # integer
  2205. print CF "\$dir_hash_level = $dir_hash_level;\n";
  2206. # string
  2207. print CF "\$default_left_size = '$default_left_size';\n";
  2208. # boolean
  2209. print CF "\$force_username_lowercase = $force_username_lowercase;\n";
  2210. # boolean
  2211. print CF "\$default_use_priority = $default_use_priority;\n";
  2212. # boolean
  2213. print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
  2214. # boolean
  2215. print CF "\$default_use_mdn = $default_use_mdn;\n";
  2216. # boolean
  2217. print CF "\$edit_identity = $edit_identity;\n";
  2218. # boolean
  2219. print CF "\$edit_name = $edit_name;\n";
  2220. # boolean
  2221. print CF "\$allow_thread_sort = $allow_thread_sort;\n";
  2222. # boolean
  2223. print CF "\$allow_server_sort = $allow_server_sort;\n";
  2224. # boolean
  2225. print CF "\$allow_charset_search = $allow_charset_search;\n";
  2226. # boolean
  2227. print CF "\$uid_support = $uid_support;\n";
  2228. print CF "\n";
  2229. # all plugins are strings
  2230. for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
  2231. print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
  2232. }
  2233. print CF "\n";
  2234. # strings
  2235. print CF "\$theme_css = '$theme_css';\n";
  2236. if ( $theme_default eq '' ) { $theme_default = '0'; }
  2237. print CF "\$theme_default = $theme_default;\n";
  2238. for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
  2239. print CF "\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
  2240. print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
  2241. }
  2242. print CF "\n";
  2243. if ( $default_use_javascript_addr_book ne "true" ) {
  2244. $default_use_javascript_addr_book = "false";
  2245. }
  2246. # boolean
  2247. print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
  2248. for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
  2249. print CF "\$ldap_server[$count] = array(\n";
  2250. # string
  2251. print CF " 'host' => '$ldap_host[$count]',\n";
  2252. # string
  2253. print CF " 'base' => '$ldap_base[$count]'";
  2254. if ( $ldap_name[$count] ) {
  2255. print CF ",\n";
  2256. # string
  2257. print CF " 'name' => '$ldap_name[$count]'";
  2258. }
  2259. if ( $ldap_port[$count] ) {
  2260. print CF ",\n";
  2261. # integer
  2262. print CF " 'port' => $ldap_port[$count]";
  2263. }
  2264. if ( $ldap_charset[$count] ) {
  2265. print CF ",\n";
  2266. # string
  2267. print CF " 'charset' => '$ldap_charset[$count]'";
  2268. }
  2269. if ( $ldap_maxrows[$count] ) {
  2270. print CF ",\n";
  2271. # integer
  2272. print CF " 'maxrows' => $ldap_maxrows[$count]";
  2273. }
  2274. print CF "\n";
  2275. print CF ");\n";
  2276. print CF "\n";
  2277. }
  2278. # string
  2279. print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
  2280. # string
  2281. print CF "\$addrbook_table = '$addrbook_table';\n\n";
  2282. # string
  2283. print CF "\$prefs_dsn = '$prefs_dsn';\n";
  2284. # string
  2285. print CF "\$prefs_table = '$prefs_table';\n";
  2286. # string
  2287. print CF "\$prefs_user_field = '$prefs_user_field';\n";
  2288. # string
  2289. print CF "\$prefs_key_field = '$prefs_key_field';\n";
  2290. # string
  2291. print CF "\$prefs_val_field = '$prefs_val_field';\n";
  2292. # boolean
  2293. print CF "\$no_list_for_subscribe = '$no_list_for_subscribe';\n";
  2294. print CF "\n";
  2295. print CF "/**\n";
  2296. print CF " * Make sure there are no characters after the PHP closing\n";
  2297. print CF " * tag below (including newline characters and whitespace).\n";
  2298. print CF " * Otherwise, that character will cause the headers to be\n";
  2299. print CF " * sent and regular output to begin, which will majorly screw\n";
  2300. print CF " * things up when we try to send more headers later.\n";
  2301. print CF " */\n";
  2302. print CF "?>";
  2303. close CF;
  2304. print "Data saved in config.php\n";
  2305. } else {
  2306. print "Error saving config.php: $!\n";
  2307. }
  2308. }
  2309. sub set_defaults {
  2310. system "clear";
  2311. print $WHT. "SquirrelMail Configuration : " . $NRM;
  2312. if ( $config == 1 ) { print "Read: config.php"; }
  2313. elsif ( $config == 2 ) { print "Read: config_default.php"; }
  2314. print "\n";
  2315. print "---------------------------------------------------------\n";
  2316. print "While we have been building SquirrelMail, we have discovered some\n";
  2317. print "preferences that work better with some servers that don't work so\n";
  2318. print "well with others. If you select your IMAP server, this option will\n";
  2319. print "set some pre-defined settings for that server.\n";
  2320. print "\n";
  2321. print "Please note that you will still need to go through and make sure\n";
  2322. print "everything is correct. This does not change everything. There are\n";
  2323. print "only a few settings that this will change.\n";
  2324. print "\n";
  2325. $continue = 0;
  2326. while ( $continue != 1 ) {
  2327. print "Please select your IMAP server:\n";
  2328. print " cyrus = Cyrus IMAP server\n";
  2329. print " uw = University of Washington's IMAP server\n";
  2330. print " exchange = Microsoft Exchange IMAP server\n";
  2331. print " courier = Courier IMAP server\n";
  2332. print " macosx = Mac OS X Mailserver\n";
  2333. print " quit = Do not change anything\n";
  2334. print "Command >> ";
  2335. $server = <STDIN>;
  2336. $server =~ s/[\r|\n]//g;
  2337. print "\n";
  2338. if ( $server eq "cyrus" ) {
  2339. $imap_server_type = "cyrus";
  2340. $default_folder_prefix = "";
  2341. $trash_folder = "INBOX.Trash";
  2342. $sent_folder = "INBOX.Sent";
  2343. $draft_folder = "INBOX.Drafts";
  2344. $show_prefix_option = false;
  2345. $default_sub_of_inbox = true;
  2346. $show_contain_subfolders_option = false;
  2347. $optional_delimiter = ".";
  2348. $disp_default_folder_prefix = "<none>";
  2349. $continue = 1;
  2350. } elsif ( $server eq "uw" ) {
  2351. $imap_server_type = "uw";
  2352. $default_folder_prefix = "mail/";
  2353. $trash_folder = "Trash";
  2354. $sent_folder = "Sent";
  2355. $draft_folder = "Drafts";
  2356. $show_prefix_option = true;
  2357. $default_sub_of_inbox = false;
  2358. $show_contain_subfolders_option = true;
  2359. $optional_delimiter = "/";
  2360. $disp_default_folder_prefix = $default_folder_prefix;
  2361. $continue = 1;
  2362. } elsif ( $server eq "exchange" ) {
  2363. $imap_server_type = "exchange";
  2364. $default_folder_prefix = "";
  2365. $default_sub_of_inbox = true;
  2366. $trash_folder = "INBOX/Deleted Items";
  2367. $sent_folder = "INBOX/Sent Items";
  2368. $drafts_folder = "INBOX/Drafts";
  2369. $show_prefix_option = false;
  2370. $show_contain_subfolders_option = false;
  2371. $optional_delimiter = "detect";
  2372. $disp_default_folder_prefix = "<none>";
  2373. $continue = 1;
  2374. } elsif ( $server eq "courier" ) {
  2375. $imap_server_type = "courier";
  2376. $default_folder_prefix = "INBOX.";
  2377. $trash_folder = "Trash";
  2378. $sent_folder = "Sent";
  2379. $draft_folder = "Drafts";
  2380. $show_prefix_option = false;
  2381. $default_sub_of_inbox = false;
  2382. $show_contain_subfolders_option = false;
  2383. $optional_delimiter = ".";
  2384. $disp_default_folder_prefix = $default_folder_prefix;
  2385. $continue = 1;
  2386. } elsif ( $server eq "macosx" ) {
  2387. $imap_server_type = "macosx";
  2388. $default_folder_prefix = "INBOX/";
  2389. $trash_folder = "Trash";
  2390. $sent_folder = "Sent";
  2391. $draft_folder = "Drafts";
  2392. $show_prefix_option = false;
  2393. $default_sub_of_inbox = true;
  2394. $show_contain_subfolders_option = false;
  2395. $optional_delimiter = "detect";
  2396. $allow_charset_search = false;
  2397. $disp_default_folder_prefix = $default_folder_prefix;
  2398. $continue = 1;
  2399. } elsif ( $server eq "quit" ) {
  2400. $continue = 1;
  2401. } else {
  2402. $disp_default_folder_prefix = $default_folder_prefix;
  2403. print "Unrecognized server: $server\n";
  2404. print "\n";
  2405. }
  2406. print " imap_server_type = $imap_server_type\n";
  2407. print " default_folder_prefix = $disp_default_folder_prefix\n";
  2408. print " trash_folder = $trash_folder\n";
  2409. print " sent_folder = $sent_folder\n";
  2410. print " draft_folder = $draft_folder\n";
  2411. print " show_prefix_option = $show_prefix_option\n";
  2412. print " default_sub_of_inbox = $default_sub_of_inbox\n";
  2413. print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
  2414. print " optional_delimiter = $optional_delimiter\n";
  2415. }
  2416. print "\nPress any key to continue...";
  2417. $tmp = <STDIN>;
  2418. }