Display number of bots separately from number of users online.
This commit is contained in:
parent
3550e09894
commit
d205bfa6a4
|
@ -9,8 +9,6 @@ include "auth.inc";
|
|||
include "$file_newsportal";
|
||||
|
||||
$logfile = $logdir . '/newsportal.log';
|
||||
throttle_hits();
|
||||
write_access_log();
|
||||
if (isset($_COOKIE['mail_name'])) {
|
||||
if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) {
|
||||
$userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-articleviews.dat';
|
||||
|
@ -101,10 +99,11 @@ if (! $message) {
|
|||
$title .= ' - ' . $group . ' - ' . $subject;
|
||||
}
|
||||
include "head.inc";
|
||||
|
||||
throttle_hits($client_device);
|
||||
if ($client_device != "bot") {
|
||||
$_SESSION['rsactive'] = true;
|
||||
}
|
||||
write_access_log();
|
||||
|
||||
echo '<h1 class="np_thread_headline">';
|
||||
echo '<a href="' . $file_index . '" target=' . $frame['menu'] . '>' . basename(getcwd()) . '</a> / ';
|
||||
|
|
|
@ -6,8 +6,6 @@ include "config.inc.php";
|
|||
include "auth.inc";
|
||||
include "$file_newsportal";
|
||||
|
||||
throttle_hits();
|
||||
|
||||
// register parameters
|
||||
$id = $_REQUEST["id"];
|
||||
$group = _rawurldecode($_REQUEST["group"]);
|
||||
|
@ -47,6 +45,7 @@ if (! $message) {
|
|||
$title .= ' - ' . $group . ' - ' . $subject;
|
||||
}
|
||||
include "head.inc";
|
||||
throttle_hits($client_device);
|
||||
|
||||
// has the user read-rights on this article?
|
||||
if ((function_exists("npreg_group_has_read_access") && ! npreg_group_has_read_access($group)) || (function_exists("npreg_group_is_visible") && ! npreg_group_is_visible($group))) {
|
||||
|
|
|
@ -1734,7 +1734,10 @@ function disable_page_by_user_agent($client_device, $useragent, $script = "Page"
|
|||
|
||||
function throttle_hits()
|
||||
{
|
||||
global $CONFIG, $logdir;
|
||||
global $CONFIG, $logdir, $client_device;
|
||||
if ($client_device == "bot") {
|
||||
$_SESSION['bot'] = 'true';
|
||||
}
|
||||
$logfile = $logdir . '/newsportal.log';
|
||||
if (! isset($_SESSION['starttime'])) {
|
||||
$_SESSION['starttime'] = time();
|
||||
|
|
|
@ -31,8 +31,6 @@ include "config.inc.php";
|
|||
include "auth.inc";
|
||||
include "$file_newsportal";
|
||||
|
||||
throttle_hits();
|
||||
write_access_log();
|
||||
if (isset($_COOKIE['mail_name'])) {
|
||||
if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) {
|
||||
$userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-articleviews.dat';
|
||||
|
@ -58,6 +56,14 @@ if (isset($_GET['thisgroup'])) {
|
|||
$title .= " - " . $config_name . " - overboard";
|
||||
}
|
||||
include "head.inc";
|
||||
throttle_hits($client_device);
|
||||
if (disable_page_by_user_agent($client_device, "bot", "Overboard")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
exit();
|
||||
}
|
||||
write_access_log();
|
||||
|
||||
$CONFIG = include ($config_file);
|
||||
$logfile = $logdir . '/overboard.log';
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ header("Pragma: cache");
|
|||
include "config.inc.php";
|
||||
include "newsportal.php";
|
||||
|
||||
throttle_hits();
|
||||
|
||||
$snippet_size = 100;
|
||||
|
||||
if (isset($_REQUEST['data']) && $_REQUEST['data'] == '') {
|
||||
|
@ -20,6 +18,7 @@ if (isset($_REQUEST['data']) && $_REQUEST['data'] == '') {
|
|||
if ((! isset($_POST['key']) || ! password_verify($CONFIG['thissitekey'], $_POST['key'])) || ((strlen(trim($_REQUEST['terms'])) < 2) && ! $_REQUEST['data'])) {
|
||||
include "head.inc";
|
||||
|
||||
throttle_hits($client_device);
|
||||
if (disable_page_by_user_agent($client_device, "bot", "Search")) {
|
||||
echo "<center>Page Disabled</center>";
|
||||
include "tail.inc";
|
||||
|
|
|
@ -8,10 +8,6 @@ include "config.inc.php";
|
|||
include ("$file_newsportal");
|
||||
include "auth.inc";
|
||||
|
||||
$logfile = $logdir . '/newsportal.log';
|
||||
throttle_hits();
|
||||
write_access_log();
|
||||
|
||||
// register parameters
|
||||
$group = _rawurldecode($_REQUEST["group"]);
|
||||
if (isset($_REQUEST["first"]))
|
||||
|
@ -41,6 +37,9 @@ if (isset($_COOKIE['mail_name'])) {
|
|||
$thread_show["latest"] = true;
|
||||
$title .= ' - ' . $group;
|
||||
include "head.inc";
|
||||
$logfile = $logdir . '/newsportal.log';
|
||||
throttle_hits($client_device);
|
||||
write_access_log();
|
||||
|
||||
$CONFIG = include ($config_file);
|
||||
|
||||
|
|
|
@ -1,49 +1,62 @@
|
|||
<?php
|
||||
include "config.inc.php";
|
||||
include ("$file_newsportal");
|
||||
if(trim($CONFIG['tac'] == '')) {
|
||||
if(is_file($spooldir.'/sessions.dat')) {
|
||||
unlink($spooldir.'/sessions.dat');
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
include "config.inc.php";
|
||||
include ("$file_newsportal");
|
||||
if (trim($CONFIG['tac'] == '')) {
|
||||
if (is_file($spooldir . '/sessions.dat')) {
|
||||
unlink($spooldir . '/sessions.dat');
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
count_users();
|
||||
|
||||
function count_articles() {
|
||||
GLOBAL $CONFIG, $spooldir;
|
||||
$database = $spooldir.'/articles-overview.db3';
|
||||
$dbh = overview_db_open($database);
|
||||
$count = $dbh->query('SELECT COUNT(DISTINCT msgid) FROM overview')->fetchColumn();
|
||||
$dbh = null;
|
||||
return $count;
|
||||
function count_articles()
|
||||
{
|
||||
GLOBAL $CONFIG, $spooldir;
|
||||
$database = $spooldir . '/articles-overview.db3';
|
||||
$dbh = overview_db_open($database);
|
||||
$count = $dbh->query('SELECT COUNT(DISTINCT msgid) FROM overview')->fetchColumn();
|
||||
$dbh = null;
|
||||
return $count;
|
||||
}
|
||||
|
||||
function count_users() {
|
||||
GLOBAL $CONFIG, $spooldir;
|
||||
$session_age = 600;
|
||||
$session_save_file = $spooldir.'/sessions.dat';
|
||||
function count_users()
|
||||
{
|
||||
GLOBAL $CONFIG, $spooldir;
|
||||
$session_age = 600;
|
||||
$session_save_file = $spooldir . '/sessions.dat';
|
||||
$session_dir = $CONFIG['tac'];
|
||||
$session_files = scandir($session_dir);
|
||||
$count = 0;
|
||||
foreach($session_files as $session_file) {
|
||||
if(filemtime($session_dir.'/'.$session_file) < time() - $session_age) {
|
||||
continue;
|
||||
}
|
||||
if(strpos($session_file, 'sess_') === 0) {
|
||||
$contents = file_get_contents($session_dir.'/'.$session_file);
|
||||
if(strpos($contents, 'rsactive') !== false) {
|
||||
$count++;
|
||||
$bot_count = 0;
|
||||
foreach ($session_files as $session_file) {
|
||||
if (filemtime($session_dir . '/' . $session_file) < time() - $session_age) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($session_file, 'sess_') === 0) {
|
||||
$contents = file_get_contents($session_dir . '/' . $session_file);
|
||||
if (strpos($contents, 'rsactive') !== false) {
|
||||
$count ++;
|
||||
}
|
||||
if (strpos($contents, 'bot') !== false) {
|
||||
$bot_count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($count == 1) {
|
||||
$are = 'is';
|
||||
$users = 'user';
|
||||
} else {
|
||||
$are = 'are';
|
||||
$users = 'users';
|
||||
}
|
||||
$session_info = '<h1 class="np_thread_headline">There '.$are.' currently '.$count.' '. $users.' online <br />Total messages: '.number_format(count_articles()).'</h1>'."\r\n";
|
||||
file_put_contents($session_save_file, $session_info);
|
||||
if ($count == 1) {
|
||||
$are = 'is';
|
||||
$users = 'user';
|
||||
} else {
|
||||
$are = 'are';
|
||||
$users = 'users';
|
||||
}
|
||||
if ($bot_count == 1) {
|
||||
$bot_are = 'is';
|
||||
$bot_users = 'spider';
|
||||
} else {
|
||||
$bot_are = 'are';
|
||||
$bot_users = 'spiders';
|
||||
}
|
||||
$session_info = '<h1 class="np_thread_headline">There ' . $are . ' currently ' . $count . ' ' . $users . ' online / plus ' . $bot_count . ' ' . $bot_users . '<br />Total messages: ' . number_format(count_articles()) . '</h1>' . "\r\n";
|
||||
file_put_contents($session_save_file, $session_info);
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue