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

Documentation generated on Sat, 07 Oct 2006 16:32:52 +0300 by phpDocumentor 1.3.0RC6