diff --git a/inc/config.php b/inc/config.php index d3f43224..2ddbe905 100644 --- a/inc/config.php +++ b/inc/config.php @@ -66,7 +66,10 @@ // Use `host` via shell_exec() to lookup hostnames, avoiding query timeouts. May not work on your system. // Requires safe_mode to be disabled. $config['dns_system'] = false; - + + // Check validity of the reverse DNS of IP addresses. Highly recommended. + $config['fcrdns'] = true; + // When executing most command-line tools (such as `convert` for ImageMagick image processing), add this // to the environment path (seperated by :). $config['shell_path'] = '/usr/local/bin'; diff --git a/inc/functions.php b/inc/functions.php index f9c09085..1b77c191 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -681,36 +681,38 @@ function listBoards($just_uri = false) { function until($timestamp) { $difference = $timestamp - time(); - if ($difference < 60) { + switch(TRUE){ + case ($difference < 60): return $difference . ' ' . ngettext('second', 'seconds', $difference); - } elseif ($difference < 60*60) { + case ($difference < 3600): //60*60 = 3600 return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num); - } elseif ($difference < 60*60*24) { - return ($num = round($difference/(60*60))) . ' ' . ngettext('hour', 'hours', $num); - } elseif ($difference < 60*60*24*7) { - return ($num = round($difference/(60*60*24))) . ' ' . ngettext('day', 'days', $num); - } elseif ($difference < 60*60*24*365) { - return ($num = round($difference/(60*60*24*7))) . ' ' . ngettext('week', 'weeks', $num); + case ($difference < 86400): //60*60*24 = 86400 + return ($num = round($difference/(3600))) . ' ' . ngettext('hour', 'hours', $num); + case ($difference < 604800): //60*60*24*7 = 604800 + return ($num = round($difference/(86400))) . ' ' . ngettext('day', 'days', $num); + case ($difference < 31536000): //60*60*24*365 = 31536000 + return ($num = round($difference/(604800))) . ' ' . ngettext('week', 'weeks', $num); + default: + return ($num = round($difference/(31536000))) . ' ' . ngettext('year', 'years', $num); } - - return ($num = round($difference/(60*60*24*365))) . ' ' . ngettext('year', 'years', $num); } function ago($timestamp) { $difference = time() - $timestamp; - if ($difference < 60) { + switch(TRUE){ + case ($difference < 60) : return $difference . ' ' . ngettext('second', 'seconds', $difference); - } elseif ($difference < 60*60) { + case ($difference < 3600): //60*60 = 3600 return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num); - } elseif ($difference < 60*60*24) { - return ($num = round($difference/(60*60))) . ' ' . ngettext('hour', 'hours', $num); - } elseif ($difference < 60*60*24*7) { - return ($num = round($difference/(60*60*24))) . ' ' . ngettext('day', 'days', $num); - } elseif ($difference < 60*60*24*365) { - return ($num = round($difference/(60*60*24*7))) . ' ' . ngettext('week', 'weeks', $num); + case ($difference < 86400): //60*60*24 = 86400 + return ($num = round($difference/(3600))) . ' ' . ngettext('hour', 'hours', $num); + case ($difference < 604800): //60*60*24*7 = 604800 + return ($num = round($difference/(86400))) . ' ' . ngettext('day', 'days', $num); + case ($difference < 31536000): //60*60*24*365 = 31536000 + return ($num = round($difference/(604800))) . ' ' . ngettext('week', 'weeks', $num); + default: + return ($num = round($difference/(31536000))) . ' ' . ngettext('year', 'years', $num); } - - return ($num = round($difference/(60*60*24*365))) . ' ' . ngettext('year', 'years', $num); } function displayBan($ban) { @@ -2267,6 +2269,12 @@ function rDNS($ip_addr) { $host = $ip_addr; } + $isip = filter_var($host, FILTER_VALIDATE_IP); + + if ($config['fcrdns'] && !$isip && DNS($host) != $ip_addr) { + $host = $ip_addr; + } + if ($config['cache']['enabled']) cache::set('rdns_' . $ip_addr, $host); diff --git a/inc/instance-config.php b/inc/instance-config.php index 56babbc8..cd9ff574 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -127,6 +127,7 @@ $config['additional_javascript'][] = 'js/mobile-style.js'; $config['additional_javascript'][] = 'js/id_highlighter.js'; $config['additional_javascript'][] = 'js/id_colors.js'; + $config['additional_javascript'][] = 'js/threadscroll.js'; $config['font_awesome_css'] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'; diff --git a/js/inline.js b/js/inline.js new file mode 100644 index 00000000..1ce0edc3 --- /dev/null +++ b/js/inline.js @@ -0,0 +1,139 @@ +;(function() { + var App = { + cache: {}, + get: function(url, cb) { + var $page = App.cache[url] + if ($page) + return cb($page) + + $.get(url, function(data) { + var $page = $(data) + App.cache[url] = $page + cb($page) + }) + }, + options: { + add: function(key, description, tab) { + tab || (tab = 'general') + + var checked = App.options.get(key) + var $el = $( + '