PHP Classes

File: chat/number_new_messages.php

Recommend this page to a friend!
  Classes of Free Ment   PHP Live Chat Browser   chat/number_new_messages.php   Download  
File: chat/number_new_messages.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Live Chat Browser
Live chat with users of the same or another site
Author: By
Last change:
Date: 1 year ago
Size: 945 bytes
 

Contents

Class file image Download
<?php

$to
= get_by_request('to');

define('DS', '/');
include(
'..' . DS . '..' . DS . 'LOM' . DS . 'O.php');
$last_activity = 0;
$O = new O($to . '.xml');
foreach(
$O->get_tagged('message') as $message) {
   
$existing_time = $O->_('time', $message);
    if(
$existing_time > $last_activity) {
       
$last_activity = $existing_time;
    }
   
// would be nice to safely to assume that the last message would be the last activity, although with how the chat is asynchronous this isn't necessarily true
}
// what about remote?
print(getmicrotime() - $last_activity);

function
getmicrotime() {
    list(
$usec, $sec) = explode(' ', microtime());
    return (float)
$usec + (float)$sec;
}

function
get_by_request($variable) {
    return
query_decode($_REQUEST[$variable]);
}

function
query_encode($string) {
   
$string = str_replace('&', '%26', $string);
    return
$string;
}

function
query_decode($string) {
   
$string = str_replace('%26', '&', $string);
    return
$string;
}

?>