Source for file options.php

Documentation is available at options.php

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

Documentation generated on Mon, 13 Jan 2020 04:23:16 +0100 by phpDocumentor 1.4.3