From 0890557ebb666dacf3356aae262ec79f486fa25d Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 04:48:13 -0400 Subject: Don't purge the ban list of expires bans every time somebody posts. Add a timer option. Less SQL queries when posting. --- inc/config.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 06c6c243..bc7711e6 100644 --- a/inc/config.php +++ b/inc/config.php @@ -983,6 +983,10 @@ // persistent spammers and ban evaders. Again, a little more database load. $config['ban_cidr'] = true; + // How often (minimum) to purge the ban list of expired bans (which have been seen). Only works when + // $config['cache'] is enabled and working. + $config['purge_bans'] = 60 * 60 * 12; // 12 hours + // Do DNS lookups on IP addresses to get their hostname for the moderator IP pages (?/IP/x.x.x.x). $config['mod']['dns_lookup'] = true; // How many recent posts, per board, to show in ?/IP/x.x.x.x. -- cgit v1.3 From 6e0e5b1e8a4e5bc5ec5dd13ed2361f37abd6d965 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 16:46:08 -0400 Subject: Not the nicest-looking fix, but comments (actual comments, not code examples) beginning with "$" are ignored by ?/config. --- inc/config.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index bc7711e6..410078d3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -475,8 +475,8 @@ // Maximum amount of animated GIF frames to resize (more frames can mean more processing power). A value // of "1" means thumbnails will not be animated. Requires $config['thumb_ext'] to be 'gif' (or blank) and - // $config['thumb_method'] to be 'imagick', 'convert', or 'convert+gifsicle'. This value is not respected - // by 'convert'; will just resize all frames if this is > 1. + // $config['thumb_method'] to be 'imagick', 'convert', or 'convert+gifsicle'. This value is not + // respected by 'convert'; will just resize all frames if this is > 1. $config['thumb_keep_animation_frames'] = 1; /* @@ -510,7 +510,7 @@ $config['strip_exif'] = false; // Use the command-line `exiftool` tool to strip EXIF metadata without decompressing/recompressing JPEGs. // Ignored when $config['redraw_image'] is true. This is also used to adjust the Orientation tag when - // $config['strip_exif'] is false and $config['convert_manual_orient'] is true. + // $config['strip_exif'] is false and $config['convert_manual_orient'] is true. $config['use_exiftool'] = false; // Redraw the image to strip any excess data (commonly ZIP archives) WARNING: This might strip the @@ -579,7 +579,7 @@ // Reject duplicate image uploads. $config['image_reject_repost'] = true; // Reject duplicate image uploads within the same thread. Doesn't change anything if - // $config['image_reject_repost'] is true. + // $config['image_reject_repost'] is true. $config['image_reject_repost_in_thread'] = false; // Display the aspect ratio of uploaded files. @@ -606,7 +606,7 @@ $config['threads_preview_sticky'] = 1; // How to display the URI of boards. Usually '/%s/' (/b/, /mu/, etc). This doesn't change the URL. Find - // $config['board_path'] if you wish to change the URL. + // $config['board_path'] if you wish to change the URL. $config['board_abbreviation'] = '/%s/'; // The default name (ie. Anonymous). @@ -909,7 +909,7 @@ // If you want to put images and other dynamic-static stuff on another (preferably cookieless) domain. // This will override $config['root'] and $config['dir']['...'] directives. "%s" will get replaced with - // $board['dir'], which includes a trailing slash. + // $board['dir'], which includes a trailing slash. // $config['uri_thumb'] = 'http://images.example.org/%sthumb/'; // $config['uri_img'] = 'http://images.example.org/%ssrc/'; @@ -984,7 +984,7 @@ $config['ban_cidr'] = true; // How often (minimum) to purge the ban list of expired bans (which have been seen). Only works when - // $config['cache'] is enabled and working. + // $config['cache'] is enabled and working. $config['purge_bans'] = 60 * 60 * 12; // 12 hours // Do DNS lookups on IP addresses to get their hostname for the moderator IP pages (?/IP/x.x.x.x). -- cgit v1.3 From c3da5ab4e1186d230c1c836a08f0cb68c55ce231 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 17:53:09 -0400 Subject: ?/config: Advanced permissions --- inc/config.php | 43 +++++++++++++++++++++++++++++++++++++++---- inc/mod/config-editor.php | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 6 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 410078d3..1437aa58 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1187,12 +1187,47 @@ $config['mod']['news_custom'] = ADMIN; // Delete news entries $config['mod']['news_delete'] = ADMIN; - - // Edit the current configuration (via web interface) - $config['mod']['edit_config'] = ADMIN; - // Execute un-filtered SQL queries on the database (?/debug/sql) $config['mod']['debug_sql'] = DISABLED; + // Edit the current configuration (via web interface) + $config['mod']['edit_config'] = MOD; + + // Config editor permissions + $config['mod']['config'] = array( + JANITOR => false, + MOD => false, + ADMIN => false, + DISABLED => false, + ); + + // Disable the following configuration variables from being changed via ?/config. The following default + // banned variables are considered somewhat dangerous. + $config['mod']['config'][DISABLED] = array( + 'mod>config', + 'mod>config_editor_php', + 'convert_args', + 'db>password', + ); + + $config['mod']['config'][JANITOR] = array( + '!', // Allow editing ONLY the variables listed (in this case, nothing). + ); + + $config['mod']['config'][MOD] = array( + '!', // Allow editing ONLY the variables listed (plus that in $config['mod']['config'][JANITOR]). + 'global_message', + ); + + // Example: Disallow ADMIN from editing (and viewing) $config['db']['password']. + // $config['mod']['config'][ADMIN] = array( + // 'db>password', + // ); + + // Example: Allow ADMIN to edit anything other than $config['db'] + // (and $config['mod']['config'][DISABLED]). + // $config['mod']['config'][ADMIN] = array( + // 'db', + // ); /* * ==================== diff --git a/inc/mod/config-editor.php b/inc/mod/config-editor.php index caca5a0e..27740378 100644 --- a/inc/mod/config-editor.php +++ b/inc/mod/config-editor.php @@ -1,5 +1,43 @@ ', $disabled_var_name); + if (count($disabled_var_name) == 1) + $disabled_var_name = $disabled_var_name[0]; + if ($varname == $disabled_var_name) + return false; + } + } + + $allow_only = false; + // for ($perm = (int)$mod['type']; $perm >= JANITOR; $perm --) { + for ($perm = JANITOR; $perm <= (int)$mod['type']; $perm ++) { + $allow_only = false; + if (is_array($config['mod']['config'][$perm])) { + foreach ($config['mod']['config'][$perm] as $perm_var_name) { + if ($perm_var_name == '!') { + $allow_only = true; + continue; + } + $perm_var_name = explode('>', $perm_var_name); + if ((count($perm_var_name) == 1 && $varname == $perm_var_name[0]) || + (is_array($varname) && array_slice($varname, 0, count($perm_var_name)) == $perm_var_name)) { + if ($allow_only) + return true; + else + return false; + } + } + } + } + + return !$allow_only; +} + function config_vars() { global $config; @@ -77,8 +115,8 @@ function config_vars() { $already_exists = true; } - if (!$already_exists) - $conf[] = $var; + if (!$already_exists && permission_to_edit_config_var($var['name'])) + $conf[] = $var; } } -- cgit v1.3 From 7a51444110c7fa539a630214b54ba1b7a9e4c6ad Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 17:53:55 -0400 Subject: This should probably still be ADMIN. By default, don't let mods or janitors edit any of the config. --- inc/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 1437aa58..61a36cad 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1190,7 +1190,7 @@ // Execute un-filtered SQL queries on the database (?/debug/sql) $config['mod']['debug_sql'] = DISABLED; // Edit the current configuration (via web interface) - $config['mod']['edit_config'] = MOD; + $config['mod']['edit_config'] = ADMIN; // Config editor permissions $config['mod']['config'] = array( -- cgit v1.3 From 0c829aa8f6fb592c15086e8b2b0276fd862e89f1 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 18:48:32 -0400 Subject: bugfix --- inc/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 61a36cad..ef2ba4ac 100644 --- a/inc/config.php +++ b/inc/config.php @@ -561,7 +561,7 @@ // Location of thumbnail to use for spoiler images. $config['spoiler_image'] = 'static/spoiler.png'; // Location of thumbnail to use for deleted images. - $config['image_deleted'] = 'static/deleted.png'; + // $config['image_deleted'] = 'static/deleted.png'; // When a thumbnailed image is going to be the same (in dimension), just copy the entire file and use // that as a thumbnail instead of resizing/redrawing. -- cgit v1.3