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
        $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);
                $topMsgNum = $bottomMsgNum = 0;
                howManyMessages($topMsgNum, $bottomMsgNum);
                postMessage(_AT('chat_system'), require AT_INCLUDE_PATH . '../mods/_standard/chat/lib/chat.inc.php', _AT('chat_user_logged_out', $chatName), $topMsgNum, $bottomMsgNum);
            }
        }
    }
}
closedir($dir);
echo '</ul>';
echo '<table width="100%" border="0" cellpadding="5" cellspacing="0">
           <tr><td align="right"><a href="history.php" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AT('chat_full_history') . '</a> | <a href="options.php" target="options" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">' . _AT('chat_refresh_user_list') . '</a></td></tr></table>';
//if ($myPrefs['navigationAidFlag'] > 0) {
echo '<br /><br />';
echo '<table width="100%" border="0" cellpadding="5" cellspacing="0">
           <tr><td align="left"><h4>' . _AT('chat_quick_keys') . '</h4></td></tr></table>';