conf.pl 204 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271
  1. #!/usr/bin/env perl
  2. # conf.pl
  3. #
  4. # Copyright (c) 1999-2007 The SquirrelMail Project Team
  5. # Licensed under the GNU GPL. For full terms see COPYING.
  6. #
  7. # A simple configure script to configure SquirrelMail
  8. #
  9. # $Id$
  10. ############################################################
  11. $conf_pl_version = "1.5.0";
  12. ############################################################
  13. # Check what directory we're supposed to be running in, and
  14. # change there if necessary. File::Basename has been in
  15. # Perl since at least 5.003_7, and nobody sane runs anything
  16. # before that, but just in case.
  17. ############################################################
  18. my $dir;
  19. if ( eval q{require "File/Basename.pm"} ) {
  20. $dir = File::Basename::dirname($0);
  21. chdir($dir);
  22. }
  23. ############################################################
  24. # Some people try to run this as a CGI. That's wrong!
  25. ############################################################
  26. if ( defined( $ENV{'PATH_INFO'} )
  27. || defined( $ENV{'QUERY_STRING'} )
  28. || defined( $ENV{'REQUEST_METHOD'} ) ) {
  29. print "Content-Type: text/html\n\n";
  30. print "You must run this script from the command line.";
  31. exit;
  32. }
  33. ############################################################
  34. # If we got here, use Cwd to get the full directory path
  35. # (the Basename stuff above will sometimes return '.' as
  36. # the base directory, which is not helpful here).
  37. ############################################################
  38. use Cwd;
  39. $dir = cwd();
  40. ############################################################
  41. # First, lets read in the data already in there...
  42. ############################################################
  43. if ( -e "config.php" ) {
  44. # Make sure that file is readable
  45. if (! -r "config.php") {
  46. clear_screen();
  47. print "WARNING:\n";
  48. print "The file \"config/config.php\" was found, but you don't\n";
  49. print "have rights to read it.\n";
  50. print "\n";
  51. print "Press enter to continue";
  52. $ctu = <STDIN>;
  53. exit;
  54. }
  55. open( FILE, "config.php" );
  56. while ( $line = <FILE> ) {
  57. $line =~ s/^\s+//;
  58. $line =~ s/^\$//;
  59. $var = $line;
  60. $var =~ s/=/EQUALS/;
  61. if ( $var =~ /^([a-z])/i ) {
  62. @o = split ( /\s*EQUALS\s*/, $var );
  63. if ( $o[0] eq "config_version" ) {
  64. $o[1] =~ s/[\n\r]//g;
  65. $o[1] =~ s/[\'\"];\s*$//;
  66. $o[1] =~ s/;$//;
  67. $o[1] =~ s/^[\'\"]//;
  68. $config_version = $o[1];
  69. close(FILE);
  70. }
  71. }
  72. }
  73. close(FILE);
  74. if ( $config_version ne $conf_pl_version ) {
  75. clear_screen();
  76. print "WARNING:\n";
  77. print " The file \"config/config.php\" was found, but it is for\n";
  78. print " an older version of SquirrelMail. It is possible to still\n";
  79. print " read the defaults from this file but be warned that many\n";
  80. print " preferences change between versions. It is recommended that\n";
  81. print " you start with a clean config.php for each upgrade that you\n";
  82. print " do. To do this, just move config/config.php out of the way.\n";
  83. print "\n";
  84. print "Continue loading with the old config.php [y/N]? ";
  85. $ctu = <STDIN>;
  86. if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
  87. exit;
  88. }
  89. print "\nDo you want me to stop warning you [y/N]? ";
  90. $ctu = <STDIN>;
  91. if ( $ctu =~ /^y\n/i ) {
  92. $print_config_version = $conf_pl_version;
  93. } else {
  94. $print_config_version = $config_version;
  95. }
  96. } else {
  97. $print_config_version = $config_version;
  98. }
  99. $config = 1;
  100. open( FILE, "config.php" );
  101. } elsif ( -e "config_default.php" ) {
  102. open( FILE, "config_default.php" );
  103. while ( $line = <FILE> ) {
  104. $line =~ s/^\s+//;
  105. $line =~ s/^\$//;
  106. $var = $line;
  107. $var =~ s/=/EQUALS/;
  108. if ( $var =~ /^([a-z])/i ) {
  109. @o = split ( /\s*EQUALS\s*/, $var );
  110. if ( $o[0] eq "config_version" ) {
  111. $o[1] =~ s/[\n\r]//g;
  112. $o[1] =~ s/[\'\"];\s*$//;
  113. $o[1] =~ s/;$//;
  114. $o[1] =~ s/^[\'\"]//;
  115. $config_version = $o[1];
  116. close(FILE);
  117. }
  118. }
  119. }
  120. close(FILE);
  121. if ( $config_version ne $conf_pl_version ) {
  122. clear_screen();
  123. print "WARNING:\n";
  124. print " You are trying to use a 'config_default.php' from an older\n";
  125. print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
  126. print " should get the 'config_default.php' that matches the version\n";
  127. print " of SquirrelMail that you are running. You can get this from\n";
  128. print " the SquirrelMail web page by going to the following URL:\n";
  129. print " http://www.squirrelmail.org.\n";
  130. print "\n";
  131. print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
  132. $ctu = <STDIN>;
  133. if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
  134. exit;
  135. }
  136. print "\nDo you want me to stop warning you [y/N]? ";
  137. $ctu = <STDIN>;
  138. if ( $ctu =~ /^y\n/i ) {
  139. $print_config_version = $conf_pl_version;
  140. } else {
  141. $print_config_version = $config_version;
  142. }
  143. } else {
  144. $print_config_version = $config_version;
  145. }
  146. $config = 2;
  147. open( FILE, "config_default.php" );
  148. } else {
  149. print "No configuration file found. Please get config_default.php\n";
  150. print "or config.php before running this again. This program needs\n";
  151. print "a default config file to get default values.\n";
  152. exit;
  153. }
  154. # Read and parse the current configuration file
  155. # (either config.php or config_default.php).
  156. while ( $line = <FILE> ) {
  157. $line =~ s/^\s+//;
  158. $line =~ s/^\$//;
  159. $var = $line;
  160. $var =~ s/=/EQUALS/;
  161. if ( $var =~ /^([a-z])/i ) {
  162. @options = split ( /\s*EQUALS\s*/, $var );
  163. $options[1] =~ s/[\n\r]//g;
  164. $options[1] =~ s/[\'\"];\s*$//;
  165. $options[1] =~ s/;$//;
  166. $options[1] =~ s/^[\'\"]//;
  167. # de-escape escaped strings
  168. $options[1] =~ s/\\'/'/g;
  169. $options[1] =~ s/\\\\/\\/g;
  170. if ( $options[0] =~ /^user_themes\[[0-9]+\]\[['"]PATH['"]\]/ ) {
  171. $sub = $options[0];
  172. $sub =~ s/\]\[['"]PATH['"]\]//;
  173. $sub =~ s/.*\[//;
  174. if ( -e "../css/" ) {
  175. $options[1] =~ s/^\.\.\/config/\.\.\/css/;
  176. }
  177. $user_theme_path[$sub] = &change_to_rel_path($options[1]);
  178. } elsif ( $options[0] =~ /^user_themes\[[0-9]+\]\[['"]NAME['"]\]/ ) {
  179. $sub = $options[0];
  180. $sub =~ s/\]\[['"]NAME['"]\]//;
  181. $sub =~ s/.*\[//;
  182. $user_theme_name[$sub] = $options[1];
  183. } elsif ( $options[0] =~ /^icon_themes\[[0-9]+\]\[['"]PATH['"]\]/ ) {
  184. $sub = $options[0];
  185. $sub =~ s/\]\[['"]PATH['"]\]//;
  186. $sub =~ s/.*\[//;
  187. if ( -e "../images/" ) {
  188. $options[1] =~ s/^\.\.\/config/\.\.\/images/;
  189. }
  190. $icon_theme_path[$sub] = &change_to_rel_path($options[1]);
  191. } elsif ( $options[0] =~ /^icon_themes\[[0-9]+\]\[['"]NAME['"]\]/ ) {
  192. $sub = $options[0];
  193. $sub =~ s/\]\[['"]NAME['"]\]//;
  194. $sub =~ s/.*\[//;
  195. $icon_theme_name[$sub] = $options[1];
  196. } elsif ( $options[0] =~ /^aTemplateSet\[[0-9]+\]\[['"]ID['"]\]/ ) {
  197. $sub = $options[0];
  198. $sub =~ s/\]\[['"]ID['"]\]//;
  199. $sub =~ s/.*\[//;
  200. if ( -e "../templates" ) {
  201. $options[1] =~ s/^\.\.\/config/\.\.\/templates/;
  202. }
  203. $templateset_id[$sub] = $options[1];
  204. ##### FIXME: This section BELOW here so old prefs files don't blow up when running conf.pl
  205. ##### Remove after a month or two
  206. } elsif ( $options[0] =~ /^aTemplateSet\[[0-9]+\]\[['"]PATH['"]\]/ ) {
  207. $sub = $options[0];
  208. $sub =~ s/\]\[['"]PATH['"]\]//;
  209. $sub =~ s/.*\[//;
  210. if ( -e "../templates" ) {
  211. $options[1] =~ s/^\.\.\/config/\.\.\/templates/;
  212. }
  213. $templateset_id[$sub] = $options[1];
  214. ##### FIXME: This section ABOVE here so old prefs files don't blow up when running conf.pl
  215. ##### Remove after a month or two
  216. } elsif ( $options[0] =~ /^aTemplateSet\[[0-9]+\]\[['"]NAME['"]\]/ ) {
  217. $sub = $options[0];
  218. $sub =~ s/\]\[['"]NAME['"]\]//;
  219. $sub =~ s/.*\[//;
  220. $templateset_name[$sub] = $options[1];
  221. } elsif ( $options[0] =~ /^plugins\[[0-9]*\]/ ) {
  222. $sub = $options[0];
  223. $sub =~ s/\]//;
  224. $sub =~ s/^plugins\[//;
  225. if ($sub eq '') {
  226. push @plugins, $options[1];
  227. } else {
  228. $plugins[$sub] = $options[1];
  229. }
  230. } elsif ($options[0] =~ /^fontsets\[\'[a-z]*\'\]/) {
  231. # parse associative $fontsets array
  232. $sub = $options[0];
  233. $sub =~ s/\'\]//;
  234. $sub =~ s/^fontsets\[\'//;
  235. $fontsets{$sub} = $options[1];
  236. } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['"]PATH|NAME['"]\]/ ) {
  237. ##
  238. ## $color themes are no longer supported. Please leave this
  239. ## so conf.pl doesn't barf if it encounters a $theme.
  240. ##
  241. } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
  242. $sub = $options[0];
  243. $sub =~ s/\]//;
  244. $sub =~ s/^ldap_server\[//;
  245. $continue = 0;
  246. while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) {
  247. if ( $tmp =~ /\);\s*$/ ) {
  248. $continue = 1;
  249. }
  250. if ( $tmp =~ /^\s*[\'\"]host[\'\"]/i ) {
  251. $tmp =~ s/^\s*[\'\"]host[\'\"]\s*=>\s*[\'\"]//i;
  252. $tmp =~ s/[\'\"],?\s*$//;
  253. $tmp =~ s/[\'\"]\);\s*$//;
  254. $host = $tmp;
  255. } elsif ( $tmp =~ /^\s*[\'\"]base[\'\"]/i ) {
  256. $tmp =~ s/^\s*[\'\"]base[\'\"]\s*=>\s*[\'\"]//i;
  257. $tmp =~ s/[\'\"],?\s*$//;
  258. $tmp =~ s/[\'\"]\);\s*$//;
  259. $base = $tmp;
  260. } elsif ( $tmp =~ /^\s*[\'\"]charset[\'\"]/i ) {
  261. $tmp =~ s/^\s*[\'\"]charset[\'\"]\s*=>\s*[\'\"]//i;
  262. $tmp =~ s/[\'\"],?\s*$//;
  263. $tmp =~ s/[\'\"]\);\s*$//;
  264. $charset = $tmp;
  265. } elsif ( $tmp =~ /^\s*[\'\"]port[\'\"]/i ) {
  266. $tmp =~ s/^\s*[\'\"]port[\'\"]\s*=>\s*[\'\"]?//i;
  267. $tmp =~ s/[\'\"]?,?\s*$//;
  268. $tmp =~ s/[\'\"]?\);\s*$//;
  269. $port = $tmp;
  270. } elsif ( $tmp =~ /^\s*[\'\"]maxrows[\'\"]/i ) {
  271. $tmp =~ s/^\s*[\'\"]maxrows[\'\"]\s*=>\s*[\'\"]?//i;
  272. $tmp =~ s/[\'\"]?,?\s*$//;
  273. $tmp =~ s/[\'\"]?\);\s*$//;
  274. $maxrows = $tmp;
  275. } elsif ( $tmp =~ /^\s*[\'\"]filter[\'\"]/i ) {
  276. $tmp =~ s/^\s*[\'\"]filter[\'\"]\s*=>\s*[\'\"]?//i;
  277. $tmp =~ s/[\'\"]?,?\s*$//;
  278. $tmp =~ s/[\'\"]?\);\s*$//;
  279. $filter = $tmp;
  280. } elsif ( $tmp =~ /^\s*[\'\"]name[\'\"]/i ) {
  281. $tmp =~ s/^\s*[\'\"]name[\'\"]\s*=>\s*[\'\"]//i;
  282. $tmp =~ s/[\'\"],?\s*$//;
  283. $tmp =~ s/[\'\"]\);\s*$//;
  284. $name = $tmp;
  285. } elsif ( $tmp =~ /^\s*[\'\"]binddn[\'\"]/i ) {
  286. $tmp =~ s/^\s*[\'\"]binddn[\'\"]\s*=>\s*[\'\"]//i;
  287. $tmp =~ s/[\'\"],?\s*$//;
  288. $tmp =~ s/[\'\"]\);\s*$//;
  289. $binddn = $tmp;
  290. } elsif ( $tmp =~ /^\s*[\'\"]bindpw[\'\"]/i ) {
  291. $tmp =~ s/^\s*[\'\"]bindpw[\'\"]\s*=>\s*[\'\"]//i;
  292. $tmp =~ s/[\'\"],?\s*$//;
  293. $tmp =~ s/[\'\"]\);\s*$//;
  294. $bindpw = $tmp;
  295. } elsif ( $tmp =~ /^\s*[\'\"]protocol[\'\"]/i ) {
  296. $tmp =~ s/^\s*[\'\"]protocol[\'\"]\s*=>\s*[\'\"]?//i;
  297. $tmp =~ s/[\'\"]?,?\s*$//;
  298. $tmp =~ s/[\'\"]?\);\s*$//;
  299. $protocol = $tmp;
  300. } elsif ( $tmp =~ /^\s*[\'\"]limit_scope[\'\"]/i ) {
  301. $tmp =~ s/^\s*[\'\"]limit_scope[\'\"]\s*=>\s*[\'\"]?//i;
  302. $tmp =~ s/[\'\"]?,?\s*$//;
  303. $tmp =~ s/[\'\"]?\);\s*$//;
  304. $limit_scope = $tmp;
  305. } elsif ( $tmp =~ /^\s*[\'\"]listing[\'\"]/i ) {
  306. $tmp =~ s/^\s*[\'\"]listing[\'\"]\s*=>\s*[\'\"]?//i;
  307. $tmp =~ s/[\'\"]?,?\s*$//;
  308. $tmp =~ s/[\'\"]?\);\s*$//;
  309. $listing = $tmp;
  310. } elsif ( $tmp =~ /^\s*[\'\"]writeable[\'\"]/i ) {
  311. $tmp =~ s/^\s*[\'\"]writeable[\'\"]\s*=>\s*[\'\"]?//i;
  312. $tmp =~ s/[\'\"]?,?\s*$//;
  313. $tmp =~ s/[\'\"]?\);\s*$//;
  314. $writeable = $tmp;
  315. } elsif ( $tmp =~ /^\s*[\'\"]search_tree[\'\"]/i ) {
  316. $tmp =~ s/^\s*[\'\"]search_tree[\'\"]\s*=>\s*[\'\"]?//i;
  317. $tmp =~ s/[\'\"]?,?\s*$//;
  318. $tmp =~ s/[\'\"]?\);\s*$//;
  319. $search_tree = $tmp;
  320. } elsif ( $tmp =~ /^\s*[\'\"]starttls[\'\"]/i ) {
  321. $tmp =~ s/^\s*[\'\"]starttls[\'\"]\s*=>\s*[\'\"]?//i;
  322. $tmp =~ s/[\'\"]?,?\s*$//;
  323. $tmp =~ s/[\'\"]?\);\s*$//;
  324. $starttls = $tmp;
  325. }
  326. }
  327. $ldap_host[$sub] = $host;
  328. $ldap_base[$sub] = $base;
  329. $ldap_name[$sub] = $name;
  330. $ldap_port[$sub] = $port;
  331. $ldap_maxrows[$sub] = $maxrows;
  332. $ldap_filter[$sub] = $filter;
  333. $ldap_charset[$sub] = $charset;
  334. $ldap_binddn[$sub] = $binddn;
  335. $ldap_bindpw[$sub] = $bindpw;
  336. $ldap_protocol[$sub] = $protocol;
  337. $ldap_limit_scope[$sub] = $limit_scope;
  338. $ldap_listing[$sub] = $listing;
  339. $ldap_writeable[$sub] = $writeable;
  340. $ldap_search_tree[$sub] = $search_tree;
  341. $ldap_starttls[$sub] = $starttls;
  342. } elsif ( $options[0] =~ /^(data_dir|attachment_dir|org_logo|signout_page|icon_theme_def)$/ ) {
  343. ${ $options[0] } = &change_to_rel_path($options[1]);
  344. } else {
  345. ${ $options[0] } = $options[1];
  346. }
  347. }
  348. }
  349. close FILE;
  350. # FIXME: unknown introduction date
  351. $useSendmail = 'false' if ( lc($useSendmail) ne 'true' );
  352. $sendmail_path = "/usr/sbin/sendmail" if ( !$sendmail_path );
  353. $pop_before_smtp = 'false' if ( !$pop_before_smtp );
  354. $default_unseen_notify = 2 if ( !$default_unseen_notify );
  355. $default_unseen_type = 1 if ( !$default_unseen_type );
  356. $config_use_color = 0 if ( !$config_use_color );
  357. $invert_time = 'false' if ( !$invert_time );
  358. $force_username_lowercase = 'false' if ( !$force_username_lowercase );
  359. $optional_delimiter = "detect" if ( !$optional_delimiter );
  360. $auto_create_special = 'false' if ( !$auto_create_special );
  361. $default_use_priority = 'true' if ( !$default_use_priority );
  362. $default_use_mdn = 'true' if ( !$default_use_mdn );
  363. $delete_folder = 'false' if ( !$delete_folder );
  364. $noselect_fix_enable = 'false' if ( !$noselect_fix_enable );
  365. $frame_top = "_top" if ( !$frame_top );
  366. $provider_uri = '' if ( !$provider_uri );
  367. $provider_name = '' if ( !$provider_name );
  368. $no_list_for_subscribe = 'false' if ( !$no_list_for_subscribe );
  369. $allow_charset_search = 'true' if ( !$allow_charset_search );
  370. $allow_advanced_search = 0 if ( !$allow_advanced_search) ;
  371. $prefs_user_field = 'user' if ( !$prefs_user_field );
  372. $prefs_key_field = 'prefkey' if ( !$prefs_key_field );
  373. $prefs_val_field = 'prefval' if ( !$prefs_val_field );
  374. $session_name = 'SQMSESSID' if ( !$session_name );
  375. $skip_SM_header = 'false' if ( !$skip_SM_header );
  376. $default_use_javascript_addr_book = 'false' if (! $default_use_javascript_addr_book);
  377. # since 1.2.0
  378. $hide_sm_attributions = 'false' if ( !$hide_sm_attributions );
  379. # since 1.2.5
  380. $edit_identity = 'true' if ( !$edit_identity );
  381. $edit_name = 'true' if ( !$edit_name );
  382. # since 1.4.0
  383. $use_smtp_tls= 'false' if ( !$use_smtp_tls);
  384. $smtp_auth_mech = 'none' if ( !$smtp_auth_mech );
  385. $use_imap_tls = 'false' if ( !$use_imap_tls );
  386. $imap_auth_mech = 'login' if ( !$imap_auth_mech );
  387. # since 1.5.0
  388. $show_alternative_names = 'false' if ( !$show_alternative_names );
  389. # $available_languages option available only in 1.5.0. removed due to $languages
  390. # implementation changes. options are provided by limit_languages plugin
  391. # $available_languages = 'all' if ( !$available_languages );
  392. $aggressive_decoding = 'false' if ( !$aggressive_decoding );
  393. # available only in 1.5.0 and 1.5.1
  394. # $advanced_tree = 'false' if ( !$advanced_tree );
  395. $use_php_recode = 'false' if ( !$use_php_recode );
  396. $use_php_iconv = 'false' if ( !$use_php_iconv );
  397. # since 1.5.1
  398. $use_icons = 'false' if ( !$use_icons );
  399. $use_iframe = 'false' if ( !$use_iframe );
  400. $lossy_encoding = 'false' if ( !$lossy_encoding );
  401. $allow_remote_configtest = 'false' if ( !$allow_remote_configtest );
  402. $addrbook_global_table = 'global_abook' if ( !$addrbook_global_table );
  403. $addrbook_global_writeable = 'false' if ( !$addrbook_global_writeable );
  404. $addrbook_global_listing = 'false' if ( !$addrbook_global_listing );
  405. $abook_global_file = '' if ( !$abook_global_file);
  406. $abook_global_file_writeable = 'false' if ( !$abook_global_file_writeable);
  407. $abook_global_file_listing = 'true' if ( !$abook_global_file_listing );
  408. $encode_header_key = '' if ( !$encode_header_key );
  409. $hide_auth_header = 'false' if ( !$hide_auth_header );
  410. $time_zone_type = '0' if ( !$time_zone_type );
  411. $prefs_user_size = 128 if ( !$prefs_user_size );
  412. $prefs_key_size = 64 if ( !$prefs_key_size );
  413. $prefs_val_size = 65536 if ( !$prefs_val_size );
  414. # add qmail-inject test here for backwards compatibility
  415. if ( !$sendmail_args && $sendmail_path =~ /qmail-inject/ ) {
  416. $sendmail_args = '';
  417. } elsif ( !$sendmail_args ) {
  418. $sendmail_args = '-i -t';
  419. }
  420. $default_fontsize = '' if ( !$default_fontsize);
  421. $default_fontset = '' if ( !$default_fontset);
  422. if ( !%fontsets) {
  423. %fontsets = ('serif', 'serif',
  424. 'sans', 'helvetica,arial,sans-serif',
  425. 'comicsans', 'comic sans ms,sans-serif',
  426. 'tahoma', 'tahoma,sans-serif',
  427. 'verasans', 'bitstream vera sans,verdana,sans-serif');
  428. }
  429. # $use_imap_tls and $use_smtp_tls are switched to integer since 1.5.1
  430. $use_imap_tls = 0 if ( $use_imap_tls eq 'false');
  431. $use_imap_tls = 1 if ( $use_imap_tls eq 'true');
  432. $use_smtp_tls = 0 if ( $use_smtp_tls eq 'false');
  433. $use_smtp_tls = 1 if ( $use_smtp_tls eq 'true');
  434. # sorting options changed names and reversed values in 1.5.1
  435. $disable_thread_sort = 'false' if ( !$disable_thread_sort );
  436. $disable_server_sort = 'false' if ( !$disable_server_sort );
  437. # since 1.5.2
  438. $abook_file_line_length = 2048 if ( !$abook_file_line_length );
  439. $config_location_base = '' if ( !$config_location_base );
  440. $smtp_sitewide_user = '' if ( !$smtp_sitewide_user );
  441. $smtp_sitewide_pass = '' if ( !$smtp_sitewide_pass );
  442. $icon_theme_def = '' if ( !$icon_theme_def );
  443. $disable_plugins = 'false' if ( !$disable_plugins );
  444. $disable_plugins_user = '' if ( !$disable_plugins_user );
  445. if ( $ARGV[0] eq '--install-plugin' ) {
  446. print "Activating plugin " . $ARGV[1] . "\n";
  447. push @plugins, $ARGV[1];
  448. save_data();
  449. exit(0);
  450. } elsif ( $ARGV[0] eq '--remove-plugin' ) {
  451. print "Removing plugin " . $ARGV[1] . "\n";
  452. foreach $plugin (@plugins) {
  453. if ( $plugin ne $ARGV[1] ) {
  454. push @newplugins, $plugin;
  455. }
  456. }
  457. @plugins = @newplugins;
  458. save_data();
  459. exit(0);
  460. } elsif ( $ARGV[0] eq '--update-plugins' or $ARGV[0] eq '-u') {
  461. build_plugin_hook_array();
  462. exit(0);
  463. } elsif ( $ARGV[0] eq '--help' or $ARGV[0] eq '-h') {
  464. print "SquirrelMail Configuration Script\n";
  465. print "Usage:\n";
  466. print " * No arguments: initiates the configuration dialog\n";
  467. print " * --install-plugin <plugin> : activates the specified plugin\n";
  468. print " * --remove-plugin <plugin> : deactivates the specified plugin\n";
  469. print " * --update-plugins , -u : rebuilds plugin_hooks.php according\n";
  470. print " to plugins activated in config.php\n";
  471. print " * --help , -h : Displays this help\n";
  472. print "\n";
  473. exit(0);
  474. }
  475. ####################################################################################
  476. # used in multiple places, define once
  477. $list_supported_imap_servers =
  478. " bincimap = Binc IMAP server\n" .
  479. " courier = Courier IMAP server\n" .
  480. " cyrus = Cyrus IMAP server\n" .
  481. " dovecot = Dovecot Secure IMAP server\n" .
  482. " exchange = Microsoft Exchange IMAP server\n" .
  483. " hmailserver = hMailServer\n" .
  484. " macosx = Mac OS X Mailserver\n" .
  485. " mercury32 = Mercury/32\n" .
  486. " uw = University of Washington's IMAP server\n";
  487. #####################################################################################
  488. if ( $config_use_color == 1 ) {
  489. $WHT = "\x1B[37;1m";
  490. $NRM = "\x1B[0m";
  491. } else {
  492. $WHT = "";
  493. $NRM = "";
  494. $config_use_color = 2;
  495. }
  496. while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
  497. clear_screen();
  498. print $WHT. "SquirrelMail Configuration : " . $NRM;
  499. if ( $config == 1 ) { print "Read: config.php"; }
  500. elsif ( $config == 2 ) { print "Read: config_default.php"; }
  501. print " ($print_config_version)\n";
  502. print "---------------------------------------------------------\n";
  503. if ( $menu == 0 ) {
  504. print $WHT. "Main Menu --\n" . $NRM;
  505. print "1. Organization Preferences\n";
  506. print "2. Server Settings\n";
  507. print "3. Folder Defaults\n";
  508. print "4. General Options\n";
  509. print "5. User Interface\n";
  510. print "6. Address Books\n";
  511. print "7. Message of the Day (MOTD)\n";
  512. print "8. Plugins\n";
  513. print "9. Database\n";
  514. print "10. Language settings\n";
  515. print "11. Tweaks\n";
  516. print "\n";
  517. print "D. Set pre-defined settings for specific IMAP servers\n";
  518. print "\n";
  519. } elsif ( $menu == 1 ) {
  520. print $WHT. "Organization Preferences\n" . $NRM;
  521. print "1. Organization Name : $WHT$org_name$NRM\n";
  522. print "2. Organization Logo : $WHT$org_logo$NRM\n";
  523. print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
  524. print "4. Organization Title : $WHT$org_title$NRM\n";
  525. print "5. Signout Page : $WHT$signout_page$NRM\n";
  526. print "6. Top Frame : $WHT$frame_top$NRM\n";
  527. print "7. Provider link : $WHT$provider_uri$NRM\n";
  528. print "8. Provider name : $WHT$provider_name$NRM\n";
  529. print "\n";
  530. print "R Return to Main Menu\n";
  531. } elsif ( $menu == 2 ) {
  532. print $WHT. "Server Settings\n\n" . $NRM;
  533. print $WHT . "General" . $NRM . "\n";
  534. print "-------\n";
  535. print "1. Domain : $WHT$domain$NRM\n";
  536. print "2. Invert Time : $WHT$invert_time$NRM\n";
  537. print "3. Sendmail or SMTP : $WHT";
  538. if ( lc($useSendmail) eq 'true' ) {
  539. print "Sendmail";
  540. } else {
  541. print "SMTP";
  542. }
  543. print "$NRM\n";
  544. print "\n";
  545. if ( $show_imap_settings ) {
  546. print $WHT . "IMAP Settings". $NRM . "\n--------------\n";
  547. print "4. IMAP Server : $WHT$imapServerAddress$NRM\n";
  548. print "5. IMAP Port : $WHT$imapPort$NRM\n";
  549. print "6. Authentication type : $WHT$imap_auth_mech$NRM\n";
  550. print "7. Secure IMAP (TLS) : $WHT" . display_use_tls($use_imap_tls) . "$NRM\n";
  551. print "8. Server software : $WHT$imap_server_type$NRM\n";
  552. print "9. Delimiter : $WHT$optional_delimiter$NRM\n";
  553. print "\n";
  554. } elsif ( $show_smtp_settings ) {
  555. if ( lc($useSendmail) eq 'true' ) {
  556. print $WHT . "Sendmail" . $NRM . "\n--------\n";
  557. print "4. Sendmail Path : $WHT$sendmail_path$NRM\n";
  558. print "5. Sendmail arguments : $WHT$sendmail_args$NRM\n";
  559. print "6. Header encryption key : $WHT$encode_header_key$NRM\n";
  560. print "\n";
  561. } else {
  562. print $WHT . "SMTP Settings" . $NRM . "\n-------------\n";
  563. print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
  564. print "5. SMTP Port : $WHT$smtpPort$NRM\n";
  565. print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
  566. print "7. SMTP Authentication : $WHT$smtp_auth_mech" . display_smtp_sitewide_userpass() ."$NRM\n";
  567. print "8. Secure SMTP (TLS) : $WHT" . display_use_tls($use_smtp_tls) . "$NRM\n";
  568. print "9. Header encryption key : $WHT$encode_header_key$NRM\n";
  569. print "\n";
  570. }
  571. }
  572. if ($show_imap_settings == 0) {
  573. print "A. Update IMAP Settings : ";
  574. print "$WHT$imapServerAddress$NRM:";
  575. print "$WHT$imapPort$NRM ";
  576. print "($WHT$imap_server_type$NRM)\n";
  577. }
  578. if ($show_smtp_settings == 0) {
  579. if ( lc($useSendmail) eq 'true' ) {
  580. print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n";
  581. } else {
  582. print "B. Update SMTP Settings : ";
  583. print "$WHT$smtpServerAddress$NRM:";
  584. print "$WHT$smtpPort$NRM\n";
  585. }
  586. }
  587. if ( $show_smtp_settings || $show_imap_settings )
  588. {
  589. print "H. Hide " .
  590. ($show_imap_settings ? "IMAP Server" :
  591. (lc($useSendmail) eq 'true') ? "Sendmail" : "SMTP") . " Settings\n";
  592. }
  593. print "\n";
  594. print "R Return to Main Menu\n";
  595. } elsif ( $menu == 3 ) {
  596. print $WHT. "Folder Defaults\n" . $NRM;
  597. print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
  598. print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
  599. print "3. Trash Folder : $WHT$trash_folder$NRM\n";
  600. print "4. Sent Folder : $WHT$sent_folder$NRM\n";
  601. print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
  602. print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
  603. print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
  604. print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
  605. print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
  606. print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
  607. print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
  608. print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
  609. print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
  610. print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
  611. print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
  612. print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
  613. print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n";
  614. print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
  615. print "\n";
  616. print "R Return to Main Menu\n";
  617. } elsif ( $menu == 4 ) {
  618. print $WHT. "General Options\n" . $NRM;
  619. print "1. Data Directory : $WHT$data_dir$NRM\n";
  620. print "2. Attachment Directory : $WHT$attachment_dir$NRM\n";
  621. print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
  622. print "4. Default Left Size : $WHT$default_left_size$NRM\n";
  623. print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
  624. print "6. Allow use of priority : $WHT$default_use_priority$NRM\n";
  625. print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
  626. print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
  627. print "9. Allow editing of identity : $WHT$edit_identity$NRM\n";
  628. print " Allow editing of name : $WHT$edit_name$NRM\n";
  629. print " Remove username from header : $WHT$hide_auth_header$NRM\n";
  630. print "10. Disable server thread sort : $WHT$disable_thread_sort$NRM\n";
  631. print "11. Disable server-side sorting : $WHT$disable_server_sort$NRM\n";
  632. print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
  633. print "13. Allow advanced search : $WHT$allow_advanced_search$NRM\n";
  634. print "14. PHP session name : $WHT$session_name$NRM\n";
  635. print "15. Time zone configuration : $WHT$time_zone_type$NRM\n";
  636. print "16. Location base : $WHT$config_location_base$NRM\n";
  637. print "\n";
  638. print "R Return to Main Menu\n";
  639. } elsif ( $menu == 5 ) {
  640. print $WHT. "User Interface\n" . $NRM;
  641. print "1. Use Icons? : $WHT$use_icons$NRM\n";
  642. # print "3. Default Icon Set : $WHT$icon_theme_def$NRM\n";
  643. print "2. Default font size : $WHT$default_fontsize$NRM\n";
  644. print "3. Manage template sets\n";
  645. print "4. Manage user themes\n";
  646. print "5. Manage font sets\n";
  647. print "6. Manage icon themes\n";
  648. print "\n";
  649. print "R Return to Main Menu\n";
  650. } elsif ( $menu == 6 ) {
  651. print $WHT. "Address Books\n" . $NRM;
  652. print "1. Change LDAP Servers\n";
  653. for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
  654. print " > $ldap_host[$count]\n";
  655. }
  656. print "2. Use Javascript address book search : $WHT$default_use_javascript_addr_book$NRM\n";
  657. print "3. Global address book file : $WHT$abook_global_file$NRM\n";
  658. print "4. Allow writing into global file address book : $WHT$abook_global_file_writeable$NRM\n";
  659. print "5. Allow listing of global file address book : $WHT$abook_global_file_listing$NRM\n";
  660. print "6. Allowed address book line length : $WHT$abook_file_line_length$NRM\n";
  661. print "\n";
  662. print "R Return to Main Menu\n";
  663. } elsif ( $menu == 7 ) {
  664. print $WHT. "Message of the Day (MOTD)\n" . $NRM;
  665. print "\n$motd\n";
  666. print "\n";
  667. print "1 Edit the MOTD\n";
  668. print "\n";
  669. print "R Return to Main Menu\n";
  670. } elsif ( $menu == 8 ) {
  671. if (lc($disable_plugins) eq 'true' && $disable_plugins_user ne '') {
  672. print $WHT. "Plugins (WARNING: All plugins are currently disabled\n for the user \"$disable_plugins_user\"!)\n" . $NRM;
  673. } elsif (lc($disable_plugins) eq 'true') {
  674. print $WHT. "Plugins (WARNING: All plugins are currently disabled!)\n" . $NRM;
  675. } else {
  676. print $WHT. "Plugins\n" . $NRM;
  677. }
  678. print " Installed Plugins\n";
  679. $num = 0;
  680. for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
  681. $num = $count + 1;
  682. print " $num. $plugins[$count]\n";
  683. }
  684. print "\n Available Plugins:\n";
  685. opendir( DIR, "../plugins" );
  686. @files = readdir(DIR);
  687. $pos = 0;
  688. @unused_plugins = ();
  689. for ( $i = 0 ; $i <= $#files ; $i++ ) {
  690. if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
  691. $match = 0;
  692. for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
  693. if ( $plugins[$k] eq $files[$i] ) {
  694. $match = 1;
  695. }
  696. }
  697. if ( $match == 0 ) {
  698. $unused_plugins[$pos] = $files[$i];
  699. $pos++;
  700. }
  701. }
  702. }
  703. for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
  704. $num = $num + 1;
  705. print " $num. $unused_plugins[$i]\n";
  706. }
  707. closedir DIR;
  708. print "\n";
  709. if (lc($disable_plugins) eq 'true' && $disable_plugins_user ne '') {
  710. print "E Enable active plugins (all plugins currently\n disabled for the user \"$disable_plugins_user\")\n";
  711. } elsif (lc($disable_plugins) eq 'true') {
  712. print "E Enable active plugins (all plugins currently\n disabled)\n";
  713. } else {
  714. print "D Disable all plugins\n";
  715. }
  716. print "U Set the user for whom plugins can be disabled\n";
  717. print "R Return to Main Menu\n";
  718. } elsif ( $menu == 9 ) {
  719. print $WHT. "Database\n" . $NRM;
  720. print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
  721. print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
  722. print "\n";
  723. print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
  724. print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
  725. print "5. Field for username : $WHT$prefs_user_field$NRM ($prefs_user_size)\n";
  726. print "6. Field for prefs key : $WHT$prefs_key_field$NRM ($prefs_key_size)\n";
  727. print "7. Field for prefs value : $WHT$prefs_val_field$NRM ($prefs_val_size)\n";
  728. print "\n";
  729. print "8. DSN for Global Address Book : $WHT$addrbook_global_dsn$NRM\n";
  730. print "9. Table for Global Address Book : $WHT$addrbook_global_table$NRM\n";
  731. print "10. Allow writing into Global Address Book : $WHT$addrbook_global_writeable$NRM\n";
  732. print "11. Allow listing of Global Address Book : $WHT$addrbook_global_listing$NRM\n";
  733. print "\n";
  734. print "R Return to Main Menu\n";
  735. } elsif ( $menu == 10 ) {
  736. print $WHT. "Language settings\n" . $NRM;
  737. print "1. Default Language : $WHT$squirrelmail_default_language$NRM\n";
  738. print "2. Default Charset : $WHT$default_charset$NRM\n";
  739. print "3. Show alternative language names : $WHT$show_alternative_names$NRM\n";
  740. print "4. Enable aggressive decoding : $WHT$aggressive_decoding$NRM\n";
  741. print "5. Enable lossy encoding : $WHT$lossy_encoding$NRM\n";
  742. print "\n";
  743. print "R Return to Main Menu\n";
  744. } elsif ( $menu == 11 ) {
  745. print $WHT. "Interface tweaks\n" . $NRM;
  746. print "1. Display html mails in iframe : $WHT$use_iframe$NRM\n";
  747. print "\n";
  748. print $WHT. "PHP tweaks\n" . $NRM;
  749. print "4. Use php recode functions : $WHT$use_php_recode$NRM\n";
  750. print "5. Use php iconv functions : $WHT$use_php_iconv$NRM\n";
  751. print "\n";
  752. print $WHT. "Configuration tweaks\n" . $NRM;
  753. print "6. Allow remote configtest : $WHT$allow_remote_configtest$NRM\n";
  754. print "\n";
  755. print "R Return to Main Menu\n";
  756. }
  757. if ( $config_use_color == 1 ) {
  758. print "C Turn color off\n";
  759. } else {
  760. print "C Turn color on\n";
  761. }
  762. print "S Save data\n";
  763. print "Q Quit\n";
  764. print "\n";
  765. print "Command >> " . $WHT;
  766. $command = <STDIN>;
  767. $command =~ s/[\n\r]//g;
  768. $command =~ tr/A-Z/a-z/;
  769. print "$NRM\n";
  770. # Read the commands they entered.
  771. if ( $command eq "r" ) {
  772. $menu = 0;
  773. } elsif ( $command eq "s" ) {
  774. save_data();
  775. print "Press enter to continue...";
  776. $tmp = <STDIN>;
  777. $saved = 1;
  778. } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
  779. print "You have not saved your data.\n";
  780. print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
  781. $save = <STDIN>;
  782. if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
  783. save_data();
  784. }
  785. } elsif ( $command eq "c" ) {
  786. if ( $config_use_color == 1 ) {
  787. $config_use_color = 2;
  788. $WHT = "";
  789. $NRM = "";
  790. } else {
  791. $config_use_color = 1;
  792. $WHT = "\x1B[37;1m";
  793. $NRM = "\x1B[0m";
  794. }
  795. } elsif ( $command eq "d" && $menu == 0 ) {
  796. set_defaults();
  797. } else {
  798. $saved = 0;
  799. if ( $menu == 0 ) {
  800. if ( ( $command > 0 ) && ( $command < 12 ) ) {
  801. $menu = $command;
  802. }
  803. } elsif ( $menu == 1 ) {
  804. if ( $command == 1 ) { $org_name = command1(); }
  805. elsif ( $command == 2 ) { $org_logo = command2(); }
  806. elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a(); }
  807. elsif ( $command == 4 ) { $org_title = command3(); }
  808. elsif ( $command == 5 ) { $signout_page = command4(); }
  809. elsif ( $command == 6 ) { $frame_top = command6(); }
  810. elsif ( $command == 7 ) { $provider_uri = command7(); }
  811. elsif ( $command == 8 ) { $provider_name = command8(); }
  812. } elsif ( $menu == 2 ) {
  813. if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; }
  814. elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; }
  815. elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; }
  816. elsif ( $command <= 3 ) {
  817. if ( $command == 1 ) { $domain = command11(); }
  818. elsif ( $command == 2 ) { $invert_time = command110(); }
  819. elsif ( $command == 3 ) { $useSendmail = command14(); }
  820. $show_imap_settings = 0; $show_smtp_settings = 0;
  821. } elsif ( $show_imap_settings ) {
  822. if ( $command == 4 ) { $imapServerAddress = command12(); }
  823. elsif ( $command == 5 ) { $imapPort = command13(); }
  824. elsif ( $command == 6 ) { $imap_auth_mech = command112a(); }
  825. elsif ( $command == 7 ) { $use_imap_tls = command_use_tls("IMAP",$use_imap_tls); }
  826. elsif ( $command == 8 ) { $imap_server_type = command19(); }
  827. elsif ( $command == 9 ) { $optional_delimiter = command111(); }
  828. } elsif ( $show_smtp_settings && lc($useSendmail) eq 'true' ) {
  829. if ( $command == 4 ) { $sendmail_path = command15(); }
  830. elsif ( $command == 5 ) { $sendmail_args = command_sendmail_args(); }
  831. elsif ( $command == 6 ) { $encode_header_key = command114(); }
  832. } elsif ( $show_smtp_settings ) {
  833. if ( $command == 4 ) { $smtpServerAddress = command16(); }
  834. elsif ( $command == 5 ) { $smtpPort = command17(); }
  835. elsif ( $command == 6 ) { $pop_before_smtp = command18a(); }
  836. elsif ( $command == 7 ) { $smtp_auth_mech = command112b(); }
  837. elsif ( $command == 8 ) { $use_smtp_tls = command_use_tls("SMTP",$use_smtp_tls); }
  838. elsif ( $command == 9 ) { $encode_header_key = command114(); }
  839. }
  840. } elsif ( $menu == 3 ) {
  841. if ( $command == 1 ) { $default_folder_prefix = command21(); }
  842. elsif ( $command == 2 ) { $show_prefix_option = command22(); }
  843. elsif ( $command == 3 ) { $trash_folder = command23a(); }
  844. elsif ( $command == 4 ) { $sent_folder = command23b(); }
  845. elsif ( $command == 5 ) { $draft_folder = command23c(); }
  846. elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
  847. elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
  848. elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
  849. elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
  850. elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
  851. elsif ( $command == 11 ) { $auto_expunge = command29(); }
  852. elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
  853. elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
  854. elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
  855. elsif ( $command == 15 ) { $default_unseen_type = command213(); }
  856. elsif ( $command == 16 ) { $auto_create_special = command214(); }
  857. elsif ( $command == 17 ) { $delete_folder = command215(); }
  858. elsif ( $command == 18 ) { $noselect_fix_enable = command216(); }
  859. } elsif ( $menu == 4 ) {
  860. if ( $command == 1 ) { $data_dir = command33a(); }
  861. elsif ( $command == 2 ) { $attachment_dir = command33b(); }
  862. elsif ( $command == 3 ) { $dir_hash_level = command33c(); }
  863. elsif ( $command == 4 ) { $default_left_size = command35(); }
  864. elsif ( $command == 5 ) { $force_username_lowercase = command36(); }
  865. elsif ( $command == 6 ) { $default_use_priority = command37(); }
  866. elsif ( $command == 7 ) { $hide_sm_attributions = command38(); }
  867. elsif ( $command == 8 ) { $default_use_mdn = command39(); }
  868. elsif ( $command == 9 ) { $edit_identity = command310(); }
  869. elsif ( $command == 10 ) { $disable_thread_sort = command312(); }
  870. elsif ( $command == 11 ) { $disable_server_sort = command313(); }
  871. elsif ( $command == 12 ) { $allow_charset_search = command314(); }
  872. elsif ( $command == 13 ) { $allow_advanced_search = command316(); }
  873. elsif ( $command == 14 ) { $session_name = command317(); }
  874. elsif ( $command == 15 ) { $time_zone_type = command318(); }
  875. elsif ( $command == 16 ) { $config_location_base = command_config_location_base(); }
  876. } elsif ( $menu == 5 ) {
  877. if ( $command == 1 ) { $use_icons = commandB3(); }
  878. # elsif ( $command == 3 ) { $icon_theme_def = commandB7(); }
  879. elsif ( $command == 2 ) { $default_fontsize = command_default_fontsize(); }
  880. elsif ( $command == 3 ) { $templateset_default = command_templates(); }
  881. elsif ( $command == 4 ) { command_userThemes(); }
  882. elsif ( $command == 5 ) { command_fontsets(); }
  883. elsif ( $command == 6 ) { command_iconSets(); }
  884. } elsif ( $menu == 6 ) {
  885. if ( $command == 1 ) { command61(); }
  886. elsif ( $command == 2 ) { command62(); }
  887. elsif ( $command == 3 ) { $abook_global_file=command63(); }
  888. elsif ( $command == 4 ) { command64(); }
  889. elsif ( $command == 5 ) { command65(); }
  890. elsif ( $command == 6 ) { command_abook_file_line_length(); }
  891. } elsif ( $menu == 7 ) {
  892. if ( $command == 1 ) { $motd = command71(); }
  893. } elsif ( $menu == 8 ) {
  894. if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
  895. elsif ( $command eq "u" ) { $disable_plugins_user = command82(); }
  896. elsif ( $command eq "d" ) { $disable_plugins = 'true'; }
  897. elsif ( $command eq "e" ) { $disable_plugins = 'false'; }
  898. } elsif ( $menu == 9 ) {
  899. if ( $command == 1 ) { $addrbook_dsn = command91(); }
  900. elsif ( $command == 2 ) { $addrbook_table = command92(); }
  901. elsif ( $command == 3 ) { $prefs_dsn = command93(); }
  902. elsif ( $command == 4 ) { $prefs_table = command94(); }
  903. elsif ( $command == 5 ) { $prefs_user_field = command95(); }
  904. elsif ( $command == 6 ) { $prefs_key_field = command96(); }
  905. elsif ( $command == 7 ) { $prefs_val_field = command97(); }
  906. elsif ( $command == 8 ) { $addrbook_global_dsn = command98(); }
  907. elsif ( $command == 9 ) { $addrbook_global_table = command99(); }
  908. elsif ( $command == 10 ) { $addrbook_global_writeable = command910(); }
  909. elsif ( $command == 11 ) { $addrbook_global_listing = command911(); }
  910. } elsif ( $menu == 10 ) {
  911. if ( $command == 1 ) { $squirrelmail_default_language = commandA1(); }
  912. elsif ( $command == 2 ) { $default_charset = commandA2(); }
  913. elsif ( $command == 3 ) { $show_alternative_names = commandA3(); }
  914. elsif ( $command == 4 ) { $aggressive_decoding = commandA4(); }
  915. elsif ( $command == 5 ) { $lossy_encoding = commandA5(); }
  916. } elsif ( $menu == 11 ) {
  917. if ( $command == 1 ) { $use_iframe = commandB2(); }
  918. elsif ( $command == 4 ) { $use_php_recode = commandB4(); }
  919. elsif ( $command == 5 ) { $use_php_iconv = commandB5(); }
  920. elsif ( $command == 6 ) { $allow_remote_configtest = commandB6(); }
  921. }
  922. }
  923. }
  924. # we exit here
  925. print "\nExiting conf.pl.\n".
  926. "You might want to test your configuration by browsing to\n".
  927. "http://your-squirrelmail-location/src/configtest.php\n".
  928. "Happy SquirrelMailing!\n\n";
  929. ####################################################################################
  930. # org_name
  931. sub command1 {
  932. print "We have tried to make the name SquirrelMail as transparent as\n";
  933. print "possible. If you set up an organization name, most places where\n";
  934. print "SquirrelMail would take credit will be credited to your organization.\n";
  935. print "\n";
  936. print "If your Organization Name includes a '\$', please precede it with a \\. \n";
  937. print "Other '\$' will be considered the beginning of a variable that\n";
  938. print "must be defined before the \$org_name is printed.\n";
  939. print "\n";
  940. print "[$WHT$org_name$NRM]: $WHT";
  941. $new_org_name = <STDIN>;
  942. if ( $new_org_name eq "\n" ) {
  943. $new_org_name = $org_name;
  944. } else {
  945. $new_org_name =~ s/[\r\n]//g;
  946. $new_org_name =~ s/\"/&quot;/g;
  947. }
  948. return $new_org_name;
  949. }
  950. # org_logo
  951. sub command2 {
  952. print "Your organization's logo is an image that will be displayed at\n";
  953. print "different times throughout SquirrelMail. ";
  954. print "\n";
  955. print "Please be aware of the following: \n";
  956. print " - Relative URLs are relative to the config dir\n";
  957. print " to use the default logo, use ../images/sm_logo.png\n";
  958. print " - To specify a logo defined outside the SquirrelMail source tree\n";
  959. print " use the absolute URL the webserver would use to include the file\n";
  960. print " e.g. http://www.example.com/images/mylogo.gif or /images/mylogo.jpg\n";
  961. print "\n";
  962. print "[$WHT$org_logo$NRM]: $WHT";
  963. $new_org_logo = <STDIN>;
  964. if ( $new_org_logo eq "\n" ) {
  965. $new_org_logo = $org_logo;
  966. } else {
  967. $new_org_logo =~ s/[\r\n]//g;
  968. }
  969. return $new_org_logo;
  970. }
  971. # org_logo_width
  972. sub command2a {
  973. print "Your organization's logo is an image that will be displayed at\n";
  974. print "different times throughout SquirrelMail. Width\n";
  975. print "and Height of your logo image. Use '0' to disable.\n";
  976. print "\n";
  977. print "Width: [$WHT$org_logo_width$NRM]: $WHT";
  978. $new_org_logo_width = <STDIN>;
  979. $new_org_logo_width =~ tr/0-9//cd; # only want digits!
  980. if ( $new_org_logo_width eq '' ) {
  981. $new_org_logo_width = $org_logo_width;
  982. }
  983. if ( $new_org_logo_width > 0 ) {
  984. print "Height: [$WHT$org_logo_height$NRM]: $WHT";
  985. $new_org_logo_height = <STDIN>;
  986. $new_org_logo_height =~ tr/0-9//cd; # only want digits!
  987. if( $new_org_logo_height eq '' ) {
  988. $new_org_logo_height = $org_logo_height;
  989. }
  990. } else {
  991. $new_org_logo_height = 0;
  992. }
  993. return ($new_org_logo_width, $new_org_logo_height);
  994. }
  995. # org_title
  996. sub command3 {
  997. print "A title is what is displayed at the top of the browser window in\n";
  998. print "the titlebar. Usually this will end up looking something like:\n";
  999. print "\"Netscape: $org_title\"\n";
  1000. print "\n";
  1001. print "If your Organization Title includes a '\$', please precede it with a \\. \n";
  1002. print "Other '\$' will be considered the beginning of a variable that\n";
  1003. print "must be defined before the \$org_title is printed.\n";
  1004. print "\n";
  1005. print "[$WHT$org_title$NRM]: $WHT";
  1006. $new_org_title = <STDIN>;
  1007. if ( $new_org_title eq "\n" ) {
  1008. $new_org_title = $org_title;
  1009. } else {
  1010. $new_org_title =~ s/[\r\n]//g;
  1011. $new_org_title =~ s/\"/\'/g;
  1012. }
  1013. return $new_org_title;
  1014. }
  1015. # signout_page
  1016. sub command4 {
  1017. print "When users click the Sign Out button they will be logged out and\n";
  1018. print "then sent to signout_page. If signout_page is left empty,\n";
  1019. print "(hit space and then return) they will be taken, as normal,\n";
  1020. print "to the default and rather sparse SquirrelMail signout page.\n";
  1021. print "\n";
  1022. print "[$WHT$signout_page$NRM]: $WHT";
  1023. $new_signout_page = <STDIN>;
  1024. if ( $new_signout_page eq "\n" ) {
  1025. $new_signout_page = $signout_page;
  1026. } else {
  1027. $new_signout_page =~ s/[\r\n]//g;
  1028. $new_signout_page =~ s/^\s+$//g;
  1029. }
  1030. return $new_signout_page;
  1031. }
  1032. # Default top frame
  1033. sub command6 {
  1034. print "SquirrelMail defaults to using the whole of the browser window.\n";
  1035. print "This allows you to keep it within a specified frame. The default\n";
  1036. print "is '_top'\n";
  1037. print "\n";
  1038. print "[$WHT$frame_top$NRM]: $WHT";
  1039. $new_frame_top = <STDIN>;
  1040. if ( $new_frame_top eq "\n" ) {
  1041. $new_frame_top = '_top';
  1042. } else {
  1043. $new_frame_top =~ s/[\r\n]//g;
  1044. $new_frame_top =~ s/^\s+$//g;
  1045. }
  1046. return $new_frame_top;
  1047. }
  1048. # Default link to provider
  1049. sub command7 {
  1050. print "Here you can set the link on the right of the page.\n";
  1051. print "If empty, it will link to the SquirrelMail About page.\n";
  1052. print "\n";
  1053. print "[$WHT$provider_uri$NRM]: $WHT";
  1054. $new_provider_uri = <STDIN>;
  1055. if ( $new_provider_uri eq "\n" ) {
  1056. $new_provider_uri = '';
  1057. } else {
  1058. $new_provider_uri =~ s/[\r\n]//g;
  1059. $new_provider_uri =~ s/^\s+$//g;
  1060. }
  1061. return $new_provider_uri;
  1062. }
  1063. sub command8 {
  1064. print "Here you can set the name of the link on the right of the page.\n";
  1065. print "The default is 'SquirrelMail'\n";
  1066. print "\n";
  1067. print "[$WHT$provider_name$NRM]: $WHT";
  1068. $new_provider_name = <STDIN>;
  1069. if ( $new_provider_name eq "\n" ) {
  1070. $new_provider_name = 'SquirrelMail';
  1071. } else {
  1072. $new_provider_name =~ s/[\r\n]//g;
  1073. $new_provider_name =~ s/^\s+$//g;
  1074. $new_provider_name =~ s/\'/\\'/g;
  1075. }
  1076. return $new_provider_name;
  1077. }
  1078. ####################################################################################
  1079. # domain
  1080. sub command11 {
  1081. print "The domain name is the suffix at the end of all email addresses. If\n";
  1082. print "for example, your email address is jdoe\@example.com, then your domain\n";
  1083. print "would be example.com.\n";
  1084. print "\n";
  1085. print "[$WHT$domain$NRM]: $WHT";
  1086. $new_domain = <STDIN>;
  1087. if ( $new_domain eq "\n" ) {
  1088. $new_domain = $domain;
  1089. } else {
  1090. $new_domain =~ s/\s//g;
  1091. }
  1092. return $new_domain;
  1093. }
  1094. # imapServerAddress
  1095. sub command12 {
  1096. print "This is the hostname where your IMAP server can be contacted.\n";
  1097. print "[$WHT$imapServerAddress$NRM]: $WHT";
  1098. $new_imapServerAddress = <STDIN>;
  1099. if ( $new_imapServerAddress eq "\n" ) {
  1100. $new_imapServerAddress = $imapServerAddress;
  1101. } else {
  1102. $new_imapServerAddress =~ s/[\r\n]//g;
  1103. }
  1104. return $new_imapServerAddress;
  1105. }
  1106. # imapPort
  1107. sub command13 {
  1108. print "This is the port that your IMAP server is on. Usually this is 143.\n";
  1109. print "[$WHT$imapPort$NRM]: $WHT";
  1110. $new_imapPort = <STDIN>;
  1111. if ( $new_imapPort eq "\n" ) {
  1112. $new_imapPort = $imapPort;
  1113. } else {
  1114. $new_imapPort =~ s/[\r\n]//g;
  1115. }
  1116. return $new_imapPort;
  1117. }
  1118. # useSendmail
  1119. sub command14 {
  1120. print "You now need to choose the method that you will use for sending\n";
  1121. print "messages in SquirrelMail. You can either connect to an SMTP server\n";
  1122. print "or use sendmail directly.\n";
  1123. if ( lc($useSendmail) eq 'true' ) {
  1124. $default_value = "1";
  1125. } else {
  1126. $default_value = "2";
  1127. }
  1128. print "\n";
  1129. print " 1. Sendmail\n";
  1130. print " 2. SMTP\n";
  1131. print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
  1132. $use_sendmail = <STDIN>;
  1133. if ( ( $use_sendmail =~ /^1\n/i )
  1134. || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
  1135. $useSendmail = 'true';
  1136. } else {
  1137. $useSendmail = 'false';
  1138. }
  1139. return $useSendmail;
  1140. }
  1141. # sendmail_path
  1142. sub command15 {
  1143. print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
  1144. print "[$WHT$sendmail_path$NRM]: $WHT";
  1145. $new_sendmail_path = <STDIN>;
  1146. if ( $new_sendmail_path eq "\n" ) {
  1147. $new_sendmail_path = $sendmail_path;
  1148. } else {
  1149. $new_sendmail_path =~ s/[\r\n]//g;
  1150. }
  1151. return $new_sendmail_path;
  1152. }
  1153. # Extra sendmail arguments
  1154. sub command_sendmail_args {
  1155. print "Specify additional sendmail program arguments.\n";
  1156. print "\n";
  1157. print "Make sure that arguments are supported by your sendmail program. -f argument \n";
  1158. print "is added automatically by SquirrelMail scripts. Variable defaults to standard\n";
  1159. print "/usr/sbin/sendmail arguments. If you use qmail-inject, nbsmtp or any other \n";
  1160. print "sendmail wrapper, which does not support -i and -t arguments, set variable to\n";
  1161. print "empty string or use arguments suitable for your mailer.\n";
  1162. print "\n";
  1163. print "[$WHT$sendmail_args$NRM]: $WHT";
  1164. $new_sendmail_args = <STDIN>;
  1165. if ( $new_sendmail_args eq "\n" ) {
  1166. $new_sendmail_args = $sendmail_args;
  1167. } else {
  1168. # strip linefeeds and crs.
  1169. $new_sendmail_args =~ s/[\r\n]//g;
  1170. }
  1171. return trim($new_sendmail_args);
  1172. }
  1173. # smtpServerAddress
  1174. sub command16 {
  1175. print "This is the hostname of your SMTP server.\n";
  1176. print "[$WHT$smtpServerAddress$NRM]: $WHT";
  1177. $new_smtpServerAddress = <STDIN>;
  1178. if ( $new_smtpServerAddress eq "\n" ) {
  1179. $new_smtpServerAddress = $smtpServerAddress;
  1180. } else {
  1181. $new_smtpServerAddress =~ s/[\r\n]//g;
  1182. }
  1183. return $new_smtpServerAddress;
  1184. }
  1185. # smtpPort
  1186. sub command17 {
  1187. print "This is the port to connect to for SMTP. Usually 25.\n";
  1188. print "[$WHT$smtpPort$NRM]: $WHT";
  1189. $new_smtpPort = <STDIN>;
  1190. if ( $new_smtpPort eq "\n" ) {
  1191. $new_smtpPort = $smtpPort;
  1192. } else {
  1193. $new_smtpPort =~ s/[\r\n]//g;
  1194. }
  1195. return $new_smtpPort;
  1196. }
  1197. # pop before SMTP
  1198. sub command18a {
  1199. print "Do you wish to use POP3 before SMTP? Your server must\n";
  1200. print "support this in order for SquirrelMail to work with it.\n";
  1201. $YesNo = 'n';
  1202. $YesNo = 'y' if ( lc($pop_before_smtp) eq 'true' );
  1203. print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
  1204. $new_pop_before_smtp = <STDIN>;
  1205. $new_pop_before_smtp =~ tr/yn//cd;
  1206. return 'true' if ( $new_pop_before_smtp eq "y" );
  1207. return 'false' if ( $new_pop_before_smtp eq "n" );
  1208. return $pop_before_smtp;
  1209. }
  1210. # imap_server_type
  1211. sub command19 {
  1212. print "Each IMAP server has its own quirks. As much as we tried to stick\n";
  1213. print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
  1214. print "the same principles. We have made some work-arounds for some of\n";
  1215. print "these servers. If you would like to use them, please select your\n";
  1216. print "IMAP server. If you do not wish to use these work-arounds, you can\n";
  1217. print "set this to \"other\", and none will be used.\n";
  1218. print $list_supported_imap_servers;
  1219. print "\n";
  1220. print " other = Not one of the above servers\n";
  1221. print "\n";
  1222. print "[$WHT$imap_server_type$NRM]: $WHT";
  1223. $new_imap_server_type = <STDIN>;
  1224. if ( $new_imap_server_type eq "\n" ) {
  1225. $new_imap_server_type = $imap_server_type;
  1226. } else {
  1227. $new_imap_server_type =~ s/[\r\n]//g;
  1228. }
  1229. return $new_imap_server_type;
  1230. }
  1231. # invert_time
  1232. sub command110 {
  1233. print "Sometimes the date of messages sent is messed up (off by a few hours\n";
  1234. print "on some machines). Typically this happens if the system doesn't support\n";
  1235. print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
  1236. print "This most often occurs on Solaris 7 machines in the United States.\n";
  1237. print "By default, this is off. It should be kept off unless problems surface\n";
  1238. print "about the time that messages are sent.\n";
  1239. print " no = Do NOT fix time -- almost always correct\n";
  1240. print " yes = Fix the time for this system\n";
  1241. $YesNo = 'n';
  1242. $YesNo = 'y' if ( lc($invert_time) eq 'true' );
  1243. print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
  1244. $new_invert_time = <STDIN>;
  1245. $new_invert_time =~ tr/yn//cd;
  1246. return 'true' if ( $new_invert_time eq "y" );
  1247. return 'false' if ( $new_invert_time eq "n" );
  1248. return $invert_time;
  1249. }
  1250. sub command111 {
  1251. print "This is the delimiter that your IMAP server uses to distinguish between\n";
  1252. print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
  1253. print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
  1254. print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
  1255. print "but if you are sure you know what delimiter your server uses, you can\n";
  1256. print "specify it here.\n";
  1257. print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
  1258. print "[$WHT$optional_delimiter$NRM]: $WHT";
  1259. $new_optional_delimiter = <STDIN>;
  1260. if ( $new_optional_delimiter eq "\n" ) {
  1261. $new_optional_delimiter = $optional_delimiter;
  1262. } else {
  1263. $new_optional_delimiter =~ s/[\r\n]//g;
  1264. }
  1265. return $new_optional_delimiter;
  1266. }
  1267. # IMAP authentication type
  1268. # Possible values: login, plain, cram-md5, digest-md5
  1269. # Now offers to detect supported mechs, assuming server & port are set correctly
  1270. sub command112a {
  1271. if ($use_imap_tls ne "0") {
  1272. # 1. Script does not handle TLS.
  1273. # 2. Server does not have to declare all supported authentication mechs when
  1274. # STARTTLS is used. Supported mechs are declared only after STARTTLS.
  1275. print "Auto-detection of login methods is unavailable when using TLS or STARTTLS.\n";
  1276. } else {
  1277. print "If you have already set the hostname and port number, I can try to\n";
  1278. print "detect the mechanisms your IMAP server supports.\n";
  1279. print "I will try to detect CRAM-MD5 and DIGEST-MD5 support. I can't test\n";
  1280. print "for \"login\" or \"plain\" without knowing a username and password.\n";
  1281. print "Auto-detecting is optional - you can safely say \"n\" here.\n";
  1282. print "\nTry to detect supported mechanisms? [y/N]: ";
  1283. $inval=<STDIN>;
  1284. chomp($inval);
  1285. if ($inval =~ /^y\b/i) {
  1286. # Yes, let's try to detect.
  1287. print "Trying to detect IMAP capabilities...\n";
  1288. my $host = $imapServerAddress . ':'. $imapPort;
  1289. print "CRAM-MD5:\t";
  1290. my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5');
  1291. if (defined($tmp)) {
  1292. if ($tmp eq 'YES') {
  1293. print "$WHT SUPPORTED$NRM\n";
  1294. } else {
  1295. print "$WHT NOT SUPPORTED$NRM\n";
  1296. }
  1297. } else {
  1298. print $WHT . " ERROR DETECTING$NRM\n";
  1299. }
  1300. print "DIGEST-MD5:\t";
  1301. $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5');
  1302. if (defined($tmp)) {
  1303. if ($tmp eq 'YES') {
  1304. print "$WHT SUPPORTED$NRM\n";
  1305. } else {
  1306. print "$WHT NOT SUPPORTED$NRM\n";
  1307. }
  1308. } else {
  1309. print $WHT . " ERROR DETECTING$NRM\n";
  1310. }
  1311. }
  1312. }
  1313. print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
  1314. print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
  1315. print $WHT . "plain" . $NRM . " - SASL PLAIN. If you need this, you already know it.\n";
  1316. print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
  1317. print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
  1318. print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
  1319. print "If you don't understand or are unsure, you probably want \"login\"\n\n";
  1320. print "login, plain, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
  1321. $inval=<STDIN>;
  1322. chomp($inval);
  1323. if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
  1324. return lc($inval);
  1325. } else {
  1326. # user entered garbage or default value so nothing needs to be set
  1327. return $imap_auth_mech;
  1328. }
  1329. }
  1330. # SMTP authentication type
  1331. # Possible choices: none, plain, cram-md5, digest-md5
  1332. sub command112b {
  1333. if ($use_smtp_tls ne "0") {
  1334. print "Auto-detection of login methods is unavailable when using TLS or STARTTLS.\n";
  1335. } elsif (eval ("use IO::Socket; 1")) {
  1336. # try loading IO::Socket module
  1337. print "If you have already set the hostname and port number, I can try to\n";
  1338. print "automatically detect some of the mechanisms your SMTP server supports.\n";
  1339. print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
  1340. print "\nTry to detect auth mechanisms? [y/N]: ";
  1341. $inval=<STDIN>;
  1342. chomp($inval);
  1343. if ($inval =~ /^y\b/i) {
  1344. # Yes, let's try to detect.
  1345. print "Trying to detect supported methods (SMTP)...\n";
  1346. # Special case!
  1347. # Check none by trying to relay to junk@microsoft.com
  1348. $host = $smtpServerAddress . ':' . $smtpPort;
  1349. my $sock = IO::Socket::INET->new($host);
  1350. print "Testing none:\t\t$WHT";
  1351. if (!defined($sock)) {
  1352. print " ERROR TESTING\n";
  1353. close $sock;
  1354. } else {
  1355. print $sock "HELO $domain\r\n";
  1356. $got = <$sock>; # Discard
  1357. print $sock "MAIL FROM:<tester\@squirrelmail.org>\r\n";
  1358. $got = <$sock>; # Discard
  1359. print $sock "RCPT TO:<junk\@microsoft.com\r\n";
  1360. $got = <$sock>; # This is the important line
  1361. if ($got =~ /^250\b/) { # SMTP will relay without auth
  1362. print "SUPPORTED$NRM\n";
  1363. } else {
  1364. print "NOT SUPPORTED$NRM\n";
  1365. }
  1366. print $sock "RSET\r\n";
  1367. print $sock "QUIT\r\n";
  1368. close $sock;
  1369. }
  1370. # Try login (SquirrelMail default)
  1371. print "Testing login:\t\t";
  1372. $tmp=detect_auth_support('SMTP',$host,'LOGIN');
  1373. if (defined($tmp)) {
  1374. if ($tmp eq 'YES') {
  1375. print $WHT . "SUPPORTED$NRM\n";
  1376. } else {
  1377. print $WHT . "NOT SUPPORTED$NRM\n";
  1378. }
  1379. } else {
  1380. print $WHT . "ERROR DETECTING$NRM\n";
  1381. }
  1382. # Try CRAM-MD5
  1383. print "Testing CRAM-MD5:\t";
  1384. $tmp=detect_auth_support('SMTP',$host,'CRAM-MD5');
  1385. if (defined($tmp)) {
  1386. if ($tmp eq 'YES') {
  1387. print $WHT . "SUPPORTED$NRM\n";
  1388. } else {
  1389. print $WHT . "NOT SUPPORTED$NRM\n";
  1390. }
  1391. } else {
  1392. print $WHT . "ERROR DETECTING$NRM\n";
  1393. }
  1394. print "Testing DIGEST-MD5:\t";
  1395. $tmp=detect_auth_support('SMTP',$host,'DIGEST-MD5');
  1396. if (defined($tmp)) {
  1397. if ($tmp eq 'YES') {
  1398. print $WHT . "SUPPORTED$NRM\n";
  1399. } else {
  1400. print $WHT . "NOT SUPPORTED$NRM\n";
  1401. }
  1402. } else {
  1403. print $WHT . "ERROR DETECTING$NRM\n";
  1404. }
  1405. }
  1406. }
  1407. print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
  1408. print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
  1409. print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
  1410. print $WHT . "plain" . $NRM . " - SASL PLAIN. You already know it if you need this.\n";
  1411. print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
  1412. print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
  1413. print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
  1414. print "If you don't understand or are unsure, you probably want \"none\"\n\n";
  1415. print "none, login, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT";
  1416. $inval=<STDIN>;
  1417. chomp($inval);
  1418. if ($inval =~ /^none\b/i) {
  1419. # remove sitewide smtp authentication information
  1420. $smtp_sitewide_user = '';
  1421. $smtp_sitewide_pass = '';
  1422. # SMTP doesn't necessarily require logins
  1423. return "none";
  1424. } elsif ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
  1425. ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
  1426. command_smtp_sitewide_userpass($inval);
  1427. return lc($inval);
  1428. } elsif (trim($inval) eq '') {
  1429. # user selected default value
  1430. command_smtp_sitewide_userpass($smtp_auth_mech);
  1431. return $smtp_auth_mech;
  1432. } else {
  1433. # user entered garbage
  1434. return $smtp_auth_mech;
  1435. }
  1436. }
  1437. sub command_smtp_sitewide_userpass($) {
  1438. # get first function argument
  1439. my $auth_mech = shift(@_);
  1440. my $default, $tmp;
  1441. $auth_mech = lc(trim($auth_mech));
  1442. if ($auth_mech eq 'none') {
  1443. return;
  1444. }
  1445. print "SMTP authentication uses IMAP username and password by default.\n";
  1446. print "\n";
  1447. print "Would you like to use other login and password for all SquirrelMail \n";
  1448. print "SMTP connections?";
  1449. if ($smtp_sitewide_user ne '') {
  1450. $default = 'y';
  1451. print " [Yn]:";
  1452. } else {
  1453. $default = 'n';
  1454. print " [yN]:";
  1455. }
  1456. $tmp=<STDIN>;
  1457. $tmp = trim($tmp);
  1458. if ($tmp eq '') {
  1459. $tmp = $default;
  1460. } else {
  1461. $tmp = lc($tmp);
  1462. }
  1463. if ($tmp eq 'n') {
  1464. $smtp_sitewide_user = '';
  1465. $smtp_sitewide_pass = '';
  1466. } elsif ($tmp eq 'y') {
  1467. print "Enter username [$smtp_sitewide_user]:";
  1468. my $new_user = <STDIN>;
  1469. $new_user = trim($new_user);
  1470. if ($new_user ne '') {
  1471. $smtp_sitewide_user = $new_user;
  1472. }
  1473. if ($smtp_sitewide_user ne '') {
  1474. print "If you don't enter any password, current sitewide password will be used.\n";
  1475. print "If you enter space, password will be set to empty string.\n";
  1476. print "Enter password:";
  1477. my $new_pass = <STDIN>;
  1478. if ($new_pass ne "\n") {
  1479. $smtp_sitewide_pass = trim($new_pass);
  1480. }
  1481. } else {
  1482. print "Invalid input. You must set username used for SMTP authentication.\n";
  1483. print "Click enter to continue\n";
  1484. $tmp = <STDIN>;
  1485. }
  1486. } else {
  1487. print "Invalid input\n";
  1488. print "Click enter to continue\n";
  1489. $tmp = <STDIN>;
  1490. }
  1491. }
  1492. # Sub adds information about SMTP authentication type to menu
  1493. sub display_smtp_sitewide_userpass() {
  1494. my $ret = '';
  1495. if ($smtp_auth_mech ne 'none') {
  1496. if ($smtp_sitewide_user ne '') {
  1497. $ret = ' (with custom username and password)';
  1498. } else {
  1499. $ret = ' (with IMAP username and password)';
  1500. }
  1501. }
  1502. return $ret;
  1503. }
  1504. # TLS
  1505. # This sub is reused for IMAP and SMTP
  1506. # Args: service name, default value
  1507. sub command_use_tls {
  1508. my($default_val,$service,$inval);
  1509. $service=$_[0];
  1510. $default_val=$_[1];
  1511. print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
  1512. print "STARTTLS extensions allow to start encryption on existing plain text connection.\n";
  1513. print "These options add specific PHP and IMAP server configuration requirements.\n";
  1514. print "See SquirrelMail documentation about connection security.\n";
  1515. print "\n";
  1516. print "If your " . $service . " server is localhost, you can safely disable this.\n";
  1517. print "If it is remote, you may wish to seriously consider enabling this.\n";
  1518. $valid_input=0;
  1519. while ($valid_input eq 0) {
  1520. print "\nSelect connection security model:\n";
  1521. print " 0 - Use plain text connection\n";
  1522. print " 1 - Use TLS connection\n";
  1523. print " 2 - Use STARTTLS extension\n";
  1524. print "Select [$default_val]: ";
  1525. $inval=<STDIN>;
  1526. $inval=trim($inval);
  1527. if ($inval =~ /^[012]$/ || $inval eq '') {
  1528. $valid_input = 1;
  1529. }
  1530. }
  1531. if ($inval ne '') {$default_val = $inval};
  1532. return $default_val;
  1533. }
  1534. # This sub is used to display human readable text for
  1535. # $use_imap_tls and $use_smtp_tls values in conf.pl menu
  1536. sub display_use_tls($) {
  1537. my $val = shift(@_);
  1538. my $ret = 'disabled';
  1539. if ($val eq '2') {
  1540. $ret = 'STARTTLS';
  1541. } elsif ($val eq '1') {
  1542. $ret = 'TLS';
  1543. }
  1544. return $ret;
  1545. }
  1546. # $encode_header_key
  1547. sub command114{
  1548. print "Encryption key allows to hide SquirrelMail Received: headers\n";
  1549. print "in outbound messages. Interface uses encryption key to encode\n";
  1550. print "username, remote address and proxied address, then stores encoded\n";
  1551. print "information in X-Squirrel-* headers.\n";
  1552. print "\n";
  1553. print "Warning: used encryption function is not bulletproof. When used\n";
  1554. print "with static encryption keys, it provides only minimal security\n";
  1555. print "measures and information can be decoded quickly.\n";
  1556. print "\n";
  1557. print "Encoded information can be decoded with decrypt_headers.php script\n";
  1558. print "from SquirrelMail contrib/ directory.\n";
  1559. print "\n";
  1560. print "Enter encryption key: ";
  1561. $new_encode_header_key = <STDIN>;
  1562. if ( $new_encode_header_key eq "\n" ) {
  1563. $new_encode_header_key = $encode_header_key;
  1564. } else {
  1565. $new_encode_header_key =~ s/[\r\n]//g;
  1566. }
  1567. return $new_encode_header_key;
  1568. }
  1569. # MOTD
  1570. sub command71 {
  1571. print "\nYou can now create the welcome message that is displayed\n";
  1572. print "every time a user logs on. You can use HTML or just plain\n";
  1573. print
  1574. "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
  1575. $new_motd = "";
  1576. do {
  1577. print "] ";
  1578. $line = <STDIN>;
  1579. $line =~ s/[\r\n]//g;
  1580. if ( $line ne "@" ) {
  1581. $line =~ s/ /\&nbsp;\&nbsp;/g;
  1582. $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
  1583. $line =~ s/$/ /;
  1584. $line =~ s/\"/\\\"/g;
  1585. $new_motd = $new_motd . $line;
  1586. }
  1587. } while ( $line ne "@" );
  1588. return $new_motd;
  1589. }
  1590. ################# PLUGINS ###################
  1591. sub command81 {
  1592. $command =~ s/[\s\n\r]*//g;
  1593. if ( $command > 0 ) {
  1594. $command = $command - 1;
  1595. if ( $command <= $#plugins ) {
  1596. @newplugins = ();
  1597. $ct = 0;
  1598. while ( $ct <= $#plugins ) {
  1599. if ( $ct != $command ) {
  1600. @newplugins = ( @newplugins, $plugins[$ct] );
  1601. }
  1602. $ct++;
  1603. }
  1604. @plugins = @newplugins;
  1605. } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
  1606. $num = $command - $#plugins - 1;
  1607. @newplugins = @plugins;
  1608. $ct = 0;
  1609. while ( $ct <= $#unused_plugins ) {
  1610. if ( $ct == $num ) {
  1611. @newplugins = ( @newplugins, $unused_plugins[$ct] );
  1612. }
  1613. $ct++;
  1614. }
  1615. @plugins = @newplugins;
  1616. }
  1617. }
  1618. return @plugins;
  1619. }
  1620. # disable_plugins_user
  1621. sub command82 {
  1622. print "When all active plugins are disabled, they can be disabled only\n";
  1623. print "for the one user named here. If left blank, plugins will be\n";
  1624. print "disabled for ALL users. This setting has no effect if plugins\n";
  1625. print "are not disabled.\n";
  1626. print "\n";
  1627. print "This must be the exact IMAP login name for the desired user.\n";
  1628. print "\n";
  1629. print "[$WHT$disable_plugins_user$NRM]: $WHT";
  1630. $new_disable_plugins_user = <STDIN>;
  1631. if ( $new_disable_plugins_user eq "\n" ) {
  1632. $new_disable_plugins_user = $disable_plugins_user;
  1633. } else {
  1634. $new_disable_plugins_user =~ s/[\r\n]//g;
  1635. }
  1636. return $new_disable_plugins_user;
  1637. }
  1638. ################# FOLDERS ###################
  1639. # default_folder_prefix
  1640. sub command21 {
  1641. print "Some IMAP servers (UW, for example) store mail and folders in\n";
  1642. print "your user space in a separate subdirectory. This is where you\n";
  1643. print "specify what that directory is.\n";
  1644. print "\n";
  1645. print "EXAMPLE: mail/";
  1646. print "\n";
  1647. print "NOTE: If you use Cyrus, or some server that would not use this\n";
  1648. print " option, you must set this to 'none'.\n";
  1649. print "\n";
  1650. print "[$WHT$default_folder_prefix$NRM]: $WHT";
  1651. $new_default_folder_prefix = <STDIN>;
  1652. if ( $new_default_folder_prefix eq "\n" ) {
  1653. $new_default_folder_prefix = $default_folder_prefix;
  1654. } else {
  1655. $new_default_folder_prefix =~ s/[\r\n]//g;
  1656. }
  1657. if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
  1658. $new_default_folder_prefix = "";
  1659. } else {
  1660. # add the trailing delimiter only if we know what the server is.
  1661. if (($imap_server_type eq 'cyrus' and
  1662. $optional_delimiter eq 'detect') or
  1663. ($imap_server_type eq 'courier' and
  1664. $optional_delimiter eq 'detect')) {
  1665. $new_default_folder_prefix =~ s/\.*$/\./;
  1666. } elsif ($imap_server_type eq 'uw' and
  1667. $optional_delimiter eq 'detect') {
  1668. $new_default_folder_prefix =~ s/\/*$/\//;
  1669. }
  1670. }
  1671. return $new_default_folder_prefix;
  1672. }
  1673. # Show Folder Prefix
  1674. sub command22 {
  1675. print "It is possible to set up the default folder prefix as a user\n";
  1676. print "specific option, where each user can specify what their mail\n";
  1677. print "folder is. If you set this to false, they will never see the\n";
  1678. print "option, but if it is true, this option will appear in the\n";
  1679. print "'options' section.\n";
  1680. print "\n";
  1681. print "NOTE: You set the default folder prefix in option '1' of this\n";
  1682. print " section. That will be the default if the user doesn't\n";
  1683. print " specify anything different.\n";
  1684. print "\n";
  1685. if ( lc($show_prefix_option) eq 'true' ) {
  1686. $default_value = "y";
  1687. } else {
  1688. $default_value = "n";
  1689. }
  1690. print "\n";
  1691. print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
  1692. $new_show = <STDIN>;
  1693. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1694. $show_prefix_option = 'true';
  1695. } else {
  1696. $show_prefix_option = 'false';
  1697. }
  1698. return $show_prefix_option;
  1699. }
  1700. # Trash Folder
  1701. sub command23a {
  1702. print "You can now specify where the default trash folder is located.\n";
  1703. print "On servers where you do not want this, you can set it to anything\n";
  1704. print "and set option 6 to false.\n";
  1705. print "\n";
  1706. print "This is relative to where the rest of your email is kept. You do\n";
  1707. print "not need to worry about their mail directory. If this folder\n";
  1708. print "would be ~/mail/trash on the filesystem, you only need to specify\n";
  1709. print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
  1710. print "\n";
  1711. print "[$WHT$trash_folder$NRM]: $WHT";
  1712. $new_trash_folder = <STDIN>;
  1713. if ( $new_trash_folder eq "\n" ) {
  1714. $new_trash_folder = $trash_folder;
  1715. } else {
  1716. if (check_imap_folder($new_trash_folder)) {
  1717. $new_trash_folder =~ s/[\r\n]//g;
  1718. } else {
  1719. $new_trash_folder = $trash_folder;
  1720. }
  1721. }
  1722. return $new_trash_folder;
  1723. }
  1724. # Sent Folder
  1725. sub command23b {
  1726. print "This is where messages that are sent will be stored. SquirrelMail\n";
  1727. print "by default puts a copy of all outgoing messages in this folder.\n";
  1728. print "\n";
  1729. print "This is relative to where the rest of your email is kept. You do\n";
  1730. print "not need to worry about their mail directory. If this folder\n";
  1731. print "would be ~/mail/sent on the filesystem, you only need to specify\n";
  1732. print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
  1733. print "\n";
  1734. print "[$WHT$sent_folder$NRM]: $WHT";
  1735. $new_sent_folder = <STDIN>;
  1736. if ( $new_sent_folder eq "\n" ) {
  1737. $new_sent_folder = $sent_folder;
  1738. } else {
  1739. if (check_imap_folder($new_sent_folder)) {
  1740. $new_sent_folder =~ s/[\r\n]//g;
  1741. } else {
  1742. $new_sent_folder = $sent_folder;
  1743. }
  1744. }
  1745. return $new_sent_folder;
  1746. }
  1747. # Draft Folder
  1748. sub command23c {
  1749. print "You can now specify where the default draft folder is located.\n";
  1750. print "On servers where you do not want this, you can set it to anything\n";
  1751. print "and set option 9 to false.\n";
  1752. print "\n";
  1753. print "This is relative to where the rest of your email is kept. You do\n";
  1754. print "not need to worry about their mail directory. If this folder\n";
  1755. print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
  1756. print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
  1757. print "\n";
  1758. print "[$WHT$draft_folder$NRM]: $WHT";
  1759. $new_draft_folder = <STDIN>;
  1760. if ( $new_draft_folder eq "\n" ) {
  1761. $new_draft_folder = $draft_folder;
  1762. } else {
  1763. if (check_imap_folder($new_draft_folder)) {
  1764. $new_draft_folder =~ s/[\r\n]//g;
  1765. } else {
  1766. $new_draft_folder = $draft_folder;
  1767. }
  1768. }
  1769. return $new_draft_folder;
  1770. }
  1771. # default move to trash
  1772. sub command24a {
  1773. print "By default, should messages get moved to the trash folder? You\n";
  1774. print "can specify the default trash folder in option 3. If this is set\n";
  1775. print "to false, messages will get deleted immediately without moving\n";
  1776. print "to the trash folder.\n";
  1777. print "\n";
  1778. print "Trash folder is currently: $trash_folder\n";
  1779. print "\n";
  1780. if ( lc($default_move_to_trash) eq 'true' ) {
  1781. $default_value = "y";
  1782. } else {
  1783. $default_value = "n";
  1784. }
  1785. print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
  1786. $new_show = <STDIN>;
  1787. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1788. $default_move_to_trash = 'true';
  1789. } else {
  1790. $default_move_to_trash = 'false';
  1791. }
  1792. return $default_move_to_trash;
  1793. }
  1794. # default move to sent
  1795. sub command24b {
  1796. print "By default, should messages get moved to the sent folder? You\n";
  1797. print "can specify the default sent folder in option 4. If this is set\n";
  1798. print "to false, messages will get sent and no copy will be made.\n";
  1799. print "\n";
  1800. print "Sent folder is currently: $sent_folder\n";
  1801. print "\n";
  1802. if ( lc($default_move_to_sent) eq 'true' ) {
  1803. $default_value = "y";
  1804. } else {
  1805. $default_value = "n";
  1806. }
  1807. print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
  1808. $new_show = <STDIN>;
  1809. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1810. $default_move_to_sent = 'true';
  1811. } else {
  1812. $default_move_to_sent = 'false';
  1813. }
  1814. return $default_move_to_sent;
  1815. }
  1816. # default save as draft
  1817. sub command24c {
  1818. print "By default, should the save to draft option be shown? You can\n";
  1819. print "specify the default drafts folder in option 5. If this is set\n";
  1820. print "to false, users will not be shown the save to draft option.\n";
  1821. print "\n";
  1822. print "Drafts folder is currently: $draft_folder\n";
  1823. print "\n";
  1824. if ( lc($default_move_to_draft) eq 'true' ) {
  1825. $default_value = "y";
  1826. } else {
  1827. $default_value = "n";
  1828. }
  1829. print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
  1830. $new_show = <STDIN>;
  1831. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1832. $default_save_as_draft = 'true';
  1833. } else {
  1834. $default_save_as_draft = 'false';
  1835. }
  1836. return $default_save_as_draft;
  1837. }
  1838. # List special folders first
  1839. sub command27 {
  1840. print "SquirrelMail has what we call 'special folders' that are not\n";
  1841. print "manipulated and viewed like normal folders. Some examples of\n";
  1842. print "these folders would be INBOX, Trash, Sent, etc. This option\n";
  1843. print "Simply asks if you want these folders listed first in the folder\n";
  1844. print "listing.\n";
  1845. print "\n";
  1846. if ( lc($list_special_folders_first) eq 'true' ) {
  1847. $default_value = "y";
  1848. } else {
  1849. $default_value = "n";
  1850. }
  1851. print "\n";
  1852. print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
  1853. $new_show = <STDIN>;
  1854. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1855. $list_special_folders_first = 'true';
  1856. } else {
  1857. $list_special_folders_first = 'false';
  1858. }
  1859. return $list_special_folders_first;
  1860. }
  1861. # Show special folders color
  1862. sub command28 {
  1863. print "SquirrelMail has what we call 'special folders' that are not\n";
  1864. print "manipulated and viewed like normal folders. Some examples of\n";
  1865. print "these folders would be INBOX, Trash, Sent, etc. This option\n";
  1866. print "wants to know if we should display special folders in a\n";
  1867. print "color than the other folders.\n";
  1868. print "\n";
  1869. if ( lc($use_special_folder_color) eq 'true' ) {
  1870. $default_value = "y";
  1871. } else {
  1872. $default_value = "n";
  1873. }
  1874. print "\n";
  1875. print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
  1876. $new_show = <STDIN>;
  1877. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1878. $use_special_folder_color = 'true';
  1879. } else {
  1880. $use_special_folder_color = 'false';
  1881. }
  1882. return $use_special_folder_color;
  1883. }
  1884. # Auto expunge
  1885. sub command29 {
  1886. print "The way that IMAP handles deleting messages is as follows. You\n";
  1887. print "mark the message as deleted, and then to 'really' delete it, you\n";
  1888. print "expunge it. This option asks if you want to just have messages\n";
  1889. print "marked as deleted, or if you want SquirrelMail to expunge the \n";
  1890. print "messages too.\n";
  1891. print "\n";
  1892. if ( lc($auto_expunge) eq 'true' ) {
  1893. $default_value = "y";
  1894. } else {
  1895. $default_value = "n";
  1896. }
  1897. print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
  1898. $new_show = <STDIN>;
  1899. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1900. $auto_expunge = 'true';
  1901. } else {
  1902. $auto_expunge = 'false';
  1903. }
  1904. return $auto_expunge;
  1905. }
  1906. # Default sub of inbox
  1907. sub command210 {
  1908. print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
  1909. print "This can cause some confusion in folder creation for users when\n";
  1910. print "they try to create folders and don't put it as a subfolder of INBOX\n";
  1911. print "and get permission errors. This option asks if you want folders\n";
  1912. print "to be subfolders of INBOX by default.\n";
  1913. print "\n";
  1914. if ( lc($default_sub_of_inbox) eq 'true' ) {
  1915. $default_value = "y";
  1916. } else {
  1917. $default_value = "n";
  1918. }
  1919. print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
  1920. $new_show = <STDIN>;
  1921. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1922. $default_sub_of_inbox = 'true';
  1923. } else {
  1924. $default_sub_of_inbox = 'false';
  1925. }
  1926. return $default_sub_of_inbox;
  1927. }
  1928. # Show contain subfolder option
  1929. sub command211 {
  1930. print "Some IMAP servers (UW) make it so that there are two types of\n";
  1931. print "folders. Those that contain messages, and those that contain\n";
  1932. print "subfolders. If this is the case for your server, set this to\n";
  1933. print "true, and it will ask the user whether the folder they are\n";
  1934. print "creating contains subfolders or messages.\n";
  1935. print "\n";
  1936. if ( lc($show_contain_subfolders_option) eq 'true' ) {
  1937. $default_value = "y";
  1938. } else {
  1939. $default_value = "n";
  1940. }
  1941. print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
  1942. $new_show = <STDIN>;
  1943. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1944. $show_contain_subfolders_option = 'true';
  1945. } else {
  1946. $show_contain_subfolders_option = 'false';
  1947. }
  1948. return $show_contain_subfolders_option;
  1949. }
  1950. # Default Unseen Notify
  1951. sub command212 {
  1952. print "This option specifies where the users will receive notification\n";
  1953. print "about unseen messages by default. This is of course an option that\n";
  1954. print "can be changed on a user level.\n";
  1955. print " 1 = No notification\n";
  1956. print " 2 = Only on the INBOX\n";
  1957. print " 3 = On all folders\n";
  1958. print "\n";
  1959. print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
  1960. $new_show = <STDIN>;
  1961. if ( $new_show =~ /^[123]\n/i ) {
  1962. $default_unseen_notify = $new_show;
  1963. }
  1964. $default_unseen_notify =~ s/[\r\n]//g;
  1965. return $default_unseen_notify;
  1966. }
  1967. # Default Unseen Type
  1968. sub command213 {
  1969. print "Here you can define the default way that unseen messages will be displayed\n";
  1970. print "to the user in the folder listing on the left side.\n";
  1971. print " 1 = Only unseen messages (4)\n";
  1972. print " 2 = Unseen and Total messages (4/27)\n";
  1973. print "\n";
  1974. print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
  1975. $new_show = <STDIN>;
  1976. if ( $new_show =~ /^[12]\n/i ) {
  1977. $default_unseen_type = $new_show;
  1978. }
  1979. $default_unseen_type =~ s/[\r\n]//g;
  1980. return $default_unseen_type;
  1981. }
  1982. # Auto create special folders
  1983. sub command214 {
  1984. print "Would you like the Sent, Trash, and Drafts folders to be created\n";
  1985. print "automatically print for you when a user logs in? If the user\n";
  1986. print "accidentally deletes their special folders, this option will\n";
  1987. print "automatically create it again for them.\n";
  1988. print "\n";
  1989. if ( lc($auto_create_special) eq 'true' ) {
  1990. $default_value = "y";
  1991. } else {
  1992. $default_value = "n";
  1993. }
  1994. print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
  1995. $new_show = <STDIN>;
  1996. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  1997. $auto_create_special = 'true';
  1998. } else {
  1999. $auto_create_special = 'false';
  2000. }
  2001. return $auto_create_special;
  2002. }
  2003. # Automatically delete folders
  2004. sub command215 {
  2005. if ( $imap_server_type eq "uw" ) {
  2006. print "UW IMAP servers will not allow folders containing mail to also contain folders.\n";
  2007. print "Deleting folders will bypass the trash folder and be immediately deleted\n\n";
  2008. print "If this is not the correct value for your server,\n";
  2009. print "please use option D on the Main Menu to configure your server correctly.\n\n";
  2010. print "Press enter to continue...\n";
  2011. $new_delete = <STDIN>;
  2012. $delete_folder = 'true';
  2013. } else {
  2014. if ( $imap_server_type eq "courier" ) {
  2015. print "Courier (or Courier-IMAP) IMAP servers may not support ";
  2016. print "subfolders of Trash. \n";
  2017. print "Specifically, if Courier is set to always move messages to Trash, \n";
  2018. print "Trash will be treated by Courier as a special folder that does not \n";
  2019. print "allow subfolders. \n\n";
  2020. print "Please verify your Courier configuration, and test folder deletion \n";
  2021. print "when changing this setting.\n\n";
  2022. }
  2023. print "Are subfolders of the Trash supported by your IMAP server?\n";
  2024. print "If so, should deleted folders be sent to Trash?\n";
  2025. print "If not, say no (deleted folders should not be sent to Trash)\n\n";
  2026. # reversal of logic.
  2027. # question was: Should folders be automatically deleted instead of sent to trash..
  2028. # we've changed the question to make it more clear,
  2029. # and are here handling that to avoid changing the answers..
  2030. if ( lc($delete_folder) eq 'true' ) {
  2031. $default_value = "n";
  2032. } else {
  2033. $default_value = "y";
  2034. }
  2035. print "Send deleted folders to Trash? (y/n) [$WHT$default_value$NRM]: $WHT";
  2036. $new_delete = <STDIN>;
  2037. if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2038. $delete_folder = 'false';
  2039. } else {
  2040. $delete_folder = 'true';
  2041. }
  2042. }
  2043. return $delete_folder;
  2044. }
  2045. #noselect fix
  2046. sub command216 {
  2047. print "Some IMAP server allow subfolders to exist even if the parent\n";
  2048. print "folders do not. This fixes some problems with the folder list\n";
  2049. print "when this is the case, causing the /NoSelect folders to be displayed\n";
  2050. print "\n";
  2051. if ( lc($noselect_fix_enable) eq 'true' ) {
  2052. $default_value = "y";
  2053. } else {
  2054. $default_value = "n";
  2055. }
  2056. print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
  2057. $noselect_fix_enable = <STDIN>;
  2058. if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2059. $noselect_fix_enable = 'true';
  2060. } else {
  2061. $noselect_fix_enable = 'false';
  2062. }
  2063. return $noselect_fix_enable;
  2064. }
  2065. ############# GENERAL OPTIONS #####################
  2066. # Data directory
  2067. sub command33a {
  2068. print "Specify the location for your data directory.\n";
  2069. print "You need to create this directory yourself.\n";
  2070. print "The path name can be absolute or relative (to the config directory).\n";
  2071. print "Here are two examples:\n";
  2072. print " Absolute: /var/local/squirrelmail/data/\n";
  2073. print " Relative: ../data/\n";
  2074. print "Relative paths to directories outside of the SquirrelMail distribution\n";
  2075. print "will be converted to their absolute path equivalents in config.php.\n\n";
  2076. print "Note: There are potential security risks with having a writeable directory\n";
  2077. print "under the web server's root directory (ex: /home/httpd/html).\n";
  2078. print "For this reason, it is recommended to put the data directory\n";
  2079. print "in an alternate location of your choice. \n";
  2080. print "\n";
  2081. print "[$WHT$data_dir$NRM]: $WHT";
  2082. $new_data_dir = <STDIN>;
  2083. if ( $new_data_dir eq "\n" ) {
  2084. $new_data_dir = $data_dir;
  2085. } else {
  2086. $new_data_dir =~ s/[\r\n]//g;
  2087. }
  2088. if ( $new_data_dir =~ /^\s*$/ ) {
  2089. $new_data_dir = "";
  2090. } else {
  2091. $new_data_dir =~ s/\/*$//g;
  2092. $new_data_dir =~ s/$/\//g;
  2093. }
  2094. return $new_data_dir;
  2095. }
  2096. # Attachment directory
  2097. sub command33b {
  2098. print "Path to directory used for storing attachments while a mail is\n";
  2099. print "being composed. The path name can be absolute or relative (to the\n";
  2100. print "config directory). Here are two examples:\n";
  2101. print " Absolute: /var/local/squirrelmail/attach/\n";
  2102. print " Relative: ../attach/\n";
  2103. print "Relative paths to directories outside of the SquirrelMail distribution\n";
  2104. print "will be converted to their absolute path equivalents in config.php.\n\n";
  2105. print "Note: There are a few security considerations regarding this\n";
  2106. print "directory:\n";
  2107. print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
  2108. print " impossible for a random person with access to the webserver\n";
  2109. print " to list files in this directory. Confidential data might\n";
  2110. print " be laying around in there.\n";
  2111. print " Depending on your user:group assignments, 730 (rwx-wx---)\n";
  2112. print " may be possible, and more secure (e.g. root:apache)\n";
  2113. print " 2. Since the webserver is not able to list the files in the\n";
  2114. print " content is also impossible for the webserver to delete files\n";
  2115. print " lying around there for too long.\n";
  2116. print " 3. It should probably be another directory than the data\n";
  2117. print " directory specified in option 3.\n";
  2118. print "\n";
  2119. print "[$WHT$attachment_dir$NRM]: $WHT";
  2120. $new_attachment_dir = <STDIN>;
  2121. if ( $new_attachment_dir eq "\n" ) {
  2122. $new_attachment_dir = $attachment_dir;
  2123. } else {
  2124. $new_attachment_dir =~ s/[\r\n]//g;
  2125. }
  2126. if ( $new_attachment_dir =~ /^\s*$/ ) {
  2127. $new_attachment_dir = "";
  2128. } else {
  2129. $new_attachment_dir =~ s/\/*$//g;
  2130. $new_attachment_dir =~ s/$/\//g;
  2131. }
  2132. return $new_attachment_dir;
  2133. }
  2134. sub command33c {
  2135. print "The directory hash level setting allows you to configure the level\n";
  2136. print "of hashing that SquirrelMail employs in your data and attachment\n";
  2137. print "directories. This value must be an integer ranging from 0 to 4.\n";
  2138. print "When this value is set to 0, SquirrelMail will simply store all\n";
  2139. print "files as normal in the data and attachment directories. However,\n";
  2140. print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
  2141. print "used to organize the files in this directory. In short, the crc32\n";
  2142. print "value for a username will be computed. Then, up to the first 4\n";
  2143. print "digits of the hash, as set by this configuration value, will be\n";
  2144. print "used to directory hash the files for that user in the data and\n";
  2145. print "attachment directory. This allows for better performance on\n";
  2146. print "servers with larger numbers of users.\n";
  2147. print "\n";
  2148. print "[$WHT$dir_hash_level$NRM]: $WHT";
  2149. $new_dir_hash_level = <STDIN>;
  2150. if ( $new_dir_hash_level eq "\n" ) {
  2151. $new_dir_hash_level = $dir_hash_level;
  2152. } else {
  2153. $new_dir_hash_level =~ s/[\r\n]//g;
  2154. }
  2155. if ( ( int($new_dir_hash_level) < 0 )
  2156. || ( int($new_dir_hash_level) > 4 )
  2157. || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
  2158. print "Invalid Directory Hash Level.\n";
  2159. print "Value must be an integer ranging from 0 to 4\n";
  2160. print "Hit enter to continue.\n";
  2161. $enter_key = <STDIN>;
  2162. $new_dir_hash_level = $dir_hash_level;
  2163. }
  2164. return $new_dir_hash_level;
  2165. }
  2166. sub command35 {
  2167. print "This is the default size (in pixels) of the left folder list.\n";
  2168. print "Default is 200, but you can set it to whatever you wish. This\n";
  2169. print "is a user preference, so this will only show up as their default.\n";
  2170. print "\n";
  2171. print "[$WHT$default_left_size$NRM]: $WHT";
  2172. $new_default_left_size = <STDIN>;
  2173. if ( $new_default_left_size eq "\n" ) {
  2174. $new_default_left_size = $default_left_size;
  2175. } else {
  2176. $new_default_left_size =~ s/[\r\n]//g;
  2177. }
  2178. return $new_default_left_size;
  2179. }
  2180. sub command36 {
  2181. print "Some IMAP servers only have lowercase letters in the usernames\n";
  2182. print "but they still allow people with uppercase to log in. This\n";
  2183. print "causes a problem with the user's preference files. This option\n";
  2184. print "transparently changes all usernames to lowercase.";
  2185. print "\n";
  2186. if ( lc($force_username_lowercase) eq 'true' ) {
  2187. $default_value = "y";
  2188. } else {
  2189. $default_value = "n";
  2190. }
  2191. print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
  2192. $new_show = <STDIN>;
  2193. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2194. return 'true';
  2195. }
  2196. return 'false';
  2197. }
  2198. sub command37 {
  2199. print "";
  2200. print "\n";
  2201. if ( lc($default_use_priority) eq 'true' ) {
  2202. $default_value = "y";
  2203. } else {
  2204. $default_value = "n";
  2205. }
  2206. print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
  2207. $new_show = <STDIN>;
  2208. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2209. return 'true';
  2210. }
  2211. return 'false';
  2212. }
  2213. sub command38 {
  2214. print "";
  2215. print "\n";
  2216. if ( lc($default_hide_attribution) eq 'true' ) {
  2217. $default_value = "y";
  2218. } else {
  2219. $default_value = "n";
  2220. }
  2221. print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
  2222. $new_show = <STDIN>;
  2223. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2224. return 'true';
  2225. }
  2226. return 'false';
  2227. }
  2228. sub command39 {
  2229. print "";
  2230. print "\n";
  2231. if ( lc($default_use_mdn) eq 'true' ) {
  2232. $default_value = "y";
  2233. } else {
  2234. $default_value = "n";
  2235. }
  2236. print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
  2237. $new_show = <STDIN>;
  2238. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2239. return 'true';
  2240. }
  2241. return 'false';
  2242. }
  2243. sub command310 {
  2244. print " In loosely managed environments, you may want to allow users
  2245. to edit their full name and email address. In strictly managed
  2246. environments, you may want to force users to use the name
  2247. and email address assigned to them.
  2248. 'y' - allow a user to edit their full name and email address,
  2249. 'n' - users must use the assigned values.
  2250. ";
  2251. if ( lc($edit_identity) eq 'true' ) {
  2252. $default_value = "y";
  2253. } else {
  2254. $default_value = "n";
  2255. }
  2256. print "Allow editing of user's identity? (y/n) [$WHT$default_value$NRM]: $WHT";
  2257. $new_edit = <STDIN>;
  2258. if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2259. $edit_identity = 'true';
  2260. $edit_name = 'true';
  2261. $hide_auth_header = command311b();
  2262. } else {
  2263. $edit_identity = 'false';
  2264. $edit_name = command311();
  2265. $hide_auth_header = command311b();
  2266. }
  2267. return $edit_identity;
  2268. }
  2269. sub command311 {
  2270. print " Given that users are not allowed to modify their
  2271. email address, can they edit their full name?
  2272. ";
  2273. if ( lc($edit_name) eq 'true' ) {
  2274. $default_value = "y";
  2275. } else {
  2276. $default_value = "n";
  2277. }
  2278. print "Allow the user to edit their full name? (y/n) [$WHT$default_value$NRM]: $WHT";
  2279. $new_edit = <STDIN>;
  2280. if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2281. $edit_name = 'true';
  2282. } else {
  2283. $edit_name = 'false';
  2284. }
  2285. return $edit_name;
  2286. }
  2287. sub command311b {
  2288. print " SquirrelMail adds username information to every sent email
  2289. in order to prevent possible sender forging when users are allowed
  2290. to change their email and/or full name.
  2291. You can remove user information from this header (y), if you think that
  2292. it violates privacy or security.
  2293. Note: If users are allowed to change their email addresses,
  2294. this setting will make it difficult to determine who sent what where.
  2295. Use at your own risk.
  2296. ";
  2297. if ( lc($hide_auth_header) eq "true" ) {
  2298. $default_value = "y";
  2299. } else {
  2300. $default_value = "n";
  2301. }
  2302. print "Remove username from email headers? (y/n) [$WHT$default_value$NRM]: $WHT";
  2303. $new_header = <STDIN>;
  2304. if ( ( $new_header =~ /^y\n/i ) || ( ( $new_header =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2305. $hide_auth_header = "true";
  2306. } else {
  2307. $hide_auth_header = "false";
  2308. }
  2309. return $hide_auth_header;
  2310. }
  2311. sub command312 {
  2312. print "This option allows you to disable server side thread sorting if your server \n";
  2313. print "declares THREAD support, but you don't want to provide threading options \n";
  2314. print "to end users or THREAD extension is broken or extension does not work with \n";
  2315. print "options used by SquirrelMail. Option is not used, if THREAD extension is \n";
  2316. print "not declared in IMAP CAPABILITY.\n";
  2317. print "\n";
  2318. if ( lc($disable_thread_sort) eq 'true' ) {
  2319. $default_value = "y";
  2320. } else {
  2321. $default_value = "n";
  2322. }
  2323. print "Disable server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
  2324. $disable_thread_sort = <STDIN>;
  2325. if ( ( $disable_thread_sort =~ /^y\n/i ) || ( ( $disable_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2326. $disable_thread_sort = 'true';
  2327. } else {
  2328. $disable_thread_sort = 'false';
  2329. }
  2330. return $disable_thread_sort;
  2331. }
  2332. sub command313 {
  2333. print "This option allows you to disable server side sorting if your server declares \n";
  2334. print "SORT support, but SORT extension is broken or does not work with options \n";
  2335. print "used by SquirrelMail. Option is not used, if SORT extension is not declared \n";
  2336. print "in IMAP CAPABILITY.\n";
  2337. print "\n";
  2338. print "It is strongly recommended to keep server side sorting enabled, if your ";
  2339. print "IMAP server supports it.";
  2340. print "\n";
  2341. if ( lc($disable_server_sort) eq 'true' ) {
  2342. $default_value = "y";
  2343. } else {
  2344. $default_value = "n";
  2345. }
  2346. print "Disable server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
  2347. $disable_server_sort = <STDIN>;
  2348. if ( ( $disable_server_sort =~ /^y\n/i ) || ( ( $disable_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2349. $disable_server_sort = 'true';
  2350. } else {
  2351. $disable_server_sort = 'false';
  2352. }
  2353. return $disable_server_sort;
  2354. }
  2355. sub command314 {
  2356. print "This option allows you to choose if SM uses charset search\n";
  2357. print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
  2358. print "\n";
  2359. if ( lc($allow_charset_search) eq 'true' ) {
  2360. $default_value = "y";
  2361. } else {
  2362. $default_value = "n";
  2363. }
  2364. print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
  2365. $allow_charset_search = <STDIN>;
  2366. if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  2367. $allow_charset_search = 'true';
  2368. } else {
  2369. $allow_charset_search = 'false';
  2370. }
  2371. return $allow_charset_search;
  2372. }
  2373. # command315 (UID support) obsoleted.
  2374. # advanced search option
  2375. sub command316 {
  2376. print "This option allows you to control the use of advanced search form.\n";
  2377. print " 0 = enable basic search only\n";
  2378. print " 1 = enable advanced search only\n";
  2379. print " 2 = enable both\n";
  2380. print "\n";
  2381. print "Allowed search (0,1,2)? [$WHT$allow_advanced_search$NRM]: $WHT";
  2382. $new_allow_advanced_search = <STDIN>;
  2383. if ( $new_allow_advanced_search =~ /^[012]\n/i ) {
  2384. $allow_advanced_search = $new_allow_advanced_search;
  2385. }
  2386. $allow_advanced_search =~ s/[\r\n]//g;
  2387. return $allow_advanced_search;
  2388. }
  2389. sub command317 {
  2390. print "This option allows you to change the name of the PHP session used\n";
  2391. print "by SquirrelMail. Unless you know what you are doing, you probably\n";
  2392. print "don't need or want to change this from the default of SQMSESSID.\n";
  2393. print "[$WHT$session_name$NRM]: $WHT";
  2394. $new_session_name = <STDIN>;
  2395. chomp($new_session_name);
  2396. if ( $new_session_name eq "" ) {
  2397. $new_session_name = $session_name;
  2398. }
  2399. return $new_session_name;
  2400. }
  2401. # time zone config (since 1.5.1)
  2402. sub command318 {
  2403. print "This option allows you to control the use of time zones.\n";
  2404. print " 0 = (default) standard, GNU C time zone names\n";
  2405. print " 1 = strict, generic time zone codes with offsets\n";
  2406. print " 2 = custom, GNU C time zones loaded from config/timezones.php\n";
  2407. print " 3 = custom strict, generic time zone codes with offsets loaded \n";
  2408. print " from config/timezones.php\n";
  2409. print "See SquirrelMail documentation about format of config/timezones.php file.\n";
  2410. print "\n";
  2411. print "Used time zone configuration (0,1,2,3)? [$WHT$time_zone_type$NRM]: $WHT";
  2412. $new_time_zone_type = <STDIN>;
  2413. if ( $new_time_zone_type =~ /^[0123]\n/i ) {
  2414. $time_zone_type = $new_time_zone_type;
  2415. } else {
  2416. print "\nInvalid configuration value.\n";
  2417. print "\nPress enter to continue...";
  2418. $tmp = <STDIN>;
  2419. }
  2420. $time_zone_type =~ s/[\r\n]//g;
  2421. return $time_zone_type;
  2422. }
  2423. # set the location base for redirects (since 1.5.2)
  2424. sub command_config_location_base {
  2425. print "Here you can set the base part of the SquirrelMail URL.\n";
  2426. print "It is normally autodetected but if that fails, use this\n";
  2427. print "option to override.\n";
  2428. print "It should contain only the protocol and hostname/port parts\n";
  2429. print "of the URL; the full path will be appended automatically.\n\n";
  2430. print "Examples:\nhttp://webmail.example.org\nhttp://webmail.example.com:8080\nhttps://webmail.example.com:6691\n\n";
  2431. print "Do not add any path elements.\n";
  2432. print "URL base? [" .$WHT."autodetect$NRM]: $WHT";
  2433. $new_config_location_base = <STDIN>;
  2434. chomp($new_config_location_base);
  2435. $config_location_base = $new_config_location_base;
  2436. return $config_location_base;
  2437. }
  2438. sub command_userThemes {
  2439. print "\nDefine the user themes that you wish to use. If you have added\n";
  2440. print "a theme of your own, just follow the instructions (?) about\n";
  2441. print "how to add them. You can also change the default theme.\n\n";
  2442. print "Available user themes:\n";
  2443. $count = 0;
  2444. while ( $count <= $#user_theme_name ) {
  2445. if ( $count == $user_theme_default ) {
  2446. print " *";
  2447. } else {
  2448. print " ";
  2449. }
  2450. if ( $count < 10 ) {
  2451. print " ";
  2452. }
  2453. $name = $user_theme_name[$count];
  2454. $num_spaces = 35 - length($name);
  2455. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  2456. $name = $name . " ";
  2457. }
  2458. print " $count. $name";
  2459. print "($user_theme_path[$count])\n";
  2460. $count++;
  2461. }
  2462. print "\n";
  2463. print ".------------------------------------.\n";
  2464. print "| t (detect user themes) |\n";
  2465. print "| + (add user theme) |\n";
  2466. print "| - N (remove user theme) |\n";
  2467. print "| m N (mark default user theme) |\n";
  2468. print "| l (list user themes) |\n";
  2469. print "| d (done) |\n";
  2470. print "`------------------------------------'\n";
  2471. print "\n[user_themes] command (?=help) > ";
  2472. $input = <STDIN>;
  2473. $input =~ s/[\r\n]//g;
  2474. while ( $input ne "d" ) {
  2475. if ( $input =~ /^\s*l\s*/i ) {
  2476. $count = 0;
  2477. while ( $count <= $#user_theme_name ) {
  2478. if ( $count == $user_theme_default ) {
  2479. print " *";
  2480. } else {
  2481. print " ";
  2482. }
  2483. if ( $count < 10 ) {
  2484. print " ";
  2485. }
  2486. $name = $user_theme_name[$count];
  2487. $num_spaces = 35 - length($name);
  2488. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  2489. $name = $name . " ";
  2490. }
  2491. print " $count. $name";
  2492. print "($user_theme_path[$count])\n";
  2493. $count++;
  2494. }
  2495. } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
  2496. $old_def = $user_theme_default;
  2497. $user_theme_default = $input;
  2498. $user_theme_default =~ s/^\s*m\s*//;
  2499. if ( ( $user_theme_default > $#user_theme_name ) || ( $user_theme_default < 0 ) ) {
  2500. print "Cannot set default theme to $user_theme_default. That theme does not exist.\n";
  2501. $user_theme_default = $old_def;
  2502. }
  2503. } elsif ( $input =~ /^\s*\+/ ) {
  2504. print "What is the name of this theme? ";
  2505. $name = <STDIN>;
  2506. $name =~ s/[\r\n]//g;
  2507. $user_theme_name[ $#user_theme_name + 1 ] = $name;
  2508. print "Be sure to put ../css/ before the filename.\n";
  2509. print "What file is this stored in (ex: ../css/my_theme/): ";
  2510. $name = <STDIN>;
  2511. $name =~ s/[\r\n]//g;
  2512. $user_theme_path[ $#user_theme_path + 1 ] = $name;
  2513. } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
  2514. if ( $input =~ /[0-9]+\s*$/ ) {
  2515. $rem_num = $input;
  2516. $rem_num =~ s/^\s*-\s*//g;
  2517. $rem_num =~ s/\s*$//;
  2518. } else {
  2519. $rem_num = $#user_theme_name;
  2520. }
  2521. if ( $rem_num == $user_theme_default ) {
  2522. print "You cannot remove the default theme!\n";
  2523. } else {
  2524. $count = 0;
  2525. @new_theme_name = ();
  2526. @new_theme_path = ();
  2527. while ( $count <= $#user_theme_name ) {
  2528. if ( $count != $rem_num ) {
  2529. @new_theme_name = ( @new_theme_name, $user_theme_name[$count] );
  2530. @new_theme_path = ( @new_theme_path, $user_theme_path[$count] );
  2531. }
  2532. $count++;
  2533. }
  2534. @user_theme_name = @new_theme_name;
  2535. @user_theme_path = @new_theme_path;
  2536. if ( $user_theme_default > $rem_num ) {
  2537. $user_theme_default--;
  2538. }
  2539. }
  2540. } elsif ( $input =~ /^\s*t\s*/i ) {
  2541. print "\nStarting detection...\n\n";
  2542. opendir( DIR, "../css" );
  2543. @files = readdir(DIR);
  2544. $cnt = 0;
  2545. while ( $cnt <= $#files ) {
  2546. $filename = "../css/" . $files[$cnt] .'/';
  2547. if ( $filename ne "../css/rtl.css" && -e $filename . "default.css" ) {
  2548. $found = 0;
  2549. for ( $x = 0 ; $x <= $#user_theme_path ; $x++ ) {
  2550. if ( $user_theme_path[$x] eq $filename ) {
  2551. $found = 1;
  2552. }
  2553. }
  2554. if ( $found != 1 ) {
  2555. print "** Found user theme: $filename\n";
  2556. print " What is its name? ";
  2557. $nm = <STDIN>;
  2558. $nm =~ s/[\n\r]//g;
  2559. $user_theme_name[ $#user_theme_name + 1 ] = $nm;
  2560. $user_theme_path[ $#user_theme_path + 1 ] = $filename;
  2561. }
  2562. }
  2563. $cnt++;
  2564. }
  2565. print "\n";
  2566. for ( $cnt = 0 ; $cnt <= $#user_theme_path ; $cnt++ ) {
  2567. $filename = $user_theme_path[$cnt];
  2568. if ( $filename != 'none' && !( -e $filename ."/default.css" ) ) {
  2569. print " Removing $filename (file not found)\n";
  2570. $offset = 0;
  2571. @new_user_theme_name = ();
  2572. @new_user_theme_path = ();
  2573. for ( $x = 0 ; $x < $#user_theme_path ; $x++ ) {
  2574. if ( $user_theme_path[$x] eq $filename ) {
  2575. $offset = 1;
  2576. }
  2577. if ( $offset == 1 ) {
  2578. $new_user_theme_name[$x] = $user_theme_name[ $x + 1 ];
  2579. $new_user_theme_path[$x] = $user_theme_path[ $x + 1 ];
  2580. } else {
  2581. $new_user_theme_name[$x] = $user_theme_name[$x];
  2582. $new_user_theme_path[$x] = $user_theme_path[$x];
  2583. }
  2584. }
  2585. @user_theme_name = @new_user_theme_name;
  2586. @user_theme_path = @new_user_theme_path;
  2587. }
  2588. }
  2589. print "\nDetection complete!\n\n";
  2590. closedir DIR;
  2591. } elsif ( $input =~ /^\s*\?\s*/ ) {
  2592. print ".------------------------------------.\n";
  2593. print "| t (detect user themes) |\n";
  2594. print "| + (add user theme) |\n";
  2595. print "| - N (remove user theme) |\n";
  2596. print "| m N (mark default user theme) |\n";
  2597. print "| l (list user themes) |\n";
  2598. print "| d (done) |\n";
  2599. print "`------------------------------------'\n";
  2600. }
  2601. print "[user_themes] command (?=help) > ";
  2602. $input = <STDIN>;
  2603. $input =~ s/[\r\n]//g;
  2604. }
  2605. }
  2606. sub command_iconSets {
  2607. print "\nDefine the icon themes that you wish to use. If you have added\n";
  2608. print "a theme of your own, just follow the instructions (?) about\n";
  2609. print "how to add them. You can also change the default and fallback\n";
  2610. print "themes. The default theme will be used when no icon theme is\n";
  2611. print "set by the user. The fallback theme will be used if an icon\n";
  2612. print "cannot be found in the currently selected icon theme.\n\n";
  2613. print "Available icon themes:\n\n";
  2614. $count = 0;
  2615. while ( $count <= $#icon_theme_name ) {
  2616. if ( $count == $icon_theme_def ) {
  2617. print " d";
  2618. } else {
  2619. print " ";
  2620. }
  2621. if ( $count eq $icon_theme_fallback ) {
  2622. print "f ";
  2623. } else {
  2624. print " ";
  2625. }
  2626. if ( $count < 10 ) {
  2627. print " ";
  2628. }
  2629. $name = $icon_theme_name[$count];
  2630. $num_spaces = 35 - length($name);
  2631. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  2632. $name = $name . " ";
  2633. }
  2634. print " $count. $name";
  2635. print "($icon_theme_path[$count])\n";
  2636. $count++;
  2637. }
  2638. print "\n d = Default icon theme\n";
  2639. print " f = Fallback icon theme\n";
  2640. print "\n";
  2641. print ".------------------------------------.\n";
  2642. print "| t (detect icon themes) |\n";
  2643. print "| + (add icon theme) |\n";
  2644. print "| - N (remove icon theme) |\n";
  2645. print "| m N (mark default icon theme) |\n";
  2646. print "| f N (set fallback icon set) |\n";
  2647. print "| l (list icon themes) |\n";
  2648. print "| d (done) |\n";
  2649. print "`------------------------------------'\n";
  2650. print "\n[icon_themes] command (?=help) > ";
  2651. $input = <STDIN>;
  2652. $input =~ s/[\r\n]//g;
  2653. while ( $input ne "d" ) {
  2654. if ( $input =~ /^\s*l\s*/i ) {
  2655. $count = 0;
  2656. print "\n";
  2657. while ( $count <= $#icon_theme_name ) {
  2658. if ( $count == $icon_theme_def ) {
  2659. print " d";
  2660. } else {
  2661. print " ";
  2662. }
  2663. if ( $count eq $icon_theme_fallback ) {
  2664. print "f ";
  2665. } else {
  2666. print " ";
  2667. }
  2668. $name = $icon_theme_name[$count];
  2669. $num_spaces = 35 - length($name);
  2670. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  2671. $name = $name . " ";
  2672. }
  2673. print " $count. $name";
  2674. print "($icon_theme_path[$count])\n";
  2675. $count++;
  2676. }
  2677. print "\n d = Default icon theme\n";
  2678. print " f = Fallback icon theme\n\n";
  2679. } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
  2680. $old_def = $icon_theme_def;
  2681. $icon_theme_def = $input;
  2682. $icon_theme_def =~ s/^\s*m\s*//;
  2683. if ( ( $icon_theme_default > $#icon_theme_name ) || ( $icon_theme_default < 0 ) ) {
  2684. print "Cannot set default icon theme to $icon_theme_default. That theme does not exist.\n";
  2685. $icon_theme_def = $old_def;
  2686. }
  2687. } elsif ( $input =~ /^\s*f\s*[0-9]+/i ) {
  2688. $old_fb = $icon_theme_fallback;
  2689. $icon_theme_fallback = $input;
  2690. $icon_theme_fallback =~ s/^\s*f\s*//;
  2691. if ( ( $icon_theme_fallback > $#icon_theme_name ) || ( $icon_theme_fallback < 0 ) ) {
  2692. print "Cannot set fallback icon theme to $icon_theme_fallback. That theme does not exist.\n";
  2693. $icon_theme_fallback = $old_fb;
  2694. }
  2695. } elsif ( $input =~ /^\s*\+/ ) {
  2696. print "What is the name of this icon theme? ";
  2697. $name = <STDIN>;
  2698. $name =~ s/[\r\n]//g;
  2699. $icon_theme_name[ $#icon_theme_name + 1 ] = $name;
  2700. print "Be sure to put ../images/themes/ before the filename.\n";
  2701. print "What directory is this icon theme stored in (ex: ../images/themes/my_theme/)? ";
  2702. $name = <STDIN>;
  2703. $name =~ s/[\r\n]//g;
  2704. $icon_theme_path[ $#icon_theme_path + 1 ] = $name;
  2705. } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
  2706. if ( $input =~ /[0-9]+\s*$/ ) {
  2707. $rem_num = $input;
  2708. $rem_num =~ s/^\s*-\s*//g;
  2709. $rem_num =~ s/\s*$//;
  2710. } else {
  2711. $rem_num = $#icon_theme_name;
  2712. }
  2713. if ( $rem_num == $icon_theme_def ) {
  2714. print "You cannot remove the default icon theme!\n";
  2715. } elsif ( $rem_num == $icon_theme_fallback ) {
  2716. print "You cannot remove the fallback icon theme!\n";
  2717. } else {
  2718. $count = 0;
  2719. @new_theme_name = ();
  2720. @new_theme_path = ();
  2721. while ( $count <= $#icon_theme_name ) {
  2722. if ( $count != $rem_num ) {
  2723. @new_theme_name = ( @new_theme_name, $icon_theme_name[$count] );
  2724. @new_theme_path = ( @new_theme_path, $icon_theme_path[$count] );
  2725. }
  2726. $count++;
  2727. }
  2728. @icon_theme_name = @new_theme_name;
  2729. @icon_theme_path = @new_theme_path;
  2730. if ( $icon_theme_def > $rem_num ) {
  2731. $icon_theme_def--;
  2732. }
  2733. }
  2734. } elsif ( $input =~ /^\s*t\s*/i ) {
  2735. print "\nStarting detection...\n\n";
  2736. opendir( DIR, "../images/themes/" );
  2737. @files = readdir(DIR);
  2738. $cnt = 0;
  2739. while ( $cnt <= $#files ) {
  2740. $filename = "../images/themes/" . $files[$cnt] .'/';
  2741. if ( -d "../images/themes/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne "CVS" ) {
  2742. $found = 0;
  2743. for ( $x = 0 ; $x <= $#icon_theme_path ; $x++ ) {
  2744. if ( $icon_theme_path[$x] eq $filename ) {
  2745. $found = 1;
  2746. }
  2747. }
  2748. if ( $found != 1 ) {
  2749. print "** Found icon theme: $filename\n";
  2750. print " What is its name? ";
  2751. $nm = <STDIN>;
  2752. $nm =~ s/[\n\r]//g;
  2753. $icon_theme_name[ $#icon_theme_name + 1 ] = $nm;
  2754. $icon_theme_path[ $#icon_theme_path + 1 ] = $filename;
  2755. }
  2756. }
  2757. $cnt++;
  2758. }
  2759. print "\n";
  2760. for ( $cnt = 0 ; $cnt <= $#icon_theme_path ; $cnt++ ) {
  2761. $filename = $icon_theme_path[$cnt];
  2762. if ( $filename ne "none" && $filename ne "template" && ! -d $filename ) {
  2763. print " Removing $filename (file not found)\n";
  2764. $offset = 0;
  2765. @new_icon_theme_name = ();
  2766. @new_icon_theme_path = ();
  2767. for ( $x = 0 ; $x < $#icon_theme_path ; $x++ ) {
  2768. if ( $icon_theme_path[$x] eq $filename ) {
  2769. $offset = 1;
  2770. }
  2771. if ( $offset == 1 ) {
  2772. $new_icon_theme_name[$x] = $icon_theme_name[ $x + 1 ];
  2773. $new_icon_theme_path[$x] = $icon_theme_path[ $x + 1 ];
  2774. } else {
  2775. $new_icon_theme_name[$x] = $icon_theme_name[$x];
  2776. $new_icon_theme_path[$x] = $icon_theme_path[$x];
  2777. }
  2778. }
  2779. @icon_theme_name = @new_icon_theme_name;
  2780. @icon_theme_path = @new_icon_theme_path;
  2781. }
  2782. }
  2783. print "\nDetection complete!\n\n";
  2784. closedir DIR;
  2785. } elsif ( $input =~ /^\s*\?\s*/ ) {
  2786. print ".------------------------------------.\n";
  2787. print "| t (detect icon themes) |\n";
  2788. print "| + (add icon theme) |\n";
  2789. print "| - N (remove icon theme) |\n";
  2790. print "| m N (mark default icon theme) |\n";
  2791. print "| f N (set fallback icon set) |\n";
  2792. print "| l (list icon themes) |\n";
  2793. print "| d (done) |\n";
  2794. print "`------------------------------------'\n";
  2795. }
  2796. print "[icon_themes] command (?=help) > ";
  2797. $input = <STDIN>;
  2798. $input =~ s/[\r\n]//g;
  2799. }
  2800. }
  2801. sub command_templates {
  2802. print "\nDefine the template sets that you wish to use. If you have added\n";
  2803. print "a template set of your own, just follow the instructions (?) about\n";
  2804. print "how to add them. You can also change the default template.\n";
  2805. print "\n Available Templates:\n";
  2806. $count = 0;
  2807. while ( $count <= $#templateset_name ) {
  2808. if ( $templateset_id[$count] eq $templateset_default ) {
  2809. print " d";
  2810. } else {
  2811. print " ";
  2812. }
  2813. if ( $templateset_id[$count] eq $templateset_fallback ) {
  2814. print "f ";
  2815. } else {
  2816. print " ";
  2817. }
  2818. if ( $count < 10 ) {
  2819. print " ";
  2820. }
  2821. $name = $templateset_name[$count];
  2822. $num_spaces = 35 - length($name);
  2823. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  2824. $name = $name . " ";
  2825. }
  2826. print " $count. $name";
  2827. print "($templateset_id[$count])\n";
  2828. $count++;
  2829. }
  2830. print "\n d = default template set\n"
  2831. . " f = fallback template set\n\n";
  2832. $menu_text = ".-------------------------------------.\n"
  2833. . "| t (detect template set) |\n"
  2834. . "| + (add template set) |\n"
  2835. . "| - N (remove template set) |\n"
  2836. . "| m N (mark default template set) |\n"
  2837. . "| f N (set fallback template set) |\n"
  2838. . "| l (list template sets) |\n"
  2839. . "| d (done) |\n"
  2840. . "|-------------------------------------|\n"
  2841. . "| where N is a template set number |\n"
  2842. . "`-------------------------------------'\n";
  2843. print "\n";
  2844. print $menu_text;
  2845. print "\n[template set] command (?=help) > ";
  2846. $input = <STDIN>;
  2847. $input =~ s/[\r\n]//g;
  2848. while ( $input ne "d" ) {
  2849. # list template sets
  2850. #
  2851. if ( $input =~ /^\s*l\s*/i ) {
  2852. $count = 0;
  2853. while ( $count <= $#templateset_name ) {
  2854. if ( $templateset_id[$count] eq $templateset_default ) {
  2855. print " d";
  2856. } else {
  2857. print " ";
  2858. }
  2859. if ( $templateset_id[$count] eq $templateset_fallback ) {
  2860. print "f ";
  2861. } else {
  2862. print " ";
  2863. }
  2864. if ( $count < 10 ) {
  2865. print " ";
  2866. }
  2867. $name = $templateset_name[$count];
  2868. $num_spaces = 35 - length($name);
  2869. for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
  2870. $name = $name . " ";
  2871. }
  2872. print " $count. $name";
  2873. print "($templateset_id[$count])\n";
  2874. $count++;
  2875. }
  2876. print "\n d = default template set\n"
  2877. . " f = fallback template set\n\n";
  2878. # mark default template set
  2879. #
  2880. } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
  2881. $old_def = $templateset_default;
  2882. $input =~ s/^\s*m\s*//;
  2883. $templateset_default = $templateset_id[$input];
  2884. if ( $templateset_default =~ /^\s*$/ ) {
  2885. print "Cannot set default template set to $input. That template set does not exist.\n";
  2886. $templateset_default = $old_def;
  2887. }
  2888. # set fallback template set
  2889. #
  2890. } elsif ( $input =~ /^\s*f\s*[0-9]+/i ) {
  2891. $old_def = $templateset_fallback;
  2892. $input =~ s/^\s*f\s*//;
  2893. $templateset_fallback = $templateset_id[$input];
  2894. if ( $templateset_fallback =~ /^\s*$/ ) {
  2895. print "Cannot set fallback template set to $input. That template set does not exist.\n";
  2896. $templateset_fallback = $old_def;
  2897. }
  2898. # add template set
  2899. #
  2900. } elsif ( $input =~ /^\s*\+/ ) {
  2901. print "\nWhat is the name of this template (as shown to your users): ";
  2902. $name = <STDIN>;
  2903. $name =~ s/[\r\n]//g;
  2904. $templateset_name[ $#templateset_name + 1 ] = $name;
  2905. print "\n\nThe directory name should not contain any path information\n"
  2906. . "or slashes, and should be the name of the directory that the\n"
  2907. . "template set is found in within the SquirrelMail templates\n"
  2908. . "directory.\n\n";
  2909. print "What directory is this stored in (ex: default_advanced): ";
  2910. $name = <STDIN>;
  2911. $name =~ s/[\r\n]//g;
  2912. $templateset_id[ $#templateset_id + 1 ] = $name;
  2913. # detect template sets
  2914. #
  2915. } elsif ( $input =~ /^\s*t\s*/i ) {
  2916. print "\nStarting detection...\n\n";
  2917. opendir( DIR, "../templates" );
  2918. @files = readdir(DIR);
  2919. $cnt = 0;
  2920. while ( $cnt <= $#files ) {
  2921. if ( -d "../templates/" . $files[$cnt] && $files[$cnt] !~ /^\./ && $files[$cnt] ne "CVS" ) {
  2922. $filename = $files[$cnt];
  2923. $found = 0;
  2924. for ( $x = 0 ; $x <= $#templateset_id ; $x++ ) {
  2925. if ( $templateset_id[$x] eq $filename ) {
  2926. $found = 1;
  2927. last;
  2928. }
  2929. }
  2930. if ( $found != 1) {
  2931. print "** Found template set: $filename\n";
  2932. print " What is it's name (as shown to your users)? ";
  2933. $nm = <STDIN>;
  2934. $nm =~ s/[\n\r]//g;
  2935. $templateset_id[ $#templateset_id + 1 ] = $filename;
  2936. $templateset_name[ $#templateset_name + 1 ] = $nm;
  2937. }
  2938. }
  2939. $cnt++;
  2940. }
  2941. print "\n";
  2942. for ( $cnt= 0 ; $cnt <= $#templateset_id ; ) {
  2943. $filename = $templateset_id[$cnt];
  2944. if ( !(-d change_to_rel_path('SM_PATH . \'templates/' . $filename)) ) {
  2945. print " Removing \"$filename\" (template set directory not found)\n";
  2946. if ( $templateset_default eq $filename ) { $templateset_default = 'default'; }
  2947. if ( $templateset_fallback eq $filename ) { $templateset_fallback = 'default'; }
  2948. $offset = 0;
  2949. @new_templateset_name = ();
  2950. @new_templateset_id = ();
  2951. for ( $x = 0 ; $x < $#templateset_id ; $x++ ) {
  2952. if ( $templateset_id[$x] eq $filename ) {
  2953. $offset = 1;
  2954. }
  2955. if ( $offset == 1 ) {
  2956. $new_templateset_name[$x] = $templateset_name[ $x + 1 ];
  2957. $new_templateset_id[$x] = $templateset_id[ $x + 1 ];
  2958. } else {
  2959. $new_templateset_name[$x] = $templateset_name[$x];
  2960. $new_templateset_id[$x] = $templateset_id[$x];
  2961. }
  2962. }
  2963. @templateset_name = @new_templateset_name;
  2964. @templateset_id = @new_templateset_id;
  2965. } else { $cnt++; }
  2966. }
  2967. print "\nDetection complete!\n\n";
  2968. closedir DIR;
  2969. # remove template set
  2970. #
  2971. # undocumented functionality of removing last template set isn't that great
  2972. #} elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
  2973. } elsif ( $input =~ /^\s*-\s*[0-9]+/ ) {
  2974. if ( $input =~ /[0-9]+\s*$/ ) {
  2975. $rem_num = $input;
  2976. $rem_num =~ s/^\s*-\s*//g;
  2977. $rem_num =~ s/\s*$//;
  2978. } else {
  2979. $rem_num = $#templateset_name;
  2980. }
  2981. if ( $templateset_id[$rem_num] eq $templateset_default ) {
  2982. print "You cannot remove the default template set!\n";
  2983. } elsif ( $templateset_id[$rem_num] eq $templateset_fallback ) {
  2984. print "You cannot remove the fallback template set!\n";
  2985. } else {
  2986. $count = 0;
  2987. @new_templateset_name = ();
  2988. @new_templateset_id = ();
  2989. while ( $count <= $#templateset_name ) {
  2990. if ( $count != $rem_num ) {
  2991. @new_templateset_name = ( @new_templateset_name, $templateset_name[$count] );
  2992. @new_templateset_id = ( @new_templateset_id, $templateset_id[$count] );
  2993. }
  2994. $count++;
  2995. }
  2996. @templateset_name = @new_templateset_name;
  2997. @templateset_id = @new_templateset_id;
  2998. }
  2999. # help
  3000. #
  3001. } elsif ( $input =~ /^\s*\?\s*/ ) {
  3002. print $menu_text;
  3003. # command not understood
  3004. #
  3005. } else {
  3006. print "Command not understood\n";
  3007. }
  3008. print "[template set] command (?=help) > ";
  3009. $input = <STDIN>;
  3010. $input =~ s/[\r\n]//g;
  3011. }
  3012. return $templateset_default;
  3013. }
  3014. # sets default font size option
  3015. sub command_default_fontsize {
  3016. print "Enter default font size [$WHT$$default_fontsize$NRM]: $WHT";
  3017. $new_size = <STDIN>;
  3018. if ( $new_size eq "\n" ) {
  3019. $new_size = $size;
  3020. } else {
  3021. $new_size =~ s/[\r\n]//g;
  3022. }
  3023. return $new_size;
  3024. }
  3025. # controls available fontsets
  3026. sub command_fontsets {
  3027. # Greeting
  3028. print "You can control fontsets available to end users here.\n";
  3029. # set initial $input value
  3030. $input = 'l';
  3031. while ( $input ne "x" ) {
  3032. if ( $input =~ /^\s*a\s*/i ) {
  3033. # add new fontset
  3034. print "\nFontset name: ";
  3035. $name = <STDIN>;
  3036. if (! $fontsets{trim($name)}) {
  3037. print "Fontset string: ";
  3038. $value = <STDIN>;
  3039. $fontsets{trim($name)} = trim($value);
  3040. } else {
  3041. print "\nERROR: Such fontset already exists.\n";
  3042. }
  3043. } elsif ( $input =~ /^\s*e\s*/i ) {
  3044. # edit existing fontset
  3045. print "\nFontset name: ";
  3046. $name = <STDIN>;
  3047. if (! $fontsets{trim($name)}) {
  3048. print "\nERROR: No such fontset.\n";
  3049. } else {
  3050. print "Fontset string [$fontsets{trim($name)}]: ";
  3051. $value = <STDIN>;
  3052. $fontsets{trim($name)} = trim($value);
  3053. }
  3054. } elsif ( $input =~ /^\s*d\s*/ ) {
  3055. # delete existing fontset
  3056. print "\nFontset name: ";
  3057. $name = <STDIN>;
  3058. if (! $fontsets{trim($name)}) {
  3059. print "\nERROR: No such fontset.\n";
  3060. } else {
  3061. delete $fontsets{trim($name)};
  3062. }
  3063. } elsif ( $input =~ /^\s*l\s*/ ) {
  3064. # list fontsets
  3065. print "\nConfigured fontsets:\n";
  3066. while (($fontset_name, $fontset_string) = each(%fontsets)) {
  3067. print " $fontset_name = $fontset_string\n";
  3068. }
  3069. print "Default fontset: $default_fontset\n";
  3070. } elsif ( $input =~ /^\s*m\s*/ ) {
  3071. # set default fontset
  3072. print "\nSet default fontset [$default_fontset]: ";
  3073. $name = <STDIN>;
  3074. if (trim($name) ne '' and ! $fontsets{trim($name)}) {
  3075. print "\nERROR: No such fontset.\n";
  3076. } else {
  3077. $default_fontset = trim($name);
  3078. }
  3079. } else {
  3080. # print available commands on any other input
  3081. print "\nAvailable commands:\n";
  3082. print " a - Adds new fontset.\n";
  3083. print " d - Deletes existing fontset.\n";
  3084. print " e - Edits existing fontset.\n";
  3085. print " h or ? - Shows this help screen.\n";
  3086. print " l - Lists available fontsets.\n";
  3087. print " m - Sets default fontset.\n";
  3088. print " x - Exits fontset editor mode.\n";
  3089. }
  3090. print "\nCommand [fontsets] (a,d,e,h,?=help,l,m,x)> ";
  3091. $input = <STDIN>;
  3092. $input =~ s/[\r\n]//g;
  3093. }
  3094. }
  3095. sub command61 {
  3096. print "You can now define different LDAP servers.\n";
  3097. print "Please ensure proper permissions for config.php when including\n";
  3098. print "sensitive passwords.\n\n";
  3099. print "[ldap] command (?=help) > ";
  3100. $input = <STDIN>;
  3101. $input =~ s/[\r\n]//g;
  3102. while ( $input ne "d" ) {
  3103. if ( $input =~ /^\s*l\s*/i ) {
  3104. $count = 0;
  3105. while ( $count <= $#ldap_host ) {
  3106. print "$count. $ldap_host[$count]\n";
  3107. print " base: $ldap_base[$count]\n";
  3108. if ( $ldap_charset[$count] ) {
  3109. print " charset: $ldap_charset[$count]\n";
  3110. }
  3111. if ( $ldap_port[$count] ) {
  3112. print " port: $ldap_port[$count]\n";
  3113. }
  3114. if ( $ldap_name[$count] ) {
  3115. print " name: $ldap_name[$count]\n";
  3116. }
  3117. if ( $ldap_maxrows[$count] ) {
  3118. print " maxrows: $ldap_maxrows[$count]\n";
  3119. }
  3120. if ( $ldap_filter[$count] ) {
  3121. print " filter: $ldap_filter[$count]\n";
  3122. }
  3123. if ( $ldap_binddn[$count] ) {
  3124. print " binddn: $ldap_binddn[$count]\n";
  3125. if ( $ldap_bindpw[$count] ) {
  3126. print " bindpw: $ldap_bindpw[$count]\n";
  3127. }
  3128. }
  3129. if ( $ldap_protocol[$count] ) {
  3130. print " protocol: $ldap_protocol[$count]\n";
  3131. }
  3132. if ( $ldap_limit_scope[$count] ) {
  3133. print " limit_scope: $ldap_limit_scope[$count]\n";
  3134. }
  3135. if ( $ldap_listing[$count] ) {
  3136. print " listing: $ldap_listing[$count]\n";
  3137. }
  3138. if ( $ldap_writeable[$count] ) {
  3139. print " writeable: $ldap_writeable[$count]\n";
  3140. }
  3141. if ( $ldap_search_tree[$count] ) {
  3142. print " search_tree: $ldap_search_tree[$count]\n";
  3143. }
  3144. if ( $ldap_starttls[$count] ) {
  3145. print " starttls: $ldap_starttls[$count]\n";
  3146. }
  3147. print "\n";
  3148. $count++;
  3149. }
  3150. } elsif ( $input =~ /^\s*\+/ ) {
  3151. $sub = $#ldap_host + 1;
  3152. print "First, we need to have the hostname or the IP address where\n";
  3153. print "this LDAP server resides. Example: ldap.bigfoot.com\n";
  3154. print "\n";
  3155. print "You can use any URI compatible with your LDAP library. Please\n";
  3156. print "note that StartTLS option is not compatible with ldaps and\n";
  3157. print "ldapi URIs.\n";
  3158. print "hostname: ";
  3159. $name = <STDIN>;
  3160. $name =~ s/[\r\n]//g;
  3161. $ldap_host[$sub] = $name;
  3162. print "\n";
  3163. print "Next, we need the server root (base dn). For this, an empty\n";
  3164. print "string is allowed.\n";
  3165. print "Example: ou=member_directory,o=netcenter.com\n";
  3166. print "base: ";
  3167. $name = <STDIN>;
  3168. $name =~ s/[\r\n]//g;
  3169. $ldap_base[$sub] = $name;
  3170. print "\n";
  3171. print "This is the TCP/IP port number for the LDAP server. Default\n";
  3172. print "port is 389. This is optional. Press ENTER for default.\n";
  3173. print "port: ";
  3174. $name = <STDIN>;
  3175. $name =~ s/[\r\n]//g;
  3176. $ldap_port[$sub] = $name;
  3177. print "\n";
  3178. print "This is the charset for the server. Default is utf-8. This\n";
  3179. print "is also optional. Press ENTER for default.\n";
  3180. print "charset: ";
  3181. $name = <STDIN>;
  3182. $name =~ s/[\r\n]//g;
  3183. $ldap_charset[$sub] = $name;
  3184. print "\n";
  3185. print "This is the name for the server, used to tag the results of\n";
  3186. print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
  3187. print "name: ";
  3188. $name = <STDIN>;
  3189. $name =~ s/[\r\n]//g;
  3190. $ldap_name[$sub] = $name;
  3191. print "\n";
  3192. print "You can specify the maximum number of rows in the search result.\n";
  3193. print "Default value is equal to 250 rows. Press ENTER for default.\n";
  3194. print "maxrows: ";
  3195. $name = <STDIN>;
  3196. $name =~ s/[\r\n]//g;
  3197. $ldap_maxrows[$sub] = $name;
  3198. print "\n";
  3199. print "If your LDAP server does not like anonymous logins, you can specify bind DN.\n";
  3200. print "Default is none, anonymous bind. Press ENTER for default.\n";
  3201. print "binddn: ";
  3202. $name = <STDIN>;
  3203. $name =~ s/[\r\n]//g;
  3204. $ldap_binddn[$sub] = $name;
  3205. print "\n";
  3206. if ( $ldap_binddn[$sub] ne '' ) {
  3207. print "Now, please specify password for that DN.\n";
  3208. print "bindpw: ";
  3209. $name = <STDIN>;
  3210. $name =~ s/[\r\n]//g;
  3211. $ldap_bindpw[$sub] = $name;
  3212. print "\n";
  3213. }
  3214. print "You can specify bind protocol version here.\n";
  3215. print "Default protocol version depends on your php ldap settings.\n";
  3216. print "Press ENTER for default.\n";
  3217. print "protocol: ";
  3218. $name = <STDIN>;
  3219. $name =~ s/[\r\n]//g;
  3220. $ldap_protocol[$sub] = $name;
  3221. print "\n";
  3222. print "This configuration section allows to set some rarely used\n";
  3223. print "options and options specific to some LDAP implementations.\n";
  3224. print "\n";
  3225. print "Do you want to set advanced LDAP directory settings? (y/N):";
  3226. $ldap_advanced_settings = <STDIN>;
  3227. if ( $ldap_advanced_settings =~ /^y\n/i ) {
  3228. $ldap_advanced_settings = 'true';
  3229. } else {
  3230. $ldap_advanced_settings = 'false';
  3231. }
  3232. if ($ldap_advanced_settings eq 'true') {
  3233. print "\n";
  3234. print "You can control LDAP directory listing here. This option can\n";
  3235. print "be useful if you run small LDAP server and want to provide listing\n";
  3236. print "of all addresses stored in LDAP to users of webmail interface.\n";
  3237. print "Number of displayed entries is limited by maxrows setting.\n";
  3238. print "\n";
  3239. print "Don't enable this option for public LDAP directories.\n";
  3240. print "\n";
  3241. print "Allow listing of LDAP directory? (y/N):";
  3242. $name = <STDIN>;
  3243. if ( $name =~ /^y\n/i ) {
  3244. $name = 'true';
  3245. } else {
  3246. $name = 'false';
  3247. }
  3248. $ldap_listing[$sub] = $name;
  3249. print "\n";
  3250. print "You can control write access to LDAP address book here. This option can\n";
  3251. print "be useful if you run small LDAP server and want to provide writable\n";
  3252. print "shared address book stored in LDAP to users of webmail interface.\n";
  3253. print "\n";
  3254. print "Don't enable this option for public LDAP directories.\n";
  3255. print "\n";
  3256. print "Allow writing to LDAP directory? (y/N):";
  3257. $name = <STDIN>;
  3258. if ( $name =~ /^y\n/i ) {
  3259. $name = 'true';
  3260. } else {
  3261. $name = 'false';
  3262. }
  3263. $ldap_writeable[$sub] = $name;
  3264. print "\n";
  3265. print "You can specify an additional search filter.\n";
  3266. print "This could be something like \"(objectclass=posixAccount)\".\n";
  3267. print "No filtering is performed by default. Press ENTER for default.\n";
  3268. print "filter: ";
  3269. $name = <STDIN>;
  3270. $name =~ s/[\r|\n]//g;
  3271. $ldap_filter[$sub] = $name;
  3272. print "\n";
  3273. print "You can control search scope here.\n";
  3274. print "This option is specific to Microsoft ADS implementation.\n";
  3275. print "It requires use of v3 or newer LDAP protocol.\n";
  3276. print "Don't enable it, if you use other LDAP server.\n";
  3277. print "\n";
  3278. print "Limit ldap scope? (y/N):";
  3279. $name = <STDIN>;
  3280. if ( $name =~ /^y\n/i ) {
  3281. $name = 'true';
  3282. } else {
  3283. $name = 'false';
  3284. }
  3285. $ldap_limit_scope[$sub] = $name;
  3286. print "\n";
  3287. print "You can control ldap search type here.\n";
  3288. print "Addresses can be searched in entire LDAP subtree (default)\n";
  3289. print "or only first level entries are returned.\n";
  3290. print "\n";
  3291. print "Search entire LDAP subtree? (Y/n):";
  3292. $name = <STDIN>;
  3293. if ( $name =~ /^n\n/i ) {
  3294. $name = 'false';
  3295. } else {
  3296. $name = 'true';
  3297. }
  3298. $ldap_search_tree[$sub] = $name;
  3299. print "\n";
  3300. print "You can control use of StartTLS on LDAP connection here.\n";
  3301. print "This option requires use of v3 or newer LDAP protocol and php 4.2+.\n";
  3302. print "\n";
  3303. print "Use StartTLS? (y/N):";
  3304. $name = <STDIN>;
  3305. if ( $name =~ /^y\n/i ) {
  3306. $name = 'true';
  3307. } else {
  3308. $name = 'false';
  3309. }
  3310. $ldap_starttls[$sub] = $name;
  3311. }
  3312. print "\n";
  3313. } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
  3314. if ( $input =~ /[0-9]+\s*$/ ) {
  3315. $rem_num = $input;
  3316. $rem_num =~ s/^\s*-\s*//g;
  3317. $rem_num =~ s/\s*$//;
  3318. } else {
  3319. $rem_num = $#ldap_host;
  3320. }
  3321. $count = 0;
  3322. @new_ldap_host = ();
  3323. @new_ldap_base = ();
  3324. @new_ldap_port = ();
  3325. @new_ldap_name = ();
  3326. @new_ldap_charset = ();
  3327. @new_ldap_maxrows = ();
  3328. @new_ldap_filter = ();
  3329. @new_ldap_bindpw = ();
  3330. @new_ldap_binddn = ();
  3331. @new_ldap_protocol = ();
  3332. @new_ldap_limit_scope = ();
  3333. @new_ldap_listing = ();
  3334. @new_ldap_writeable = ();
  3335. @new_ldap_search_tree = ();
  3336. @new_ldap_starttls = ();
  3337. while ( $count <= $#ldap_host ) {
  3338. if ( $count != $rem_num ) {
  3339. @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
  3340. @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
  3341. @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
  3342. @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
  3343. @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
  3344. @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
  3345. @new_ldap_filter = ( @new_ldap_filter, $ldap_filter[$count] );
  3346. @new_ldap_binddn = ( @new_ldap_binddn, $ldap_binddn[$count] );
  3347. @new_ldap_bindpw = ( @new_ldap_bindpw, $ldap_bindpw[$count] );
  3348. @new_ldap_protocol = ( @new_ldap_protocol, $ldap_protocol[$count] );
  3349. @new_ldap_limit_scope = ( @new_ldap_limit_scope, $ldap_limit_scope[$count] );
  3350. @new_ldap_listing = ( @new_ldap_listing, $ldap_listing[$count] );
  3351. @new_ldap_writeable = ( @new_ldap_writeable, $ldap_writeable[$count] );
  3352. @new_ldap_search_tree = ( @new_ldap_search_tree, $ldap_search_tree[$count] );
  3353. @new_ldap_starttls = ( @new_ldap_starttls, $ldap_starttls[$count] );
  3354. }
  3355. $count++;
  3356. }
  3357. @ldap_host = @new_ldap_host;
  3358. @ldap_base = @new_ldap_base;
  3359. @ldap_port = @new_ldap_port;
  3360. @ldap_name = @new_ldap_name;
  3361. @ldap_charset = @new_ldap_charset;
  3362. @ldap_maxrows = @new_ldap_maxrows;
  3363. @ldap_filter = @new_ldap_filter;
  3364. @ldap_binddn = @new_ldap_binddn;
  3365. @ldap_bindpw = @new_ldap_bindpw;
  3366. @ldap_protocol = @new_ldap_protocol;
  3367. @ldap_limit_scope = @new_ldap_limit_scope;
  3368. @ldap_listing = @new_ldap_listing;
  3369. @ldap_writeable = @new_ldap_writeable;
  3370. @ldap_search_tree = @new_ldap_search_tree;
  3371. @ldap_starttls = @new_ldap_starttls;
  3372. } elsif ( $input =~ /^\s*\?\s*/ ) {
  3373. print ".-------------------------.\n";
  3374. print "| + (add host) |\n";
  3375. print "| - N (remove host) |\n";
  3376. print "| l (list hosts) |\n";
  3377. print "| d (done) |\n";
  3378. print "`-------------------------'\n";
  3379. }
  3380. print "[ldap] command (?=help) > ";
  3381. $input = <STDIN>;
  3382. $input =~ s/[\r\n]//g;
  3383. }
  3384. }
  3385. sub command62 {
  3386. print "Some of our developers have come up with very good javascript interface\n";
  3387. print "for searching through address books, however, our original goals said\n";
  3388. print "that we would be 100% HTML. In order to make it possible to use their\n";
  3389. print "interface, and yet stick with our goals, we have also written a plain\n";
  3390. print "HTML version of the search. Here, you can choose which version to use.\n";
  3391. print "\n";
  3392. print "This is just the default value. It is also a user option that each\n";
  3393. print "user can configure individually\n";
  3394. print "\n";
  3395. if ( lc($default_use_javascript_addr_book) eq 'true' ) {
  3396. $default_value = "y";
  3397. } else {
  3398. $default_use_javascript_addr_book = 'false';
  3399. $default_value = "n";
  3400. }
  3401. print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
  3402. $new_show = <STDIN>;
  3403. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3404. $default_use_javascript_addr_book = 'true';
  3405. } else {
  3406. $default_use_javascript_addr_book = 'false';
  3407. }
  3408. return $default_use_javascript_addr_book;
  3409. }
  3410. # global filebased address book
  3411. sub command63 {
  3412. print "If you want to use global file address book, then you\n";
  3413. print "must set this option to a valid value. If option does\n";
  3414. print "not have path elements, system assumes that file is\n";
  3415. print "stored in data directory. If relative path is set, it is\n";
  3416. print "relative to main SquirrelMail directory. If value is empty,\n";
  3417. print "address book is not enabled.\n";
  3418. print "\n";
  3419. print "[$WHT$abook_global_file$NRM]: $WHT";
  3420. $new_abook_global_file = <STDIN>;
  3421. if ( $new_abook_global_file eq "\n" ) {
  3422. $new_abook_global_file = $abook_global_file;
  3423. } else {
  3424. $new_abook_global_file =~ s/[\r\n]//g;
  3425. }
  3426. return $new_abook_global_file;
  3427. }
  3428. # writing into global filebased abook control
  3429. sub command64 {
  3430. print "This setting controls writing into global file address\n";
  3431. print "book options. Address book file must be writeable by\n";
  3432. print "webserver's user, if you want to enable this option.\n";
  3433. print "\n";
  3434. if ( lc($abook_global_file_writeable) eq 'true' ) {
  3435. $default_value = "y";
  3436. } else {
  3437. $abook_global_file_writeable = 'false';
  3438. $default_value = "n";
  3439. }
  3440. print "Allow writing into global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
  3441. $new_show = <STDIN>;
  3442. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3443. $abook_global_file_writeable = 'true';
  3444. } else {
  3445. $abook_global_file_writeable = 'false';
  3446. }
  3447. return $abook_global_file_writeable;
  3448. }
  3449. # listing of global filebased abook control
  3450. sub command65 {
  3451. print "This setting controls listing of global file address\n";
  3452. print "book in addresses page.\n";
  3453. print "\n";
  3454. if ( lc($abook_global_file_listing) eq 'true' ) {
  3455. $default_value = "y";
  3456. } else {
  3457. $abook_global_file_listing = 'false';
  3458. $default_value = "n";
  3459. }
  3460. print "Allow listing of global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
  3461. $new_show = <STDIN>;
  3462. if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3463. $abook_global_file_listing = 'true';
  3464. } else {
  3465. $abook_global_file_listing = 'false';
  3466. }
  3467. return $abook_global_file_listing;
  3468. }
  3469. # controls $abook_file_line_length setting
  3470. sub command_abook_file_line_length {
  3471. print "This setting controls space allocated to file based address book records.\n";
  3472. print "End users will be unable to save address book entry, if total entry size \n";
  3473. print "(quoted address book fields + 4 delimiters + linefeed) exceeds allowed \n";
  3474. print "address book length size.\n";
  3475. print "\n";
  3476. print "Same setting is applied to personal and global file based address books.\n";
  3477. print "\n";
  3478. print "It is strongly recommended to keep default setting value. Change it only\n";
  3479. print "if you really want to store address book entries that are bigger than two\n";
  3480. print "kilobytes (2048).\n";
  3481. print "\n";
  3482. print "Enter allowed address book line length [$abook_file_line_length]: ";
  3483. my $tmp = <STDIN>;
  3484. $tmp = trim($tmp);
  3485. # value is not modified, if user hits Enter or enters space
  3486. if ($tmp ne '') {
  3487. # make sure that input is numeric
  3488. if ($tmp =~ /^\d+$/) {
  3489. $abook_file_line_length = $tmp;
  3490. } else {
  3491. print "If you want to change this setting, you must enter number.\n";
  3492. print "If you want to keep original setting - enter space.\n\n";
  3493. print "Press Enter to continue...";
  3494. $tmp = <STDIN>;
  3495. }
  3496. }
  3497. }
  3498. sub command91 {
  3499. print "If you want to store your users address book details in a database then\n";
  3500. print "you need to set this DSN to a valid value. The format for this is:\n";
  3501. print "mysql://user:pass\@hostname/dbname\n";
  3502. print "Where mysql can be one of the databases PHP supports, the most common\n";
  3503. print "of these are mysql, msql and pgsql.\n";
  3504. print "Please ensure proper permissions for config.php when including\n";
  3505. print "sensitive passwords.\n\n";
  3506. print "If the DSN is left empty (hit space and then return) the database\n";
  3507. print "related code for address books will not be used.\n";
  3508. print "\n";
  3509. if ( $addrbook_dsn eq "" ) {
  3510. $default_value = "Disabled";
  3511. } else {
  3512. $default_value = $addrbook_dsn;
  3513. }
  3514. print "[$WHT$addrbook_dsn$NRM]: $WHT";
  3515. $new_dsn = <STDIN>;
  3516. if ( $new_dsn eq "\n" ) {
  3517. $new_dsn = "";
  3518. } else {
  3519. $new_dsn =~ s/[\r\n]//g;
  3520. $new_dsn =~ s/^\s+$//g;
  3521. }
  3522. return $new_dsn;
  3523. }
  3524. sub command92 {
  3525. print "This is the name of the table you want to store the address book\n";
  3526. print "data in, it defaults to 'address'\n";
  3527. print "\n";
  3528. print "[$WHT$addrbook_table$NRM]: $WHT";
  3529. $new_table = <STDIN>;
  3530. if ( $new_table eq "\n" ) {
  3531. $new_table = $addrbook_table;
  3532. } else {
  3533. $new_table =~ s/[\r\n]//g;
  3534. }
  3535. return $new_table;
  3536. }
  3537. sub command93 {
  3538. print "If you want to store your users preferences in a database then\n";
  3539. print "you need to set this DSN to a valid value. The format for this is:\n";
  3540. print "mysql://user:pass\@hostname/dbname\n";
  3541. print "Where mysql can be one of the databases PHP supports, the most common\n";
  3542. print "of these are mysql, msql and pgsql.\n";
  3543. print "Please ensure proper permissions for config.php when including\n";
  3544. print "sensitive passwords.\n\n";
  3545. print "If the DSN is left empty (hit space and then return) the database\n";
  3546. print "related code for address books will not be used.\n";
  3547. print "\n";
  3548. if ( $prefs_dsn eq "" ) {
  3549. $default_value = "Disabled";
  3550. } else {
  3551. $default_value = $prefs_dsn;
  3552. }
  3553. print "[$WHT$prefs_dsn$NRM]: $WHT";
  3554. $new_dsn = <STDIN>;
  3555. if ( $new_dsn eq "\n" ) {
  3556. $new_dsn = "";
  3557. } else {
  3558. $new_dsn =~ s/[\r\n]//g;
  3559. $new_dsn =~ s/^\s+$//g;
  3560. }
  3561. return $new_dsn;
  3562. }
  3563. sub command94 {
  3564. print "This is the name of the table you want to store the preferences\n";
  3565. print "data in, it defaults to 'userprefs'\n";
  3566. print "\n";
  3567. print "[$WHT$prefs_table$NRM]: $WHT";
  3568. $new_table = <STDIN>;
  3569. if ( $new_table eq "\n" ) {
  3570. $new_table = $prefs_table;
  3571. } else {
  3572. $new_table =~ s/[\r\n]//g;
  3573. }
  3574. return $new_table;
  3575. }
  3576. sub command95 {
  3577. print "This is the name of the field in which you want to store the\n";
  3578. print "username of the person the prefs are for. It default to 'user'\n";
  3579. print "which clashes with a reserved keyword in PostgreSQL so this\n";
  3580. print "will need to be changed for that database at least\n";
  3581. print "\n";
  3582. print "[$WHT$prefs_user_field$NRM]: $WHT";
  3583. $new_field = <STDIN>;
  3584. if ( $new_field eq "\n" ) {
  3585. $new_field = $prefs_user_field;
  3586. } else {
  3587. $new_field =~ s/[\r\n]//g;
  3588. }
  3589. $prefs_user_size = db_pref_size($prefs_user_size);
  3590. return $new_field;
  3591. }
  3592. sub command96 {
  3593. print "This is the name of the field in which you want to store the\n";
  3594. print "preferences keyword. It defaults to 'prefkey'\n";
  3595. print "\n";
  3596. print "[$WHT$prefs_key_field$NRM]: $WHT";
  3597. $new_field = <STDIN>;
  3598. if ( $new_field eq "\n" ) {
  3599. $new_field = $prefs_key_field;
  3600. } else {
  3601. $new_field =~ s/[\r\n]//g;
  3602. }
  3603. $prefs_key_size = db_pref_size($prefs_key_size);
  3604. return $new_field;
  3605. }
  3606. sub command97 {
  3607. print "This is the name of the field in which you want to store the\n";
  3608. print "preferences value. It defaults to 'prefval'\n";
  3609. print "\n";
  3610. print "[$WHT$prefs_val_field$NRM]: $WHT";
  3611. $new_field = <STDIN>;
  3612. if ( $new_field eq "\n" ) {
  3613. $new_field = $prefs_val_field;
  3614. } else {
  3615. $new_field =~ s/[\r\n]//g;
  3616. }
  3617. $prefs_val_size = db_pref_size($prefs_val_size);
  3618. return $new_field;
  3619. }
  3620. # routine is used to set database field limits
  3621. # it needs one argument
  3622. sub db_pref_size() {
  3623. my ($size) = $_[0];
  3624. print "\nDatabase fields have size limits.\n";
  3625. print "\n";
  3626. print "What limit is set for this field? [$WHT$size$NRM]: $WHT";
  3627. $new_size = <STDIN>;
  3628. if ( $new_size eq "\n" ) {
  3629. $new_size = $size;
  3630. } else {
  3631. $new_size =~ s/[\r\n]//g;
  3632. }
  3633. return $new_size;
  3634. }
  3635. sub command98 {
  3636. print "If you want to store your global address book in a database then\n";
  3637. print "you need to set this DSN to a valid value. The format for this is:\n";
  3638. print "mysql://user:pass\@hostname/dbname\n";
  3639. print "Where mysql can be one of the databases PHP supports, the most common\n";
  3640. print "of these are mysql, msql and pgsql.\n";
  3641. print "Please ensure proper permissions for config.php when including\n";
  3642. print "sensitive passwords.\n\n";
  3643. print "If the DSN is left empty (hit space and then return) the database\n";
  3644. print "related code for global SQL address book will not be used.\n";
  3645. print "\n";
  3646. if ( $addrbook_global_dsn eq "" ) {
  3647. $default_value = "Disabled";
  3648. } else {
  3649. $default_value = $addrbook_global_dsn;
  3650. }
  3651. print "[$WHT$addrbook_global_dsn$NRM]: $WHT";
  3652. $new_dsn = <STDIN>;
  3653. if ( $new_dsn eq "\n" ) {
  3654. $new_dsn = "";
  3655. } else {
  3656. $new_dsn =~ s/[\r\n]//g;
  3657. $new_dsn =~ s/^\s+$//g;
  3658. }
  3659. return $new_dsn;
  3660. }
  3661. sub command99 {
  3662. print "This is the name of the table you want to store the global address book\n";
  3663. print "data in. Default table name is 'global_abook'. Address book uses same\n";
  3664. print "database format as personal address book.\n";
  3665. print "\n";
  3666. print "[$WHT$addrbook_global_table$NRM]: $WHT";
  3667. $new_table = <STDIN>;
  3668. if ( $new_table eq "\n" ) {
  3669. $new_table = $addrbook_global_table;
  3670. } else {
  3671. $new_table =~ s/[\r\n]//g;
  3672. }
  3673. return $new_table;
  3674. }
  3675. sub command910 {
  3676. print "This option controls users\' ability to add or modify records stored \n";
  3677. print "in global address book\n";
  3678. if ( lc($addrbook_global_writeable) eq 'true' ) {
  3679. $default_value = "y";
  3680. } else {
  3681. $default_value = "n";
  3682. }
  3683. print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
  3684. $addrbook_global_writeable = <STDIN>;
  3685. if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3686. $addrbook_global_writeable = 'true';
  3687. } else {
  3688. $addrbook_global_writeable = 'false';
  3689. }
  3690. return $addrbook_global_writeable;
  3691. }
  3692. sub command911 {
  3693. print "Enable this option if you want to see listing of addresses stored \n";
  3694. print "in global address book\n";
  3695. if ( lc($addrbook_global_listing) eq 'true' ) {
  3696. $default_value = "y";
  3697. } else {
  3698. $default_value = "n";
  3699. }
  3700. print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
  3701. $addrbook_global_listing = <STDIN>;
  3702. if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3703. $addrbook_global_listing = 'true';
  3704. } else {
  3705. $addrbook_global_listing = 'false';
  3706. }
  3707. return $addrbook_global_listing;
  3708. }
  3709. # Default language
  3710. sub commandA1 {
  3711. print "SquirrelMail attempts to set the language in many ways. If it\n";
  3712. print "can not figure it out in another way, it will default to this\n";
  3713. print "language. Please use the code for the desired language.\n";
  3714. print "\n";
  3715. print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
  3716. $new_squirrelmail_default_language = <STDIN>;
  3717. if ( $new_squirrelmail_default_language eq "\n" ) {
  3718. $new_squirrelmail_default_language = $squirrelmail_default_language;
  3719. } else {
  3720. $new_squirrelmail_default_language =~ s/[\r\n]//g;
  3721. $new_squirrelmail_default_language =~ s/^\s+$//g;
  3722. }
  3723. return $new_squirrelmail_default_language;
  3724. }
  3725. # Default Charset
  3726. sub commandA2 {
  3727. print "This option controls what character set is used when sending\n";
  3728. print "mail and when sending HTML to the browser. Option works only\n";
  3729. print "with US English (en_US) translation. Other translations use\n";
  3730. print "charsets that are set in translation settings.\n";
  3731. print "\n";
  3732. print "[$WHT$default_charset$NRM]: $WHT";
  3733. $new_default_charset = <STDIN>;
  3734. if ( $new_default_charset eq "\n" ) {
  3735. $new_default_charset = $default_charset;
  3736. } else {
  3737. $new_default_charset =~ s/[\r\n]//g;
  3738. }
  3739. return $new_default_charset;
  3740. }
  3741. # Alternative language names
  3742. sub commandA3 {
  3743. print "Enable this option if you want to see localized language names in\n";
  3744. print "language selection box. Note, that this option can trigger\n";
  3745. print "installation of foreign language support modules in some browsers.\n";
  3746. print "\n";
  3747. if ( lc($show_alternative_names) eq 'true' ) {
  3748. $default_value = "y";
  3749. } else {
  3750. $default_value = "n";
  3751. }
  3752. print "Show alternative language names? (y/n) [$WHT$default_value$NRM]: $WHT";
  3753. $show_alternative_names = <STDIN>;
  3754. if ( ( $show_alternative_names =~ /^y\n/i ) || ( ( $show_alternative_names =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3755. $show_alternative_names = 'true';
  3756. } else {
  3757. $show_alternative_names = 'false';
  3758. }
  3759. return $show_alternative_names;
  3760. }
  3761. # Aggressive decoding
  3762. sub commandA4 {
  3763. print "Enable this option if you want to use CPU and memory intensive decoding\n";
  3764. print "functions. This option allows reading multibyte charset, that are used\n";
  3765. print "in Eastern Asia. SquirrelMail will try to use recode functions here,\n";
  3766. print "even when you have disabled use of recode in Tweaks section.\n";
  3767. print "\n";
  3768. if ( lc($aggressive_decoding) eq 'true' ) {
  3769. $default_value = "y";
  3770. } else {
  3771. $default_value = "n";
  3772. }
  3773. print "Enable aggressive decoding? (y/n) [$WHT$default_value$NRM]: $WHT";
  3774. $aggressive_decoding = <STDIN>;
  3775. if ( ( $aggressive_decoding =~ /^y\n/i ) || ( ( $aggressive_decoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3776. $aggressive_decoding = 'true';
  3777. } else {
  3778. $aggressive_decoding = 'false';
  3779. }
  3780. return $aggressive_decoding;
  3781. }
  3782. # Lossy encoding
  3783. sub commandA5 {
  3784. print "Enable this option if you want to allow lossy charset encoding in message\n";
  3785. print "composition pages. This option allows charset conversions when output\n";
  3786. print "charset does not support all symbols used in original charset. Symbols\n";
  3787. print "unsupported by output charset will be replaced with question marks.\n";
  3788. print "\n";
  3789. if ( lc($lossy_encoding) eq 'true' ) {
  3790. $default_value = "y";
  3791. } else {
  3792. $default_value = "n";
  3793. }
  3794. print "Enable lossy encoding? (y/n) [$WHT$default_value$NRM]: $WHT";
  3795. $lossy_encoding = <STDIN>;
  3796. if ( ( $lossy_encoding =~ /^y\n/i ) || ( ( $lossy_encoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3797. $lossy_encoding = 'true';
  3798. } else {
  3799. $lossy_encoding = 'false';
  3800. }
  3801. return $lossy_encoding;
  3802. }
  3803. # display html emails in iframe
  3804. sub commandB2 {
  3805. print "This option can enable html email rendering inside iframe.\n";
  3806. print "Inline frames are used in order to provide sandbox environment";
  3807. print "for html code included in html formated emails.";
  3808. print "Option is experimental and might have glitches in some parts of code.";
  3809. print "\n";
  3810. if ( lc($use_iframe) eq 'true' ) {
  3811. $default_value = "y";
  3812. } else {
  3813. $default_value = "n";
  3814. }
  3815. print "Display html emails in iframe? (y/n) [$WHT$default_value$NRM]: $WHT";
  3816. $use_iframe = <STDIN>;
  3817. if ( ( $use_iframe =~ /^y\n/i ) || ( ( $use_iframe =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3818. $use_iframe = 'true';
  3819. } else {
  3820. $use_iframe = 'false';
  3821. }
  3822. return $use_iframe;
  3823. }
  3824. # use icons
  3825. sub commandB3 {
  3826. print "Enabling this option will cause icons to be used instead of text\n";
  3827. print "markers next to each message in mailbox lists that represent\n";
  3828. print "new, read, flagged, and deleted messages, as well as those that\n";
  3829. print "have been replied to and forwarded. Icons are also used next to\n";
  3830. print "(un)expanded folders in the folder list (Oldway = false). These\n";
  3831. print "icons are quite small, but will obviously be more of a resource\n";
  3832. print "drain than text markers.\n";
  3833. print "\n";
  3834. if ( lc($use_icons) eq 'true' ) {
  3835. $default_value = "y";
  3836. } else {
  3837. $default_value = "n";
  3838. }
  3839. print "Use icons? (y/n) [$WHT$default_value$NRM]: $WHT";
  3840. $use_icons = <STDIN>;
  3841. if ( ( $use_icons =~ /^y\n/i ) || ( ( $use_icons =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3842. $use_icons = 'true';
  3843. } else {
  3844. $use_icons = 'false';
  3845. }
  3846. return $use_icons;
  3847. }
  3848. # php recode
  3849. sub commandB4 {
  3850. print "Enable this option if you want to use php recode functions to read\n";
  3851. print "emails written in charset that differs from the one that is set in\n";
  3852. print "translation selected by user. Code is experimental, it might cause\n";
  3853. print "errors, if email contains charset unsupported by recode or if your\n";
  3854. print "php does not have recode support.\n";
  3855. print "\n";
  3856. if ( lc($use_php_recode) eq 'true' ) {
  3857. $default_value = "y";
  3858. } else {
  3859. $default_value = "n";
  3860. }
  3861. print "Use php recode functions? (y/n) [$WHT$default_value$NRM]: $WHT";
  3862. $use_php_recode = <STDIN>;
  3863. if ( ( $use_php_recode =~ /^y\n/i ) || ( ( $use_php_recode =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3864. $use_php_recode = 'true';
  3865. } else {
  3866. $use_php_recode = 'false';
  3867. }
  3868. return $use_php_recode;
  3869. }
  3870. # php iconv
  3871. sub commandB5 {
  3872. print "Enable this option if you want to use php iconv functions to read\n";
  3873. print "emails written in charset that differs from the one that is set in\n";
  3874. print "translation selected by user. Code is experimental, it works only\n";
  3875. print "with translations that use utf-8 charset. Code might cause errors,\n";
  3876. print "if email contains charset unsupported by iconv or if your php does\n";
  3877. print "not have iconv support.\n";
  3878. print "\n";
  3879. if ( lc($use_php_iconv) eq 'true' ) {
  3880. $default_value = "y";
  3881. } else {
  3882. $default_value = "n";
  3883. }
  3884. print "Use php iconv functions? (y/n) [$WHT$default_value$NRM]: $WHT";
  3885. $use_php_iconv = <STDIN>;
  3886. if ( ( $use_php_iconv =~ /^y\n/i ) || ( ( $use_php_iconv =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3887. $use_php_iconv = 'true';
  3888. } else {
  3889. $use_php_iconv = 'false';
  3890. }
  3891. return $use_php_iconv;
  3892. }
  3893. # configtest block
  3894. sub commandB6 {
  3895. print "Enable this option if you want to check SquirrelMail configuration\n";
  3896. print "remotely with configtest.php script.\n";
  3897. print "\n";
  3898. if ( lc($allow_remote_configtest) eq 'true' ) {
  3899. $default_value = "y";
  3900. } else {
  3901. $default_value = "n";
  3902. }
  3903. print "Allow remote configuration tests? (y/n) [$WHT$default_value$NRM]: $WHT";
  3904. $allow_remote_configtest = <STDIN>;
  3905. if ( ( $allow_remote_configtest =~ /^y\n/i ) || ( ( $allow_remote_configtest =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
  3906. $allow_remote_configtest = 'true';
  3907. } else {
  3908. $allow_remote_configtest = 'false';
  3909. }
  3910. return $allow_remote_configtest;
  3911. }
  3912. # Default Icon theme
  3913. sub commandB7 {
  3914. print "You may change the path to the default icon theme to be used, if icons\n";
  3915. print "have been enabled. This theme will be used when an icon cannot be\n";
  3916. print "found in the current theme, or when no icon theme is specified. If\n";
  3917. print "left blank, and icons are enabled, the default theme will be used\n";
  3918. print "from images/themes/default/.\n";
  3919. print "\n";
  3920. print "To clear out an existing value, just type a space for the input.\n";
  3921. print "\n";
  3922. print "Please be aware of the following: \n";
  3923. print " - Relative URLs are relative to the config dir\n";
  3924. print " to use the icon themes directory, use ../images/themes/newtheme/\n";
  3925. print " - The icon theme may be outside the SquirrelMail directory, but\n";
  3926. print " it must be web accessible.\n";
  3927. print "[$WHT$icon_theme_def$NRM]: $WHT";
  3928. $new_icon_theme_def = <STDIN>;
  3929. if ( $new_icon_theme_def eq "\n" ) {
  3930. $new_icon_theme_def = $icon_theme_def;
  3931. } else {
  3932. $new_icon_theme_def =~ s/[\r\n]//g;
  3933. }
  3934. $new_icon_theme_def =~ s/^\s*//;
  3935. return $new_icon_theme_def;
  3936. }
  3937. sub save_data {
  3938. $tab = " ";
  3939. if ( open( CF, ">config.php" ) ) {
  3940. print CF "<?php\n";
  3941. print CF "\n";
  3942. print CF "/**\n";
  3943. print CF " * SquirrelMail Configuration File\n";
  3944. print CF " * Created using the configure script, conf.pl\n";
  3945. print CF " */\n";
  3946. print CF "\n";
  3947. print CF "global \$version;\n";
  3948. if ($print_config_version) {
  3949. print CF "\$config_version = '$print_config_version';\n";
  3950. }
  3951. # integer
  3952. print CF "\$config_use_color = $config_use_color;\n";
  3953. print CF "\n";
  3954. # string
  3955. print CF "\$org_name = \"$org_name\";\n";
  3956. # string
  3957. print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n";
  3958. $org_logo_width |= 0;
  3959. $org_logo_height |= 0;
  3960. # string
  3961. print CF "\$org_logo_width = '$org_logo_width';\n";
  3962. # string
  3963. print CF "\$org_logo_height = '$org_logo_height';\n";
  3964. # string that can contain variables.
  3965. print CF "\$org_title = \"$org_title\";\n";
  3966. # string
  3967. print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n";
  3968. # string
  3969. print CF "\$frame_top = '$frame_top';\n";
  3970. print CF "\n";
  3971. print CF "\$provider_uri = '$provider_uri';\n";
  3972. print CF "\n";
  3973. print CF "\$provider_name = '$provider_name';\n";
  3974. print CF "\n";
  3975. # string that can contain variables
  3976. print CF "\$motd = \"$motd\";\n";
  3977. print CF "\n";
  3978. # string
  3979. print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
  3980. # string
  3981. print CF "\$default_charset = '$default_charset';\n";
  3982. # boolean
  3983. print CF "\$show_alternative_names = $show_alternative_names;\n";
  3984. # boolean
  3985. print CF "\$aggressive_decoding = $aggressive_decoding;\n";
  3986. # boolean
  3987. print CF "\$lossy_encoding = $lossy_encoding;\n";
  3988. print CF "\n";
  3989. # string
  3990. print CF "\$domain = '$domain';\n";
  3991. # string
  3992. print CF "\$imapServerAddress = '$imapServerAddress';\n";
  3993. # integer
  3994. print CF "\$imapPort = $imapPort;\n";
  3995. # boolean
  3996. print CF "\$useSendmail = $useSendmail;\n";
  3997. # string
  3998. print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
  3999. # integer
  4000. print CF "\$smtpPort = $smtpPort;\n";
  4001. # string
  4002. print CF "\$sendmail_path = '$sendmail_path';\n";
  4003. # string
  4004. print CF "\$sendmail_args = '$sendmail_args';\n";
  4005. # boolean
  4006. # print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
  4007. # boolean
  4008. print CF "\$pop_before_smtp = $pop_before_smtp;\n";
  4009. # string
  4010. print CF "\$imap_server_type = '$imap_server_type';\n";
  4011. # boolean
  4012. print CF "\$invert_time = $invert_time;\n";
  4013. # string
  4014. print CF "\$optional_delimiter = '$optional_delimiter';\n";
  4015. # string
  4016. print CF "\$encode_header_key = '$encode_header_key';\n";
  4017. print CF "\n";
  4018. # string
  4019. print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
  4020. # string
  4021. print CF "\$trash_folder = '$trash_folder';\n";
  4022. # string
  4023. print CF "\$sent_folder = '$sent_folder';\n";
  4024. # string
  4025. print CF "\$draft_folder = '$draft_folder';\n";
  4026. # boolean
  4027. print CF "\$default_move_to_trash = $default_move_to_trash;\n";
  4028. # boolean
  4029. print CF "\$default_move_to_sent = $default_move_to_sent;\n";
  4030. # boolean
  4031. print CF "\$default_save_as_draft = $default_save_as_draft;\n";
  4032. # boolean
  4033. print CF "\$show_prefix_option = $show_prefix_option;\n";
  4034. # boolean
  4035. print CF "\$list_special_folders_first = $list_special_folders_first;\n";
  4036. # boolean
  4037. print CF "\$use_special_folder_color = $use_special_folder_color;\n";
  4038. # boolean
  4039. print CF "\$auto_expunge = $auto_expunge;\n";
  4040. # boolean
  4041. print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
  4042. # boolean
  4043. print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
  4044. # integer
  4045. print CF "\$default_unseen_notify = $default_unseen_notify;\n";
  4046. # integer
  4047. print CF "\$default_unseen_type = $default_unseen_type;\n";
  4048. # boolean
  4049. print CF "\$auto_create_special = $auto_create_special;\n";
  4050. # boolean
  4051. print CF "\$delete_folder = $delete_folder;\n";
  4052. # boolean
  4053. print CF "\$noselect_fix_enable = $noselect_fix_enable;\n";
  4054. print CF "\n";
  4055. # string
  4056. print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n";
  4057. # string that can contain a variable
  4058. print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n";
  4059. # integer
  4060. print CF "\$dir_hash_level = $dir_hash_level;\n";
  4061. # string
  4062. print CF "\$default_left_size = '$default_left_size';\n";
  4063. # boolean
  4064. print CF "\$force_username_lowercase = $force_username_lowercase;\n";
  4065. # boolean
  4066. print CF "\$default_use_priority = $default_use_priority;\n";
  4067. # boolean
  4068. print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
  4069. # boolean
  4070. print CF "\$default_use_mdn = $default_use_mdn;\n";
  4071. # boolean
  4072. print CF "\$edit_identity = $edit_identity;\n";
  4073. # boolean
  4074. print CF "\$edit_name = $edit_name;\n";
  4075. # boolean
  4076. print CF "\$hide_auth_header = $hide_auth_header;\n";
  4077. # boolean
  4078. print CF "\$disable_thread_sort = $disable_thread_sort;\n";
  4079. # boolean
  4080. print CF "\$disable_server_sort = $disable_server_sort;\n";
  4081. # boolean
  4082. print CF "\$allow_charset_search = $allow_charset_search;\n";
  4083. # integer
  4084. print CF "\$allow_advanced_search = $allow_advanced_search;\n";
  4085. print CF "\n";
  4086. # integer
  4087. print CF "\$time_zone_type = $time_zone_type;\n";
  4088. print CF "\n";
  4089. # string
  4090. print CF "\$config_location_base = '$config_location_base';\n";
  4091. print CF "\n";
  4092. # boolean
  4093. print CF "\$disable_plugins = $disable_plugins;\n";
  4094. # string
  4095. print CF "\$disable_plugins_user = '$disable_plugins_user';\n";
  4096. print CF "\n";
  4097. # all plugins are strings
  4098. for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
  4099. print CF "\$plugins[] = '$plugins[$ct]';\n";
  4100. }
  4101. print CF "\n";
  4102. # strings
  4103. if ( $user_theme_default eq '' ) { $user_theme_default = '0'; }
  4104. print CF "\$user_theme_default = $user_theme_default;\n";
  4105. for ( $count = 0 ; $count <= $#user_theme_name ; $count++ ) {
  4106. if ($user_theme_path[$count] eq 'none') {
  4107. $path = '\'none\'';
  4108. } else {
  4109. $path = &change_to_SM_path($user_theme_path[$count]);
  4110. }
  4111. print CF "\$user_themes[$count]['PATH'] = " . $path . ";\n";
  4112. # escape theme name so it can contain single quotes.
  4113. $esc_name = $user_theme_name[$count];
  4114. $esc_name =~ s/\\/\\\\/g;
  4115. $esc_name =~ s/'/\\'/g;
  4116. print CF "\$user_themes[$count]['NAME'] = '$esc_name';\n";
  4117. }
  4118. print CF "\n";
  4119. if ( $icon_theme_def eq '' ) { $icon_theme_def = '0'; }
  4120. print CF "\$icon_theme_def = $icon_theme_def;\n";
  4121. if ( $icon_theme_fallback eq '' ) { $icon_theme_fallback = '0'; }
  4122. print CF "\$icon_theme_fallback = $icon_theme_fallback;\n";
  4123. for ( $count = 0 ; $count <= $#icon_theme_name ; $count++ ) {
  4124. $path = $icon_theme_path[$count];
  4125. if ($path eq 'none' || $path eq 'template') {
  4126. $path = "'".$path."'";
  4127. } else {
  4128. $path = &change_to_SM_path($icon_theme_path[$count]);
  4129. }
  4130. print CF "\$icon_themes[$count]['PATH'] = " . $path . ";\n";
  4131. # escape theme name so it can contain single quotes.
  4132. $esc_name = $icon_theme_name[$count];
  4133. $esc_name =~ s/\\/\\\\/g;
  4134. $esc_name =~ s/'/\\'/g;
  4135. print CF "\$icon_themes[$count]['NAME'] = '$esc_name';\n";
  4136. }
  4137. print CF "\n";
  4138. if ( $templateset_default eq '' ) { $templateset_default = 'default'; }
  4139. print CF "\$templateset_default = '$templateset_default';\n";
  4140. if ( $templateset_fallback eq '' ) { $templateset_fallback = 'default'; }
  4141. print CF "\$templateset_fallback = '$templateset_fallback';\n";
  4142. for ( $count = 0 ; $count <= $#templateset_name ; $count++ ) {
  4143. print CF "\$aTemplateSet[$count]['ID'] = '" . $templateset_id[$count] . "';\n";
  4144. # escape theme name so it can contain single quotes.
  4145. $esc_name = $templateset_name[$count];
  4146. $esc_name =~ s/\\/\\\\/g;
  4147. $esc_name =~ s/'/\\'/g;
  4148. print CF "\$aTemplateSet[$count]['NAME'] = '$esc_name';\n";
  4149. }
  4150. print CF "\n";
  4151. # integer
  4152. print CF "\$default_fontsize = '$default_fontsize';\n";
  4153. # string
  4154. print CF "\$default_fontset = '$default_fontset';\n";
  4155. print CF "\n";
  4156. # assoc. array (maybe initial value should be set somewhere else)
  4157. print CF '$fontsets = array();'."\n";
  4158. while (($fontset_name, $fontset_value) = each(%fontsets)) {
  4159. print CF "\$fontsets\['$fontset_name'\] = '$fontset_value';\n";
  4160. }
  4161. print CF "\n";
  4162. ## Address books
  4163. # boolean
  4164. print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
  4165. for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
  4166. print CF "\$ldap_server[$count] = array(\n";
  4167. # string
  4168. print CF " 'host' => '$ldap_host[$count]',\n";
  4169. # string
  4170. print CF " 'base' => '$ldap_base[$count]'";
  4171. if ( $ldap_name[$count] ) {
  4172. print CF ",\n";
  4173. # string
  4174. print CF " 'name' => '$ldap_name[$count]'";
  4175. }
  4176. if ( $ldap_port[$count] ) {
  4177. print CF ",\n";
  4178. # integer
  4179. print CF " 'port' => $ldap_port[$count]";
  4180. }
  4181. if ( $ldap_charset[$count] ) {
  4182. print CF ",\n";
  4183. # string
  4184. print CF " 'charset' => '$ldap_charset[$count]'";
  4185. }
  4186. if ( $ldap_maxrows[$count] ) {
  4187. print CF ",\n";
  4188. # integer
  4189. print CF " 'maxrows' => $ldap_maxrows[$count]";
  4190. }
  4191. # string
  4192. if ( $ldap_filter[$count] ) {
  4193. print CF ",\n";
  4194. print CF " 'filter' => '$ldap_filter[$count]'";
  4195. }
  4196. if ( $ldap_binddn[$count] ) {
  4197. print CF ",\n";
  4198. # string
  4199. print CF " 'binddn' => '$ldap_binddn[$count]'";
  4200. if ( $ldap_bindpw[$count] ) {
  4201. print CF ",\n";
  4202. # string
  4203. print CF " 'bindpw' => '$ldap_bindpw[$count]'";
  4204. }
  4205. }
  4206. if ( $ldap_protocol[$count] ) {
  4207. print CF ",\n";
  4208. # integer
  4209. print CF " 'protocol' => $ldap_protocol[$count]";
  4210. }
  4211. if ( $ldap_limit_scope[$count] ) {
  4212. print CF ",\n";
  4213. # boolean
  4214. print CF " 'limit_scope' => $ldap_limit_scope[$count]";
  4215. }
  4216. if ( $ldap_listing[$count] ) {
  4217. print CF ",\n";
  4218. # boolean
  4219. print CF " 'listing' => $ldap_listing[$count]";
  4220. }
  4221. if ( $ldap_writeable[$count] ) {
  4222. print CF ",\n";
  4223. # boolean
  4224. print CF " 'writeable' => $ldap_writeable[$count]";
  4225. }
  4226. if ( $ldap_search_tree[$count] ) {
  4227. print CF ",\n";
  4228. # integer
  4229. print CF " 'search_tree' => $ldap_search_tree[$count]";
  4230. }
  4231. if ( $ldap_listing[$count] ) {
  4232. print CF ",\n";
  4233. # boolean
  4234. print CF " 'starttls' => $ldap_starttls[$count]";
  4235. }
  4236. print CF "\n";
  4237. print CF ");\n";
  4238. print CF "\n";
  4239. }
  4240. # string
  4241. print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
  4242. # string
  4243. print CF "\$addrbook_table = '$addrbook_table';\n\n";
  4244. # string
  4245. print CF "\$prefs_dsn = '$prefs_dsn';\n";
  4246. # string
  4247. print CF "\$prefs_table = '$prefs_table';\n";
  4248. # string
  4249. print CF "\$prefs_user_field = '$prefs_user_field';\n";
  4250. # integer
  4251. print CF "\$prefs_user_size = $prefs_user_size;\n";
  4252. # string
  4253. print CF "\$prefs_key_field = '$prefs_key_field';\n";
  4254. # integer
  4255. print CF "\$prefs_key_size = $prefs_key_size;\n";
  4256. # string
  4257. print CF "\$prefs_val_field = '$prefs_val_field';\n";
  4258. # integer
  4259. print CF "\$prefs_val_size = $prefs_val_size;\n\n";
  4260. # string
  4261. print CF "\$addrbook_global_dsn = '$addrbook_global_dsn';\n";
  4262. # string
  4263. print CF "\$addrbook_global_table = '$addrbook_global_table';\n";
  4264. # boolean
  4265. print CF "\$addrbook_global_writeable = $addrbook_global_writeable;\n";
  4266. # boolean
  4267. print CF "\$addrbook_global_listing = $addrbook_global_listing;\n\n";
  4268. # string
  4269. print CF "\$abook_global_file = '$abook_global_file';\n";
  4270. # boolean
  4271. print CF "\$abook_global_file_writeable = $abook_global_file_writeable;\n\n";
  4272. # boolean
  4273. print CF "\$abook_global_file_listing = $abook_global_file_listing;\n\n";
  4274. # integer
  4275. print CF "\$abook_file_line_length = $abook_file_line_length;\n\n";
  4276. # boolean
  4277. print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
  4278. # string
  4279. print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
  4280. print CF "\$smtp_sitewide_user = '". quote_single($smtp_sitewide_user) ."';\n";
  4281. print CF "\$smtp_sitewide_pass = '". quote_single($smtp_sitewide_pass) ."';\n";
  4282. # string
  4283. print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
  4284. # boolean
  4285. print CF "\$use_imap_tls = $use_imap_tls;\n";
  4286. # boolean
  4287. print CF "\$use_smtp_tls = $use_smtp_tls;\n";
  4288. # string
  4289. print CF "\$session_name = '$session_name';\n";
  4290. print CF "\n";
  4291. # boolean
  4292. print CF "\$use_iframe = $use_iframe;\n";
  4293. print CF "\n";
  4294. # boolean
  4295. print CF "\$use_icons = $use_icons;\n";
  4296. print CF "\n";
  4297. # boolean
  4298. print CF "\$use_php_recode = $use_php_recode;\n";
  4299. print CF "\n";
  4300. # boolean
  4301. print CF "\$use_php_iconv = $use_php_iconv;\n";
  4302. print CF "\n";
  4303. # boolean
  4304. print CF "\$allow_remote_configtest = $allow_remote_configtest;\n";
  4305. print CF "\n";
  4306. close CF;
  4307. print "Data saved in config.php\n";
  4308. build_plugin_hook_array();
  4309. } else {
  4310. print "Error saving config.php: $!\n";
  4311. }
  4312. }
  4313. sub set_defaults {
  4314. clear_screen();
  4315. print $WHT. "SquirrelMail Configuration : " . $NRM;
  4316. if ( $config == 1 ) { print "Read: config.php"; }
  4317. elsif ( $config == 2 ) { print "Read: config_default.php"; }
  4318. print "\n";
  4319. print "---------------------------------------------------------\n";
  4320. print "While we have been building SquirrelMail, we have discovered some\n";
  4321. print "preferences that work better with some servers that don't work so\n";
  4322. print "well with others. If you select your IMAP server, this option will\n";
  4323. print "set some pre-defined settings for that server.\n";
  4324. print "\n";
  4325. print "Please note that you will still need to go through and make sure\n";
  4326. print "everything is correct. This does not change everything. There are\n";
  4327. print "only a few settings that this will change.\n";
  4328. print "\n";
  4329. $continue = 0;
  4330. while ( $continue != 1 ) {
  4331. print "Please select your IMAP server:\n";
  4332. print $list_supported_imap_servers;
  4333. print "\n";
  4334. print " quit = Do not change anything\n";
  4335. print "\n";
  4336. print "Command >> ";
  4337. $server = <STDIN>;
  4338. $server =~ s/[\r\n]//g;
  4339. # variable is used to display additional messages.
  4340. $message = "";
  4341. print "\n";
  4342. if ( $server eq "cyrus" ) {
  4343. $imap_server_type = "cyrus";
  4344. $default_folder_prefix = "";
  4345. $trash_folder = "INBOX.Trash";
  4346. $sent_folder = "INBOX.Sent";
  4347. $draft_folder = "INBOX.Drafts";
  4348. $show_prefix_option = false;
  4349. $default_sub_of_inbox = true;
  4350. $show_contain_subfolders_option = false;
  4351. $optional_delimiter = ".";
  4352. $disp_default_folder_prefix = "<none>";
  4353. $force_username_lowercase = false;
  4354. # Delimiter might differ if unixhierarchysep is set to yes.
  4355. $message = "\nIf you have enabled unixhierarchysep, you must change delimiter and special folder names.\n";
  4356. $continue = 1;
  4357. } elsif ( $server eq "uw" ) {
  4358. $imap_server_type = "uw";
  4359. $default_folder_prefix = "mail/";
  4360. $trash_folder = "Trash";
  4361. $sent_folder = "Sent";
  4362. $draft_folder = "Drafts";
  4363. $show_prefix_option = true;
  4364. $default_sub_of_inbox = false;
  4365. $show_contain_subfolders_option = true;
  4366. $optional_delimiter = "/";
  4367. $disp_default_folder_prefix = $default_folder_prefix;
  4368. $delete_folder = true;
  4369. $force_username_lowercase = true;
  4370. $continue = 1;
  4371. } elsif ( $server eq "exchange" ) {
  4372. $imap_server_type = "exchange";
  4373. $default_folder_prefix = "";
  4374. $default_sub_of_inbox = true;
  4375. $trash_folder = "INBOX/Deleted Items";
  4376. $sent_folder = "INBOX/Sent Items";
  4377. $drafts_folder = "INBOX/Drafts";
  4378. $show_prefix_option = false;
  4379. $show_contain_subfolders_option = false;
  4380. $optional_delimiter = "detect";
  4381. $disp_default_folder_prefix = "<none>";
  4382. $force_username_lowercase = true;
  4383. $continue = 1;
  4384. } elsif ( $server eq "courier" ) {
  4385. $imap_server_type = "courier";
  4386. $default_folder_prefix = "INBOX.";
  4387. $trash_folder = "Trash";
  4388. $sent_folder = "Sent";
  4389. $draft_folder = "Drafts";
  4390. $show_prefix_option = false;
  4391. $default_sub_of_inbox = false;
  4392. $show_contain_subfolders_option = false;
  4393. $optional_delimiter = ".";
  4394. $disp_default_folder_prefix = $default_folder_prefix;
  4395. $delete_folder = true;
  4396. $force_username_lowercase = false;
  4397. $continue = 1;
  4398. } elsif ( $server eq "macosx" ) {
  4399. $imap_server_type = "macosx";
  4400. $default_folder_prefix = "INBOX/";
  4401. $trash_folder = "Trash";
  4402. $sent_folder = "Sent";
  4403. $draft_folder = "Drafts";
  4404. $show_prefix_option = false;
  4405. $default_sub_of_inbox = true;
  4406. $show_contain_subfolders_option = false;
  4407. $optional_delimiter = "detect";
  4408. $allow_charset_search = false;
  4409. $disp_default_folder_prefix = $default_folder_prefix;
  4410. $continue = 1;
  4411. } elsif ( $server eq "hmailserver" ) {
  4412. $imap_server_type = "hmailserver";
  4413. $default_folder_prefix = "";
  4414. $trash_folder = "INBOX.Trash";
  4415. $sent_folder = "INBOX.Sent";
  4416. $draft_folder = "INBOX.Drafts";
  4417. $show_prefix_option = false;
  4418. $default_sub_of_inbox = true;
  4419. $show_contain_subfolders_option = false;
  4420. $optional_delimiter = "detect";
  4421. $allow_charset_search = false;
  4422. $disp_default_folder_prefix = $default_folder_prefix;
  4423. $delete_folder = false;
  4424. $force_username_lowercase = false;
  4425. $continue = 1;
  4426. } elsif ( $server eq "mercury32" ) {
  4427. $imap_server_type = "mercury32";
  4428. $default_folder_prefix = "";
  4429. $trash_folder = "Trash";
  4430. $sent_folder = "Sent";
  4431. $draft_folder = "Drafts";
  4432. $show_prefix_option = false;
  4433. $default_sub_of_inbox = true;
  4434. $show_contain_subfolders_option = true;
  4435. $optional_delimiter = "detect";
  4436. $delete_folder = true;
  4437. $force_username_lowercase = true;
  4438. $continue = 1;
  4439. } elsif ( $server eq "dovecot" ) {
  4440. $imap_server_type = "dovecot";
  4441. $default_folder_prefix = "";
  4442. $trash_folder = "Trash";
  4443. $sent_folder = "Sent";
  4444. $draft_folder = "Drafts";
  4445. $show_prefix_option = false;
  4446. $default_sub_of_inbox = false;
  4447. $show_contain_subfolders_option = false;
  4448. $delete_folder = false;
  4449. $force_username_lowercase = true;
  4450. $optional_delimiter = "detect";
  4451. $disp_default_folder_prefix = "<none>";
  4452. $continue = 1;
  4453. } elsif ( $server eq "bincimap" ) {
  4454. $imap_server_type = "bincimap";
  4455. $default_folder_prefix = "INBOX/";
  4456. $trash_folder = "Trash";
  4457. $sent_folder = "Sent";
  4458. $draft_folder = "Drafts";
  4459. $show_prefix_option = false;
  4460. $default_sub_of_inbox = false;
  4461. $show_contain_subfolders_option = false;
  4462. $delete_folder = true;
  4463. $force_username_lowercase = false;
  4464. $optional_delimiter = "detect";
  4465. $disp_default_folder_prefix = $default_folder_prefix;
  4466. # Default folder prefix depends on used depot.
  4467. $message = "\nIf you use IMAPdir depot, you must set default folder prefix to empty string.\n";
  4468. $continue = 1;
  4469. } elsif ( $server eq "quit" ) {
  4470. $continue = 1;
  4471. } else {
  4472. $disp_default_folder_prefix = $default_folder_prefix;
  4473. print "Unrecognized server: $server\n";
  4474. print "\n";
  4475. }
  4476. print " imap_server_type = $imap_server_type\n";
  4477. print " default_folder_prefix = $disp_default_folder_prefix\n";
  4478. print " trash_folder = $trash_folder\n";
  4479. print " sent_folder = $sent_folder\n";
  4480. print " draft_folder = $draft_folder\n";
  4481. print " show_prefix_option = $show_prefix_option\n";
  4482. print " default_sub_of_inbox = $default_sub_of_inbox\n";
  4483. print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
  4484. print " optional_delimiter = $optional_delimiter\n";
  4485. print " delete_folder = $delete_folder\n";
  4486. print " force_username_lowercase = $force_username_lowercase\n";
  4487. print "$message";
  4488. }
  4489. print "\nPress enter to continue...";
  4490. $tmp = <STDIN>;
  4491. }
  4492. # This subroutine corrects relative paths to ensure they
  4493. # will work within the SM space. If the path falls within
  4494. # the SM directory tree, the SM_PATH variable will be
  4495. # prepended to the path, if not, then the path will be
  4496. # converted to an absolute path, e.g.
  4497. # '../images/logo.gif' --> SM_PATH . 'images/logo.gif'
  4498. # '../../someplace/data' --> '/absolute/path/someplace/data'
  4499. # 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif'
  4500. # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
  4501. # 'http://whatever/' --> 'http://whatever'
  4502. # $some_var/path --> "$some_var/path"
  4503. sub change_to_SM_path() {
  4504. my ($old_path) = @_;
  4505. my $new_path = '';
  4506. my @rel_path;
  4507. my @abs_path;
  4508. my $subdir;
  4509. # If the path is absolute, don't bother.
  4510. return "\'" . $old_path . "\'" if ( $old_path eq '');
  4511. return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http)/ );
  4512. return "\'" . $old_path . "\'" if ( $old_path =~ /^\w:\// );
  4513. return $old_path if ( $old_path =~ /^\'(\/|http)/ );
  4514. return $old_path if ( $old_path =~ /^\'\w:\// );
  4515. return $old_path if ( $old_path =~ /^SM_PATH/);
  4516. if ( $old_path =~ /^\$/ ) {
  4517. # check if it's a single var, or a $var/path combination
  4518. # if it's $var/path, enclose in ""
  4519. if ( $old_path =~ /\// ) {
  4520. return '"'.$old_path.'"';
  4521. }
  4522. return $old_path;
  4523. }
  4524. # Remove remaining '
  4525. $old_path =~ s/\'//g;
  4526. # For relative paths, split on '../'
  4527. @rel_path = split(/\.\.\//, $old_path);
  4528. if ( $#rel_path > 1 ) {
  4529. # more than two levels away. Make it absolute.
  4530. @abs_path = split(/\//, $dir);
  4531. # Lop off the relative pieces of the absolute path..
  4532. for ( $i = 0; $i <= $#rel_path; $i++ ) {
  4533. pop @abs_path;
  4534. shift @rel_path;
  4535. }
  4536. push @abs_path, @rel_path;
  4537. $new_path = "\'" . join('/', @abs_path) . "\'";
  4538. } elsif ( $#rel_path > 0 ) {
  4539. # it's within the SM tree, prepend SM_PATH
  4540. $new_path = $old_path;
  4541. $new_path =~ s/^\.\.\//SM_PATH . \'/;
  4542. $new_path .= "\'";
  4543. } else {
  4544. # Last, it's a relative path without any leading '.'
  4545. # Prepend SM_PATH and config, since the paths are
  4546. # relative to the config directory
  4547. $new_path = "SM_PATH . \'config/" . $old_path . "\'";
  4548. }
  4549. return $new_path;
  4550. }
  4551. # Change SM_PATH to admin-friendly version, e.g.:
  4552. # SM_PATH . 'images/logo.gif' --> '../images/logo.gif'
  4553. # SM_PATH . 'config/some.php' --> 'some.php'
  4554. # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
  4555. # 'http://whatever/' --> 'http://whatever'
  4556. sub change_to_rel_path() {
  4557. my ($old_path) = @_;
  4558. my $new_path = $old_path;
  4559. if ( $old_path =~ /^SM_PATH/ ) {
  4560. # FIXME: the following replacement loses the opening quote mark!
  4561. $new_path =~ s/^SM_PATH . \'/\.\.\//;
  4562. $new_path =~ s/\.\.\/config\///;
  4563. }
  4564. return $new_path;
  4565. }
  4566. # Attempts to auto-detect if a specific auth mechanism is supported.
  4567. # Called by 'command112a' and 'command112b'
  4568. # ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
  4569. sub detect_auth_support {
  4570. # Try loading IO::Socket
  4571. unless (eval("use IO::Socket; 1")) {
  4572. print "Perl IO::Socket module is not available.";
  4573. return undef;
  4574. }
  4575. # Misc setup
  4576. my $service = shift;
  4577. my $host = shift;
  4578. my $mech = shift;
  4579. # Sanity checks
  4580. if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
  4581. # Error - wrong # of args
  4582. print "BAD ARGS!\n";
  4583. return undef;
  4584. }
  4585. if ($service eq 'SMTP') {
  4586. $cmd = "AUTH $mech\r\n";
  4587. $logout = "QUIT\r\n";
  4588. } elsif ($service eq 'IMAP') {
  4589. $cmd = "A01 AUTHENTICATE $mech\n";
  4590. $logout = "C01 LOGOUT\n";
  4591. } else {
  4592. # unknown service - whoops.
  4593. return undef;
  4594. }
  4595. # Get this show on the road
  4596. my $sock=IO::Socket::INET->new($host);
  4597. if (!defined($sock)) {
  4598. # Connect failed
  4599. return undef;
  4600. }
  4601. my $discard = <$sock>; # Server greeting/banner - who cares..
  4602. if ($service eq 'SMTP') {
  4603. # Say hello first..
  4604. print $sock "HELO $domain\r\n";
  4605. $discard = <$sock>; # Yeah yeah, you're happy to see me..
  4606. }
  4607. print $sock $cmd;
  4608. my $response = <$sock>;
  4609. chomp($response);
  4610. if (!defined($response)) {
  4611. return undef;
  4612. }
  4613. # So at this point, we have a response, and it is (hopefully) valid.
  4614. if ($service eq 'SMTP') {
  4615. if (($response =~ /^535/) or ($response =~/^502/)) {
  4616. # Not supported
  4617. print $sock $logout;
  4618. close $sock;
  4619. return 'NO';
  4620. } elsif ($response =~ /^503/) {
  4621. #Something went wrong
  4622. return undef;
  4623. }
  4624. } elsif ($service eq 'IMAP') {
  4625. if ($response =~ /^A01/) {
  4626. # Not supported
  4627. print $sock $logout;
  4628. close $sock;
  4629. return 'NO';
  4630. }
  4631. } else {
  4632. # Unknown service - this shouldn't be able to happen.
  4633. close $sock;
  4634. return undef;
  4635. }
  4636. # If it gets here, the mech is supported
  4637. print $sock "*\n"; # Attempt to cancel authentication
  4638. print $sock $logout; # Try to log out, but we don't really care if this fails
  4639. close $sock;
  4640. return 'YES';
  4641. }
  4642. # trims whitespace
  4643. # Example code from O'Reilly Perl Cookbook
  4644. sub trim {
  4645. my @out = @_;
  4646. for (@out) {
  4647. s/^\s+//;
  4648. s/\s+$//;
  4649. }
  4650. return wantarray ? @out : $out[0];
  4651. }
  4652. sub clear_screen() {
  4653. if ( $^O =~ /^mswin/i) {
  4654. system "cls";
  4655. } else {
  4656. system "clear";
  4657. }
  4658. }
  4659. # checks IMAP mailbox name. Refuses to accept 8bit folders
  4660. # returns 0 (folder name is not correct) or 1 (folder name is correct)
  4661. sub check_imap_folder($) {
  4662. my $folder_name = shift(@_);
  4663. if ($folder_name =~ /[\x80-\xFFFF]/) {
  4664. print "Folder name contains 8bit characters. Configuration utility requires\n";
  4665. print "UTF7-IMAP encoded folder names.\n";
  4666. print "Press enter to continue...";
  4667. my $tmp = <STDIN>;
  4668. return 0;
  4669. } elsif ($folder_name =~ /[&\*\%]/) {
  4670. # check for ampersand and list-wildcards
  4671. print "Folder name contains special UTF7-IMAP characters.\n";
  4672. print "Are you sure that folder name is correct? (yN): ";
  4673. my $tmp = <STDIN>;
  4674. $tmp = lc(trim($tmp));
  4675. if ($tmp =~ /^y$/) {
  4676. return 1;
  4677. } else {
  4678. return 0;
  4679. }
  4680. } else {
  4681. return 1;
  4682. }
  4683. }
  4684. # quotes string written in single quotes
  4685. sub quote_single($) {
  4686. my $string = shift(@_);
  4687. $string =~ s/\'/\\'/g;
  4688. return $string;
  4689. }
  4690. # parses the setup.php files for all activated plugins and
  4691. # builds static plugin hooks array so we don't have to load
  4692. # ALL plugins are runtime and build the hook array on every
  4693. # page request
  4694. #
  4695. # hook array is saved in config/plugin_hooks.php
  4696. #
  4697. # Note the $verbose variable at the top of this routine
  4698. # can be set to zero to quiet it down.
  4699. #
  4700. # NOTE/FIXME: we aren't necessarily interested in writing
  4701. # a full-blown PHP parsing engine, so plenty
  4702. # of assumptions are included herein about the
  4703. # coding of the plugin setup files, and things
  4704. # like commented out curly braces or other
  4705. # such oddities can break this in a bad way.
  4706. #
  4707. sub build_plugin_hook_array() {
  4708. $verbose = 1;
  4709. if ($verbose) {
  4710. print "\n\n";
  4711. }
  4712. if ( open( HOOKFILE, ">plugin_hooks.php" ) ) {
  4713. print HOOKFILE "<?php\n";
  4714. print HOOKFILE "\n";
  4715. print HOOKFILE "/**\n";
  4716. print HOOKFILE " * SquirrelMail Plugin Hook Registration File\n";
  4717. print HOOKFILE " * Auto-generated using the configure script, conf.pl\n";
  4718. print HOOKFILE " */\n";
  4719. print HOOKFILE "\n";
  4720. print HOOKFILE "global \$squirrelmail_plugin_hooks;\n";
  4721. print HOOKFILE "\n";
  4722. PLUGIN: for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
  4723. if ($verbose) {
  4724. print "Activating plugin \"" . $plugins[$ct] . "\"...\n";
  4725. }
  4726. $setup_file = '../plugins/' . $plugins[$ct] . '/setup.php';
  4727. if ( -e "$setup_file" ) {
  4728. # Make sure that file is readable
  4729. if (! -r "$setup_file") {
  4730. print "\n";
  4731. print "WARNING:\n";
  4732. print "The file \"$setup_file\" was found, but you don't\n";
  4733. print "have rights to read it. The plugin \"";
  4734. print $plugins[$ct] . "\" will not be activated until you fix this.\n";
  4735. print "\nPress enter to continue";
  4736. $ctu = <STDIN>;
  4737. print "\n";
  4738. next;
  4739. }
  4740. open( FILE, "$setup_file" );
  4741. $inside_init_fxn = 0;
  4742. $brace_count = 0;
  4743. while ( $line = <FILE> ) {
  4744. # throw away lines until we get to target function
  4745. #
  4746. if (!$inside_init_fxn
  4747. && $line !~ /^\s*function\s*squirrelmail_plugin_init_/i) {
  4748. next;
  4749. }
  4750. $inside_init_fxn = 1;
  4751. # count open braces
  4752. #
  4753. if ($line =~ /{/) {
  4754. $brace_count++;
  4755. }
  4756. # count close braces
  4757. #
  4758. if ($line =~ /}/) {
  4759. $brace_count--;
  4760. # leaving <plugin>_init() function...
  4761. if ($brace_count == 0) {
  4762. close(FILE);
  4763. next PLUGIN;
  4764. }
  4765. }
  4766. # throw away lines that are not exactly one "brace set" deep
  4767. #
  4768. if ($brace_count > 1) {
  4769. next;
  4770. }
  4771. # also not interested in lines that are not
  4772. # hook registration points
  4773. #
  4774. if ($line !~ /^\s*\$squirrelmail_plugin_hooks/i) {
  4775. next;
  4776. }
  4777. # if $line does not have an ending semicolon,
  4778. # we need to recursively read in subsequent
  4779. # lines until we find one
  4780. while ( $line !~ /;\s*$/ ) {
  4781. $line =~ s/[\n\r]\s*$//;
  4782. $line .= <FILE>;
  4783. }
  4784. $line =~ s/^\s+//;
  4785. $line =~ s/^\$//;
  4786. $var = $line;
  4787. $var =~ s/=/EQUALS/;
  4788. if ( $var =~ /^([a-z])/i ) {
  4789. @options = split ( /\s*EQUALS\s*/, $var );
  4790. $options[1] =~ s/[\n\r]//g;
  4791. $options[1] =~ s/[\'\"];\s*$//;
  4792. $options[1] =~ s/;$//;
  4793. $options[1] =~ s/^[\'\"]//;
  4794. # de-escape escaped strings
  4795. $options[1] =~ s/\\'/'/g;
  4796. $options[1] =~ s/\\\\/\\/g;
  4797. if ( $options[0] =~ /^squirrelmail_plugin_hooks\s*\[\s*['"]([a-z0-9 \/._*-]+)['"]\s*\]\s*\[\s*['"]([0-9a-z._-]+)['"]\s*\]/i ) {
  4798. $hook_name = $1;
  4799. $hooked_plugin_name = $2;
  4800. # Note: if we wanted to stop plugins from registering
  4801. # a *different* plugin on a hook, we could catch
  4802. # it here, however this has actually proven to be
  4803. # a useful *feature*
  4804. #if ($hooked_plugin_name ne $plugins[$ct]) {
  4805. # print "...plugin is tring to hook in under different name...\n";
  4806. #}
  4807. #FIXME: do we want to count the number of hook registrations for each plugin and warn if a plugin doesn't have any?
  4808. # hook registration has been found!
  4809. if ($verbose) {
  4810. if ($hooked_plugin_name ne $plugins[$ct]) {
  4811. print " registering on hook \"" . $hook_name . "\" (as \"$hooked_plugin_name\" plugin)\n";
  4812. } else {
  4813. print " registering on hook \"" . $hook_name . "\"\n";
  4814. }
  4815. }
  4816. $line =~ s/ {2,}/ /g;
  4817. $line =~ s/=/\n =/;
  4818. print HOOKFILE "\$$line";
  4819. }
  4820. }
  4821. }
  4822. close(FILE);
  4823. } else {
  4824. print "\n";
  4825. print "WARNING:\n";
  4826. print "The file \"$setup_file\" was not found.\n";
  4827. print "The plugin \"" . $plugins[$ct];
  4828. print "\" will not be activated until you fix this.\n";
  4829. print "\nPress enter to continue";
  4830. $ctu = <STDIN>;
  4831. print "\n";
  4832. next;
  4833. }
  4834. }
  4835. print HOOKFILE "\n\n";
  4836. close(HOOKFILE);
  4837. # if ($verbose) {
  4838. print "\nDone activating plugins; registration data saved in plugin_hooks.php\n\n";
  4839. # }
  4840. } else {
  4841. print "\n";
  4842. print "WARNING:\n";
  4843. print "The file \"plugin_hooks.php\" was not able to be written to.\n";
  4844. print "No plugins will be activated until you fix this.\n";
  4845. print "\nPress enter to continue";
  4846. $ctu = <STDIN>;
  4847. print "\n";
  4848. }
  4849. }