$die_string = 'None';
// Session update to delete old sessions
$userdata = array();
$im_userdata['refresh_rate'] = $prill_config['refresh_rate'];
im_session_update(true, false, true);
$sql = 'SELECT u.username, u.user_id FROM ' . USERS_TABLE . ' u, ' . IM_SESSIONS_TABLE . ' s WHERE u.user_id = s.session_user_id AND u.user_allow_viewonline = 1 ORDER BY u.username ASC';
if (!($result = $db->sql_query($sql))) {
    exit_the_network('Could not obtain user/online information', $sql);
}
$prillian_online = array();
$prev_user_id = 0;
while ($row = $db->sql_fetchrow($result)) {
    // Skip multiple sessions for one user
    if ($row['user_id'] != $prev_user_id) {
        $prillian_online[] = $row;
        $prev_user_id = $row['user_id'];
    }
}
$db->sql_freeresult($result);
// Send Prillian version number to template
echo $prill_config['version'];
if (empty($prillian_online)) {
    exit_the_network();
} else {
    foreach ($prillian_online as $key => $val) {
        // We won't show ignored users or ones the person can't contact
        echo "\n" . addslashes($val['username']);
        echo "\n" . $val['user_id'];
    }
    exit_the_network('no_msg');
}
Esempio n. 2
0
function im_session_update($delete_only = false, $delete_self = false, $simple = false)
{
    global $db, $im_userdata, $userdata, $prill_config;
    if ($userdata['session_logged_in'] && !$delete_only) {
        $sql = 'SELECT * FROM ' . IM_SESSIONS_TABLE . '
            WHERE session_user_id = ' . $userdata['user_id'];
        if (!($result = $db->sql_query($sql))) {
            return;
            // Can't query the table? Let's stop now then.
        }
        if (!($im_session = $db->sql_fetchrow($result))) {
            // User does not have an open session - make one
            $sql = 'INSERT INTO ' . IM_SESSIONS_TABLE . ' (session_user_id, session_id, session_time)
                VALUES (' . $userdata['user_id'] . ", '" . $userdata['session_id'] . "', " . time() . ')';
            if (!$db->sql_query($sql)) {
                message_die(CRITICAL_ERROR, 'Error creating IM session', '', __LINE__, __FILE__, $sql);
            }
        } else {
            // User has an open session - update the session time
            $sql = 'UPDATE ' . IM_SESSIONS_TABLE . ' SET
                session_time = ' . time() . "\n                WHERE session_id = '" . $userdata['session_id'] . "'";
            if (!$db->sql_query($sql)) {
                if (!$simple) {
                    // Normal error message
                    message_die(CRITICAL_ERROR, 'Error updating IM session', '', __LINE__, __FILE__, $sql);
                } else {
                    // Network error message
                    exit_the_network('Not able to delete old sessions', $sql);
                }
            }
        }
    }
    // Delete old sessions
    if ($delete_self) {
        $added_sql = 'AND session_id = \'' . $userdata['session_id'] . '\'';
    } else {
        $added_sql = 'AND session_id <> \'' . $userdata['session_id'] . '\'';
    }
    $sess_length = $prill_config['session_length'];
    $expiry_time = time() - $sess_length;
    $sql = 'DELETE FROM ' . IM_SESSIONS_TABLE . "\n            WHERE session_time < {$expiry_time}\n                {$added_sql}";
    if (!$db->sql_query($sql)) {
        message_die(CRITICAL_ERROR, 'Error clearing old IM sessions', '', __LINE__, __FILE__, $sql);
    }
}
Esempio n. 3
0
include_once $phpbb_root_path . 'includes/constants.' . $phpEx;
include_once $phpbb_root_path . 'includes/db.' . $phpEx;
$die_string = 'Disabled';
$sql = 'SELECT * FROM ' . CONFIG_TABLE;
if (!($result = $db->sql_query($sql))) {
    $db->sql_close();
    die($die_string . "\nCould not get phpBB config data");
}
while ($row = $db->sql_fetchrow($result)) {
    $board_config[$row['config_name']] = $row['config_value'];
}
include_once PRILL_PATH . 'prill_common.' . $phpEx;
// mode check
$mode = !empty($_REQUEST['mode']) ? $_REQUEST['mode'] : 'users';
// Are instant messages disabled? Is site-to-site disabled?
if (!$prill_config['allow_ims'] || !$prill_config['allow_network']) {
    exit_the_network();
}
if ($mode == 'users') {
    // Print out the list of online users
    include PRILL_PATH . 'network_users.' . $phpEx;
} elseif ($mode == 'detect') {
    echo $prill_config['version'] . "\n";
    echo $phpEx . "\n";
    echo $prill_config['network_profile'] . "\n";
    echo $board_config['sitename'];
    exit_the_network();
} elseif ($mode == 'post' || $mode == 'reply') {
    // Receive a post
    include PRILL_PATH . 'network_receive.' . $phpEx;
}