*
* 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 .
*/
date_default_timezone_set('UTC');
$U=array();// This user data
$P=array();// All present users
$A=array();// All registered members
$M=array();// Members: display names
$G=array();// Guests: display names
$F=array();// Fonts
$C=array();// Configuration
$H=array();// HTML-stuff
$I=array();// Translations
$L=array();// Languages
$mysqli;// MySQL database connection
$countmods=0;
load_fonts();
load_config();
load_lang();
load_html();
check_db();
// set session variable to cookie if cookies are enabled
if(!isSet($_REQUEST['session']) && isSet($_COOKIE[$C['cookiename']])){
$_REQUEST['session']=$_COOKIE[$C['cookiename']];
}
// main program: decide what to do based on queries
if(!isSet($_REQUEST['action'])){
send_login();
}elseif($_REQUEST['action']=='view'){
check_session();
send_messages();
}elseif($_REQUEST['action']=='redirect' && isSet($_GET['url']) && !$_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 || ($countmods==0 && $U['status']>=3)){
kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message']);
if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge') del_all_messages($_REQUEST['sendto']);
}
}elseif(isSet($_REQUEST['message']) && isSet($_REQUEST['sendto']) && !preg_match('/^\s*$/',$_REQUEST['message'])){
validate_input();
add_message();
}
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') del_all_messages($U['nickname']);
if($_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();
if($_REQUEST['what']=='selected') clean_selected();
if($_REQUEST['what']=='room') clean_room();
send_admin();
}elseif($_REQUEST['do']=='kick'){
if(!isSet($_REQUEST['name'])) send_admin();
kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage']);
if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge'){
foreach($_REQUEST['name'] as $name){
del_all_messages($name);
}
}
send_admin();
}elseif($_REQUEST['do']=='logout'){
if(!isSet($_REQUEST['name'])) send_admin();
logout_chatter($_REQUEST['name']);
send_admin();
}elseif($_REQUEST['do']=='sessions'){
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['set']) && preg_match('/^[0123]$/', $_REQUEST['set'])){
update_setting('guestaccess', $_REQUEST['set']);
}
}elseif($_REQUEST['do']=='filter'){
manage_filter();
send_filter();
}
send_admin();
}elseif($_REQUEST['action']=='setup'){
$tables=array('captcha', 'filter', 'members', 'messages', 'notes', 'sessions', 'settings');
$num_tables=0;
$result=mysqli_query($mysqli, 'SHOW TABLES');
while($tmp=mysqli_fetch_array($result, MYSQLI_NUM)){
if(in_array($tmp[0],$tables)) $num_tables++;
}
if($num_tables<7) send_init();
if(!valid_admin()) send_alogin();
if(!isSet($_REQUEST['do'])){
}elseif($_REQUEST['do']=='guestaccess'){
if(isSet($_REQUEST['set']) && preg_match('/^[0123]$/', $_REQUEST['set'])){
update_setting('guestaccess', $_REQUEST['set']);
}
}elseif($_REQUEST['do']=='dbupdate'){
update_db();
}elseif($_REQUEST['do']=='messages'){
update_messages();
}
send_setup();
}elseif($_REQUEST['action']=='init'){
init_chat();
}else{
send_login();
}
exit;
// html output subs
function print_credits(){
global $I, $C;
echo '';
if($C['showcredits']){
echo "$I[contributors]
";
echo 'Programming - Daniel Winzen
';
echo 'German - Daniel Winzen
';
echo 'English - Daniel Winzen
';
}
echo "
LE CHAT-PHP - $C[version]";
}
function print_stylesheet($arg1=''){
echo "\n";
}
function print_end(){
echo '