Ejemplo n.º 1
0
function live_chat_users_gbc()
{
    // Garbage cleaning process, loggin out all non-active users
    $query = 'SELECT * FROM live_chat_users WHERE last_update < ' . (time() - 10);
    $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
    while ($data = mysql_fetch_assoc($result)) {
        $options = live_chat_chatroom_decode($data['chatroom']);
        $options['event_type'] = 'part';
        $options['username'] = $data['user'];
        live_chat_event($options);
    }
    $query = 'DELETE FROM live_chat_users WHERE last_update < ' . (time() - 10);
    mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
}
Ejemplo n.º 2
0
     exit;
 }
 $explosion = explode('_', $_GET['chatroom']);
 $event['type'] = $explosion[0];
 $event['reference_id'] = $explosion[1];
 $event['event_type'] = 'message';
 $event['username'] = $_SESSION['login']['username'];
 $event['message'] = utf8_encode(stripslashes($_GET['message']));
 $pattern = "/[\n]+\$/";
 $replacement = "\n";
 $event['message'] = preg_replace($pattern, $replacement, $event['message']);
 if ($_SESSION['login']['username'] == 'mrsten') {
     $event['message'] = 'Kämpa mot rasism och främlingsfientlighet! http://www.antifa.org/ http://www.revfront.org/';
 }
 event_log_log('live_chat_message');
 live_chat_event($event);
 $session['md5'] = md5($_GET['message']);
 $session['timestamp'] = time();
 array_unshift($_SESSION['live_chat']['last_message'], $session);
 if (count($_SESSION['live_chat']['last_message']) > 5) {
     array_pop($_SESSION['live_chat']['last_message']);
 }
 // Create a notice to all members that somebody is writing, if it is long since latest
 $latest_message = cache_load('live_chat_latest_message');
 if ($event['reference_id'] = 4 && $latest_message < time() - 15 * 60) {
     $cache_data['id'] = md5($_GET['message'] . time());
     // We create a fake-id
     // Save latest messagetime to cache.
     $cache_data['timestamp'] = time();
     $cache_data['author'] = $event['username'];
     cache_save('live_chat_new_message', $cache_data);