Source for file class.Chatter.inc

Documentation is available at class.Chatter.inc

  1. <?php //-*-php-*-
  2. /* ******************************************************************** **
  3. ** Copyright notice **
  4. ** **
  5. ** (c) 1995-2003 PHPOpenChat Development Team **
  6. ** http://phpopenchat.sourceforge.net/ **
  7. ** **
  8. ** All rights reserved **
  9. ** **
  10. ** This script is part of the PHPOpenChat project. The PHPOpenChat **
  11. ** project is free software; you can redistribute it and/or modify **
  12. ** it under the terms of the GNU General Public License as published by **
  13. ** the Free Software Foundation; either version 2 of the License, or **
  14. ** (at your option) any later version. **
  15. ** **
  16. ** The GNU General Public License can be found at **
  17. ** http://www.gnu.org/copyleft/gpl.html. **
  18. ** A copy is found in the textfile GPL and important notices to the **
  19. ** license from the team is found in the textfile LICENSE distributed **
  20. ** with these scripts. **
  21. ** **
  22. ** This script is distributed in the hope that it will be useful, **
  23. ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
  24. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
  25. ** GNU General Public License for more details. **
  26. ** **
  27. ** This copyright notice MUST APPEAR in all copies of the script! **
  28. ** ******************************************************************** */
  29.  
  30. /** Get configuration settings */
  31. (POC_BASE.'/config.inc.php');
  32. require_once(POC_INCLUDE_PATH.'/class.Logger.inc');
  33. require_once(POC_INCLUDE_PATH.'/class.Channel.inc');
  34.  
  35. /**
  36. * Class Chatter represents a person taking part in a chat session
  37. *
  38. * @package phpopenchat
  39. * @author Frerk Meyer <frerk@meychern.de>
  40. * @author Michael Oertel <michael@ortelius.de>
  41. * @access public
  42. * @version $Id: class.Chatter.inc,v 1.102 2004/05/27 09:16:51 jjaeschke Exp $
  43. */
  44. class Chatter
  45. {
  46. /**
  47. * every chatter is identified by a uniq nick name
  48. *
  49. * @var string
  50. */
  51. var $nick = '';
  52. /**
  53. * password of chatter
  54. *
  55. * @var string
  56. */
  57. var $password = '';
  58. var $password_new = '';
  59. /**
  60. * every chatter has an user name
  61. *
  62. * @var string
  63. */
  64. var $user = '';
  65.  
  66. /**
  67. * user name
  68. *
  69. * @var string
  70. */
  71. var $name = '';
  72.  
  73. /**
  74. * birthday of chatter
  75. *
  76. * @var string
  77. */
  78. var $birthday = '';
  79.  
  80. /**
  81. * gender of chatter
  82. *
  83. * @var string
  84. */
  85. var $gender = '';
  86.  
  87. /**
  88. * email of chatter
  89. *
  90. * @var string
  91. */
  92. var $email = '';
  93.  
  94. /**
  95. * hide email
  96. *
  97. * @var boolean
  98. */
  99. var $hide_email = true;
  100.  
  101. /**
  102. * A URL of a picture of chatter
  103. *
  104. * @var string
  105. */
  106. var $pictureURL = '';
  107.  
  108. /**
  109. * A home page URL of chatter
  110. *
  111. * @var string
  112. */
  113. var $homePageURL = '';
  114.  
  115. /**
  116. * Interests of chatter
  117. *
  118. * @var string
  119. */
  120. var $interests = '';
  121.  
  122. /**
  123. * Motto of chatter
  124. *
  125. * @var string
  126. */
  127. var $motto = '';
  128.  
  129. /**
  130. * A ICQ number of chatter
  131. *
  132. * @var integer
  133. */
  134. var $icqNumber = 0;
  135.  
  136. /**
  137. * A AIM nickname of chatter
  138. *
  139. * @var string
  140. */
  141. var $aimNickname = '';
  142.  
  143. /**
  144. * A YIM nickname of chatter
  145. *
  146. * @var string
  147. */
  148. var $yimNickname = '';
  149.  
  150. /**
  151. * chatter grade
  152. *
  153. * @var string
  154. */
  155. var $grade = '';
  156.  
  157. /**
  158. * chatter grade
  159. *
  160. * @var string
  161. */
  162. var $theme = DEFAULT_THEME;
  163.  
  164. /**
  165. * chatter groups
  166. *
  167. * @var array
  168. */
  169. var $groups = array();
  170.  
  171. /**
  172. * chatter disabled
  173. *
  174. * @var int
  175. */
  176. var $disabled = 0;
  177.  
  178. /**
  179. * online time in seconds
  180. *
  181. * @var int
  182. */
  183. var $online_time = 0;
  184.  
  185. /**
  186. * stores chatter objects of ignored chatters
  187. *
  188. * @var array
  189. */
  190. var $ignored_sender = array();
  191.  
  192. /**
  193. * stores friends of chatter
  194. *
  195. * @var array
  196. */
  197. var $friends = array();
  198.  
  199. /**
  200. * @var boolean
  201. * @access private
  202. */
  203. var $private = false;
  204.  
  205. /**
  206. * @var boolean
  207. * @access private
  208. */
  209. var $halted = false;
  210.  
  211. /**
  212. * @var boolean
  213. * @access private
  214. */
  215. var $bodies = false;
  216.  
  217. /**
  218. * @var boolean
  219. * @access private
  220. */
  221. var $sys_msg = false;
  222. /**
  223. * @var string
  224. * @access public
  225. */
  226. var $color = '';
  227. /**
  228. * @var string
  229. * @access public
  230. */
  231. var $advice = null;
  232. /**
  233. * @var string
  234. * @access public
  235. */
  236. var $scrollspeed = -1;
  237. /**
  238. * @var string
  239. * @access public
  240. */
  241. var $regTime = '';
  242. /**
  243. * @var string
  244. * @access public
  245. */
  246. var $lastActive = '';
  247. /**
  248. * @var string
  249. * @access public
  250. */
  251. var $lastHost = '';
  252. /**
  253. * @var string
  254. * @access public
  255. */
  256. var $lastIP = '';
  257. /**
  258. * @var string
  259. * @access public
  260. */
  261. var $lastReferer = '';
  262. /**
  263. * @var string
  264. * @access public
  265. */
  266. var $lastUserAgent = '';
  267. /**
  268. * @var string
  269. * @access public
  270. */
  271. var $lastSessionId = '';
  272. /**
  273. * @var object
  274. * @access private
  275. * @see connect()
  276. */
  277. var $db;
  278. /**
  279. * @var boolean
  280. * @access private
  281. * @see check_user()
  282. */
  283. var $guest = false;
  284. /**
  285. * @var integer
  286. * @see connect()
  287. * @see disconnect()
  288. */
  289. var $connection_count = 0;
  290. /**
  291. * @var float
  292. */
  293. var $lines_per_day = 0;
  294. /**
  295. * @var float
  296. */
  297. var $logins_per_day = 0;
  298.  
  299. /**
  300. * @var integer
  301. */
  302. var $days_registered = 0;
  303.  
  304. /**
  305. * @var integer
  306. */
  307. var $db_instance_lifetime = 0;
  308.  
  309. /**
  310. * @var array
  311. */
  312. var $unlocked_channels = array();
  313.  
  314. /**
  315. * @var array
  316. */
  317. var $line_styles = array();
  318. /**
  319. * Constructor
  320. *
  321. * Implements a chat user
  322. * @desc Implements a chat user
  323. *
  324. * @param string $nick
  325. * @param string $password
  326. */
  327. function Chatter($user = null, $password = null )
  328. {
  329.  
  330. if ( $_user = $this->check_user($user,$password) ) {
  331. $this->set_nick( $_user );
  332. if( $this->is_guest() )
  333. $this->register();
  334. $this->password = $password;
  335. } else {
  336. $this->nick = null;
  337. }
  338. }
  339. /**
  340. * Check if user name and it's account data are valid
  341. *
  342. * Return false if $user is not valid
  343. *
  344. * @param string
  345. * @param string
  346. * @return boolean
  347. */
  348. function check_user($user,$password)
  349. {
  350. //don't check if nick equals STATUS_BOT_NAME
  351. //note: chat users can't login as 'STATUS_BOT_NAME'
  352. if ( $user == strval(STATUS_BOT_NAME) )
  353. return STATUS_BOT_NAME;
  354.  
  355. // nick names must be strings
  356. if (!isset($user))
  357. return '';
  358.  
  359. // passwords can't be empty
  360. if ($password == '')
  361. {
  362. if( ALLOW_GUEST_LOGIN )
  363. {
  364. $this->guest = true;
  365. $guest_nickname = '###GUEST_NICK_PREFIX###'.'_'.rand(10000,99999);
  366. return $guest_nickname;
  367. }
  368. else
  369. return '';
  370. }
  371.  
  372. // nick names must be strings
  373. if (!is_string($user))
  374. return '';
  375.  
  376. // nick names are no longer than 16 characters
  377. if (strlen($user) > NICKNAME_MAX_LENGTH)
  378. return '';
  379. // nick names start with a character and go on with alphanumeric
  380. // Attention: Spaces are allowed
  381. if (!eregi("^[[:alpha:]]+[[:alnum:]]*",$user))
  382. return '';
  383. // the given password must match with the db-password
  384. return $this->is_authorized($user, $password);
  385.  
  386. }
  387.  
  388. /**
  389. * Provides the status of chatter
  390. *
  391. * @access public
  392. * @return boolean
  393. */
  394. function is_moderator()
  395. {
  396. return in_array('moderator', $this->groups);
  397. }
  398.  
  399. /**
  400. * Provides the status of chatter
  401. *
  402. * @access public
  403. * @return boolean
  404. */
  405. function is_vip()
  406. {
  407. return in_array('vip', $this->groups);
  408. }
  409.  
  410. /**
  411. * Provides the status of chatter
  412. *
  413. * @access public
  414. * @return boolean
  415. */
  416. function is_kicked()
  417. {
  418. $this->connect();
  419. $rs = $this->db->Execute( 'SELECT DISABLED FROM poc_user_account WHERE USER=\''.$this->user.'\'');
  420. $status = intval($rs->fields[0]);
  421. $rs->Close();
  422. $this->disconnect();
  423.  
  424. return ($status === 1 );
  425. }
  426. function is_disabled()
  427. {
  428. return $this-is_kicked();
  429. }
  430.  
  431.  
  432. /**
  433. * Provides the online status of chatter
  434. *
  435. * @access public
  436. * @return boolean
  437. */
  438. function is_online()
  439. {
  440. $this->connect();
  441. $rs = $this->db->Execute( 'SELECT ONLINE FROM poc_user_data WHERE USER=\''.$this->user.'\'');
  442. $status = intval($rs->fields[0]);
  443. $rs->Close();
  444. $this->disconnect();
  445.  
  446. return ($status === 1 );
  447. }
  448.  
  449. /**
  450. * Provides the status of chatter
  451. *
  452. * @access public
  453. * @return boolean
  454. */
  455. function is_banned( $channel )
  456. {
  457. $this->connect();
  458. $rs = $this->db->Execute( 'SELECT TIME_BANNED FROM poc_banned_users WHERE USER=\''.$this->user.'\' AND TIME_BANNED >= '.$this->db->DBTimeStamp(time()).' AND BANNED_FOR=\''.$channel.'\'');
  459. $status = ( $rs->RecordCount() >= 1 );
  460. $rs->Close();
  461. $this->disconnect();
  462.  
  463. return $status;
  464. }
  465.  
  466. /**
  467. * Banishment of chatter
  468. *
  469. * @access public
  470. * @return boolean
  471. */
  472. function ban( $channel, $period )
  473. {
  474. if( $this->is_banned($channel) ) return null;
  475. $this->count_hit('bann');
  476. $this->connect();
  477. $rs = $this->db->Execute( 'DELETE FROM poc_banned_users WHERE USER = \''. $this->user .'\' AND BANNED_FOR = \''.$channel.'\'' );
  478. $rs = $this->db->Execute( 'SELECT USER,BANNED_FOR,TIME_BANNED FROM poc_banned_users WHERE USER = \''. $this->user .'\'' );
  479. $record = array();
  480. $record[ 'TIME_BANNED' ] = $this->db->DBTimeStamp( (time() + (intval($period) * 60)) );
  481. $record[ 'BANNED_FOR' ] = $channel;
  482. $record[ 'USER' ] = $this->user;
  483. $insert_sql = $this->db->GetInsertSQL( $rs, $record );
  484. $insert_sql = preg_replace('/\'\'/','\'',$insert_sql);
  485. //Insert the records into the database
  486. $status = $this->db->Execute( $insert_sql );
  487.  
  488. $this->disconnect();
  489. unset($record);
  490. unset($insert_sql);
  491. unset($rs);
  492. return $status;
  493. }
  494. /**
  495. * Changes the channel
  496. *
  497. */
  498. function join_channel( $post_channel, $private_new_window = false )
  499. {
  500. $prefix = ($private_new_window)? abs(crc32($post_channel)).'_':'';
  501. $bot = &new Chatter(strval(STATUS_BOT_NAME),'');
  502. if(!$private_new_window)
  503. {
  504. //chatter want's to change the channel
  505. //we have to say goodbye in the old channel first»
  506. //$said = $_SESSION['chatter']->get_nick().' ###LEAVES_THIS_CHANNEL### <!--'.rand(0,15).'-->';
  507. $said = $_SESSION['chatter']->get_nick().htmlentities(' ###LEAVES_THIS_CHANNEL### ');
  508. $said .= htmlentities(' ###GOES_TO_CHANNEL### ').$post_channel;
  509. $bot = &new Chatter(strval(STATUS_BOT_NAME),'');
  510. $line = &new Line($bot, $said);
  511. $line->set_leave($_SESSION['chatter']->get_nick());
  512. $_SESSION['channel_buffer']->connect();
  513. $_SESSION['channel_buffer']->put_line($line);
  514. $_SESSION['channel_buffer']->disconnect();
  515. }
  516. //create the new channel object and write it into the session
  517. //because of a critical bug: http://bugs.php.net/bug.php?id=18071
  518. //do stupid things to register a new channel object in session
  519. //if bug is fixed, use:
  520. //$_SESSION[$prefix.'channel_buffer'] = &new Channel_Buffer(strval($post_channel));
  521. //$_SESSION[$prefix.'channel'] = &new Channel(strval($post_channel));
  522. //change buffer
  523. if(function_exists('session_unregister')) {
  524. @session_unregister($prefix.'channel_buffer');
  525. }
  526. if(function_exists('session_register')) {
  527. session_register($prefix.'channel_buffer');
  528. }
  529. ${$prefix.'channel_buffer'} = &new Channel_Buffer($post_channel);
  530. $_SESSION[$prefix.'channel_buffer'] = ${$prefix.'channel_buffer'};
  531. //change channel
  532. if(function_exists('session_unregister')) {
  533. @session_unregister($prefix.'channel');
  534. }
  535. if(function_exists('session_register')) {
  536. session_register($prefix.'channel');
  537. }
  538. ${$prefix.'channel'} = &new Channel($post_channel);
  539. $_SESSION[$prefix.'channel'] = ${$prefix.'channel'};
  540. //get current line index
  541. $_SESSION[$prefix.'channel_buffer']->connect();
  542. ${$prefix.'lastRedLine'} = $_SESSION[$prefix.'channel_buffer']->get_cur_line_idx();
  543. $_SESSION[$prefix.'channel_buffer']->disconnect();
  544. $_SESSION[$prefix.'lastRedLine'] = ${$prefix.'lastRedLine'};
  545. if(!$private_new_window){
  546. $_SESSION['chatter']->go_online($post_channel);
  547. //$_SESSION['chatter']->get_db_groups($post_channel);
  548. /*
  549. * Update JavaScript array in frameset.tpl of operators of current channel
  550. */
  551. if( isset($_SESSION['chat']) ) {
  552. $_SESSION['chat']->connect();
  553. $members = $_SESSION['chat']->get_group_members('operator', $post_channel);
  554. $_SESSION['chat']->disconnect();
  555. $csv_members = '';
  556. if( is_array($members) && count($members) > 0 ) {
  557. reset($members);
  558. do{
  559. $csv_members .= ',"'.current($members).'"';
  560. }while( next($members) );
  561. $csv_members = substr_replace($csv_members,'',0,1);
  562. }
  563. } else {
  564. $_SESSION['logger']->warning('$_SESSION[\'chat\'] doesn\'t exists.', __FILE__, __LINE__ - 9 );
  565. }
  566. unset($members);
  567. $operator_label =(isset($_SESSION['chatter'])&&$_SESSION['chatter']->is_operator())? OPERATOR_LABEL:'';
  568. //the chatter has changed the channel, so we have to update the JS array in the frameset containing all operators of current channel
  569. //
  570. $_SESSION['chat']->write_sys_msg( '<script type="text/javascript">parent.operators = new Array('.$csv_members.');parent.operator_label="'.$operator_label.'"<\/script>',$_SESSION['chatter'], true, true );
  571. //$_SESSION['chat']->write_sys_msg( 'debug: ',$_SESSION['chatter'], true );
  572. unset($csv_members);
  573. unset($operator_label);
  574. }
  575.  
  576. //now we have to say hello in the new channel«
  577. $said = $_SESSION['chatter']->get_nick().htmlentities(' ###JOINS_THIS_CHANNEL### "').$_SESSION[$prefix.'channel']->get_name().'"';
  578. $line = &new Line($bot, $said);
  579. $line->set_login($_SESSION['chatter']->get_nick());
  580. $_SESSION[$prefix.'channel_buffer']->connect();
  581. $_SESSION[$prefix.'channel_buffer']->put_line($line);
  582. $_SESSION[$prefix.'channel_buffer']->disconnect();
  583. if( $_SESSION[$prefix.'channel']->get_message() != '' )
  584. $_SESSION['chat']->write_sys_msg( '<br />'.$_SESSION[$prefix.'channel']->get_message(),$_SESSION['chatter'], true );
  585. unset($bot);
  586. unset($said);
  587. unset($line);
  588. unset($prefix);
  589. }
  590.  
  591. /* function is_authorized_for( $channel )
  592. {
  593. if( !$_SESSION['channel']->is_password_protected() ) return true;
  594. return ( in_array($channel,$this->unlocked_channels ) );
  595. } */
  596.  
  597. function is_authorized_for( $channel )
  598. {
  599. $chnl =& new Channel($channel);
  600. if ( ! $chnl->get_name() ) {
  601. return(false);
  602. }
  603. if( !$chnl->is_password_protected() ) return true;
  604. return ( in_array($channel,$this->unlocked_channels ) );
  605. }
  606.  
  607. function unlock_channel( $channel )
  608. {
  609. if( !is_string($channel) ) die('String expected');
  610. $this->unlocked_channels[] = $channel;
  611. }
  612.  
  613. function lock_channel ($channel) {
  614. if( !is_string($channel) ) die('String expected');
  615. // assure duplicates are removed, too
  616. while ( false !== $key = array_search ($channel, $this->unlocked_channels) ) {
  617. unset ($this->unlocked_channels[$key]);
  618. }
  619. }
  620.  
  621. /**
  622. * Provides the status of chatter
  623. *
  624. * @access public
  625. * @return boolean
  626. */
  627. function is_operator()
  628. {
  629. return in_array('operator', $this->groups);
  630. }
  631. /**
  632. * Connect to the database
  633. *
  634. * Establish a database connection
  635. *
  636. * @access public
  637. */
  638. function connect( $force_reconnect = false )
  639. {
  640. if( !$force_reconnect && ++$this->connection_count > 1 )
  641. return null;
  642.  
  643. if( $force_reconnect && is_object($this->db) ) {
  644. $this->db->Close();
  645. unset($this->db);
  646. }
  647. //create a database object
  648. $this->db = &NewADOConnection( DATABASE_DRIVER );
  649. if( USE_PCONNECT )
  650. $this->db->PConnect( DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_TABLESPACE );
  651. else
  652. $this->db->Connect( DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_TABLESPACE );
  653.  
  654. return true;
  655. }
  656.  
  657. /**
  658. * Disconnect the database
  659. *
  660. * @access public
  661. * @see connect()
  662. */
  663. function disconnect()
  664. {
  665. if( --$this->connection_count == 0 )
  666. {
  667. $this->db->Close();
  668. /*
  669. * NOTE: a db->Close() will be not enough! without setting $this->db to null,
  670. * PHP 4.2.1 can't serialize the object $line ( see Channel_Buffer_DB::put_line() )
  671. * who contains a chatter object.
  672. */
  673. $this->db = null;
  674. return true;
  675. }
  676. return false;
  677. }
  678.  
  679. /**
  680. * Sets chatter status to online
  681. *
  682. * @access public
  683. * @see go_offline()
  684. * @param string
  685. */
  686. function go_online( $channel )
  687. {
  688. $this->connect();
  689. $rs = $this->db->Execute( 'SELECT ONLINE,LAST_CHANNEL,LAST_ACTIVE_TIME,LAST_HOST,LAST_IP,LAST_USER_AGENT,LAST_SESSIONID,LAST_REFERER FROM poc_user_data WHERE NICK = \''. $this->nick .'\'' );
  690. $record = array();
  691. $record[ 'ONLINE' ] = 1;
  692. $record[ 'LAST_CHANNEL' ] = $channel;
  693. //$record[ 'LAST_ACTIVE_TIME' ] = date( "Y-m-d H:i:s", time() );
  694. $record[ 'LAST_ACTIVE_TIME' ] = $this->db->DBTimeStamp( time() );
  695. if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '' )
  696. {
  697. $record[ 'LAST_HOST' ] = @gethostbyaddr( $_SERVER['HTTP_X_FORWARDED_FOR'] );
  698. $record[ 'LAST_IP' ] = $_SERVER['HTTP_X_FORWARDED_FOR'];
  699. }
  700. else
  701. {
  702. $record[ 'LAST_HOST' ] = @gethostbyaddr($_SERVER['REMOTE_ADDR']);
  703. $record[ 'LAST_IP' ] = $_SERVER['REMOTE_ADDR'];
  704. }
  705. $this->lastIP = (isset($record[ 'LAST_IP' ]) && $record[ 'LAST_IP' ] != '')? $record[ 'LAST_IP' ]:'-';
  706. $record[ 'LAST_USER_AGENT' ] = $_SERVER['HTTP_USER_AGENT'];
  707. $record[ 'LAST_SESSIONID' ] = session_id();
  708. if( $_SESSION['chat']->get_referer() != '' )
  709. $record[ 'LAST_REFERER' ] = $_SESSION['chat']->get_referer();
  710. $update_sql = $this->db->GetUpdateSQL( $rs, $record );
  711. $update_sql = preg_replace('/\'\'/','\'',$update_sql);
  712.  
  713. //Insert the records into the database
  714. if( !$this->db->Execute( $update_sql ) )
  715. $_SESSION['logger']->error('DB-Update failed. SQL: "'.$update_sql.'"', __FILE__, __LINE__);
  716.  
  717. $_SESSION['logger']->info('login '. $this->nick );
  718. $this->groups = $this->get_db_groups($channel);
  719. $this->disconnect();
  720. unset($record);
  721. unset($update_sql);
  722. unset($rs);
  723. }
  724. /**
  725. * Refreshs chatter's online time
  726. *
  727. * @access public
  728. * @see go_online()
  729. * @param string
  730. */
  731. function refresh()
  732. {
  733. $this->connect();
  734. $rs = $this->db->Execute( 'SELECT LAST_ACTIVE_TIME,ONLINE_TIME FROM poc_user_data WHERE USER = \''. $this->user .'\'' );
  735. $online_time = $rs->fields[1];
  736. $this->set_online_time((intval(LINE_POLLING_INTERVAL) * 2) + $online_time);
  737. $record = array();
  738. //$record[ 'LAST_ACTIVE_TIME' ] = date( "Y-m-d H:i:s", time() );//SQL92 date format
  739. $record[ 'LAST_ACTIVE_TIME' ] = $this->db->DBTimeStamp( time() );
  740. $record[ 'ONLINE_TIME' ] = (intval(LINE_POLLING_INTERVAL) * 2) + $online_time;
  741. unset($online_time);
  742. $update_sql = $this->db->GetUpdateSQL( $rs, $record );
  743. $update_sql = preg_replace('/\'\'/','\'',$update_sql);//DBTimeStamp and GetUpdateSQL quotes time-strings and so we have to remove the double single quotes
  744.  
  745. //Insert the records into the database
  746. if( !$this->db->Execute( $update_sql ) )
  747. $_SESSION['logger']->error('DB-Update failed. SQL: "'.$update_sql.'"', __FILE__, __LINE__);
  748.  
  749. $this->disconnect();
  750. unset($record);
  751. unset($update_sql);
  752. unset($rs);
  753. }
  754. /**
  755. * Sets chatter's online time
  756. *
  757. * @access public
  758. * @see refresh()
  759. * @param integer
  760. */
  761. function set_online_time( $time )
  762. {
  763. $this->online_time = $time;
  764. }
  765. /**
  766. * Provides chatter's online time
  767. *
  768. * @access public
  769. * @return integer
  770. */
  771. function get_online_time()
  772. {
  773. return $this->online_time;
  774. }
  775. /**
  776. * Provides chatter's online time from DB
  777. *
  778. * @access public
  779. * @return integer
  780. */
  781. function get_db_online_time()
  782. {
  783. $this->connect();
  784. $rs = $this->db->Execute(