<commit_before><?php
session_start();

ob_start();

include "./common.php";
include "./lib/tasks.php";

$db = new Database();

moderator_access();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?= _('Stalker MW admin interface')?></title>
<style type="text/css">
td, table.menu {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
	border-width: 1px;
    border-style: solid;
    border-color: #E5E5E5;
	background-color:#88BBFF
}
td.other {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
	border-width: 1px;
    border-style: solid;
    border-color: #E5E5E5;
	background-color:#FFFFFF;
}
.td_stat{
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
    text-align: right;
	border-width: 0px;
    border-style: solid;
    border-color: #E5E5E5;
	background-color:#f5f5f5;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:16px
}
a{
	color:#FFFFFF;
	font-weight: bold;
	text-decoration:none;
}
a:link{
	color:#FFFFFF;
	font-weight: bold;
}
a:visited{
    color:#FFFFFF;
	font-weight: bold;
	text-decoration:none;
}
a:hover{
	color:#FFFFFF;
	font-weight: bold;
	text-decoration:underline;
}
.lang{
    color: blue !important;
    font-weight: normal !important;
    font-family: Arial, sans-serif;
    font-size: 14px;
}
</style>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.cookies.2.2.0.js"></script>

<script type="text/javascript">

    $(function(){
        $('.lang').click(function(e){
            var lang = $(e.target).attr('lang');
            $.cookies.set('language', lang, {expiresAt: new Date( 2037, 1, 1 )});
            document.location = document.location;
        });
    });

</script>

</head>

<body>
<div style="width: 80%; margin:0 auto; text-align: right">
    <a href="javascript://" class="lang" lang="en">en</a> | <a href="javascript://" class="lang" lang="ru">ru</a>
</div>
<br>
<br>
<table width="80%" border="0" align="center">
  <tr>
    <td align="right" class="other" style="border-width: 0px;"><?echo date("Y-m-d H:i:s")?></td>
  </tr>
</table>

<table width="80%"  border="1" align="center" cellpadding="3" cellspacing="0" class="menu">
  <tr>
    <td colspan="3" align="center"><span class="style1"><?= _('Sections')?></span></td>
  </tr>
  
  <tr>
    <td width="47%"><div align="center"><a href="add_itv.php"><?= _('IPTV channels')?></a></div></td>
    <td width="6%">&nbsp;</td>
    <td width="47%"><div align="center"><a href="users.php"><?= _('Users')?></a></div></td>
  </tr>
  
  <tr>
    <td><div align="center"><a href="add_video.php"><?= _('VIDEO CLUB')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"><a href="events.php"><?= _('Events')?></a></td>
  </tr>
  
  <tr>
    <td><div align="center"><a href="add_karaoke.php"><?= _('KARAOKE')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"><a href="logout.php">[<?echo $_SESSION['login']?>] <?= _('Logout')?></a></td>
  </tr>
  
  <tr>
    <td><div align="center"><a href="add_radio.php"><?= _('RADIO')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"></td>
  </tr>
  
  <tr>
    <td><!--<div align="center"><a href="ad.php">РЕКЛАМА</a></div>--></td>
    <td>&nbsp;</td>
    <td align="center"></td>
  </tr>

  <tr>
    <td><div align="center"><a href="tariffs.php"><?= _('TARIFFS')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"><?
    if (check_access(array(1,2))){
        echo "<a href='tasks.php'>".sprintf(_('Tasks (new messages: %s)'), get_count_unreaded_msgs_by_uid())."</a>";
    }
    ?></td>
  </tr>
  
</table>

<br>
<?
function get_online_users(){
    global $db;
    
    $sql = "select count(id) as online from users where keep_alive>now()-".Config::get('watchdog_timeout')*2;
    $rs=$db->executeQuery($sql);
    $online = @$rs->getValueByName(0, 'online');
    return $online;
}

function get_offline_users(){
    global $db;
    
    $sql = "select count(id) as offline from users where keep_alive<now()-".Config::get('watchdog_timeout')*2;
    $rs=$db->executeQuery($sql);
    $offline = @$rs->getValueByName(0, 'offline');
    return $offline;
}

$online = get_online_users();
$offline = get_offline_users();

$cur_tv = get_cur_playing_type($db, 'itv');
$cur_vclub = get_cur_active_playing_type($db, 'vclub');
$cur_tv_archive = Mysql::getInstance()->from('users')->where(array('UNIX_TIMESTAMP(keep_alive)>' => time() - Config::get('watchdog_timeout')*2, 'now_playing_type' => 11))->get()->count();
$cur_records = Mysql::getInstance()->from('users')->where(array('UNIX_TIMESTAMP(keep_alive)>' => time() - Config::get('watchdog_timeout')*2, 'now_playing_type' => 12))->get()->count();
$cur_aclub = get_cur_active_playing_type($db, 'aclub');<commit_msg>Fix online status (issue #1112)<commit_after><?php
session_start();

ob_start();

include "./common.php";
include "./lib/tasks.php";

$db = new Database();

moderator_access();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?= _('Stalker MW admin interface')?></title>
<style type="text/css">
td, table.menu {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
	border-width: 1px;
    border-style: solid;
    border-color: #E5E5E5;
	background-color:#88BBFF
}
td.other {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
	border-width: 1px;
    border-style: solid;
    border-color: #E5E5E5;
	background-color:#FFFFFF;
}
.td_stat{
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-decoration: none;
    color: #000000;
    text-align: right;
	border-width: 0px;
    border-style: solid;
    border-color: #E5E5E5;
	background-color:#f5f5f5;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:16px
}
a{
	color:#FFFFFF;
	font-weight: bold;
	text-decoration:none;
}
a:link{
	color:#FFFFFF;
	font-weight: bold;
}
a:visited{
    color:#FFFFFF;
	font-weight: bold;
	text-decoration:none;
}
a:hover{
	color:#FFFFFF;
	font-weight: bold;
	text-decoration:underline;
}
.lang{
    color: blue !important;
    font-weight: normal !important;
    font-family: Arial, sans-serif;
    font-size: 14px;
}
</style>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.cookies.2.2.0.js"></script>

<script type="text/javascript">

    $(function(){
        $('.lang').click(function(e){
            var lang = $(e.target).attr('lang');
            $.cookies.set('language', lang, {expiresAt: new Date( 2037, 1, 1 )});
            document.location = document.location;
        });
    });

</script>

</head>

<body>
<div style="width: 80%; margin:0 auto; text-align: right">
    <a href="javascript://" class="lang" lang="en">en</a> | <a href="javascript://" class="lang" lang="ru">ru</a>
</div>
<br>
<br>
<table width="80%" border="0" align="center">
  <tr>
    <td align="right" class="other" style="border-width: 0px;"><?echo date("Y-m-d H:i:s")?></td>
  </tr>
</table>

<table width="80%"  border="1" align="center" cellpadding="3" cellspacing="0" class="menu">
  <tr>
    <td colspan="3" align="center"><span class="style1"><?= _('Sections')?></span></td>
  </tr>
  
  <tr>
    <td width="47%"><div align="center"><a href="add_itv.php"><?= _('IPTV channels')?></a></div></td>
    <td width="6%">&nbsp;</td>
    <td width="47%"><div align="center"><a href="users.php"><?= _('Users')?></a></div></td>
  </tr>
  
  <tr>
    <td><div align="center"><a href="add_video.php"><?= _('VIDEO CLUB')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"><a href="events.php"><?= _('Events')?></a></td>
  </tr>
  
  <tr>
    <td><div align="center"><a href="add_karaoke.php"><?= _('KARAOKE')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"><a href="logout.php">[<?echo $_SESSION['login']?>] <?= _('Logout')?></a></td>
  </tr>
  
  <tr>
    <td><div align="center"><a href="add_radio.php"><?= _('RADIO')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"></td>
  </tr>
  
  <tr>
    <td><!--<div align="center"><a href="ad.php">РЕКЛАМА</a></div>--></td>
    <td>&nbsp;</td>
    <td align="center"></td>
  </tr>

  <tr>
    <td><div align="center"><a href="tariffs.php"><?= _('TARIFFS')?></a></div></td>
    <td>&nbsp;</td>
    <td align="center"><?
    if (check_access(array(1,2))){
        echo "<a href='tasks.php'>".sprintf(_('Tasks (new messages: %s)'), get_count_unreaded_msgs_by_uid())."</a>";
    }
    ?></td>
  </tr>
  
</table>

<br>
<?
function get_online_users(){
    global $db;

    $sql = "select count(id) as online from users where UNIX_TIMESTAMP(keep_alive)>UNIX_TIMESTAMP(now())-".Config::get('watchdog_timeout')*2;
    $rs=$db->executeQuery($sql);
    $online = @$rs->getValueByName(0, 'online');
    return $online;
}

function get_offline_users(){
    global $db;

    $sql = "select count(id) as offline from users where UNIX_TIMESTAMP(keep_alive)<UNIX_TIMESTAMP(now())-".Config::get('watchdog_timeout')*2;
    $rs=$db->executeQuery($sql);
    $offline = @$rs->getValueByName(0, 'offline');
    return $offline;
}

$online = get_online_users();
$offline = get_offline_users();

$cur_tv = get_cur_playing_type($db, 'itv');
$cur_vclub = get_cur_active_playing_type($db, 'vclub');
$cur_tv_archive = Mysql::getInstance()->from('users')->where(array('UNIX_TIMESTAMP(keep_alive)>' => time() - Config::get('watchdog_timeout')*2, 'now_playing_type' => 11))->get()->count();
$cur_records = Mysql::getInstance()->from('users')->where(array('UNIX_TIMESTAMP(keep_alive)>' => time() - Config::get('watchdog_timeout')*2, 'now_playing_type' => 12))->get()->count();
$cur_aclub = get_cur_active_playing_type($db, 'aclub');
{'fraction_non_alphanumeric': 0.23718959400867165, 'fraction_numerical': 0.01931415057154119, 'mean_word_length': 4.250387997930678, 'pattern_counts': {'":': 0, '<': 279, '<?xml version=': 0, '>': 313, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2111080', 'n_tokens_mistral': 4102, 'n_tokens_neox': 3951, 'n_words': 681}