$board) { $query = prepare(sprintf(" SELECT IFNULL(MAX(id),0) max, (SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 HOUR)) pph, (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)); $r = $query->fetch(PDO::FETCH_ASSOC); $tquery = prepare("SELECT `tag` FROM ``board_tags`` WHERE `uri` = :uri"); $tquery->execute([":uri" => $board['uri']]) or error(db_error($tquery)); $r2 = $tquery->fetchAll(PDO::FETCH_ASSOC); $tags = array(); if ($r2) { foreach ($r2 as $ii => $t) { $tag=to_tag($t['tag']); $tags[] = $tag; if (!isset($all_tags[$tag])) { $all_tags[$tag] = (int)$r['uniq_ip']; } else { $all_tags[$tag] += $r['uniq_ip']; } } } $pph = $r['pph']; $total_posts_hour += $pph; $total_posts += $r['max']; $boards[$i]['pph'] = $pph; $boards[$i]['ppd'] = $pph*24; $boards[$i]['max'] = $r['max']; $boards[$i]['uniq_ip'] = $r['uniq_ip']; $boards[$i]['tags'] = $tags; if ($write_maxes) fwrite($fp, $board['uri'] . ':' . $boards[$i]['max'] . "\n"); } if ($write_maxes) fclose($fp); usort($boards, function ($a, $b) { $x = $b['uniq_ip'] - $a['uniq_ip']; if ($x) { return $x; //} else { return strcmp($a['uri'], $b['uri']); } } else { return $b['max'] - $a['max']; } }); $hidden_boards_total = 0; $rows = array(); foreach ($boards as $i => &$board) { $board_config = @file_get_contents($board['uri'].'/config.php'); $boardCONFIG = array(); if ($board_config && $board['uri'] !== 'int') { $board_config = str_replace('$config', '$boardCONFIG', $board_config); $board_config = str_replace('"; if ($showboard || $admin) { if (!$showboard) { $lock = ' '; } else { $lock = ''; } $board['ago'] = human_time_diff(strtotime($board['time'])); } else { unset($boards[$i]); $hidden_boards_total += 1; } } $n_boards = sizeof($boards); $t_boards = $hidden_boards_total + $n_boards; $boards = array_values($boards); arsort($all_tags); $config['additional_javascript'] = array('js/jquery.min.js', 'js/jquery.tablesorter.min.js'); $body = Element("8chan/boards-tags.html", array("config" => $config, "n_boards" => $n_boards, "t_boards" => $t_boards, "hidden_boards_total" => $hidden_boards_total, "total_posts" => $total_posts, "total_posts_hour" => $total_posts_hour, "boards" => $boards, "last_update" => date('r'), "uptime_p" => shell_exec('uptime -p'), 'tags' => $all_tags, 'top2k' => false)); $html = Element("page.html", array("config" => $config, "body" => $body, "title" => "Boards on ∞chan")); $boards_top2k = $boards; array_splice($boards_top2k, 2000); $boards_top2k = array_values($boards_top2k); $body = Element("8chan/boards-tags.html", array("config" => $config, "n_boards" => $n_boards, "t_boards" => $t_boards, "hidden_boards_total" => $hidden_boards_total, "total_posts" => $total_posts, "total_posts_hour" => $total_posts_hour, "boards" => $boards_top2k, "last_update" => date('r'), "uptime_p" => shell_exec('uptime -p'), 'tags' => $all_tags, 'top2k' => true)); $html_top2k = Element("page.html", array("config" => $config, "body" => $body, "title" => "Boards on ∞chan")); if ($admin) { echo $html; } else { foreach ($boards as $i => &$b) { unset($b['img']); } file_write("boards.json", json_encode($boards)); file_write("tags.json", json_encode($all_tags)); foreach ($boards as $i => $b) { if (in_array($b['uri'], $config['no_top_bar_boards'])) { unset($boards[$i]); } unset($boards[$i]['img']); } array_splice($boards, 48); $boards = array_values($boards); file_write("boards-top20.json", json_encode($boards)); file_write("boards.html", $html_top2k); file_write("boards_full.html", $html); echo 'Done'; }