From abd7a3f85445e0d136b57e0675a58ff9f8e3d507 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Sun, 27 Jan 2002 13:53:31 +0000 Subject: [PATCH] Administrator Plugin -------------------- This plugin is not yet complete, but I add it to the CVS in order to get your coopertaion. Once activated, only the owner of config.php can see the plugin. Make sure config.php is 660 with the owner set to the one that can edit it and the group to the use who's running php. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2247 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/administrator/defines.php | 85 ++++++++++++ plugins/administrator/options.php | 219 ++++++++++++++++++++++++++++++ plugins/administrator/setup.php | 37 +++++ 3 files changed, 341 insertions(+) create mode 100644 plugins/administrator/defines.php create mode 100644 plugins/administrator/options.php create mode 100644 plugins/administrator/setup.php diff --git a/plugins/administrator/defines.php b/plugins/administrator/defines.php new file mode 100644 index 00000000..d7180b8a --- /dev/null +++ b/plugins/administrator/defines.php @@ -0,0 +1,85 @@ + $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 diff --git a/plugins/administrator/options.php b/plugins/administrator/options.php new file mode 100644 index 00000000..b4600f6e --- /dev/null +++ b/plugins/administrator/options.php @@ -0,0 +1,219 @@ +" . + '' , + ""; +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 "\n"; +} +echo "" , + '
" . _("Configuration Administrator") . "
$name"; + + switch ( $type ) { + case SMOPT_TYPE_INTEGER: + if ( isset( $HTTP_POST_VARS[$e] ) ) { + $v = intval( $HTTP_POST_VARS[$e] ); + $newcfg[$k] = $v; + } + echo ""; + break; + case SMOPT_TYPE_STRLIST: + if ( isset( $HTTP_POST_VARS[$e] ) ) { + $v = '"' . $HTTP_POST_VARS[$e] . '"'; + $newcfg[$k] = $v; + } + echo "'; + break; + + case SMOPT_TYPE_STRING: + if ( isset( $HTTP_POST_VARS[$e] ) ) { + $v = '"' . $HTTP_POST_VARS[$e] . '"'; + $newcfg[$k] = $v; + } + echo ""; + 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 "" . _("Yes") . + "" . _("No"); + break; + default: + echo "$v"; + } + echo "
'; + +/* + Write the options to the file. +*/ +$fp = fopen( $cfgfile, 'w' ); +fwrite( $fp, " $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 ); +?> diff --git a/plugins/administrator/setup.php b/plugins/administrator/setup.php new file mode 100644 index 00000000..c665523a --- /dev/null +++ b/plugins/administrator/setup.php @@ -0,0 +1,37 @@ + _("Administration"), + 'url' => '../plugins/administrator/options.php', + 'desc' => _("This module allows administrators to run SquirrelMail configuration remotely."), + 'js' => false + ); +} +?> \ No newline at end of file -- 2.25.1