215 lines
5.5 KiB
PHP
215 lines
5.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board v2.0.0
|
|
| =============================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2004 Invision Power Services, Inc.
|
|
| http://www.invisionpower.com
|
|
| =============================================
|
|
| Web: http://www.invisionboard.com
|
|
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
|
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > IPChat functions
|
|
| > Script written by Matt Mecham
|
|
| > Date started: 29th September 2003
|
|
|
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
if ( ! defined( 'IN_IPB' ) )
|
|
{
|
|
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
|
exit();
|
|
}
|
|
|
|
|
|
class chat_functions
|
|
{
|
|
|
|
var $class = "";
|
|
var $server = "";
|
|
var $html = "";
|
|
|
|
function chat_functions()
|
|
{
|
|
global $DB, $std, $ibforums;
|
|
|
|
$this->server = str_replace( 'http://', '', $ibforums->vars['chat04_whodat_server_addr'] );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// register_class($class)
|
|
//
|
|
// Register a $this-> with this class
|
|
//
|
|
//-----------------------------------------
|
|
|
|
function register_class(&$class)
|
|
{
|
|
$this->class = $class;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Print online list
|
|
//
|
|
//-----------------------------------------
|
|
|
|
function get_online_list()
|
|
{
|
|
global $DB, $std, $ibforums;
|
|
|
|
if ( ! $ibforums->vars['chat04_who_on'] )
|
|
{
|
|
return;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get details from the DB
|
|
//-----------------------------------------
|
|
|
|
$DB->query("SELECT * FROM ibf_cache_store WHERE cs_key='chatstat'");
|
|
|
|
$row = $DB->fetch_row();
|
|
|
|
list( $hits, $time ) = explode( '&', $row['cs_extra'] );
|
|
|
|
//-----------------------------------------
|
|
// Do we need to update?
|
|
//-----------------------------------------
|
|
|
|
$final = "";
|
|
$time_is_running_out = time();
|
|
$member_ids = array();
|
|
|
|
if ( $time < time() - ( $ibforums->vars['chat04_who_save'] * 60 ) )
|
|
//if ( 1 == 1)
|
|
{
|
|
//-----------------------------------------
|
|
// Get service library
|
|
//-----------------------------------------
|
|
|
|
require_once( ROOT_PATH.'retail/chatservice.php' );
|
|
|
|
$server_url = 'http://'.$CHAT_SERVER[ $ibforums->vars['chat04_servicetype'] ].'/'.$CHAT_ONLINELIST[ $ibforums->vars['chat04_servicetype'] ].$ibforums->vars['chat04_account_no'];
|
|
|
|
if ( $data = @file( $server_url ) )
|
|
{
|
|
if ( count($data) > 0 )
|
|
{
|
|
$hits_left = intval( array_shift($data) );
|
|
}
|
|
|
|
$data = implode( "", $data );
|
|
$data = str_replace( "<html>" , "", $data );
|
|
$data = str_replace( "</html>", "", $data );
|
|
|
|
$data = preg_replace( "#^.+?:\s#i", "", strtolower($data) );
|
|
$tmp = explode( " ", $data );
|
|
$na = array();
|
|
|
|
if ( is_array( $tmp ) and count ($tmp) )
|
|
{
|
|
foreach( $tmp as $n )
|
|
{
|
|
$n = trim( $n );
|
|
|
|
//-----------------------------------------
|
|
// Look for underscore version too?
|
|
//-----------------------------------------
|
|
|
|
if ( strstr( $n, '_' ) )
|
|
{
|
|
//$n = str_replace( '_', ' ', $n );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Like?
|
|
//-----------------------------------------
|
|
|
|
if ( strstr( $n, '-' ) )
|
|
{
|
|
$n = str_replace( '-', '_', $n );
|
|
}
|
|
|
|
$n = str_replace( '"', '"', $n );
|
|
|
|
$na[] = "lower(name) LIKE '{$n}'";
|
|
}
|
|
}
|
|
|
|
$timecutoff = time() - ( 30 * 60 );
|
|
|
|
$query_string = implode( ' OR ', $na );
|
|
|
|
if ( $query_string )
|
|
{
|
|
$DB->query("SELECT m.id, m.name, g.g_id, g.prefix, g.suffix FROM ibf_members m
|
|
LEFT JOIN ibf_groups g ON (m.mgroup=g.g_id)
|
|
WHERE $query_string AND m.last_activity > $timecutoff ORDER BY m.name");
|
|
|
|
while ( $m = $DB->fetch_row() )
|
|
{
|
|
$member_ids[] = "<a href=\"{$ibforums->base_url}showuser={$m['id']}\">{$m['prefix']}{$m['name']}{$m['suffix']}</a>";
|
|
}
|
|
|
|
$final = implode( ",\n", $member_ids );
|
|
|
|
$final .= '|&|'.intval(count($member_ids));
|
|
}
|
|
|
|
if ( ! $hits_left )
|
|
{
|
|
$hits_left = 100000;
|
|
}
|
|
|
|
$DB->query("UPDATE ibf_cache_store SET cs_value='".$DB->add_slashes($final)."', cs_extra='{$hits_left}&{$time_is_running_out}' WHERE cs_key='chatstat'");
|
|
|
|
$row['cs_value'] = $final;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Any members to show?
|
|
//-----------------------------------------
|
|
|
|
$ibforums->vars['chat04_height'] += $ibforums->vars['chat04_poppad'] ? $ibforums->vars['chat04_poppad'] : 50;
|
|
$ibforums->vars['chat04_width'] += $ibforums->vars['chat04_poppad'] ? $ibforums->vars['chat04_poppad'] : 50;
|
|
|
|
$chat_link = ( $ibforums->vars['chat04_display'] == 'self' )
|
|
? $this->class->html->whoschatting_inline_link()
|
|
: $this->class->html->whoschatting_popup_link();
|
|
|
|
list ($names, $count) = explode( '|&|', $row['cs_value'] );
|
|
|
|
if ( $count > 0 )
|
|
{
|
|
$txt = sprintf( $ibforums->lang['whoschatting_delay'], $ibforums->vars['chat04_who_save'] );
|
|
$this->html = $this->class->html->whoschatting_show( intval($count), stripslashes($names), $chat_link, $txt );
|
|
}
|
|
else
|
|
{
|
|
if ( ! $ibforums->vars['chat04_hide_whoschatting'] )
|
|
{
|
|
$this->html = $this->class->html->whoschatting_empty($chat_link);
|
|
}
|
|
}
|
|
|
|
return $this->html;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|