Display number of users in thread.php

This commit is contained in:
Retro_Guy 2021-04-29 16:16:32 -07:00
parent ec635be396
commit d12f36e1dd
8 changed files with 66 additions and 18 deletions

View File

@ -109,6 +109,7 @@ sed -i '' -e "s|<anonymous_password>|$anonymous_password|" $configpath/rslight.i
sed -i '' -e "s|<local_password>|$local_password|" $configpath/rslight.inc.php
sed -i '' -e "s|<admin_password>|$admin_password|" $configpath/admin.inc.php
sed -i '' -e "s|<admin_key>|$admin_key|" $configpath/admin.inc.php
sed -i '' -e "s|<sessions_path>|/var/lib/php/sessions|" $configpath/rslight.inc.php
echo "done"
echo
echo "***************************************************"

View File

@ -108,6 +108,7 @@ sed -i '' -e "s|<anonymous_password>|$anonymous_password|" $configpath/rslight.i
sed -i '' -e "s|<local_password>|$local_password|" $configpath/rslight.inc.php
sed -i '' -e "s|<admin_password>|$admin_password|" $configpath/admin.inc.php
sed -i '' -e "s|<admin_key>|$admin_key|" $configpath/admin.inc.php
sed -i '' -e "s|<sessions_path>|/tmp|" $configpath/rslight.inc.php
echo "done"
echo
echo "***************************************************"

View File

@ -1,10 +1,11 @@
<center>
<font size="1em">
<i>rocksolid light</i> 0.6.9
<br />
<a href="https://github.com/novabbs/rocksolid-light" target=_blank>clearnet</a>
<a href="http://rslight.i2p/getrslight" target=_blank>i2p</a>
<a href="http://git.fuwafuwaqtlkkxwc.onion/novabbs/rocksolid-light" target=_blank>tor</a>
</font>
</center>
<?php
echo '<center>';
echo '<font size="1em">';
echo '<i>rocksolid light</i> 0.6.9';
echo '<br />';
echo '<a href="https://github.com/novabbs/rocksolid-light" target=_blank>clearnet</a>';
echo '<a href="http://rslight.i2p/getrslight" target=_blank>i2p</a>';
echo '<a href="http://git.fuwafuwaqtlkkxwc.onion/novabbs/rocksolid-light" target=_blank>tor</a>';
echo '</font>';
echo '</center>';
?>

View File

@ -137,5 +137,7 @@ if(isset($frames_on) && $frames_on === true) {
} else {
echo $text_register["no_access_group"];
}
$sessions_data = file_get_contents($spooldir.'/sessions.dat');
echo '<h1 class="np_thread_headline">'.$sessions_data.'</h1>';
include "tail.inc";
?>

View File

@ -37,7 +37,7 @@ return [
'spamc' => 'spamc',
'spamgroup' => 'rocksolid.spam',
'php_exec' => 'php',
'tac' => 'tac',
'tac' => '<sessions_path>',
'webserver_user' => '<webserver_user>',
'enable_nocem' => '',
'nocem_groups' => 'rocksolid.spam',

View File

@ -0,0 +1,40 @@
<?php
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_users() {
GLOBAL $CONFIG, $spooldir;
$session_age = 300;
$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, 'starttime') !== false) {
$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</h1>'."\r\n";
file_put_contents($session_save_file, $session_info);
}
?>

View File

@ -25,11 +25,14 @@
}
}
fclose($fp1);
exec($CONFIG['php_exec']." ".$config_dir."scripts/nntp.php > /dev/null 2>&1");
exec($CONFIG['php_exec']." ".$config_dir."/scripts/nntp.php > /dev/null 2>&1");
if(is_numeric($CONFIG['local_ssl_port'])) {
exec($CONFIG['php_exec']." ".$config_dir."scripts/nntp-ssl.php > /dev/null 2>&1");
exec($CONFIG['php_exec']." ".$config_dir."/scripts/nntp-ssl.php > /dev/null 2>&1");
}
}
# Generate user count file (must be root)
exec($CONFIG['php_exec']." ".$config_dir."/scripts/count_users.php");
echo "Updated user count\n";
/* Change to non root user */
$uinfo=posix_getpwnam($CONFIG['webserver_user']);
change_identity($uinfo["uid"],$uinfo["gid"]);
@ -39,7 +42,7 @@
if(isset($CONFIG['enable_nocem']) && $CONFIG['enable_nocem'] == true) {
@mkdir($spooldir."nocem",0755,'recursive');
exec($CONFIG['php_exec']." ".$config_dir."scripts/nocem.php");
exec($CONFIG['php_exec']." ".$config_dir."/scripts/nocem.php");
}
reset($menulist);
@ -51,14 +54,14 @@ foreach($menulist as $menu) {
chdir("../".$menuitem[0]);
# Send articles
echo "Sending articles\n";
echo exec($CONFIG['php_exec']." ".$config_dir."scripts/send.php");
echo exec($CONFIG['php_exec']." ".$config_dir."/scripts/send.php");
# Refresh spool
if(isset($spoolnews) && ($spoolnews == true)) {
exec($CONFIG['php_exec']." ".$config_dir."scripts/spoolnews.php");
exec($CONFIG['php_exec']." ".$config_dir."/scripts/spoolnews.php");
echo "Refreshed spoolnews\n";
}
# Expire articles
exec($CONFIG['php_exec']." ".$config_dir."scripts/expire.php");
exec($CONFIG['php_exec']." ".$config_dir."/scripts/expire.php");
echo "Expired articles\n";
}
# Rotate log files

View File

@ -51,7 +51,7 @@ return [
# Executables on your system
'php_exec' => 'The path to php, or just php if it is already in your path',
'tac' => 'The shell command to display a file in reverse (Try tac, or tail -r)',
'tac' => 'Path to php session files (leave empty to not display number of users online)',
'webserver_user' => 'The user that your webserver runs as',
# NOCEM