Esempio n. 1
0
function cleanUp()
{
    global $admin;
    $msgLifeSpan = $admin['msgLifeSpan'];
    $chatSessionLifeSpan = $admin['chatSessionLifeSpan'];
    $chatIDLifeSpan = $admin['chatIDLifeSpan'];
    $now = time();
    if (!$msgLifeSpan || !$chatSessionLifeSpan || !$chatIDLifeSpan) {
        echo 'Nope, something missing: ' . $msgLifeSpan . ', ' . $chatSessionLifeSpan . ', ' . $chatIDLifeSpan . '<br />';
    } else {
        /* Clean up messages */
        if ($dir = @opendir(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/msgs/')) {
            while (($file = readdir($dir)) !== false) {
                if (substr($file, -strlen('.message')) == '.message') {
                    $info = @stat(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/msgs/' . $file);
                    if ($now - $info['mtime'] > $msgLifeSpan) {
                        unlink(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/msgs/' . $file);
                    }
                }
            }
        }
        /* Clean up inactive users (doesn't delete the users, just logs them out) */
        if ($dir = @opendir(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/users/')) {
            while (($file = readdir($dir)) !== false) {
                if (substr($file, -strlen('.prefs')) == '.prefs') {
                    $chatName = substr($file, 0, -strlen('.prefs'));
                    $la = getLastAccessed($chatName);
                    if ($now - $la > $chatSessionLifeSpan && $la > 0) {
                        postMessage('system', 'User ' . $chatName . ' has been logged out due to inactivity.', $topMsgNum, $bottomMsgNum);
                        resetLastAccessed($chatName);
                    }
                }
            }
        }
    }
}
Esempio n. 2
0
</a></td></tr></table>
<br /><br />
<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr>
<th
align="left"><?php 
echo _AT('chat_list_and_history');
?>
</th></tr></table><?php 
echo '<ul>';
if ($dir = opendir(AT_CONTENT_DIR . 'chat/' . $_SESSION['course_id'] . '/users/')) {
    while (($file = readdir($dir)) !== false) {
        if ($file == '..' || $file == '.') {
            continue;
        }
        $chatName = substr($file, 0, -strlen('.prefs'));
        $la = getLastAccessed($chatName);
        $now = time();
        if ($la == 0 || !$la) {
            $la = 0;
        } else {
            if ($now - $la < $admin['chatSessionLifeSpan']) {
                $colour = getChatIDColour($chatName, $myPrefs['colours']);
                if ($chatName == $_SESSION['login']) {
                    echo '<li><a href="filterHistory.php?filterChatID=' . $chatName . '" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><span style="color:' . $colour . '">' . $chatName . '</span></a> (' . _AT('chat_you') . ')</li>';
                } else {
                    if ($chatName != '') {
                        echo '<li><a href="filterHistory.php?filterChatID=' . $chatName . '" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><span style="color:' . $colour . '">' . $chatName . '</span></a></li>';
                    }
                }
            } else {
                resetLastAccessed($chatName);