*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
if($_SERVER['REQUEST_METHOD']=='HEAD') exit; // ignore HEAD requests
date_default_timezone_set('UTC');
$A=array();// All registered members
$C=array();// Configuration
$F=array();// Fonts
$G=array();// Guests: display names
$H=array();// HTML-stuff
$I=array();// Translations
$L=array();// Languages
$M=array();// Members: display names
$P=array();// All present users
$U=array();// This user data
$countmods=0;// Present moderators
$memcached;// Memcached connection
$mysqli;// MySQL database connection
load_config();
// set session variable to cookie if cookies are enabled
if(!isSet($_REQUEST['session']) && isSet($_COOKIE[$C['cookiename']])){
$_REQUEST['session']=$_COOKIE[$C['cookiename']];
}
elseif(!isSet($_REQUEST['session'])) $_REQUEST['session']='';
load_fonts();
load_lang();
load_html();
check_db();
// main program: decide what to do based on queries
if(!isSet($_REQUEST['action'])){
if(check_init()<7) send_init();
send_login();
}elseif($_REQUEST['action']=='view'){
check_session();
send_messages();
}elseif($_REQUEST['action']=='redirect' && !empty($_GET['url'])){
send_redirect();
}elseif($_REQUEST['action']=='wait'){
send_waiting_room();
}elseif($_REQUEST['action']=='post'){
check_session();
if(isSet($_REQUEST['kick']) && isSet($_REQUEST['sendto']) && valid_nick($_REQUEST['sendto'])){
if($U['status']>=5 || ($C['memkick'] && $countmods==0 && $U['status']>=3)){
if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge') kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], true);
else kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], false);
}
}elseif(isSet($_REQUEST['message']) && isSet($_REQUEST['sendto'])){
validate_input();
}
send_post();
}elseif($_REQUEST['action']=='login'){
check_login();
send_frameset();
}elseif($_REQUEST['action']=='controls'){
check_session();
send_controls();
}elseif($_REQUEST['action']=='delete'){
check_session();
if($_REQUEST['what']=='all'){
if(isSet($_REQUEST['confirm'])) del_all_messages($U['nickname'], 10, $U['entry']);
else send_del_confirm();
}
elseif($_REQUEST['what']=='last') del_last_message();
send_post();
}elseif($_REQUEST['action']=='profile'){
check_session();
if(isSet($_REQUEST['do']) && $_REQUEST['do']=='save') save_profile();
send_profile();
}elseif($_REQUEST['action']=='logout'){
kill_session();
send_logout();
}elseif($_REQUEST['action']=='colours'){
check_session();
send_colours();
}elseif($_REQUEST['action']=='notes'){
check_session();
if($U['status']<5) send_login();
send_notes('staff');
}elseif($_REQUEST['action']=='help'){
check_session();
send_help();
}elseif($_REQUEST['action']=='admnotes'){
check_session();
if($U['status']<6) send_login();
send_notes('admin');
}elseif($_REQUEST['action']=='admin'){
check_session();
if($U['status']<5) send_login();
if(!isSet($_REQUEST['do'])){
send_admin();
}elseif($_REQUEST['do']=='clean'){
if($_REQUEST['what']=='choose') send_choose_messages();
elseif($_REQUEST['what']=='selected') clean_selected();
elseif($_REQUEST['what']=='room') clean_room();
elseif($_REQUEST['what']=='nick') del_all_messages($_REQUEST['nickname'], $U['status'], 0);
send_admin();
}elseif($_REQUEST['do']=='kick'){
if(!isSet($_REQUEST['name'])) send_admin();
if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge') kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], true);
else kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], false);
send_admin();
}elseif($_REQUEST['do']=='logout'){
if(!isSet($_REQUEST['name'])) send_admin();
logout_chatter($_REQUEST['name']);
send_admin();
}elseif($_REQUEST['do']=='sessions'){
if(isSet($_REQUEST['nick'])) kick_chatter(array($_REQUEST['nick']), '', false);
send_sessions();
}elseif($_REQUEST['do']=='register'){
register_guest(3);
check_session();
send_admin();
}elseif($_REQUEST['do']=='superguest'){
register_guest(2);
check_session();
send_admin();
}elseif($_REQUEST['do']=='status'){
change_status();
}elseif($_REQUEST['do']=='regnew'){
register_new();
}elseif($_REQUEST['do']=='approve'){
approve_session();
send_approve_waiting();
}elseif($_REQUEST['do']=='guestaccess'){
if(isSet($_REQUEST['guestaccess']) && preg_match('/^[0123]$/', $_REQUEST['guestaccess'])){
update_setting('guestaccess', $_REQUEST['guestaccess']);
}
}elseif($_REQUEST['do']=='filter'){
manage_filter();
send_filter();
}
send_admin();
}elseif($_REQUEST['action']=='setup'){
if(check_init()<7) send_init();
update_db();
if(!valid_admin()) send_alogin();
if(!isSet($_REQUEST['do'])){
}elseif($_REQUEST['do']=='save'){
$settings=array('guestaccess', 'englobalpass', 'globalpass', 'msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'dateformat', 'captcha', 'css', 'memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage');
foreach($settings as $setting){
if(isSet($_REQUEST[$setting])) update_setting($setting, $_REQUEST[$setting]);
}
if(isSet($_REQUEST['rulestxt'])){
$_REQUEST['rulestxt']=preg_replace("/\r\n/", '
', $_REQUEST['rulestxt']);
$_REQUEST['rulestxt']=preg_replace("/\n/", '
', $_REQUEST['rulestxt']);
$_REQUEST['rulestxt']=preg_replace("/\r/", '
', $_REQUEST['rulestxt']);
update_setting('rulestxt', $_REQUEST['rulestxt']);
}
}
send_setup();
}elseif($_REQUEST['action']=='init'){
init_chat();
}else{
send_login();
}
mysqli_close($mysqli);
exit;
// html output subs
function print_stylesheet(){
global $C;
$css=get_setting('css');
echo "";
}
function print_end(){
global $mysqli;
echo '