diff --git a/boards.php b/boards.php index f1d6656e..c4e42651 100644 --- a/boards.php +++ b/boards.php @@ -22,7 +22,7 @@ foreach ($boards as $i => $board) { SELECT MAX(id) max, (SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 DAY)) ppd, (SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 HOUR)) pph, (SELECT count(id) FROM ``posts_%s``) count, -(SELECT COUNT(DISTINCT ip) FROM ``posts_%s``) uniq_ip +(SELECT COUNT(DISTINCT ip) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 3 DAY)) uniq_ip FROM ``posts_%s`` ", $board['uri'], $board['uri'], $board['uri'], $board['uri'], $board['uri'])); $query->execute() or error(db_error($query)); @@ -42,7 +42,7 @@ SELECT MAX(id) max, (SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) usort($boards, function ($a, $b) { - $x = $b['ppd'] - $a['ppd']; + $x = $b['uniq_ip'] - $a['uniq_ip']; if ($x) { return $x; //} else { return strcmp($a['uri'], $b['uri']); } } else { return $b['max'] - $a['max']; } diff --git a/inc/instance-config.php b/inc/instance-config.php index 320533d1..56babbc8 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -97,6 +97,7 @@ $config['additional_javascript'][] = 'js/style-select.js'; $config['additional_javascript'][] = 'js/options/general.js'; $config['additional_javascript'][] = 'js/post-hover.js'; + $config['additional_javascript'][] = 'js/update_boards.js'; $config['additional_javascript'][] = 'js/favorites.js'; $config['additional_javascript'][] = 'js/show-op.js'; $config['additional_javascript'][] = 'js/hide-threads.js'; @@ -137,7 +138,8 @@ $config['markup'][] = array("/\[spoiler\](.+?)\[\/spoiler\]/", "\$1"); $config['markup'][] = array("/~~(.+?)~~/", "\$1"); - $config['boards'] = array(array('' => '/', '' => '/boards.html', '' => '/faq.html', '' => '/random.php', '' => '/create.php', '' => '/search.php', '' => '/mod.php', '' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array(''=>'https://twitter.com/infinitechan')); + $config['boards'] = array(array('' => '/', '' => '/boards.html', '' => '/faq.html', '' => '/random.php', '' => '/create.php', '' => '/search.php', '' => '/mod.php', '' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array(''=>'https://twitter.com/infinitechan')); + //$config['boards'] = array(array('' => '/', '' => '/boards.html', '' => '/faq.html', '' => '/random.php', '' => '/create.php', '' => '/search.php', '' => '/mod.php', '' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array(''=>'https://twitter.com/infinitechan')); $config['footer'][] = 'Contribute to 8chan.co development at github'; $config['footer'][] = 'To make a DMCA request or report illegal content, please email admin@8chan.co or use the "Global Report" functionality on every page.'; diff --git a/js/update_boards.js b/js/update_boards.js new file mode 100644 index 00000000..15f9ea04 --- /dev/null +++ b/js/update_boards.js @@ -0,0 +1,20 @@ +$(document).ready(function(){ + +window.boards = new Array(); +function handle_boards(data) { + $.each(data, function(k, v) { + if (v.uri != 'meta' && v.uri != 'b' && v.uri != 'int') { + boards.push(''+v.uri+''); + } + }) + + if (boards[0]) { + $('.favorite-boards').before(' [ '+boards.slice(0,15).join(" / ")+' ] '); + } + +} + +$.getJSON("/boards.json", handle_boards) + + +});