185 lines
5.2 KiB
PHP
185 lines
5.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board 2.1.7
|
|
| =============================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2005 Invision Power Services, Inc.
|
|
| http://www.invisionpower.com
|
|
| =============================================
|
|
| Web: http://www.invisionboard.com
|
|
| http://www.ibresource.ru/products/invisionpowerboard/
|
|
| Time: Tuesday 18th of July 2006 05:56:00 PM
|
|
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
| http://www.ibresource.ru/license
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
|
|
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
|
|
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
|
|
+---------------------------------------------------------------------------
|
|
| > $Date: 2005-10-10 14:08:54 +0100 (Mon, 10 Oct 2005) $
|
|
| > $Revision: 23 $
|
|
| > $Author: matt $
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > 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://', '', $this->ipsclass->vars['chat_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 ( ! $this->ipsclass->vars['chat_who_on'] )
|
|
{
|
|
return;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get details from the DB
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->query("SELECT * FROM ibf_cache_store WHERE cs_key='chatstat'");
|
|
|
|
$row = $this->ipsclass->DB->fetch_row();
|
|
|
|
list( $hits, $time ) = explode( '&', $row['cs_extra'] );
|
|
|
|
//-----------------------------------------
|
|
// Do we need to update?
|
|
//-----------------------------------------
|
|
|
|
$final = "";
|
|
$time_is_running_out = time();
|
|
$member_ids = array();
|
|
$new = array();
|
|
|
|
if ( $time < time() - ( $this->ipsclass->vars['chat_who_save'] * 60 ) )
|
|
{
|
|
$server_url = 'http://'.$this->server.'/ipc_who.pl?id='.$this->ipsclass->vars['chat_account_no'].'&pw='.$this->ipsclass->vars['chat_pass_md5'];
|
|
|
|
if ( $data = @file( $server_url ) )
|
|
{
|
|
if ( count($data) > 0 )
|
|
{
|
|
$hits_left = array_shift($data);
|
|
}
|
|
|
|
foreach( $data as $t )
|
|
{
|
|
$t = strtolower(trim($t));
|
|
$t = str_replace( '_', ' ', $t );
|
|
$t = str_replace( '"', '"', $t );
|
|
|
|
$new[] = $t;
|
|
}
|
|
|
|
$name_string = implode( '","', $new );
|
|
|
|
if ( count($new) > 0 )
|
|
{
|
|
$this->ipsclass->DB->query("SELECT m.id, m.name, m.mgroup FROM ibf_members m
|
|
WHERE lower(name) IN (\"".$name_string."\") ORDER BY m.name");
|
|
|
|
while ( $m = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$g = $this->ipsclass->cache['group_cache'][ $m['mgroup'] ];
|
|
$member_ids[] = "<a href=\"{$this->ipsclass->vars['board_url']}/index.{$this->ipsclass->vars['php_ext']}?showuser={$m['id']}\">{$g['prefix']}{$m['name']}{$g['suffix']}</a>";
|
|
}
|
|
|
|
$final = implode( ",\n", $member_ids );
|
|
|
|
$final .= '|&|'.intval(count($member_ids));
|
|
}
|
|
|
|
$this->ipsclass->DB->query("UPDATE ibf_cache_store SET cs_value='".addslashes($final)."', cs_extra='{$hits_left}&{$time_is_running_out}' WHERE cs_key='chatstat'");
|
|
|
|
$row['cs_value'] = $final;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Any members to show?
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->vars['chat_height'] += $this->ipsclass->vars['chat_poppad'] ? $this->ipsclass->vars['chat_poppad'] : 50;
|
|
$this->ipsclass->vars['chat_width'] += $this->ipsclass->vars['chat_poppad'] ? $this->ipsclass->vars['chat_poppad'] : 50;
|
|
|
|
$chat_link = ( $this->ipsclass->vars['chat_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( $this->ipsclass->lang['whoschatting_delay'], $this->ipsclass->vars['chat_who_save'] );
|
|
$this->html = $this->class->html->whoschatting_show( intval($count), stripslashes($names), $chat_link, $txt );
|
|
}
|
|
else
|
|
{
|
|
if ( ! $this->ipsclass->vars['chat_hide_whoschatting'] )
|
|
{
|
|
$this->html = $this->class->html->whoschatting_empty($chat_link);
|
|
}
|
|
}
|
|
|
|
return $this->html;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|