Source for file class.Chat.inc

Documentation is available at class.Chat.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 default values
  31. require_once(POC_BASE.'/config.inc.php');
  32. require_once(POC_INCLUDE_PATH.'/functions.inc');
  33.  
  34. require_once(POC_INCLUDE_PATH.'/adodb/adodb.inc.php');
  35. require_once(POC_INCLUDE_PATH.'/class.Language.inc');
  36. require_once(POC_INCLUDE_PATH.'/class.Chatter.inc');
  37. require_once(POC_INCLUDE_PATH.'/class.Channel.inc');
  38. require_once(POC_INCLUDE_PATH.'/class.Line.inc');
  39. require_once(POC_INCLUDE_PATH.'/class.Channel_Buffer_'.CHANNEL_BUFFER_TYPE.'.inc');
  40. require_once(POC_INCLUDE_PATH.'/class.Logger.inc');
  41. require_once(POC_INCLUDE_PATH.'/class.Template.inc');
  42.  
  43. /**
  44. * Chat describes the whole chat
  45. *
  46. * @package phpopenchat
  47. * @author Michael Oertel <michael@ortelius.de>
  48. * @access public
  49. * @version $Id: class.Chat.inc,v 1.91 2004/05/27 09:17:57 jjaeschke Exp $
  50. */
  51. class Chat {
  52. /**
  53. * @var string
  54. * @access public
  55. * @see Chat()
  56. */
  57. var $name = '';
  58. /**
  59. * @var integer
  60. * @see connect()
  61. * @see disconnect()
  62. */
  63. var $connection_count = 0;
  64. /**
  65. * Interface language of chat
  66. * @var string
  67. */
  68. var $language = '';
  69. /**
  70. * search string for nicknames
  71. * @var string
  72. */
  73. var $restrict = '';
  74. /**
  75. * referer
  76. * @var string
  77. */
  78. var $referer = '';
  79. /**
  80. * show profile flag
  81. * @var boolean
  82. */
  83. var $show_profile = true;
  84. /**
  85. * nicknames which will never die
  86. * @var array
  87. */
  88. var $deathless_chatters = array();
  89. /**
  90. * all supported languages
  91. * @var array
  92. */
  93. var $supported_languages = array();
  94. /**
  95. * Constructor.
  96. *
  97. * create a new chat object
  98. *
  99. * @param string $channel
  100. * @access public
  101. */
  102. function Chat( $name = CHAT_NAME, $supported_languages )
  103. {
  104. $lang = &new Language();
  105. //negotiate languages between HTTP_ACCEPT_LANGUAGE and $supported_languages
  106. //$possible_languages contains the result of negotiation
  107. $possible_languages = array();
  108. if( !$lang->get_list($supported_languages,$possible_languages) )
  109. {
  110. //no supported language in HTTP_ACCEPT_LANGUAGE found, so we take
  111. //the default language, the first entry in array $supported_languages,
  112. //defined in config.inc
  113. reset($supported_languages);
  114. $possible_languages = array();
  115. $possible_languages[current($supported_languages)] = '';
  116. }
  117. reset($possible_languages);
  118. $this->language = key($possible_languages);// $possible_languages are sorted by Q-factor and so we take the first one
  119. $this->name = $name;
  120. $this->supported_languages = $supported_languages;
  121. }
  122. /**
  123. * Gets language of the chat
  124. *
  125. * @access public
  126. * @return string interface language of chat
  127. */
  128. function get_language()
  129. {
  130. return $this->language;
  131. }
  132. /**
  133. * Provides the default language of the chat
  134. *
  135. * @access public
  136. * @return string
  137. */
  138. function get_default_language()
  139. {
  140. return $this->supported_languages[0];
  141. }
  142. function _check_flag( $lang )
  143. {
  144. $flag_dir = '/images/flags';
  145. $flag_path = $flag_dir.'/'.strtolower($lang).'.gif';
  146. if( file_exists($_SESSION['template']->get_tmpl_sys_path().$flag_path) )
  147. return '<img src="'.$_SESSION['template']->get_tmpl_web_path().$flag_path.'" align="middle" alt="'.$_SESSION['translator']->out('CHOOSE_LANGUAGE').'" width="24" hight="16" border="0" />';
  148. return $lang;
  149. }
  150. function get_lang_switch()
  151. {
  152. if( isset($_GET['language']) && in_array($_GET['language'], $this->supported_languages) )
  153. {
  154. $_SESSION['translator']->set_language($_GET['language']);
  155. $this->set_language($_GET['language']);
  156. }
  157. $content = '';
  158. reset($this->supported_languages);
  159. do
  160. {
  161. $cur_lang = current($this->supported_languages);
  162. if( $cur_lang == $this->get_language() )
  163. {/*$lang_switch .= '<strong>'.check_flag( $cur_lang ).'</strong> | ';*/}
  164. else
  165. $content .= '<a class="imageLink" href="'.$_SERVER['SCRIPT_NAME'].'?language='.$cur_lang.'&amp;'.session_name().'='.session_id().'">'.$this->_check_flag( $cur_lang ).'</a> | ';
  166.  
  167. }while(next($this->supported_languages));
  168. return substr( $content, 0, -2 );
  169. }
  170. /**
  171. * Sets primary language prefix of the chat
  172. *
  173. * @access public
  174. * @param string
  175. */
  176. function set_language( $primary_lang_prefix )
  177. {
  178. $this->language = $primary_lang_prefix;
  179. }
  180. /**
  181. * Gets referer
  182. *
  183. * @access public
  184. * @return string
  185. */
  186. function get_referer()
  187. {
  188. return $this->referer;
  189. }
  190. /**
  191. * Sets referer
  192. *
  193. * @access public
  194. * @param string
  195. */
  196. function set_referer( $referer )
  197. {
  198. $this->referer = $referer;
  199. }
  200. /**
  201. * Sets the show profile flag
  202. *
  203. * @access public
  204. * @param boolean
  205. */
  206. function set_show_profile( $bool = true )
  207. {
  208. $this->show_profile = $bool;
  209. }
  210. /**
  211. * Provides the show profile flag
  212. *
  213. * @access public
  214. * @return boolean
  215. */
  216. function get_show_profile()
  217. {
  218. return $this->show_profile;
  219. }
  220. /**
  221. * Sets dethless chatters
  222. *
  223. * @access public
  224. * @param array
  225. */
  226. function set_deathless_chatters( $deathless_chatters )
  227. {
  228. $this->deathless_chatters = $deathless_chatters;
  229. }
  230.  
  231. /**
  232. * Connect to the database
  233. *
  234. * Establish a database connection
  235. *
  236. * @access public
  237. * @return boolean
  238. */
  239. function connect()
  240. {
  241. if( ++$this->connection_count > 1 )
  242. return true;
  243.  
  244. //create a database object
  245. $this->db = &NewADOConnection( DATABASE_DRIVER );
  246. if( USE_PCONNECT )
  247. $status1 = $this->db->PConnect( DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_TABLESPACE );
  248. else
  249. $status1 = $this->db->Connect( DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_TABLESPACE );
  250. //$this->db->debug=1;
  251. $status2 = $this->db->Execute( 'SELECT THEME FROM poc_user_data' );
  252.  
  253. return ( $status1 && $status2 );
  254. }
  255.  
  256. /**
  257. * Creates a new instance of class channel within session
  258. *
  259. * @access public
  260. * @return boolean
  261. */
  262. function mkinstance_channel($post_channel)
  263. {
  264. $channel = &new Channel($post_channel);
  265. $_SESSION['channel'] = $channel;
  266.  
  267. //test if someone posts a wrong channel name
  268. return ( is_null($_SESSION['channel']->get_name()) == false );
  269. }
  270.  
  271. /**
  272. * Creates a new instance of class chatter
  273. *
  274. * @access public
  275. * @param string; a nickname of a chatter
  276. * @return mixed
  277. */
  278. function mkinstance_chatter($post_nickname, $force = false)
  279. {
  280. $_chatter = &new Chatter(STATUS_BOT_NAME);
  281. $_chatter->set_nick($post_nickname);
  282. return ( $_chatter->get_regTime() != '' || $force)? $_chatter:null;
  283. }
  284.  
  285. /**
  286. * Writes a message from the system-bot to given recipient
  287. *
  288. * @access public
  289. * @param string; message to write
  290. * @param object; recipient
  291. * @return boolean
  292. */
  293. function write_sys_msg( $message, $recipient, $whispered = false, $hidden = false )
  294. {
  295. $_chatter = &new Chatter(STATUS_BOT_NAME);
  296. $line = &new Line( $_chatter, $message);
  297. unset($_chatter);
  298. if( is_object($recipient) )
  299. $line->set_recipient( $recipient );
  300. else return false;
  301.  
  302.  
  303. $line->filter_buffer_input();
  304. if($whispered) {
  305. $line->set_whispered();
  306. $line->set_info();
  307. }
  308. if( $hidden ) {
  309. //echo 'line is set to hidden';
  310. $line->set_hidden();
  311. }
  312. if( isset($_SESSION['channel_buffer']) && is_object($_SESSION['channel_buffer']) ) {
  313. $_SESSION['channel_buffer']->connect();
  314. $_SESSION['channel_buffer']->put_line($line);
  315. $_SESSION['channel_buffer']->disconnect();
  316. } else {
  317. return false;
  318. }
  319.  
  320. return true;
  321. }
  322.  
  323. /**
  324. * Writes javascript code to update clients
  325. *
  326. * @access public
  327. * @param string; message to write
  328. * @param object; recipient
  329. * @return boolean
  330. */
  331. function write_js_update( $message, $recipient = null )
  332. {
  333. /*
  334. if(!preg_match('/^.*$/', $message) ) {
  335. $_SESSION['logger']->warning(__CLASS__.'::'.__FUNCTION__.' was missused!');
  336. return false;
  337. }*/
  338. $message = preg_replace('#</script>#i', '<\\/script>', $message);
  339. $message = preg_replace('/\r\n|\n|\r/', '', $message);
  340. $_chatter = &new Chatter(STATUS_BOT_NAME);
  341. $line = &new Line( $_chatter, $message);
  342. if( $recipient == null ) {
  343. $line->set_hidden_javascript_update();//this will get every chatter in the same channel
  344. $line->set_recipient($_chatter);//recipient doesn't matter
  345. } else {
  346. $line->set_recipient($recipient);
  347. $line->set_whispered();
  348. $line->set_info();
  349. $line->set_hidden();
  350. }
  351. unset($_chatter);
  352.  
  353. $line->filter_buffer_input();
  354. //
  355. if( isset($_SESSION['channel_buffer']) && is_object($_SESSION['channel_buffer']) ) {
  356. $_SESSION['channel_buffer']->connect();
  357. $_SESSION['channel_buffer']->put_line($line);
  358. $_SESSION['channel_buffer']->disconnect();
  359. } else {
  360. return false;
  361. }
  362.  
  363. return true;
  364. }
  365.  
  366. /**
  367. * Disconnect the database
  368. *
  369. * @access public
  370. * @see connect()
  371. */
  372. function disconnect()
  373. {
  374. if( --$this->connection_count == 0 ) {
  375. $this->db->Close();
  376. return true;
  377. }
  378. return null;
  379. }
  380. /**
  381. * Sets the confirm code to null
  382. *
  383. * @access public
  384. * @param string
  385. * @return boolean
  386. */
  387. function confirm( $code )
  388. {
  389. if( $this->connection_count == 0 )
  390. die('Not connected! Use connect() first!');
  391. $record = array();
  392. $record[ 'CONFIRM_CODE' ] = 'null';
  393. $rs = $this->db->Execute( 'SELECT CONFIRM_CODE FROM poc_user_account WHERE CONFIRM_CODE=\''.$code.'\'' );
  394. $update_sql = $this->db->GetUpdateSQL( $rs, $record );
  395. unset($record);
  396. unset($rs);
  397. $this->db->Execute( $update_sql );
  398. unset($update_sql);
  399. return ( $this->db->Affected_Rows() === 1 );
  400. }
  401. function set_operator_passwd()
  402. {
  403. if( $this->connection_count == 0 )
  404. die('Not connected! Use connect() first!');
  405. $rs = $this->db->Execute( 'SELECT USER FROM poc_user_account WHERE USER=\'operator\' AND PASSWORD=\'\'' );
  406. if( $rs->RecordCount() == 0 ) {
  407. return '';
  408. } else {
  409. $operator_passwd = substr(md5( strval(rand(10000,99999)) ),0,PASSWORD_MIN_LENGTH);
  410.  
  411. $record = array();
  412. $record[ 'PASSWORD' ] =(MD5_PASSWORDS)? md5($operator_passwd):$operator_passwd;
  413. $rs = $this->db->Execute( 'SELECT PASSWORD FROM poc_user_account WHERE USER=\'operator\'' );
  414. $update_sql = $this->db->GetUpdateSQL( $rs, $record );
  415. unset($record);
  416. unset($rs);
  417. return ( $this->db->Execute( $update_sql ) )? $operator_passwd:'';
  418. }
  419. }
  420.  
  421. /**
  422. * Creates a private channel
  423. *
  424. * @access public
  425. * @param string
  426. * @return void
  427. */
  428. function create_private_channel( $channel_name )
  429. {
  430. if( $this->connection_count == 0 )
  431. die('Not connected! Use connect() first!');
  432. $record = array();
  433. $record[ 'NAME' ] = $channel_name;
  434. $record[ 'MAX_LINE_NUMBER' ] = CB_MAX_LINE;
  435. $record[ 'TYPE' ] = 2; //type=2 it's a private channel
  436. $rs = $this->db->Execute( 'SELECT NAME,MAX_LINE_NUMBER,TYPE FROM poc_channels' );
  437. $insert_sql = $this->db->GetInsertSQL( $rs, $record );
  438. unset($record);
  439. unset($rs);
  440. //Insert the records into the database
  441. $this->db->Execute( $insert_sql );
  442. unset($insert_sql);
  443. //initialize the channel buffer
  444. $_SESSION['channel_buffer']->init($channel_name);
  445. //invite the owner of this private channel
  446. $_SESSION['chatter']->invite( $_SESSION['chatter']->get_nick() );
  447. }
  448. /**
  449. * Creates a channel (default, moderated)
  450. *
  451. * @access public
  452. * @param string
  453. * @param integer
  454. * @return boolean
  455. */
  456. function create_channel( $name, $type, $passwd, $message )
  457. {
  458. if( $this->connection_count == 0 )
  459. die('Not connected! Use connect() first!');
  460. if( $name == '' || $type > 1 ) return false;
  461. function create_channel_error($errno, $errmsg, $filename, $linenum, $vars)
  462. {
  463. $_SESSION['logger']->error('Could not create channel!', $filename, $linenum);
  464. return false;
  465. }
  466. $record = array();
  467. $record[ 'NAME' ] = $name;
  468. $record[ 'MAX_LINE_NUMBER' ] = CB_MAX_LINE;
  469. $record[ 'TYPE' ] = $type; //type=0 it's a default channel
  470. $record[ 'PASSWORD' ] = $passwd;
  471. $record[ 'MESSAGE' ] = $message;
  472. //type=1 it's a moderated channel
  473. $rs = $this->db->Execute( 'SELECT NAME,MAX_LINE_NUMBER,TYPE,PASSWORD,MESSAGE FROM poc_channels' );
  474. $insert_sql = $this->db->GetInsertSQL( $rs, $record );
  475. unset($record);
  476. unset($rs);
  477. //Insert the records into the database
  478. set_error_handler('create_channel_error');
  479. $this->db->Execute( $insert_sql );
  480. restore_error_handler();
  481. unset($insert_sql);
  482. //initialize the channel buffer
  483. $channel_buffer = &new Channel_Buffer($name);
  484. $channel_buffer->init();
  485. unset($channel_buffer);
  486. return true;
  487. }
  488. /**
  489. * Creates a channel (default, moderated)
  490. *
  491. * @access public
  492. * @param string
  493. * @param integer
  494. * @return void
  495. */
  496. function update_channel( $name, $type, $passwd, $message )
  497. {
  498. if( $this->connection_count == 0 )
  499. die('Not connected! Use connect() first!');
  500. if( $type > 1 ) return false;
  501. function update_channel_error($errno, $errmsg, $filename, $linenum, $vars)
  502. {
  503. $_SESSION['logger']->error('Could not update channel!', $filename, $linenum);
  504. return false;
  505. }
  506. $record = array();
  507. $record[ 'TYPE' ] = $type; //type=0 it's a default channel
  508. $record[ 'PASSWORD' ] = $passwd;
  509. $record[ 'MESSAGE' ] = $message;
  510. //type=1 it's a moderated channel
  511. $rs = $this->db->Execute( 'SELECT TYPE, PASSWORD, MESSAGE FROM poc_channels WHERE NAME = \''.$name.'\'' );
  512. $update_sql = $this->db->GetUpdateSQL( $rs, $record );
  513. unset($record);
  514. unset($rs);
  515. //Insert the records into the database
  516. set_error_handler('update_channel_error');
  517. $this->db->Execute( $update_sql );
  518. restore_error_handler();
  519. unset($update_sql);
  520. return true;
  521. }
  522.  
  523. /**
  524. * Deletes a channel
  525. *
  526. * @access public
  527. * @param string
  528. * @return boolean
  529. */
  530. function delete_channel( $channel_name )
  531. {
  532. if( $this->connection_count == 0 )
  533. die('Not connected! Use connect() first!');
  534. //remove channel
  535. $rs = $this->db->Execute( 'DELETE FROM poc_channels WHERE NAME=\''.$channel_name.'\'' );
  536. $rows_effected = $this->db->Affected_Rows();
  537. if( CHANNEL_BUFFER_TYPE == 'DB' ) {
  538. //remove the dependent channel buffer if necessary
  539. $rs = $this->db->Execute( 'DELETE FROM poc_line_buffer WHERE NAME=\''.$channel_name.'\'' );
  540. $rows_effected += $this->db->Affected_Rows();
  541. unset($rs);
  542. return( $rows_effected == 2 );
  543. } elseif( CHANNEL_BUFFER_TYPE == 'MEM' ) {
  544. //TODO: cleanup the shared memory, if necessary...
  545. unset($rs);
  546. return ( $rows_effected == 1 );
  547. } else {
  548. //other buffer types may doesn't need any clean up
  549. unset($rs);
  550. return ( $rows_effected == 1 );
  551. }
  552. }
  553. /**
  554. * initialisation of channel_buffers
  555. *
  556. * @access public
  557. * @return void
  558. * @see create_channel()
  559. * @see create_private_channel()
  560. */
  561. function init_channel_buffers()
  562. {
  563. return null;
  564. if( $this->connection_count == 0 )
  565. die('Not connected! Use connect() first!');
  566. $channels = array();
  567. $channels = $this->get_channels();
  568. reset($channels);
  569. do{
  570. $_SESSION['channel_buffer']->init( current($channels) );
  571. }while( next($channels) );
  572. }
  573. function move_channel_to_top( $channel )
  574. {
  575. if( $this->connection_count == 0 )
  576. die('Not connected! Use connect() first!');
  577. $channels = array();
  578. $channels = $this->get_channels();
  579. unset( $channels[array_search($channel,$channels)] );
  580. $channels=array_reverse ($channels);
  581. $channels[]=$channel;
  582. $channels=array_reverse($channels);
  583. foreach($channels as $key => $value)
  584. {
  585. $rs = $this->db->Execute( 'UPDATE poc_channels SET ORDER_IDX = '.$key.' WHERE NAME=\''.$value.'\'' );
  586. }
  587. }
  588. /**
  589. * Gets all the channels as an option list specially for select boxes in the chat
  590. *
  591. * @param int $current_channel
  592. * @access public
  593. * @return string
  594. */
  595. function get_channels_option_list( $current_channel = '')
  596. {
  597. if( $this->connection_count == 0 )
  598. die('Not connected! Use connect() first!');
  599.  
  600. //Get a list of all channels except for private channels
  601. //ordinary channel: TYPE = NULL
  602. //moderated channel: TYPE = 1
  603. //private channel: TYPE = 2
  604. $rs1 = $this->db->Execute( 'SELECT NAME,INVITED,TYPE, 0 AS COUNT FROM poc_channels ORDER BY ORDER_IDX' );
  605. $rs2 = $this->db->Execute( 'SELECT c.NAME AS NAME,
  606. c.INVITED AS INVITED,
  607. c.TYPE AS TYPE,
  608. COUNT(c.NAME) AS COUNT
  609. FROM poc_user_data d,
  610. poc_channels c
  611. WHERE ONLINE = \'1\'
  612. AND LAST_CHANNEL = c.NAME
  613. GROUP BY c.NAME
  614. ORDER BY ORDER_IDX');
  615.  
  616. $channels = array_merge($rs1->GetAssoc(),$rs2->GetAssoc());
  617. $rs1->Close();
  618. $rs2->Close();
  619. unset($rs1);
  620. unset($rs2);
  621. $option_list = '';
  622. $option_list_of_public_channels = '';
  623. $option_list_of_moderated_channels = '';
  624. $option_list_of_private_channels = '';
  625.  
  626. foreach ( $channels as $current )
  627. {
  628. $occupancy = ' ('.$current['COUNT'].'/'.MAX_CONCURRENT_CHATTER.')';
  629. $current_value = $current['NAME'];
  630. $disabled = '';
  631. if( $current['COUNT'] >= MAX_CONCURRENT_CHATTER )
  632. {
  633. $occupancy = ' ('.$_SESSION['translator']->out('FULL').')';
  634. if( isset($_SESSION['channel'])
  635. && $_SESSION['channel']->get_name() == $current['NAME'] )
  636. {}
  637. elseif(!isset($_SESSION['channel_buffer'])) continue;
  638. else
  639. {
  640. $current_value = '';
  641. $disabled = 'disabled="disabled"';
  642. }
  643. }
  644. if( $current['NAME'] == $current_channel )
  645. $selected = 'selected="selected"';
  646. else
  647. $selected = '';
  648.  
  649. $chatters_invited_into = array();
  650. if( $current['TYPE'] == 2 && is_string($current['INVITED']) ) {
  651. $chatters_invited_into = unserialize($current['INVITED']);
  652. if( !is_array($chatters_invited_into) ) $chatters_invited_into = array();
  653. }
  654. //add private channels if invited and it's not a call from the login form
  655. //if( !is_null($chatters_invited_into) &&
  656. if( $current_channel != '' &&
  657. isset($_SESSION['chatter']) && in_array($_SESSION['chatter']->get_nick(),$chatters_invited_into) )
  658. {
  659. $option_list_of_private_channels .= TAB.'<option value="'.$current_value.'" '.$selected.' '.$disabled.'>';
  660. $option_list_of_private_channels .= preg_replace( "/\#{3}([^#]*)\#{3}/e", "\$_SESSION['translator']->out('\\1')", $current['NAME'] );
  661. $option_list_of_private_channels .= $occupancy.'</option>'.NL;
  662. }
  663. //if( is_null($chatters_invited_into) )
  664. if( count($chatters_invited_into) == 0 && $current['TYPE'] < 2 )
  665. {
  666. if( isset($_SESSION['chatter']) && $_SESSION['chatter']->is_banned( $current['NAME']) )
  667. {}
  668. elseif( $current['TYPE'] == 1 )
  669. $option_list_of_moderated_channels .= TAB.'<option value="'.$current_value.'" '.$selected.' '.$disabled.'>'.$current['NAME'].$occupancy.'</option>'.NL;
  670. else
  671. $option_list_of_public_channels .= TAB.'<option value="'.$current_value.'" '.$selected.' '.$disabled.'>'.$current['NAME'].$occupancy.'</option>'.NL;
  672. }
  673. }
  674.  
  675. unset($selected);
  676. if( $option_list_of_public_channels != '' )
  677. {
  678. $option_list .= '<optgroup label="'.$_SESSION['translator']->out('PUBLIC_CHANNEL').'">'.NL;
  679. $option_list .= $option_list_of_public_channels;
  680. $option_list .= TAB.TAB.'</optgroup>'.NL;
  681. }
  682. if( $option_list_of_moderated_channels != '' )
  683. {
  684. $option_list .= '<optgroup label="'.$_SESSION['translator']->out('MODERATED_CHANNEL').'">'.NL;
  685. $option_list .= $option_list_of_moderated_channels;
  686. $option_list .= TAB.TAB.'</optgroup>'.NL;
  687. }
  688. if( $option_list_of_private_channels != '' )
  689. {
  690. $option_list .= '<optgroup label="'.$_SESSION['translator']->out('PRIVATE_CHANNEL').'">'.NL;
  691. $option_list .= $option_list_of_private_channels;
  692. $option_list .=