Source for file options.php

Documentation is available at options.php

  1. <?php
  2. /**
  3.  * Administrator Plugin - Options Page
  4.  *
  5.  * This script creates separate page, that allows to review and modify
  6.  * SquirrelMail configuration file.
  7.  *
  8.  * @version $Id: options.php 14840 2020-01-07 07:42:38Z pdontthink $
  9.  * @author Philippe Mingo
  10.  * @copyright (c) 1999-2020 The SquirrelMail Project Team
  11.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  12.  * @package plugins
  13.  * @subpackage administrator
  14.  */
  15.  
  16. /** This is the administrator_options page */
  17. define('PAGE_NAME''administrator_options');
  18.  
  19. /**
  20.  * parse the config file
  21.  *
  22.  * @param string $cfg_file 
  23.  * @access private
  24.  */
  25. function parseConfig$cfg_file {
  26.  
  27.     global $newcfg;
  28.  
  29.     $cfg file$cfg_file );
  30.     $mode '';
  31.     $l count$cfg );
  32.     $modifier FALSE;
  33.  
  34.     for ($i=0;$i<$l;$i++{
  35.         $line trim$cfg[$i);
  36.         $s strlen$line );
  37.         for ($j=0;$j<$s;$j++{
  38.             switch $mode {
  39.             case '=':
  40.                 if $line{$j== '=' {
  41.                     // Ok, we've got a right value, lets detect what type
  42.                     $mode 'D';
  43.                 else if $line{$j== ';' {
  44.                     // hu! end of command
  45.                     $key $mode '';
  46.                 }
  47.                 break;
  48.             case 'K':
  49.                 // Key detect
  50.                 if $line{$j== ' ' {
  51.                     $mode '=';
  52.                 else {
  53.                     $key .= $line{$j};
  54.                 }
  55.                 break;
  56.             case ';':
  57.                 // Skip until next ;
  58.                 if $line{$j== ';' {
  59.                     $mode '';
  60.                 }
  61.                 break;
  62.             case 'S':
  63.                 if $line{$j== '\\' {
  64.                     $value .= $line{$j};
  65.                     $modifier TRUE;
  66.                 else if $line{$j== $delimiter && $modifier === FALSE {
  67.                     // End of string;
  68.                     $newcfg[$key$value $delimiter;
  69.                     $key $value '';
  70.                     $mode ';';
  71.                 else {
  72.                     $value .= $line{$j};
  73.                     $modifier FALSE;
  74.                 }
  75.                 break;
  76.             case 'N':
  77.                 if $line{$j== ';' {
  78.                     $newcfg{$key$value;
  79.                     $key $mode '';
  80.                 else {
  81.                     $value .= $line{$j};
  82.                 }
  83.                 break;
  84.             case 'C':
  85.                 // Comments
  86.                 if $s $j 1  &&
  87.                      $line{$j}.$line{$j+1== '*/' {
  88.                     $mode '';
  89.                     $j++;
  90.                 }
  91.                 break;
  92.             case 'D':
  93.                 // Delimiter detect
  94.                 switch $line{$j{
  95.                 case '"':
  96.                 case "'":
  97.                     // Double quote string
  98.                     $delimiter $value $line{$j};
  99.                     $mode 'S';
  100.                     break;
  101.                 case ' ':
  102.                     // Nothing yet
  103.                     break;
  104.                 default:
  105.                     if strtouppersubstr$line$j) ) == 'TRUE'  {
  106.                         // Boolean TRUE
  107.                         $newcfg{$key'TRUE';
  108.                         $key '';
  109.                         $mode ';';
  110.                     else if strtouppersubstr$line$j) ) == 'FALSE'  {
  111.                         $newcfg{$key'FALSE';
  112.                         $key '';
  113.                         $mode ';';
  114.                     else {
  115.                         // Number or function call
  116.                         $mode 'N';
  117.                         $value $line{$j};
  118.                     }
  119.                 }
  120.                 break;
  121.             default:
  122.                 if $line{$j== '$' {
  123.                     // We must detect $key name
  124.                     $mode 'K';
  125.                     $key '$';
  126.                 else if $s $j {
  127.                 else if strtouppersubstr$line$j) ) == 'GLOBAL ' {
  128.                     // Skip untill next ;
  129.                     $mode ';';
  130.                     $j += 6;
  131.                 else if $line{$j}.$line{$j+1== '/*' {
  132.                     $mode 'C';
  133.                     $j++;
  134.                 else if $line{$j== '#' || $line{$j}.$line{$j+1== '//' {
  135.                     // Delete till the end of the line
  136.                     $j $s;
  137.                 }
  138.             }
  139.         }
  140.     }
  141. }
  142.  
  143. /**
  144.  * Change paths containing SM_PATH to admin-friendly paths
  145.  * relative to the config dir, i.e.:
  146.  *    ''                          --> <empty string>
  147.  *    SM_PATH . 'images/logo.gif' --> ../images/logo.gif
  148.  *    '/absolute/path/logo.gif'   --> /absolute/path/logo.gif
  149.  *    'http://whatever/'          --> http://whatever
  150.  *  Note removal of quotes in returned value
  151.  *  
  152.  * @param string $old_path path that has to be converted
  153.  * @return string new path
  154.  * @access private
  155.  */
  156. function change_to_rel_path($old_path{
  157.     $new_path str_replace("SM_PATH . '""../"$old_path)
  158.     $new_path str_replace("../config/",""$new_path);
  159.     $new_path str_replace("'",""$new_path);
  160.     return $new_path;
  161. }
  162.  
  163. /**
  164.  * Change relative path (relative to config dir) to
  165.  *  internal SM_PATH, i.e.:
  166.  *     empty_string            --> ''
  167.  *     ../images/logo.gif      --> SM_PATH . 'images/logo.gif'
  168.  *     images/logo.gif         --> SM_PATH . 'config/images/logo.gif'
  169.  *     /absolute/path/logo.gif --> '/absolute/path/logo.gif'
  170.  *     C:/absolute/win/path    --> 'C:/absolute/win/path'
  171.  *     http://whatever/        --> 'http://whatever'
  172.  *  
  173.  * @param string $old_path path that has to be converted
  174.  * @return string new path
  175.  * @access private
  176. */     
  177. function change_to_sm_path($old_path{
  178.     if $old_path === '' || $old_path == "''" {
  179.         return "''";
  180.     elseif preg_match("/^(\/|http)/"$old_path||
  181.         substr($old_path,1,2== ':/' {
  182.         return "'" $old_path "'";
  183.     elseif preg_match("/^(\$|SM_PATH)/"$old_path) ) {
  184.         return $old_path;
  185.     }
  186.    
  187.     $new_path '';
  188.     $rel_path explode("../"$old_path);
  189.     if count($rel_path{
  190.         // Since we're relative to the config dir, 
  191.         // more than 1 ../ puts us OUTSIDE the SM tree.
  192.         // get full path to config.php, then pop the filename
  193.         $abs_path explode('/'realpath (SM_PATH 'config/config.php'));
  194.         array_pop ($abs_path)
  195.         foreach $rel_path as $subdir {
  196.             if $subdir === '' {
  197.                 array_pop ($abs_path);
  198.             else {
  199.                 array_push($abs_path$subdir);
  200.             }
  201.         }
  202.         foreach ($abs_path as $subdir{
  203.             $new_path .= $subdir '/';
  204.         }
  205.         $new_path "'$new_path'";
  206.     elseif count($rel_path{
  207.         // we're within the SM tree, prepend SM_PATH
  208.         $new_path str_replace('../',"SM_PATH . '"$old_path "'");
  209.     else {
  210.         // Last, if it's a relative path without a .. prefix, 
  211.         // we're somewhere within the config dir, so prepend
  212.         //  SM_PATH . 'config/  
  213.         $new_path "SM_PATH . 'config/" $old_path "'";
  214.     }
  215.     return $new_path;
  216. }
  217.  
  218.  
  219. /* ---------------------- main -------------------------- */
  220.  
  221. /** @ignore */
  222. define('SM_PATH','../../');
  223.  
  224. /* SquirrelMail required files. */
  225. require_once(SM_PATH 'include/validate.php');
  226. require_once(SM_PATH 'plugins/administrator/defines.php');
  227. require_once(SM_PATH 'plugins/administrator/auth.php');
  228.  
  229. global $data_dir$username;
  230.  
  231. if !adm_check_user() ) {
  232.     header('Location: ' SM_PATH 'src/options.php';
  233.     exit;
  234. }
  235.  
  236. displayPageHeader($color'None');
  237.  
  238. $newcfg array);
  239.  
  240. foreach $defcfg as $key => $def {
  241.     $newcfg[$key'';
  242. }
  243.  
  244. $cfgfile SM_PATH 'config/config.php';
  245. parseConfigSM_PATH 'config/config_default.php' );
  246. parseConfig$cfgfile );
  247. // backward compatibility for IMAP/SMTP TLS
  248. if ($newcfg['$use_imap_tls'=== 'TRUE')
  249.     $newcfg['$use_imap_tls''1';
  250. if ($newcfg['$use_smtp_tls'=== 'TRUE')
  251.     $newcfg['$use_smtp_tls''1';
  252. // Test/debug
  253. // sm_print_r($newcfg);
  254.  
  255. $colapse array'Titles' => 'off',
  256.                   'Group1' => getPref($data_dir$username'adm_Group1''off' ),
  257.                   'Group2' => getPref($data_dir$username'adm_Group2''on' ),
  258.                   'Group3' => getPref($data_dir$username'adm_Group3''on' ),
  259.                   'Group4' => getPref($data_dir$username'adm_Group4''on' ),
  260.                   'Group5' => getPref($data_dir$username'adm_Group5''on' ),
  261.                   'Group6' => getPref($data_dir$username'adm_Group6''on' ),
  262.                   'Group7' => getPref($data_dir$username'adm_Group7''on' ),
  263.                   'Group8' => getPref($data_dir$username'adm_Group8''on' ),
  264.                   'Group9' => getPref($data_dir$username'adm_Group9''on' ),
  265.                   'Group10' => getPref($data_dir$username'adm_Group10''on' ) );
  266.  
  267. /* look in $_GET array for 'switch' */
  268. if sqgetGlobalVar('switch'$switchSQ_GET) ) {
  269.     if $colapse[$switch== 'on' {
  270.         $colapse[$switch'off';
  271.     else {
  272.         $colapse[$switch'on';
  273.     }
  274.     setPref($data_dir$username"adm_$switch"$colapse[$switch);
  275. }
  276.  
  277. echo '<form action="options.php" method="post" name="options">' .
  278.      '<center><table width="95%" bgcolor="'.$color[5].'"><tr><td>'.
  279.      '<table width="100%" cellspacing="0" bgcolor="'.$color[4].'">'.
  280.      '<tr bgcolor="'.$color[5].'"><th colspan="2">'.
  281.      _("Configuration Administrator").'</th></tr>'.
  282.      '<tr bgcolor="'.$color[5].'"><td colspan="2" align="center"><small>'.
  283.      _("Note: it is recommended that you configure your system using conf.pl, and not this plugin. conf.pl contains additional information regarding the purpose of variables and appropriate values, as well as additional verification steps.").
  284.      '<br />'.
  285.      _("Run or consult conf.pl should you run into difficulty with your configuration.").
  286.      '</small></td></tr>';
  287.  
  288.  
  289. $act_grp 'Titles';  /* Active group */
  290.  
  291. foreach $newcfg as $k => $v {
  292.     $l strtolower$v );
  293.     $type SMOPT_TYPE_UNDEFINED;
  294.     $n substr$k);
  295.     $n str_replace'[''_'$n );
  296.     $n str_replace']''_'$n );
  297.     $e 'adm_' $n;
  298.     $name $k;
  299.     $size 50;
  300.     if isset$defcfg[$k) ) {
  301.         $name $defcfg[$k]['name'];
  302.         $type $defcfg[$k]['type'];
  303.         if isset$defcfg[$k]['size') ) {
  304.             $size $defcfg[$k]['size'];
  305.         else {
  306.             $size 40;
  307.         }
  308.     else if $l == 'true' {
  309.         $v 'TRUE';
  310.         $type SMOPT_TYPE_BOOLEAN;
  311.     else if $l == 'false' {
  312.         $v 'FALSE';
  313.         $type SMOPT_TYPE_BOOLEAN;
  314.     else if $v{0== "'" {
  315.         $type SMOPT_TYPE_STRING;
  316.     else if $v{0== '"' {
  317.         $type SMOPT_TYPE_STRING;
  318.     }
  319.  
  320.     if substr$k0== '$theme[' {
  321.         $type SMOPT_TYPE_THEME;
  322.     else if substr$k0== '$plugins[' {
  323.         $type SMOPT_TYPE_PLUGINS;
  324.     else if substr$k013 == '$ldap_server[' {
  325.         $type SMOPT_TYPE_LDAP;
  326.     }
  327.  
  328.     if $type == SMOPT_TYPE_TITLE || $colapse[$act_grp== 'off' {
  329.  
  330.         switch $type {
  331.         case SMOPT_TYPE_LDAP:
  332.         case SMOPT_TYPE_PLUGINS:
  333.         case SMOPT_TYPE_THEME:
  334.         case SMOPT_TYPE_HIDDEN:
  335.             break;
  336.         case SMOPT_TYPE_EXTERNAL:
  337.             echo "<tr><td>$name</td><td><b>.
  338.                  $defcfg[$k]['value'.
  339.                  '</b></td></tr>';
  340.             break;
  341.         case SMOPT_TYPE_TITLE:
  342.             if $colapse[$k== 'on' {
  343.                 $sw '(+)';
  344.             else {
  345.                 $sw '(-)';
  346.             }
  347.             echo '<tr bgcolor="'.$color[0].'"><th colspan="2">'.
  348.                  "<a href=\"options.php?switch=$k\" style=\"text-decoration:none\">".
  349.                  '<b>'.$sw.'</b></a> '.$name.'</th></tr>';
  350.             $act_grp $k;
  351.             break;
  352.         case SMOPT_TYPE_COMMENT:
  353.             $v substr$v1strlen$v );
  354.             echo "<tr><td>$name</td><td>".
  355.                  "<b>$v</b>";
  356.             $newcfg[$k"'$v'";
  357.             if isset$defcfg[$k]['comment') ) {
  358.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  359.             }
  360.             echo "</td></tr>\n";
  361.             break;
  362.         case SMOPT_TYPE_INTEGER:
  363.             /* look for variable $e in POST, fill into $v */
  364.             if sqgetGlobalVar($e$new_vSQ_POST) ) {
  365.                 $v intval$new_v );
  366.                 $newcfg[$k$v;
  367.             }
  368.             echo "<tr><td>$name</td><td>".
  369.                  "<input size=\"10\" name=\"adm_$n\" value=\"$v\" />";
  370.             if isset$defcfg[$k]['comment') ) {
  371.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  372.             }
  373.             echo "</td></tr>\n";
  374.             break;
  375.         case SMOPT_TYPE_NUMLIST:
  376.             if (  sqgetGlobalVar($e$new_vSQ_POST) ) {
  377.                 $v $new_v;
  378.                 $newcfg[$k$v;
  379.             }
  380.             echo "<tr><td>$name</td><td>";
  381.             echo "<select name=\"adm_$n\">";
  382.             foreach $defcfg[$k]['posvals'as $kp => $vp {
  383.                 echo "<option value=\"$kp\"";
  384.                 if $kp == $v {
  385.                     echo ' selected="selected"';
  386.                 }
  387.                 echo ">$vp</option>";
  388.             }
  389.             echo '</select>';
  390.             if isset$defcfg[$k]['comment') ) {
  391.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  392.             }
  393.             echo "</td></tr>\n";
  394.             break;
  395.         case SMOPT_TYPE_STRLIST:
  396.             if (  sqgetGlobalVar($e$new_vSQ_POST) ) {
  397.                 $v '"' $new_v '"';
  398.                 $newcfg[$k$v;
  399.             }
  400.             echo "<tr><td>$name</td><td>".
  401.                  "<select name=\"adm_$n\">";
  402.             foreach $defcfg[$k]['posvals'as $kp => $vp {
  403.                 echo "<option value=\"$kp\"";
  404.                 if $kp == substr$v1strlen$v ) ) {
  405.                     echo ' selected="selected"';
  406.                 }
  407.                 echo ">$vp</option>";
  408.             }
  409.             echo '</select>';
  410.             if isset$defcfg[$k]['comment') ) {
  411.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  412.             }
  413.             echo "</td></tr>\n";
  414.             break;
  415.  
  416.         case SMOPT_TYPE_TEXTAREA:
  417.             if (  sqgetGlobalVar($e$new_vSQ_POST) ) {
  418.                 $v '"' $new_v '"';
  419.                 $newcfg[$kstr_replace"\n"''$v );
  420.             }
  421.             echo "<tr><td valign=\"top\">$name</td><td>".
  422.                  "<textarea cols=\"$size\" rows=\"4\" name=\"adm_$n\">substr$v1strlen$v "</textarea>";
  423.             if isset$defcfg[$k]['comment') ) {
  424.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  425.             }
  426.             echo "</td></tr>\n";
  427.             break;
  428.         case SMOPT_TYPE_STRING:
  429.             if (  sqgetGlobalVar($e$new_vSQ_POST) ) {
  430.                 $v '"' $new_v '"';
  431.                 $newcfg[$k$v;
  432.             }
  433.             if $v == '""' && isset$defcfg[$k]['default') ) {
  434.                 $v "'" $defcfg[$k]['default'"'";
  435.                 $newcfg[$k$v;
  436.             }
  437.             echo "<tr><td>$name</td><td>".
  438.                  "<input size=\"$size\" name=\"adm_$n\" value=\"substr$v1strlen$v '" />';
  439.             if isset$defcfg[$k]['comment') ) {
  440.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  441.             }
  442.             echo "</td></tr>\n";
  443.             break;
  444.         case SMOPT_TYPE_BOOLEAN:
  445.             if (  sqgetGlobalVar($e$new_vSQ_POST) ) {
  446.                 $v $new_v;
  447.                 $newcfg[$k$v;
  448.             else {
  449.                 $v strtoupper$v );
  450.             }
  451.             if $v == 'TRUE' {
  452.                 $ct ' checked="checked"';
  453.                 $cf '';
  454.             else {
  455.                 $ct '';
  456.                 $cf ' checked="checked"';
  457.             }
  458.             echo "<tr><td>$name</td><td>.
  459.                  "<input$ct type=\"radio\" name=\"adm_$n\" value=\"TRUE\" />_("Yes".
  460.                  "<input$cf type=\"radio\" name=\"adm_$n\" value=\"FALSE\" />_("No");
  461.             if isset$defcfg[$k]['comment') ) {
  462.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  463.             }
  464.             echo "</td></tr>\n";
  465.             break;
  466.         case SMOPT_TYPE_PATH:
  467.             if (  sqgetGlobalVar($e$new_vSQ_POST) ) {
  468.                $v change_to_sm_path($new_v);
  469.                $newcfg[$k$v;
  470.             }
  471.             if $v == "''" && isset$defcfg[$k]['default') ) {
  472.                $v change_to_sm_path($defcfg[$k]['default']);
  473.                $newcfg[$k$v;
  474.             }
  475.             echo "<tr><td>$name</td><td>".
  476.                  "<input size=\"$size\" name=\"adm_$n\" value=\"change_to_rel_path($v'" />';
  477.             if isset$defcfg[$k]['comment') ) {
  478.                  echo ' &nbsp; ' $defcfg[$k]['comment'];
  479.             }
  480.             echo "</td></tr>\n";
  481.             break;
  482.         default:
  483.             echo "<tr><td>$name</td><td>.
  484.                  "<b><i>$v</i></b>";
  485.             if isset$defcfg[$k]['comment') ) {
  486.                 echo ' &nbsp; ' $defcfg[$k]['comment'];
  487.             }
  488.             echo "</td></tr>\n";
  489.         }
  490.     }
  491. }
  492.  
  493. /* Special Themes Block */
  494. if $colapse['Group7'== 'off' {
  495.     $i 0;
  496.     echo '<tr><th>' _("Theme Name".
  497.          '</th><th>' _("Theme Path".
  498.          '</th></tr>';
  499.     while isset$newcfg["\$theme[$i]['NAME']") ) {
  500.         $k1 "\$theme[$i]['NAME']";
  501.         $e1 "theme_name_$i";
  502.         if (  sqgetGlobalVar($e$v1SQ_POST) ) {
  503.             $v1 '"' str_replace'\"''"'$v1 '"';
  504.             $v1 '"' str_replace'"''\"'$v1 '"';
  505.             $newcfg[$k1$v1;
  506.         else {
  507.             $v1 $newcfg[$k1];
  508.         }
  509.         $k2 "\$theme[$i]['PATH']";
  510.         $e2 "theme_path_$i";
  511.         if (  sqgetGlobalVar($e$v2SQ_POST) ) {
  512.             $v2 change_to_sm_path($v2);
  513.             $newcfg[$k2$v2;
  514.         else {
  515.             $v2 $newcfg[$k2];
  516.         }
  517.         $name substr$v11strlen$v1 );
  518.         $path change_to_rel_path($v2);
  519.         echo '<tr>'.
  520.              "<td align=\"right\">$i. <input name=\"$e1\" value=\"$name\" size=\"30\" /></td>".
  521.              "<td><input name=\"$e2\" value=\"$path\" size=\"40\" /></td>".
  522.              "</tr>\n";
  523.         $i++;
  524.  
  525.     }
  526. }
  527.  
  528. /* Special Plugins Block */
  529. if $colapse['Group8'== 'on' {
  530.     $sw '(+)';
  531. else {
  532.     $sw '(-)';
  533. }
  534. echo '<tr bgcolor="'.$color[0].'"><th colspan="2">'.
  535.      '<a href="options.php?switch=Group8" style="text-decoration:none"><b>'.
  536.      $sw.'</b></a> '._("Plugins").'</th></tr>';
  537.  
  538. if $colapse['Group8'== 'off' {
  539.  
  540.     $plugpath SM_PATH 'plugins/';
  541.     if file_exists($plugpath) ) {
  542.         $fd opendir$plugpath );
  543.         $op_plugin array();
  544.         $p_count 0;
  545.         while (false !== ($file readdir($fd))) {
  546.             if ($file != '.' && $file != '..' && $file != 'CVS' && is_dir($plugpath $file) ) {
  547.                 $op_plugin[$file;
  548.                 $p_count++;
  549.             }
  550.         }
  551.         closedir($fd);
  552.         asort$op_plugin );
  553.  
  554.         /* Lets get the plugins that are active */
  555.         $plugins array();
  556.         if (  sqgetGlobalVar('plg'$vSQ_POST) ) {
  557.             foreach $op_plugin as $plg {
  558.                 if (  sqgetGlobalVar("plgs_$plg"$v2SQ_POST&& $v2 == 'on' {
  559.                     $plugins[$plg;
  560.                 }
  561.             }
  562.             $i 0;
  563.             foreach $plugins as $plg {
  564.                 $k "\$plugins[$i]";
  565.                 $newcfg[$k"'$plg'";
  566.                 $i++;
  567.             }
  568.             while isset$newcfg["\$plugins[$i]") ) {
  569.                 $k "\$plugins[$i]";
  570.                 $newcfg[$k'';
  571.                 $i++;
  572.             }
  573.         else {
  574.             $i 0;
  575.             while isset$newcfg["\$plugins[$i]") ) {
  576.                 $k "\$plugins[$i]";
  577.                 $v $newcfg[$k];
  578.                 $plugins[substr$v1strlen$v );
  579.                 $i++;
  580.             }
  581.         }
  582.         echo '<tr><td colspan="2"><input type="hidden" name="plg" value="on" /><center><table>';
  583.         foreach $op_plugin as $plg {
  584.             if in_array$plg$plugins ) ) {
  585.                 $sw ' checked="checked"';
  586.             else {
  587.                 $sw '';
  588.             }
  589.             echo '<tr><td>';
  590.             if (file_exists(SM_PATH "plugins/$plg/README")) {
  591.                 echo "<a href=\"../$plg/README\" target=\"_blank\">$plg</a>";
  592.             else {
  593.                 echo $plg;
  594.             }
  595.             echo "</td>\n".
  596.                  "<td><input$sw type=\"checkbox\" name=\"plgs_$plg\" /></td>".
  597.                  "</tr>\n";
  598.         }
  599.         echo '</table></center></td></tr>';
  600.     else {
  601.         echo '<tr><td colspan="2" align="center">'.
  602.              sprintf(_("Plugin directory could not be found: %s")$plugpath).
  603.              "</td></tr>\n";
  604.     }
  605. }
  606. echo '<tr bgcolor="'.$color[5].'"><th colspan="2"><input value="'.
  607.      _("Change Settings").'" type="submit" /><br />'.
  608.      '<a href="'.SM_PATH.'src/configtest.php" target="_blank">'.
  609.      _("Test Configuration")."</a></th></tr>\n".
  610.      '</table></td></tr></table></center></form>';
  611.  
  612. /*
  613.     Write the options to the file.
  614. */
  615.  
  616. // Testing/debug
  617. // $cfgfile = '/tmp/config.php';
  618. if $fp @fopen$cfgfile'w' ) ) {
  619.     fwrite$fp"<?php\n".
  620.     "/**\n".
  621.     " * SquirrelMail Configuration File\n".
  622.     " * Created using the Administrator Plugin\n".
  623.     " */\n".
  624.     "\n".
  625.     "global \$version;\n" );
  626.  
  627.     foreach $newcfg as $k => $v {
  628.         if $k{0== '$' && $v <> '' || is_int($v)) {
  629.             if substr$k111 == 'ldap_server' {
  630.                 $v substr$v0strlen$v "\n)";
  631.                 $v str_replace'array('"array(\n\t"$v );
  632.                 $v str_replace"',""',\n\t"$v );
  633.             }
  634.             fwrite$fp"$k = $v;\n);
  635.         }
  636.     }
  637.     // add local config support
  638.     fwrite$fp"@include SM_PATH . 'config/config_local.php';\n" );
  639.     // close php
  640.     fwrite$fp'?>' );
  641.     fclose$fp );
  642. else {
  643.     echo '<br /><p align="center"><big>'.
  644.          _("Config file can't be opened. Please check config.php.").
  645.          '</big></p>';
  646. }
  647. ?>
  648. </body></html>

Documentation generated on Mon, 13 Jan 2020 04:25:07 +0100 by phpDocumentor 1.4.3