conf.pl 88 KB

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