Documentation is available at index.php
- <?php //-*-php-*-
- /* ******************************************************************** **
- ** Copyright notice **
- ** **
- ** (c) 1995-2003 PHPOpenChat Development Team **
- ** http://phpopenchat.sourceforge.net/ **
- ** **
- ** All rights reserved **
- ** **
- ** This script is part of the PHPOpenChat project. The PHPOpenChat **
- ** project is free software; you can redistribute it and/or modify **
- ** it under the terms of the GNU General Public License as published by **
- ** the Free Software Foundation; either version 2 of the License, or **
- ** (at your option) any later version. **
- ** **
- ** The GNU General Public License can be found at **
- ** http://www.gnu.org/copyleft/gpl.html. **
- ** A copy is found in the textfile GPL and important notices to the **
- ** license from the team is found in the textfile LICENSE distributed **
- ** with these scripts. **
- ** **
- ** This script is distributed in the hope that it will be useful, **
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
- ** GNU General Public License for more details. **
- ** **
- ** This copyright notice MUST APPEAR in all copies of the script! **
- ** ******************************************************************** */
- /*
- $Author: jjaeschke $
- $Date: 2003/10/14 14:43:17 $
- $Source: /cvsroot/phpopenchat/chat3/index.php,v $
- $Revision: 1.83 $
- */
- //Get default values
- require_once('config.inc.php');
- require_once(POC_INCLUDE_PATH.'/adodb/adodb.inc.php');
- require_once(POC_INCLUDE_PATH.'/class.Chat.inc');
- require_once(POC_INCLUDE_PATH.'/class.Chatter.inc');
- require_once(POC_INCLUDE_PATH.'/class.Line.inc');
- require_once(POC_INCLUDE_PATH.'/class.Channel.inc');
- require_once(POC_INCLUDE_PATH.'/class.Channel_Buffer_'.CHANNEL_BUFFER_TYPE.'.inc');
- require_once(POC_INCLUDE_PATH.'/class.Template.inc');
- require_once(POC_INCLUDE_PATH.'/class.Translator.inc');
- require_once(POC_INCLUDE_PATH.'/class.Logger.inc');
- function POC_Error_Handler($errno, $errmsg, $filename, $linenum, $vars)
- {
- if( $errno == 2 ){
- //the webserver has no write access to the tmp dir
- Chat::display_error( $errmsg, $filename );
- exit;
- }
- }
- //$old_error_handler = set_error_handler("Chat::POC_Error_Handler");
- //jj problems with this $old_error_handler = set_error_handler("POC_Error_Handler");
- @session_start();
- //if ($old_error_handler) set_error_handler($old_error_handler);
- unset($old_error_handler);
- $jScript = '';
- $operator_passwd = '';
- $chatters_online_list = '';
- $_tmp =( isset($_SESSION['chatter']) )? $_SESSION['chatter']->get_user():'';
- if(!isset($_GET['nickname']))
- $_GET['nickname']=( isset($_COOKIE['poc_nick']) )? $_COOKIE['poc_nick']:$_tmp;
- if(!isset($_GET['password']))
- $_GET['password']=( isset($_COOKIE['poc_password']) )? $_COOKIE['poc_password']:$_tmp;//it's a fake, only to show some stars in the password field
- unset($_tmp);
- function check_private_icon( $nick )
- {
- global $ACCEPTED_MIME_TYPES;
- $smiley_dir = '/images/icons/chatter';
- for ($i=0;$i<count($ACCEPTED_MIME_TYPES);$i++)
- {
- preg_match('#image/[x\-]?(.*)#',$ACCEPTED_MIME_TYPES[$i], $parts);
- $file_extension = $parts[1];
- $smiley_path = $smiley_dir.'/'.strtolower($nick).'.'.$file_extension;
- if( file_exists($_SESSION['template']->get_tmpl_sys_path().$smiley_path) )
- return '<img src="'.$_SESSION['template']->get_tmpl_web_path().$smiley_path.'" align="middle" alt="'.$_SESSION['translator']->out('PRIVATE_IMAGE').'" />';
- }
- return ' ';
- }
- if( !isset($_SESSION['chat']) || !is_object($_SESSION['chat']))
- {
- if( !isset($_SESSION['chatter']) && function_exists('session_register') ) {
- session_register('chatter');
- }
- if( !isset($_SESSION['template']) && function_exists('session_register') ) {
- session_register('template');
- }
- if(function_exists('session_register')) {
- session_register('chat','translator','channel','channel_buffer','lastRedLine','mailbox','current_mailbox_type','curr_mail_idx','inbox_count_new','outbox_count_new','trash_count_new','session_get','session_post','reload_count','poll_count','logger');
- }
- $reload_count=0;$_SESSION['reload_count']=0;
- $poll_count=0;$_SESSION['poll_count']=0;
- $session_get = session_name().'='.session_id();
- $_SESSION['session_get'] = $session_get;
- $session_post = '<input type="hidden" name="'.session_name().'" value="'.session_id().'" />';
- $_SESSION['session_post'] = $session_post;
- $logger = &new Logger();
- $_SESSION['logger'] = $logger;
- $chat = &new Chat( strval(CHAT_NAME), $supported_languages );
- $_SESSION['chat'] = $chat;
- $translator = &new Translator( $_SESSION['chat']->get_language() );
- $_SESSION['translator'] = $translator;
- $_SESSION['chat']->set_deathless_chatters( $DEATHLESS_CHATTERS );
- if( isset($_SERVER['HTTP_REFERER']) )
- $_SESSION['chat']->set_referer($_SERVER['HTTP_REFERER']);
- $_SESSION['chat']->connect();
- $_SESSION['chat']->alter_db_schema();
- $_SESSION['chat']->make_clean();
- //Set operator password
- $operator_passwd = $_SESSION['chat']->set_operator_passwd();
- $_SESSION['chat']->disconnect();
- }
- if( isset($_GET['pnlogin']) )
- {
- //here a postnuke user has a chatter object already in the db
- //this object was created by the first request from postnuke enviroment
- //see below if( function_exists('pnUserGetVar') )...
- $_SESSION['chat']->connect();
- $_SESSION['chatter'] = $_SESSION['chat']->get_chatter_instance($_GET['pnlogin']);
- if( !is_object($_SESSION['chatter']) || $_SESSION['chatter']->db_instance_is_outdated() )
- unset($_SESSION['chatter']);
- else
- {
- $_SESSION['chatter']->mkinstance_clean();
- $_SESSION['chat']->set_show_profile(false);//profile data are managed by PN
- }
- $_SESSION['chat']->disconnect();
- }
- /*
- if( isset($_GET['language']) && in_array($_GET['language'], $supported_languages) )
- {
- $_SESSION['chat']->set_language($_GET['language']);
- $_SESSION['translator']->set_language($_GET['language']);
- }
- */
- if ( !isset($_SESSION['template']) )
- {
- $template = &new Template();
- $_SESSION['template'] = $template;
- if( isset($_SESSION['chatter']) )
- $_SESSION['template']->set_theme( $_SESSION['chatter']->get_theme() );
- unset($theme);
- if( function_exists('pnUserGetVar') )
- {
- // this is a request from the postnuke enviroment
- if ( pnUserLoggedIn() )
- {
- //register or update POC userdata
- $_chatter = Chat::mkinstance_chatter( pnUserGetVar('uname'), true );
- $_chatter->set_user( pnUserGetVar('uname') );
- $_chatter->set_email( pnUserGetVar('email') );//is hidden by default
- $_chatter->set_name( pnUserGetVar('name') );
- $_chatter->set_homePageURL( pnUserGetVar('url') );
- $_chatter->set_aimNickname( pnUserGetVar('user_aim') );
- $_chatter->set_yimNickname( pnUserGetVar('user_yim') );
- $_chatter->set_interests( pnUserGetVar('user_intrest') );
- if(!$_chatter->is_registered()) $_chatter->register();
- $_chatter->update();
- $_chatter->set_db_instance_lifetime();
- $_chatter->mkinstance_persist();
- unset($_chatter);
- $poc_web_root = $_SESSION['template']->get_poc_web_root();
- //clean PN session
- unset($_SESSION['chat']);
- //unset($_SESSION['chatter']);
- unset($_SESSION['reload_count']);
- unset($_SESSION['template']);
- unset($_SESSION['translator']);
- unset($_SESSION['logger']);
- unset($_SESSION['session_post']);
- unset($_SESSION['session_get']);
- header('Status: 301');
- header('Location: '.$poc_web_root.'/index.php?pnlogin='.pnUserGetVar('uname'));
- exit;
- }
- else
- {
- $_SESSION['template']->get_template('pn_login_failure');
- }
- }
- }
- $TEMPLATE_OUT['lang_switch'] = $_SESSION['chat']->get_lang_switch();
- if ( isset($_POST['account_data'])
- || ( isset($_SESSION['chatter']) && !$_SESSION['chatter']->is_kicked() && AUTOLOGIN_DIRECTLY ) )
- {
- /*
- * Create a new chatter to check account data
- * Object chatter has no nick, if
- * -the password doesn't match
- * -the nick contains incorrect characters
- * -the nick is too long
- */
- if(isset($_POST['nick'])
- && $_POST['nick'] == strval(STATUS_BOT_NAME))
- unset($_POST['nick']);
- if( !isset($_SESSION['chatter']) || $_SESSION['chatter']->is_guest() )
- {
- if( !Chat::mkinstance_channel( $_POST['channel'] ) )
- die('Channel doesn\'t exists!');
- $_chatter = &new Chatter($_POST['nick'],$_POST['password']);
- }
- else
- {
- if( !isset($_POST['channel']) )
- $_POST['channel'] = ENTRY_CHANNEL;
- if( !Chat::mkinstance_channel( $_POST['channel'] ) )
- die('Channel doesn\'t exists!');
- $_chatter = $_SESSION['chatter'];
- }
- if (!is_null($_chatter->get_nick()) || isset($_SESSION['chatter']) )
- {
- if ( !isset($_SESSION['chatter']) || $_SESSION['chatter']->is_guest() )
- $_SESSION['chatter'] = $_chatter;
- if ( isset($_POST['storeAccountData']) )
- {
- setcookie('poc_nick',$_POST['nick'],COOKIE_EXPIRE,COOKIE_PATH,COOKIE_DOMAIN,COOKIE_SECURE);
- setcookie('poc_password',$_POST['password'],COOKIE_EXPIRE,COOKIE_PATH,COOKIE_DOMAIN,COOKIE_SECURE);
- }
- //connect to the line buffer of choosen channel
- $channel_buffer = &new Channel_Buffer($_POST['channel']);
- $_SESSION['channel_buffer'] = $channel_buffer;
- $_SESSION['channel_buffer']->connect();
- $lastRedLine = $_SESSION['channel_buffer']->get_cur_line_idx();
- $_SESSION['channel_buffer']->disconnect();
- $_SESSION['lastRedLine'] = $lastRedLine;
- $_SESSION['chat']->connect();
- $_SESSION['chat']->create_private_channel( $_chatter->get_nick(true) );
- $_SESSION['chat']->disconnect();
- $banned_msg = '';
- if( $_SESSION['chatter']->is_banned( $_POST['channel']) )
- {
- $banned_msg = ' ###BANNED_MSG###';
- $_SESSION['chatter']->join_channel( $_SESSION['chatter']->get_nick() );
- }
- if( !$_SESSION['chatter']->already_seen_today() )
- $_SESSION['chatter']->count_hit('login');
- $_SESSION['chatter']->refresh();
- $_SESSION['chatter']->set_grade($GRADES);
- $_SESSION['template']->set_theme( $_SESSION['chatter']->get_theme() );
- //hey, the chatter is authorized
- $_SESSION['chatter']->go_online( $_SESSION['channel']->get_name() );
- //$_SESSION['chatter']->get_db_groups( $_SESSION['channel']->get_name() );
- //we have to say hello in the current channel first»
- $bot = &new Chatter(strval(STATUS_BOT_NAME));
- $said = $_SESSION['chatter']->get_nick().' ###JOINS_THE_CHAT###';
- $said .= $banned_msg;
- $line = &new Line($bot, $said);
- $line->set_login($_SESSION['chatter']->get_nick());
- $_SESSION['channel_buffer']->connect();
- //get current line number within channel buffer
- $_SESSION['channel_buffer']->put_line($line);
- $_SESSION['channel_buffer']->disconnect();
- if( $_SESSION['channel']->get_message() != '' ) {
- $_SESSION['chat']->write_sys_msg( '<br />'.$_SESSION['channel']->get_message(),$_SESSION['chatter'], true );
- }
- unset($line);
- unset($line_message);
- unset($bot);
- unset($said);
- unset($_SESSION['in']);
- header('Status: 301');
- header('Location: frameset.php?'.session_name().'='.session_id());
- exit;
- }
- else
- {
- unset($_SESSION['channel']);
- unset($_chatter);
- }
- }
- else
- {
- header('Content-type: text/html; charset='.$_SESSION['translator']->out('CHARACTER_ENCODING'));
- $_SESSION['template']->get_cached_content( 60*2 );//get cached content with a max age of 2 minutes
- }
- if( !$_SESSION['chat']->connect() )
- {
- unset($_SESSION['chat']);
- unset($_SESSION['chatter']);
- unset($_SESSION['channel_buffer']);
- unset($_SESSION['lastRedLine']);
- header('Status: 301');
- header('Location: test.php');
- exit;
- }
- $chatters_online = array();
- $chatters_online = $_SESSION['chat']->get_chatters('%');
- $count_chatters_online = count($chatters_online);
- if( $count_chatters_online > 0 )
- {
- $td_count = 0;
- for($i=0;$i<$count_chatters_online;$i++)
- {
- $td_count++;
- if($i==0 || ($i % COL_COUNT_CHATTER_LIST) == 0) $chatters_online_list .= NL.TAB.'<tr>';
- $chatters_online_list .= NL.TAB.TAB.'<td class="chatterTableImgCell">'.check_private_icon( $chatters_online[$i] ).'</td>
- <td class="chatterTable"> '.preg_replace( "/\#{3}([^#]*)\#{3}/e", "htmlentities(\$_SESSION['translator']->out('\\1'))", $chatters_online[$i] ).' </td>';
- if($i > 0 && ($i % COL_COUNT_CHATTER_LIST) == 0)
- {
- $td_count = 0;
- $chatters_online_list .= NL.TAB.'</tr>';
- }
- }
- for ($i = $td_count; $i < COL_COUNT_CHATTER_LIST; $i++)
- {
- $chatters_online_list .= NL.TAB.TAB.'<td colspan="2"></td>';
- }
- if( $td_count > 0 ) $chatters_online_list .= NL.TAB.'</tr>';
- }
- else
- $chatters_online_list = '<tr><td> </td></tr>';
- $TEMPLATE_OUT['count_chatters_online'] = $count_chatters_online;
- //get statistics
- $TEMPLATE_OUT['online_count_last24h'] = $_SESSION['chat']->get_online_count_last24h();
- $TEMPLATE_OUT['online_time_avg'] = round($_SESSION['chat']->get_online_time_avg()/(60*60*24),3);
- $TEMPLATE_OUT['registered_count'] = $_SESSION['chat']->get_registered_count();
- $TEMPLATE_OUT['last_registered'] = array();
- $last_registered_user = $_SESSION['chat']->get_last_registered();
- $TEMPLATE_OUT['last_registered']['NICK'] = $last_registered_user[0]['NICK'];
- $TEMPLATE_OUT['last_registered']['REGTIME'] = $last_registered_user[0]['REGTIME'];
- $TEMPLATE_OUT['mail_count'] = $_SESSION['chat']->get_mail_count();
- $TEMPLATE_OUT['mail_count_last_24h'] = $_SESSION['chat']->get_mail_count_last_24h();
- $TEMPLATE_OUT['option_list_of_channels'] = $_SESSION['chat']->get_channels_option_list(CHANNEL_SELECTED);
- $_SESSION['chat']->disconnect();
- //unset objects in session
- //unset($_SESSION['chatter']);
- unset($_SESSION['channel_buffer']);
- unset($_SESSION['lastRedLine']);
- $jump = ( isset($_GET['jump']) )? $_GET['jump']:'index.php';
- if( isset($_GET['onTop']) )
- $jScript .= '
- if( opener ) {
- /*click on exit within satellit*/
- opener.parent.location.href="'.$jump.'";
- window.close();
- }
- else {
- //alert(\'debug\');
- top.location.href="'.$jump.'";
- }
- ';
- if( isset($_GET['forceOnTop']) )
- $jScript .= '
- top.location.href="'.$jump.'";
- ';
- $TEMPLATE_OUT['disable'] = '';
- if( isset($_SESSION['chatter']) && !AUTOLOGIN_DIRECTLY && !$_SESSION['chatter']->is_guest() )
- {
- $TEMPLATE_OUT['disable'] = 'disabled="disabled"';
- }
- $TEMPLATE_OUT['nickname'] = '';
- $TEMPLATE_OUT['greeting'] = '';
- if( isset($_SESSION['chatter']) )
- {
- $TEMPLATE_OUT['nickname'] = $_SESSION['chatter']->get_nick().':';
- $TEMPLATE_OUT['greeting'] = $_SESSION['translator']->out('GREETING');
- }
- $TEMPLATE_OUT['jScript'] = $jScript;
- $TEMPLATE_OUT['operator_passwd'] = $operator_passwd;
- $TEMPLATE_OUT['chatters_online_list'] = $chatters_online_list;
- header('Content-type: text/html; charset='.$_SESSION['translator']->out('CHARACTER_ENCODING'));
- $_SESSION['template']->get_template('index');
- ?>
Documentation generated on Tue, 29 Jun 2004 14:42:29 +0200 by phpDocumentor 1.3.0RC3