X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=plugins%2Fadministrator%2Foptions.php;h=2baf4ed88f289fb1a99fcb35f4255860bbe2490f;hb=3656ccef5631a36c623368000b13d831541145ad;hp=cf9cb62a13ec404952e042d13fbe237ba4c933fe;hpb=f0b554f994b11c89139e3f13021b3b3c4cbcf45f;p=squirrelmail.git diff --git a/plugins/administrator/options.php b/plugins/administrator/options.php index cf9cb62a..2baf4ed8 100644 --- a/plugins/administrator/options.php +++ b/plugins/administrator/options.php @@ -1,16 +1,27 @@ - SM_PATH . 'images/logo.gif' --> ../images/logo.gif - '/absolute/path/logo.gif' --> /absolute/path/logo.gif - 'http://whatever/' --> http://whatever - Note removal of quotes in returned value -*/ +/** + * Change paths containing SM_PATH to admin-friendly paths + * relative to the config dir, i.e.: + * '' --> + * SM_PATH . 'images/logo.gif' --> ../images/logo.gif + * '/absolute/path/logo.gif' --> /absolute/path/logo.gif + * 'http://whatever/' --> http://whatever + * Note removal of quotes in returned value + * + * @param string $old_path path that has to be converted + * @return string new path + * @access private + */ function change_to_rel_path($old_path) { - $new_path = str_replace("SM_PATH . '", "../", $old_path); + $new_path = str_replace("SM_PATH . '", "../", $old_path); $new_path = str_replace("../config/","", $new_path); $new_path = str_replace("'","", $new_path); return $new_path; } -/* Change relative path (relative to config dir) to - internal SM_PATH, i.e.: - empty_string --> '' - ../images/logo.gif --> SM_PATH . 'images/logo.gif' - images/logo.gif --> SM_PATH . 'config/images/logo.gif' - /absolute/path/logo.gif --> '/absolute/path/logo.gif' - http://whatever/ --> 'http://whatever' -*/ +/** + * Change relative path (relative to config dir) to + * internal SM_PATH, i.e.: + * empty_string --> '' + * ../images/logo.gif --> SM_PATH . 'images/logo.gif' + * images/logo.gif --> SM_PATH . 'config/images/logo.gif' + * C:/absolute/win/path --> 'C:/absolute/win/path' + * /absolute/path/logo.gif --> '/absolute/path/logo.gif' + * http://whatever/ --> 'http://whatever' + * + * @param string $old_path path that has to be converted + * @return string new path + * @access private +*/ function change_to_sm_path($old_path) { - if ( $old_path === '' || $old_path == "''" ) { - return "''"; - } elseif ( preg_match("/^(\/|http)/", $old_path) ) { - return "'" . $old_path . "'"; - } elseif ( preg_match("/^(\$|SM_PATH)/", $old_path) ) { - return $old_path; - } - - $new_path = ''; - $rel_path = explode("../", $old_path); - if ( count($rel_path) > 2 ) { - // Since we're relative to the config dir, - // more than 1 ../ puts us OUTSIDE the SM tree. - // get full path to config.php, then pop the filename - $abs_path = explode('/', realpath (SM_PATH . 'config/config.php')); - array_pop ($abs_path); - foreach ( $rel_path as $subdir ) { - if ( $subdir === '' ) { - array_pop ($abs_path); - } else { - array_push($abs_path, $subdir); - } - } - foreach ($abs_path as $subdir) { - $new_path .= $subdir . '/'; - } - $new_path = "'$new_path'"; - } elseif ( count($rel_path) > 1 ) { - // we're within the SM tree, prepend SM_PATH - $new_path = str_replace('../',"SM_PATH . '", $old_path . "'"); - } else { - // Last, if it's a relative path without a .. prefix, - // we're somewhere within the config dir, so prepend - // SM_PATH . 'config/ - $new_path = "SM_PATH . 'config/" . $old_path . "'"; - } - return $new_path; + if ( $old_path === '' || $old_path == "''" ) { + return "''"; + } elseif ( preg_match("/^(\/|http)/", $old_path) || + substr($old_path,1,2) == ':/' ) { + return "'" . $old_path . "'"; + } elseif ( preg_match("/^(\$|SM_PATH)/", $old_path) ) { + return $old_path; + } + + $new_path = ''; + $rel_path = explode("../", $old_path); + if ( count($rel_path) > 2 ) { + // Since we're relative to the config dir, + // more than 1 ../ puts us OUTSIDE the SM tree. + // get full path to config.php, then pop the filename + $abs_path = explode('/', realpath (SM_PATH . 'config/config.php')); + array_pop ($abs_path); + foreach ( $rel_path as $subdir ) { + if ( $subdir === '' ) { + array_pop ($abs_path); + } else { + array_push($abs_path, $subdir); + } + } + foreach ($abs_path as $subdir) { + $new_path .= $subdir . '/'; + } + $new_path = "'$new_path'"; + } elseif ( count($rel_path) > 1 ) { + // we're within the SM tree, prepend SM_PATH + $new_path = str_replace('../',"SM_PATH . '", $old_path . "'"); + } else { + // Last, if it's a relative path without a .. prefix, + // we're somewhere within the config dir, so prepend + // SM_PATH . 'config/ + $new_path = "SM_PATH . 'config/" . $old_path . "'"; + } + return $new_path; } /* ---------------------- main -------------------------- */ +/** main SquirrelMail include */ +require('../../include/init.php'); +/* configuration definitions */ +include_once(SM_PATH . 'plugins/administrator/defines.php'); +/* additional functions */ +include_once(SM_PATH . 'plugins/administrator/auth.php'); -define('SM_PATH','../../'); - -/* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/page_header.php'); -require_once(SM_PATH . 'functions/imap.php'); -require_once(SM_PATH . 'include/load_prefs.php'); -require_once(SM_PATH . 'plugins/administrator/defines.php'); -require_once(SM_PATH . 'plugins/administrator/auth.php'); - -GLOBAL $data_dir, $username; +global $data_dir, $username; if ( !adm_check_user() ) { header('Location: ' . SM_PATH . 'src/options.php') ; exit; } -displayPageHeader($color, 'None'); +displayPageHeader($color); $newcfg = array( ); @@ -232,30 +257,32 @@ $colapse = array( 'Titles' => 'off', 'Group5' => getPref($data_dir, $username, 'adm_Group5', 'on' ), 'Group6' => getPref($data_dir, $username, 'adm_Group6', 'on' ), 'Group7' => getPref($data_dir, $username, 'adm_Group7', 'on' ), - 'Group8' => getPref($data_dir, $username, 'adm_Group8', 'on' ) ); + 'Group8' => getPref($data_dir, $username, 'adm_Group8', 'on' ), + 'Group9' => getPref($data_dir, $username, 'adm_Group9', 'on' ), + 'Group10' => getPref($data_dir, $username, 'adm_Group10', 'on' ), + 'Group11' => getPref($data_dir, $username, 'adm_Group11', 'on' ) ); -if ( isset( $_GET['switch'] ) ) { - $switch = $_GET['switch']; +/* look in $_GET array for 'switch' */ +if ( sqgetGlobalVar('switch', $switch, SQ_GET) ) { if ( $colapse[$switch] == 'on' ) { - $colapse[$switch] = 'off'; + $colapse[$switch] = 'off'; } else { - $colapse[$switch] = 'on'; + $colapse[$switch] = 'on'; } setPref($data_dir, $username, "adm_$switch", $colapse[$switch] ); } -echo "
" . - "
". - "" , - "", - " -' . + '
" . _("Configuration Administrator") . "
"; -?> -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.
-Run or consult conf.pl should you run into difficulty with your configuration.
-
'. + ''. + ''. + ''; + $act_grp = 'Titles'; /* Active group */ @@ -294,12 +321,16 @@ foreach ( $newcfg as $k => $v ) { $type = SMOPT_TYPE_PLUGINS; } else if ( substr( $k, 0, 13 ) == '$ldap_server[' ) { $type = SMOPT_TYPE_LDAP; + } else if ( substr( $k, 0, 9 ) == '$fontsets' || + substr( $k, 0, 13 ) == '$aTemplateSet' ) { + $type = SMOPT_TYPE_CUSTOM; } - if( $type == SMOPT_TYPE_TITLE || $colapse[$act_grp] == 'off' ) { + if ( $type == SMOPT_TYPE_TITLE || $colapse[$act_grp] == 'off' ) { switch ( $type ) { case SMOPT_TYPE_LDAP: + case SMOPT_TYPE_CUSTOM: case SMOPT_TYPE_PLUGINS: case SMOPT_TYPE_THEME: case SMOPT_TYPE_HIDDEN: @@ -307,7 +338,7 @@ foreach ( $newcfg as $k => $v ) { case SMOPT_TYPE_EXTERNAL: echo ""; + ''; break; case SMOPT_TYPE_TITLE: if ( $colapse[$k] == 'on' ) { @@ -315,9 +346,9 @@ foreach ( $newcfg as $k => $v ) { } else { $sw = '(-)'; } - echo ""; + echo ''; $act_grp = $k; break; case SMOPT_TYPE_COMMENT: @@ -331,20 +362,21 @@ foreach ( $newcfg as $k => $v ) { echo "\n"; break; case SMOPT_TYPE_INTEGER: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = intval( $HTTP_POST_VARS[$e] ); + /* look for variable $e in POST, fill into $v */ + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + $v = intval( $new_v ); $newcfg[$k] = $v; } echo "\n"; break; case SMOPT_TYPE_NUMLIST: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = $HTTP_POST_VARS[$e]; + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + $v = $new_v; $newcfg[$k] = $v; } echo "\n"; break; case SMOPT_TYPE_STRLIST: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = '"' . $HTTP_POST_VARS[$e] . '"'; + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + $v = '"' . $new_v . '"'; $newcfg[$k] = $v; } echo "\n"; break; case SMOPT_TYPE_STRING: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = '"' . $HTTP_POST_VARS[$e] . '"'; + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + $v = '"' . addslashes($new_v) . '"'; $newcfg[$k] = $v; } if ( $v == '""' && isset( $defcfg[$k]['default'] ) ) { $v = "'" . $defcfg[$k]['default'] . "'"; $newcfg[$k] = $v; } - echo "\n"; break; case SMOPT_TYPE_BOOLEAN: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = $HTTP_POST_VARS[$e]; + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + $v = $new_v; $newcfg[$k] = $v; } else { $v = strtoupper( $v ); } if ( $v == 'TRUE' ) { - $ct = ' checked'; + $ct = ' checked="checked"'; $cf = ''; } else { $ct = ''; - $cf = ' checked'; + $cf = ' checked="checked"'; } echo "\n"; break; - case SMOPT_TYPE_PATH: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = change_to_sm_path($HTTP_POST_VARS[$e]); - $newcfg[$k] = $v; + case SMOPT_TYPE_PATH: + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + // FIXME: fix use of $data_dir in $attachment_dir + $v = change_to_sm_path($new_v); + $newcfg[$k] = $v; } if ( $v == "''" && isset( $defcfg[$k]['default'] ) ) { $v = change_to_sm_path($defcfg[$k]['default']); $newcfg[$k] = $v; } - echo "\n"; - break; + echo "\n"; + break; default: echo "'. - "". - "". + "". + "". "\n"; $i++; @@ -501,101 +538,115 @@ if ( $colapse['Group8'] == 'on' ) { } else { $sw = '(-)'; } -echo "'; - -if( $colapse['Group8'] == 'off' ) { - - $plugpath = SM_PATH . 'plugins/'; - if ( file_exists($plugpath) ) { - $fd = opendir( $plugpath ); - $op_plugin = array(); - $p_count = 0; - while (false !== ($file = readdir($fd))) { - if ($file != '.' && $file != '..' && $file != 'CVS' && is_dir($plugpath . $file) ) { - $op_plugin[] = $file; - $p_count++; - } - } - closedir($fd); - asort( $op_plugin ); - - /* Lets get the plugins that are active */ - $plugins = array(); - if ( isset( $HTTP_POST_VARS['plg'] ) ) { - foreach ( $op_plugin as $plg ) { - if ( isset( $HTTP_POST_VARS["plgs_$plg"] ) && - $HTTP_POST_VARS["plgs_$plg"] == 'on' ) { - $plugins[] = $plg; +echo ''; + +if ( $colapse['Group8'] == 'off' ) { + + $plugpath = SM_PATH . 'plugins/'; + if ( file_exists($plugpath) ) { + $fd = opendir( $plugpath ); + $op_plugin = array(); + $p_count = 0; + while (false !== ($file = readdir($fd))) { + if ($file != '.' && $file != '..' && $file != 'CVS' && is_dir($plugpath . $file) ) { + $op_plugin[] = $file; + $p_count++; } } - $i = 0; - foreach ( $plugins as $plg ) { - $k = "\$plugins[$i]"; - $newcfg[$k] = "'$plg'"; - $i++; - } - while ( isset( $newcfg["\$plugins[$i]"] ) ) { - $k = "\$plugins[$i]"; - $newcfg[$k] = ''; - $i++; - } - } else { - $i = 0; - while ( isset( $newcfg["\$plugins[$i]"] ) ) { - $k = "\$plugins[$i]"; - $v = $newcfg[$k]; - $plugins[] = substr( $v, 1, strlen( $v ) - 2 ); - $i++; - } - } - echo "'; - } else { - echo '\n"; - } + echo ''; + } else { + echo '\n"; + } } -echo "" , +echo '\n". '
'. + _("Configuration Administrator").'
'. + _("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."). + '
'. + _("Run or consult conf.pl should you run into difficulty with your configuration."). + '
$name" . $defcfg[$k]['value'] . - "
" . - "$sw " . - "$name
'. + "". + ''.$sw.' '.$name.'
$name". - ""; + ""; if ( isset( $defcfg[$k]['comment'] ) ) { echo '   ' . $defcfg[$k]['comment']; } echo "
$name"; @@ -352,7 +384,7 @@ foreach ( $newcfg as $k => $v ) { foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) { echo ""; } @@ -363,8 +395,8 @@ foreach ( $newcfg as $k => $v ) { echo "
$name". @@ -372,7 +404,7 @@ foreach ( $newcfg as $k => $v ) { foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) { echo ""; } @@ -384,71 +416,76 @@ foreach ( $newcfg as $k => $v ) { break; case SMOPT_TYPE_TEXTAREA: - if ( isset( $HTTP_POST_VARS[$e] ) ) { - $v = '"' . $HTTP_POST_VARS[$e] . '"'; + if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) { + $v = '"' . addslashes($new_v) . '"'; $newcfg[$k] = str_replace( "\n", '', $v ); } - echo "
$name". - ""; + echo "
$name" + .""; if ( isset( $defcfg[$k]['comment'] ) ) { echo '   ' . $defcfg[$k]['comment']; } echo "
$name". - ""; + echo "
$name" + ."'; if ( isset( $defcfg[$k]['comment'] ) ) { echo '   ' . $defcfg[$k]['comment']; } echo "
$name" . - "" . _("Yes") . - "" . _("No"); + "" . _("Yes") . + "" . _("No"); if ( isset( $defcfg[$k]['comment'] ) ) { echo '   ' . $defcfg[$k]['comment']; } echo "
$name". - ""; + echo "
$name". + "'; if ( isset( $defcfg[$k]['comment'] ) ) { echo '   ' . $defcfg[$k]['comment']; } - echo "
$name" . "$v"; @@ -469,8 +506,8 @@ if ( $colapse['Group7'] == 'off' ) { while ( isset( $newcfg["\$theme[$i]['NAME']"] ) ) { $k1 = "\$theme[$i]['NAME']"; $e1 = "theme_name_$i"; - if ( isset( $HTTP_POST_VARS[$e1] ) ) { - $v1 = '"' . str_replace( '\"', '"', $HTTP_POST_VARS[$e1] ) . '"'; + if ( sqgetGlobalVar($e, $v1, SQ_POST) ) { + $v1 = '"' . str_replace( '\"', '"', $v1 ) . '"'; $v1 = '"' . str_replace( '"', '\"', $v1 ) . '"'; $newcfg[$k1] = $v1; } else { @@ -478,17 +515,17 @@ if ( $colapse['Group7'] == 'off' ) { } $k2 = "\$theme[$i]['PATH']"; $e2 = "theme_path_$i"; - if ( isset( $HTTP_POST_VARS[$e2] ) ) { - $v2 = change_to_sm_path($HTTP_POST_VARS[$e2]); - $newcfg[$k2] = $v2; + if ( sqgetGlobalVar($e, $v2, SQ_POST) ) { + $v2 = change_to_sm_path($v2); + $newcfg[$k2] = $v2; } else { $v2 = $newcfg[$k2]; } $name = substr( $v1, 1, strlen( $v1 ) - 2 ); $path = change_to_rel_path($v2); echo '
$i. $i.
" . - "$sw " . - _("Plugins") . '
'. + ''. + $sw.' '._("Plugins").'
' . - "". - "\n"; - } - echo '
"; - foreach ( $op_plugin as $plg ) { - if ( in_array( $plg, $plugins ) ) { - $sw = ' checked'; + closedir($fd); + asort( $op_plugin ); + + /* Lets get the plugins that are active */ + $plugins = array(); + if ( sqgetGlobalVar('plg', $v, SQ_POST) ) { + foreach ( $op_plugin as $plg ) { + if ( sqgetGlobalVar("plgs_$plg", $v2, SQ_POST) && $v2 == 'on' ) { + $plugins[] = $plg; + } + } + $i = 0; + foreach ( $plugins as $plg ) { + $k = "\$plugins[$i]"; + $newcfg[$k] = "'$plg'"; + $i++; + } + while ( isset( $newcfg["\$plugins[$i]"] ) ) { + $k = "\$plugins[$i]"; + $newcfg[$k] = ''; + $i++; + } } else { - $sw = ''; + $i = 0; + while ( isset( $newcfg["\$plugins[$i]"] ) ) { + $k = "\$plugins[$i]"; + $v = $newcfg[$k]; + $plugins[] = substr( $v, 1, strlen( $v ) - 2 ); + $i++; + } } - echo '
$plg
Plugin directory could not be found: ' . $plugpath . "
'; + foreach ( $op_plugin as $plg ) { + if ( in_array( $plg, $plugins ) ) { + $sw = ' checked="checked"'; + } else { + $sw = ''; + } + echo '\n". + "". + "\n"; + } + echo '
'; + if (file_exists(SM_PATH . "plugins/$plg/README")) { + echo "$plg"; + } else { + echo $plg; + } + echo "
'. + sprintf(_("Plugin directory could not be found: %s"), $plugpath). + "

'. + ''. + _("Test Configuration")."
'; /* Write the options to the file. */ -if( $fp = @fopen( $cfgfile, 'w' ) ) { - fwrite( $fp, " $v ) { - if ( $k{0} == '$' && $v <> '' ) { + if ( $k{0} == '$' && $v <> '' || is_int($v)) { if ( substr( $k, 1, 11 ) == 'ldap_server' ) { $v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)"; $v = str_replace( 'array(', "array(\n\t", $v ); $v = str_replace( "',", "',\n\t", $v ); } + /* FIXME: add elseif that reverts plugins[#] to plugins[] */ fwrite( $fp, "$k = $v;\n" ); } } + // close php fwrite( $fp, '?>' ); fclose( $fp ); } else { - echo '
'. + echo '

'. _("Config file can't be opened. Please check config.php."). - ''; + '

'; } + ?> +