--- /dev/null
+<?PHP
+
+/**
+ * defines.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Philippe Mingo
+ *
+ * $Id$
+ */
+
+
+/* Define constants for the various option types. */
+define('SMOPT_TYPE_UNDEFINED', -1);
+define('SMOPT_TYPE_STRING', 0);
+define('SMOPT_TYPE_STRLIST', 1);
+define('SMOPT_TYPE_TEXTAREA', 2);
+define('SMOPT_TYPE_INTEGER', 3);
+define('SMOPT_TYPE_FLOAT', 4);
+define('SMOPT_TYPE_BOOLEAN', 5);
+define('SMOPT_TYPE_HIDDEN', 6);
+define('SMOPT_TYPE_COMMENT', 7);
+
+/* Define constants for the options refresh levels. */
+define('SMOPT_REFRESH_NONE', 0);
+define('SMOPT_REFRESH_FOLDERLIST', 1);
+define('SMOPT_REFRESH_ALL', 2);
+
+/* Define constants for the options size. */
+define('SMOPT_SIZE_TINY', 0);
+define('SMOPT_SIZE_SMALL', 1);
+define('SMOPT_SIZE_MEDIUM', 2);
+define('SMOPT_SIZE_LARGE', 3);
+define('SMOPT_SIZE_HUGE', 4);
+
+define('SMOPT_SAVE_DEFAULT', 'save_option');
+define('SMOPT_SAVE_NOOP', 'save_option_noop');
+
+global $languages;
+
+$language_values = array();
+foreach ($languages as $lang_key => $lang_attributes) {
+ if (isset($lang_attributes['NAME'])) {
+ $language_values[$lang_key] = $lang_attributes['NAME'];
+ }
+}
+asort( $language_values );
+
+$namcfg = array( '$config_version' => array( 'name' => _("Config File Version"),
+ 'type' => 'string',
+ 'size' => 7 ),
+ '$org_logo' => array( 'name' => _("Organization Logo"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ '$org_name' => array( 'name' => _("Organization Name"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ '$org_title' => array( 'name' => _("Organization Name"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ '$squirrelmail_default_language' => array( 'name' => _("Default Language"),
+ 'type' => SMOPT_TYPE_STRLIST,
+ 'size' => 7,
+ 'posvals' => $language_values ),
+ '$imapServerAddress' => array( 'name' => _("IMAP Server Address"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ '$imapPort' => array( 'name' => _("IMAP Server Port"),
+ 'type' => SMOPT_TYPE_INTEGER ),
+ '$domain' => array( 'name' => _("Mail Domain"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ '$smtpServerAddress' => array( 'name' => _("SMTP Server Address"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ '$smtpPort' => array( 'name' => _("SMTP Server Port"),
+ 'type' => SMOPT_TYPE_INTEGER ),
+ '$motd' => array( 'name' => _("Message of the Day"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'size' => 40 ),
+ );
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * Administrator Plugin
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Philippe Mingo
+ *
+ * $Id$
+ */
+
+chdir('..');
+require_once('../src/validate.php');
+require_once('../functions/page_header.php');
+require_once('../functions/imap.php');
+require_once('../src/load_prefs.php');
+require_once('../plugins/administrator/defines.php');
+
+displayPageHeader($color, 'None');
+
+$cfgfile = '../config/config.php';
+$cfg_defaultfile = '../config/config_default.php';
+$cfg = file( $cfg_defaultfile );
+$newcfg = $defcfg = array( );
+$cm = FALSE;
+foreach ( $cfg as $l ) {
+ $l = preg_replace( '/\/\*.*\*\//', '', $l );
+ $l = preg_replace( '/#.*$/', '', $l );
+ $l = preg_replace( '/\/\/.*$/', '', $l );
+ $v = $s = trim( $l );
+ if ( $cm ) {
+ if( substr( $v, -2 ) == '*/' ) {
+ $v = '';
+ $cm = FALSE;
+ } else if( $i = strpos( $v, '*/' ) ) {
+ $v = substr( $v, $i );
+ $cm = FALSE;
+ } else {
+ $v = '';
+ }
+ } else {
+ if( $v{0}.$v{1} == '/*' ) {
+ $v = '';
+ $cm = TRUE;
+ } else if ( $i = strpos( $v, '/*' ) ) {
+ $v = substr( $v, 0, $i );
+ $cm = TRUE;
+ }
+ }
+
+ if ( $i = strpos( $v, '=' ) ) {
+ $key = trim( substr( $v, 0, $i - 1 ) );
+ $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) );
+ $newcfg[$key] = $val;
+ $defcfg[$key] = $val;
+ }
+
+}
+
+$cfg = file( $cfgfile );
+asort( $cfg );
+
+$cm = FALSE;
+foreach ( $cfg as $l ) {
+ $l = preg_replace( '/\/\*.*\*\//', '', $l );
+ $l = preg_replace( '/#.*$/', '', $l );
+ $l = preg_replace( '/\/\/.*$/', '', $l );
+ $v = $s = trim( $l );
+ if ( $cm ) {
+ if( substr( $v, -2 ) == '*/' ) {
+ $v = '';
+ $cm = FALSE;
+ } else if( $i = strpos( $v, '*/' ) ) {
+ $v = substr( $v, $i );
+ $cm = FALSE;
+ } else {
+ $v = '';
+ }
+ } else {
+ if( $v{0}.$v{1} == '/*' ) {
+ $v = '';
+ $cm = TRUE;
+ } else if ( $i = strpos( $v, '/*' ) ) {
+ $v = substr( $v, 0, $i );
+ $cm = TRUE;
+ }
+ }
+
+ if ( $i = strpos( $v, '=' ) ) {
+ $key = trim( substr( $v, 0, $i - 1 ) );
+ $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) );
+ $newcfg[$key] = $val;
+ }
+
+}
+
+echo "<form action=$PHP_SELF method=post>" .
+ '<table width=100%>' ,
+ "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
+foreach ( $newcfg as $k => $v ) {
+ $l = strtolower( $v );
+ $type = SMOPT_TYPE_UNDEFINED;
+ $n = substr( $k, 1 );
+ $n = str_replace( '[', '_', $n );
+ $n = str_replace( ']', '_', $n );
+ $e = 'adm_' . $n;
+ $name = $k;
+ $size = 50;
+ if ( isset( $namcfg[$k] ) ) {
+ $name = $namcfg[$k]['name'];
+ $type = $namcfg[$k]['type'];
+ $size = $namcfg[$k]['size'];
+ } else if ( $l == 'true' ) {
+ $v = 'TRUE';
+ $type = SMOPT_TYPE_BOOLEAN;
+ } else if ( $l == 'false' ) {
+ $v = 'FALSE';
+ $type = SMOPT_TYPE_BOOLEAN;
+ } else if ( $v{0} == "'" ) {
+ $type = SMOPT_TYPE_STRING;
+ } else if ( $v{0} == '"' ) {
+ $type = SMOPT_TYPE_STRING;
+ }
+
+ echo "<tr><td>$name</td><td>";
+
+ switch ( $type ) {
+ case SMOPT_TYPE_INTEGER:
+ if ( isset( $HTTP_POST_VARS[$e] ) ) {
+ $v = intval( $HTTP_POST_VARS[$e] );
+ $newcfg[$k] = $v;
+ }
+ echo "<input size=10 name=\"adm_$n\" value=\"$v\">";
+ break;
+ case SMOPT_TYPE_STRLIST:
+ if ( isset( $HTTP_POST_VARS[$e] ) ) {
+ $v = '"' . $HTTP_POST_VARS[$e] . '"';
+ $newcfg[$k] = $v;
+ }
+ echo "<select name=\"adm_$n\">";
+ foreach ( $namcfg[$k]['posvals'] as $kp => $vp ) {
+ echo "<option value=\"$kp\"";
+ if ( $kp == substr( $v, 1, strlen( $v ) - 2 ) ) {
+ echo ' selected';
+ }
+ echo ">$vp</option>";
+ }
+ echo '</select>';
+ break;
+
+ case SMOPT_TYPE_STRING:
+ if ( isset( $HTTP_POST_VARS[$e] ) ) {
+ $v = '"' . $HTTP_POST_VARS[$e] . '"';
+ $newcfg[$k] = $v;
+ }
+ echo "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . "\">";
+ break;
+ case SMOPT_TYPE_BOOLEAN:
+ if ( isset( $HTTP_POST_VARS[$e] ) ) {
+ $v = $HTTP_POST_VARS[$e];
+ $newcfg[$k] = $v;
+ }
+ if ( $v == 'TRUE' ) {
+ $ct = ' checked';
+ $cf = '';
+ } else {
+ $ct = '';
+ $cf = ' checked';
+ }
+ echo "<INPUT$ct type=radio NAME=\"adm_$n\" value=\"TRUE\">" . _("Yes") .
+ "<INPUT$cf type=radio NAME=\"adm_$n\" value=\"FALSE\">" . _("No");
+ break;
+ default:
+ echo "<b><i>$v</i></b>";
+ }
+ echo "</td></tr>\n";
+}
+echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
+ _("Change Settings") . "\" type=submit></th></tr>" ,
+ '</table></form>';
+
+/*
+ Write the options to the file.
+*/
+$fp = fopen( $cfgfile, 'w' );
+fwrite( $fp, "<?PHP\n".
+ "/**\n".
+ " * SquirrelMail Configuration File\n".
+ " * Created using the Administrator Plugin\n".
+ " */\n\n" );
+
+fwrite( $fp, 'GLOBAL ' );
+$not_first = FALSE;
+foreach ( $newcfg as $k => $v ) {
+ if( $i = strpos( $k, '[' ) ) {
+ if( strpos( $k, '[0]' ) ) {
+ if( $not_first ) {
+ fwrite( $fp, ', ' );
+ }
+ fwrite( $fp, substr( $k, 0, $i) );
+ $not_first = TRUE;
+ }
+ } else {
+ if( $not_first ) {
+ fwrite( $fp, ', ' );
+ }
+ fwrite( $fp, $k );
+ $not_first = TRUE;
+ }
+}
+fwrite( $fp, ";\n" );
+foreach ( $newcfg as $k => $v ) {
+ fwrite( $fp, "$k = $v;\n" );
+}
+fwrite( $fp, '?>' );
+fclose( $fp );
+?>