Don't keep track of moderator count globally, use new function instead.
This commit is contained in:
25
chat.php
25
chat.php
@ -42,7 +42,6 @@ $I=array();// Translations
|
|||||||
$L=array();// Languages
|
$L=array();// Languages
|
||||||
$P=array();// All present users [display name, style, status, nickname]
|
$P=array();// All present users [display name, style, status, nickname]
|
||||||
$U=array();// This user data
|
$U=array();// This user data
|
||||||
$countmods=0;// Present moderators
|
|
||||||
$db;// Database connection
|
$db;// Database connection
|
||||||
$memcached;// Memcached connection
|
$memcached;// Memcached connection
|
||||||
$language;// user selected language
|
$language;// user selected language
|
||||||
@ -59,7 +58,7 @@ route();
|
|||||||
|
|
||||||
// main program: decide what to do based on queries
|
// main program: decide what to do based on queries
|
||||||
function route(){
|
function route(){
|
||||||
global $U, $countmods;
|
global $U;
|
||||||
if(!isSet($_REQUEST['action'])){
|
if(!isSet($_REQUEST['action'])){
|
||||||
if(!check_init()){
|
if(!check_init()){
|
||||||
send_init();
|
send_init();
|
||||||
@ -75,7 +74,7 @@ function route(){
|
|||||||
}elseif($_REQUEST['action']==='post'){
|
}elseif($_REQUEST['action']==='post'){
|
||||||
check_session();
|
check_session();
|
||||||
if(isSet($_REQUEST['kick']) && isSet($_REQUEST['sendto']) && $_REQUEST['sendto']!=='&'){
|
if(isSet($_REQUEST['kick']) && isSet($_REQUEST['sendto']) && $_REQUEST['sendto']!=='&'){
|
||||||
if($U['status']>=5 || ($U['status']>=3 && $countmods===0 && get_setting('memkick'))){
|
if($U['status']>=5 || ($U['status']>=3 && get_count_mods()==0 && get_setting('memkick'))){
|
||||||
if(isSet($_REQUEST['what']) && $_REQUEST['what']==='purge'){
|
if(isSet($_REQUEST['what']) && $_REQUEST['what']==='purge'){
|
||||||
kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], true);
|
kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], true);
|
||||||
}else{
|
}else{
|
||||||
@ -1486,10 +1485,10 @@ function send_approve_waiting(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send_waiting_room(){
|
function send_waiting_room(){
|
||||||
global $H, $I, $U, $countmods, $db, $language;
|
global $H, $I, $U, $db, $language;
|
||||||
parse_sessions();
|
parse_sessions();
|
||||||
$ga=(int) get_setting('guestaccess');
|
$ga=(int) get_setting('guestaccess');
|
||||||
if($ga===3 && ($countmods>0 || !get_setting('modfallback'))){
|
if($ga===3 && (get_count_mods()>0 || !get_setting('modfallback'))){
|
||||||
$wait=false;
|
$wait=false;
|
||||||
}else{
|
}else{
|
||||||
$wait=true;
|
$wait=true;
|
||||||
@ -1574,7 +1573,7 @@ function send_del_confirm(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send_post(){
|
function send_post(){
|
||||||
global $I, $P, $U, $countmods, $db;
|
global $I, $P, $U, $db;
|
||||||
$U['postid']=substr(time(), -6);
|
$U['postid']=substr(time(), -6);
|
||||||
print_start('post');
|
print_start('post');
|
||||||
if(!isSet($_REQUEST['sendto'])){
|
if(!isSet($_REQUEST['sendto'])){
|
||||||
@ -1641,7 +1640,7 @@ function send_post(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '</select>';
|
echo '</select>';
|
||||||
if(!$disablepm && ($U['status']>=5 || ($U['status']>=3 && $countmods===0 && get_setting('memkick')))){
|
if(!$disablepm && ($U['status']>=5 || ($U['status']>=3 && get_count_mods()==0 && get_setting('memkick')))){
|
||||||
echo "<input type=\"checkbox\" name=\"kick\" id=\"kick\" value=\"kick\"><label for=\"kick\"> $I[kick]</label>";
|
echo "<input type=\"checkbox\" name=\"kick\" id=\"kick\" value=\"kick\"><label for=\"kick\"> $I[kick]</label>";
|
||||||
echo "<input type=\"checkbox\" name=\"what\" id=\"what\" value=\"purge\" checked><label for=\"what\"> $I[alsopurge]</label>";
|
echo "<input type=\"checkbox\" name=\"what\" id=\"what\" value=\"purge\" checked><label for=\"what\"> $I[alsopurge]</label>";
|
||||||
}
|
}
|
||||||
@ -2275,6 +2274,12 @@ function check_expired(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_count_mods(){
|
||||||
|
global $db;
|
||||||
|
$c=$db->query('SELECT COUNT(*) FROM ' . PREFIX . 'sessions WHERE status>=5')->fetch(PDO::FETCH_NUM);
|
||||||
|
return $c[0];
|
||||||
|
}
|
||||||
|
|
||||||
function check_kicked(){
|
function check_kicked(){
|
||||||
global $I, $U;
|
global $I, $U;
|
||||||
if($U['status']==0){
|
if($U['status']==0){
|
||||||
@ -2293,7 +2298,7 @@ function get_nowchatting(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parse_sessions(){
|
function parse_sessions(){
|
||||||
global $P, $U, $countmods, $db;
|
global $P, $U, $db;
|
||||||
// delete old sessions
|
// delete old sessions
|
||||||
$time=time();
|
$time=time();
|
||||||
$result=$db->prepare('SELECT nickname, status FROM ' . PREFIX . 'sessions WHERE (status<=2 AND lastpost<(?-60*(SELECT value FROM ' . PREFIX . "settings WHERE setting='guestexpire'))) OR (status>2 AND lastpost<(?-60*(SELECT value FROM " . PREFIX . "settings WHERE setting='memberexpire')));");
|
$result=$db->prepare('SELECT nickname, status FROM ' . PREFIX . 'sessions WHERE (status<=2 AND lastpost<(?-60*(SELECT value FROM ' . PREFIX . "settings WHERE setting='guestexpire'))) OR (status>2 AND lastpost<(?-60*(SELECT value FROM " . PREFIX . "settings WHERE setting='memberexpire')));");
|
||||||
@ -2324,7 +2329,6 @@ function parse_sessions(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// load other sessions
|
// load other sessions
|
||||||
$countmods=0;
|
|
||||||
$P=array();
|
$P=array();
|
||||||
if(isSet($U['nickname'])){
|
if(isSet($U['nickname'])){
|
||||||
$stmt=$db->prepare('SELECT nickname, style, status, incognito FROM ' . PREFIX . 'sessions WHERE entry!=0 AND status>0 AND nickname NOT IN (SELECT ign FROM '. PREFIX . 'ignored WHERE ignby=?) AND nickname NOT IN (SELECT ignby FROM '. PREFIX . 'ignored WHERE ign=?) ORDER BY status DESC, lastpost DESC;');
|
$stmt=$db->prepare('SELECT nickname, style, status, incognito FROM ' . PREFIX . 'sessions WHERE entry!=0 AND status>0 AND nickname NOT IN (SELECT ign FROM '. PREFIX . 'ignored WHERE ignby=?) AND nickname NOT IN (SELECT ignby FROM '. PREFIX . 'ignored WHERE ign=?) ORDER BY status DESC, lastpost DESC;');
|
||||||
@ -2336,9 +2340,6 @@ function parse_sessions(){
|
|||||||
if(!$temp['incognito']){
|
if(!$temp['incognito']){
|
||||||
$P[$temp['nickname']]=[$temp['nickname'], $temp['style'], $temp['status'], $temp['nickname']];
|
$P[$temp['nickname']]=[$temp['nickname'], $temp['style'], $temp['status'], $temp['nickname']];
|
||||||
}
|
}
|
||||||
if($temp['status']>=5){
|
|
||||||
++$countmods;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user