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/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 8b2c4c7b..0c9b9983 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -687,9 +687,19 @@ function checkBan($board = 0) { // No reason to keep expired bans in the database (except those that haven't been viewed yet) function purge_bans() { + global $config; + + if ($config['cache']['enabled'] && $last_time_purged = cache::get('purged_bans_last')) { + if (time() - $last_time_purged < 60 * 30) + return; + } + $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :time AND `seen` = 1"); $query->bindValue(':time', time()); $query->execute() or error(db_error($query)); + + if ($config['cache']['enabled']) + cache::set('purged_bans_last', time()); } function threadLocked($id) { -- cgit v1.3 From 6409ac61639e588f62904d54a4fb37158d31a5f4 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 04:49:21 -0400 Subject: fix last commit --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 0c9b9983..fe27a568 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -690,7 +690,7 @@ function purge_bans() { global $config; if ($config['cache']['enabled'] && $last_time_purged = cache::get('purged_bans_last')) { - if (time() - $last_time_purged < 60 * 30) + if (time() - $last_time_purged < $config['purge_bans'] ) return; } -- cgit v1.3 From 0f00f800b9735fe8b2c5c366a9b3972039c317e0 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 05:03:21 -0400 Subject: Use new shell_exec function for $config['dns_system'] `host` queries too --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index fe27a568..82f047b5 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1901,7 +1901,7 @@ function rDNS($ip_addr) { if (!$config['dns_system']) { $host = gethostbyaddr($ip_addr); } else { - $resp = shell_exec('host -W 1 ' . $ip_addr); + $resp = shell_exec_error('host -W 1 ' . $ip_addr); if (preg_match('/domain name pointer ([^\s]+)$/', $resp, $m)) $host = $m[1]; else @@ -1926,7 +1926,7 @@ function DNS($host) { if ($ip_addr == $host) $ip_addr = false; } else { - $resp = shell_exec('host -W 1 ' . $host); + $resp = shell_exec_error('host -W 1 ' . $host); if (preg_match('/has address ([^\s]+)$/', $resp, $m)) $ip_addr = $m[1]; else -- cgit v1.3 From acfda35648b5a3eac5607084b781c0ced8e0bc53 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 4 Aug 2013 16:32:36 -0400 Subject: gifsicle: redirect stdout to /dev/null but keep stderr going to stdout --- inc/functions.php | 5 +++-- inc/image.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 82f047b5..01fdb18e 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1939,13 +1939,14 @@ function DNS($host) { return $ip_addr; } -function shell_exec_error($command) { +function shell_exec_error($command, $suppress_stdout = false) { global $config, $debug; if ($config['debug']) $start = microtime(true); - $return = trim(shell_exec('PATH="' . escapeshellcmd($config['shell_path']) . ':$PATH";' . $command . ' 2>&1 && echo "TB_SUCCESS"')); + $return = trim(shell_exec('PATH="' . escapeshellcmd($config['shell_path']) . ':$PATH";' . + $command . ' 2>&1 ' . ($suppress_stdout ? '> /dev/null ' : '') . '&& echo "TB_SUCCESS"')); $return = preg_replace('/TB_SUCCESS$/', '', $return); if ($config['debug']) { diff --git a/inc/image.php b/inc/image.php index b3c0e6b5..920cf8f9 100644 --- a/inc/image.php +++ b/inc/image.php @@ -321,8 +321,8 @@ class ImageConvert extends ImageBase { if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) { if ($this->gifsicle) { if (($error = shell_exec_error("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " . - escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" >/dev/null -o " . - escapeshellarg($this->temp))) || !file_exists($this->temp)) + escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" -o " . + escapeshellarg($this->temp), true)) || !file_exists($this->temp)) error('Failed to resize image!', null, $error); } else { if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg')) -- cgit v1.3