diff --git a/CHANGELOG b/CHANGELOG index 6b7f640..77e9883 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +Version 1.14 - Oct. 30, 2015 +Added support for sqlite and PostgreSQL database engines +Replaced deprecated HTML with CSS for HTML5 compatibility +Show Topic on login and don't prepend "Topic:" +More optimizations and fixes + Version 1.13.1 - Sep. 15, 2015 Fix saving some setup settings diff --git a/README b/README index b6fb262..7553bfa 100644 --- a/README +++ b/README @@ -19,7 +19,7 @@ along with this program. If not, see . GENERAL INFORMATION: This is a PHP Chat based on LE CHAT v.1.14. An up-to-date copy of this script can be downloaded at https://github.com/DanWin/le-chat-php -The original perl LE CHAT script by Lucky Eddie can be downloaded at http://4fvfamdpoulu2nms.onion/lechat/ or via a tor2web proxy like https://4fvfamdpoulu2nms.tor2web.blutmagie.de/lechat/ if you don't have TOR installed. +The original perl LE CHAT script by Lucky Eddie can be downloaded at http://4fvfamdpoulu2nms.onion/lechat/ or via a tor2web proxy like https://4fvfamdpoulu2nms.onion.to/lechat/ if you don't have TOR installed. If you add your own cool features or have a feature request, please tell me and I will add them, if I like them. Please also let me know about any bugs you find in the code, so I can fix them. Now a piece of information about the origin of the name "LE CHAT" copied from the original script: @@ -88,6 +88,6 @@ If you never used regex before, check out this starting guide to begin with regu LIVE DEMO: -If you want to see the script in action, you can visit my TOR hidden service http://tt3j2x4k5ycaa5zt.onion/chat.php or via a tor2web proxy like http://tt3j2x4k5ycaa5zt.tor2web.blutmagie.de/chat.php if you don't have TOR installed. +If you want to see the script in action, you can visit my TOR hidden service http://tt3j2x4k5ycaa5zt.onion/chat.php or via a tor2web proxy like http://tt3j2x4k5ycaa5zt.onion.to/chat.php if you don't have TOR installed. Considering this is a hidden service, you should be prepared for the worst case, as people often tend to do illegal activities in the TOR network. I'm not online 24/7 so it might not be possible to remove such content right away. If you should see illegal content, don't panic. Use the contact form on my site to notify me and clean your browser cache afterwards. diff --git a/README.md b/README.md index 0afbe94..05d074f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ General Information: -------------------- This is a PHP Chat based on LE CHAT v.1.14. An up-to-date copy of this script can be downloaded at https://github.com/DanWin/le-chat-php -The original perl LE CHAT script by Lucky Eddie can be downloaded at [his site](http://4fvfamdpoulu2nms.onion/lechat/) or via a tor2web proxy like [this one](https://4fvfamdpoulu2nms.tor2web.blutmagie.de/lechat/) if you don't have TOR installed. +The original perl LE CHAT script by Lucky Eddie can be downloaded at [his site](http://4fvfamdpoulu2nms.onion/lechat/) or via a tor2web proxy like [this one](https://4fvfamdpoulu2nms.onion.to/lechat/) if you don't have TOR installed. If you add your own cool features or have a feature request, please tell me and I will add them, if I like them. Please also let me know about any bugs you find in the code, so I can fix them. Now a piece of information about the origin of the name "LE CHAT" copied from the original script: @@ -76,6 +76,6 @@ If you never used regex before, check out [this starting guide](http://docs.acti Live demo: ---------- -If you want to see the script in action, you can visit my [TOR hidden service](http://tt3j2x4k5ycaa5zt.onion/chat.php) or via a tor2web proxy like [this one](http://tt3j2x4k5ycaa5zt.tor2web.blutmagie.de/chat.php) if you don't have TOR installed. +If you want to see the script in action, you can visit my [TOR hidden service](http://tt3j2x4k5ycaa5zt.onion/chat.php) or via a tor2web proxy like [this one](http://tt3j2x4k5ycaa5zt.onion.to/chat.php) if you don't have TOR installed. Considering this is a hidden service, you should be prepared for the worst case, as people often tend to do illegal activities in the TOR network. I'm not online 24/7 so it might not be possible to remove such content right away. If you should see illegal content, don't panic. Use the contact form on my site to notify me and clean your browser cache afterwards. I will remove the content as soon as possible. diff --git a/chat.php b/chat.php index f2027f8..7c7fab1 100755 --- a/chat.php +++ b/chat.php @@ -18,16 +18,15 @@ * along with this program. If not, see . */ -if($_SERVER['REQUEST_METHOD']=='HEAD') exit; // ignore HEAD requests +header('Content-Type: text/html; charset=UTF-8'); header('Pragma: no-cache'); header('Cache-Control: no-cache'); header('Expires: 0'); +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 @@ -35,9 +34,8 @@ $db;// Database connection $memcached;// Memcached connection load_config(); // set session variable to cookie if cookies are enabled -if(!isSet($_REQUEST['session'])){ - if(isSet($_COOKIE[$C['cookiename']])) $_REQUEST['session']=$_COOKIE[$C['cookiename']]; - else $_REQUEST['session']=''; +if(!isSet($_REQUEST['session']) && isSet($_COOKIE[$C['cookiename']])){ + $_REQUEST['session']=$_COOKIE[$C['cookiename']]; } load_fonts(); load_lang(); @@ -48,13 +46,13 @@ check_db(); if(!isSet($_REQUEST['action'])){ if(!check_init()) send_init(); send_login(); -}elseif($_REQUEST['action']=='view'){ +}elseif($_REQUEST['action']==='view'){ check_session(); send_messages(false); -}elseif($_REQUEST['action']=='jsview'){ +}elseif($_REQUEST['action']==='jsview'){ check_session(); send_messages(true); -}elseif($_REQUEST['action']=='jsrefresh'){ +}elseif($_REQUEST['action']==='jsrefresh'){ check_session(); ob_start(); print_messages(); @@ -62,103 +60,100 @@ if(!isSet($_REQUEST['action'])){ ob_start(); print_chatters(); $chatters=ob_get_clean(); - $topic=get_setting('topic'); - if(!empty($topic)) $topic=sprintf($I['topic'], $topic); - echo json_encode(array($_REQUEST['id'], $msgs, $chatters, $topic)); -}elseif($_REQUEST['action']=='redirect' && !empty($_GET['url'])){ + echo json_encode(array($_REQUEST['id'], $msgs, $chatters, get_setting('topic'))); +}elseif($_REQUEST['action']==='redirect' && !empty($_GET['url'])){ send_redirect(); -}elseif($_REQUEST['action']=='wait'){ +}elseif($_REQUEST['action']==='wait'){ send_waiting_room(); -}elseif($_REQUEST['action']=='post'){ +}elseif($_REQUEST['action']==='post'){ check_session(); if(isSet($_REQUEST['kick']) && isSet($_REQUEST['sendto']) && valid_nick($_REQUEST['sendto'])){ - if($U['status']>=5 || (get_setting('memkick') && $countmods==0 && $U['status']>=3)){ - if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge') kick_chatter(array($_REQUEST['sendto']), $_REQUEST['message'], true); + if($U['status']>=5 || ($U['status']>=3 && $countmods===0 && get_setting('memkick'))){ + 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'){ +}elseif($_REQUEST['action']==='login'){ check_login(); send_frameset(); -}elseif($_REQUEST['action']=='controls'){ +}elseif($_REQUEST['action']==='controls'){ check_session(); send_controls(); -}elseif($_REQUEST['action']=='delete'){ +}elseif($_REQUEST['action']==='delete'){ check_session(); - if($_REQUEST['what']=='all'){ + 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(); + elseif($_REQUEST['what']==='last') del_last_message(); send_post(); -}elseif($_REQUEST['action']=='profile'){ +}elseif($_REQUEST['action']==='profile'){ check_session(); - if(isSet($_REQUEST['do']) && $_REQUEST['do']=='save') save_profile(); + if(isSet($_REQUEST['do']) && $_REQUEST['do']==='save') save_profile(); send_profile(); -}elseif($_REQUEST['action']=='logout'){ +}elseif($_REQUEST['action']==='logout'){ kill_session(); send_logout(); -}elseif($_REQUEST['action']=='colours'){ +}elseif($_REQUEST['action']==='colours'){ check_session(); send_colours(); -}elseif($_REQUEST['action']=='notes'){ +}elseif($_REQUEST['action']==='notes'){ check_session(); - if(!empty($_REQUEST['do']) && $_REQUEST['do']=='admin' && $U['status']>6) send_notes('admin'); + if(!empty($_REQUEST['do']) && $_REQUEST['do']==='admin' && $U['status']>6) send_notes('admin'); if($U['status']<5) send_login(); send_notes('staff'); -}elseif($_REQUEST['action']=='help'){ +}elseif($_REQUEST['action']==='help'){ check_session(); send_help(); -}elseif($_REQUEST['action']=='admin'){ +}elseif($_REQUEST['action']==='admin'){ check_session(); if($U['status']<5) send_login(); if(empty($_REQUEST['do'])){ - }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); - }elseif($_REQUEST['do']=='kick'){ + }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); + }elseif($_REQUEST['do']==='kick'){ if(!isSet($_REQUEST['name'])) send_admin(); - if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge') kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], true); + if(isSet($_REQUEST['what']) && $_REQUEST['what']==='purge') kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], true); else kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], false); - }elseif($_REQUEST['do']=='logout'){ - if(!isSet($_REQUEST['name'])) send_admin(); - logout_chatter($_REQUEST['name']); - }elseif($_REQUEST['do']=='sessions'){ + }elseif($_REQUEST['do']==='logout'){ + if(isSet($_REQUEST['name'])) logout_chatter($_REQUEST['name']); + }elseif($_REQUEST['do']==='sessions'){ if(isSet($_REQUEST['nick'])) kick_chatter(array($_REQUEST['nick']), '', false); send_sessions(); - }elseif($_REQUEST['do']=='register'){ + }elseif($_REQUEST['do']==='register'){ register_guest(3); - }elseif($_REQUEST['do']=='superguest'){ + }elseif($_REQUEST['do']==='superguest'){ register_guest(2); - }elseif($_REQUEST['do']=='status'){ + }elseif($_REQUEST['do']==='status'){ change_status(); - }elseif($_REQUEST['do']=='regnew'){ + }elseif($_REQUEST['do']==='regnew'){ register_new(); - }elseif($_REQUEST['do']=='approve'){ + }elseif($_REQUEST['do']==='approve'){ approve_session(); send_approve_waiting(); - }elseif($_REQUEST['do']=='guestaccess'){ + }elseif($_REQUEST['do']==='guestaccess'){ if(isSet($_REQUEST['guestaccess']) && preg_match('/^[0123]$/', $_REQUEST['guestaccess'])){ update_setting('guestaccess', $_REQUEST['guestaccess']); } - }elseif($_REQUEST['do']=='filter'){ + }elseif($_REQUEST['do']==='filter'){ manage_filter(); send_filter(); - }elseif($_REQUEST['do']=='linkfilter'){ + }elseif($_REQUEST['do']==='linkfilter'){ manage_linkfilter(); send_linkfilter(); - }elseif($_REQUEST['do']=='topic'){ + }elseif($_REQUEST['do']==='topic'){ if(isSet($_REQUEST['topic'])) update_setting('topic', htmlspecialchars($_REQUEST['topic'])); - }elseif($_REQUEST['do']=='passreset'){ + }elseif($_REQUEST['do']==='passreset'){ passreset(); } send_admin(); -}elseif($_REQUEST['action']=='setup'){ +}elseif($_REQUEST['action']==='setup'){ if(!check_init()) send_init(); update_db(); if(!valid_admin()) send_alogin(); @@ -170,7 +165,7 @@ if(!isSet($_REQUEST['action'])){ $C['text_settings']=array('dateformat', 'captchachars', 'redirect', 'chatname'); $C['settings']=array_merge(array('guestaccess', 'englobalpass', 'globalpass', 'captcha', 'dismemcaptcha', 'topic'), $C['bool_settings'], $C['colour_settings'], $C['msg_settings'], $C['number_settings'], $C['textarea_settings'], $C['text_settings']); // All settings in the database if(empty($_REQUEST['do'])){ - }elseif($_REQUEST['do']=='save'){ + }elseif($_REQUEST['do']==='save'){ foreach($C['msg_settings'] as $setting) $_REQUEST[$setting]=htmlspecialchars($_REQUEST[$setting]); foreach($C['number_settings'] as $setting) settype($_REQUEST[$setting], 'int'); $_REQUEST['rulestxt']=preg_replace("/(\r?\n|\r\n?)/", '
', $_REQUEST['rulestxt']); @@ -189,17 +184,17 @@ if(!isSet($_REQUEST['action'])){ foreach($C['settings'] as $setting){ if(isSet($_REQUEST[$setting])) update_setting($setting, $_REQUEST[$setting]); } - }elseif($_REQUEST['do']=='backup' && $U['status']==8){ + }elseif($_REQUEST['do']==='backup' && $U['status']==8){ send_backup(); - }elseif($_REQUEST['do']=='restore' && $U['status']==8){ + }elseif($_REQUEST['do']==='restore' && $U['status']==8){ restore_backup(); send_backup(); - }elseif($_REQUEST['do']=='destroy' && $U['status']==8){ + }elseif($_REQUEST['do']==='destroy' && $U['status']==8){ if(isSet($_REQUEST['confirm'])) destroy_chat(); else send_destroy_chat(); } send_setup(); -}elseif($_REQUEST['action']=='init'){ +}elseif($_REQUEST['action']==='init'){ init_chat(); }else{ send_login(); @@ -219,20 +214,14 @@ function print_end(){ exit; } -function frmpst($arg1='', $arg2=''){ - global $C, $H, $U; - $string="<$H[form]>".hidden('action', $arg1).hidden('session', $U['session']).hidden('lang', $C['lang']); - if(!empty($arg2)){ - if(!isSet($_REQUEST['multi'])) $_REQUEST['multi']=''; - if(!isSet($_REQUEST['sendto'])) $_REQUEST['sendto']=''; - $string.=hidden('what', $arg2).hidden('sendto', $_REQUEST['sendto']).hidden('multi', $_REQUEST['multi']); - } - return $string; +function frmpst($arg1=''){ + global $H; + echo "<$H[form]>$H[commonform]".hidden('action', $arg1); } function frmadm($arg1=''){ - global $C, $H, $U; - return "<$H[form]>".hidden('action', 'admin').hidden('do', $arg1).hidden('session', $U['session']).hidden('lang', $C['lang']); + global $H; + echo "<$H[form]>$H[commonform]".hidden('action', 'admin').hidden('do', $arg1); } function hidden($arg1='', $arg2=''){ @@ -249,11 +238,10 @@ function thr(){ function print_start($class='', $ref=0, $url=''){ global $H, $I, $U; - header('Content-Type: text/html; charset=UTF-8'); header('Pragma: no-cache'); header('Cache-Control: no-cache'); header('Expires: 0'); if(!empty($url)) header("Refresh: $ref; URL=$url"); echo "$H[meta_html]"; if(!empty($url)) echo ""; - if($class=='init'){ + if($class==='init'){ echo "$I[init]"; echo ""; }else{ @@ -280,64 +268,64 @@ function send_redirect(){ function send_captcha(){ global $C, $I, $db, $memcached; - $difficulty=get_setting('captcha'); - if($difficulty==0) return; + $difficulty=(int) get_setting('captcha'); + if($difficulty===0) return; $captchachars=get_setting('captchachars'); $length=strlen($captchachars)-1; $code=''; for($i=0;$i<5;++$i){ - $code.=$captchachars[rand(0, $length)]; + $code.=$captchachars[mt_rand(0, $length)]; } - $randid=rand(0, 99999999); + $randid=mt_rand(); $time=time(); if($C['memcached']){ $memcached->set("$C[dbname]-$C[prefix]captcha-$randid", $code, get_setting('captchatime')); }else{ - $stmt=$db->prepare("INSERT INTO `$C[prefix]captcha` (`id`, `time`, `code`) VALUES (?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]captcha (id, time, code) VALUES (?, ?, ?);"); $stmt->execute(array($randid, $time, $code)); } - echo "$I[copy]"; - if($difficulty==1){ + echo "$I[copy]
"; + if($difficulty===1){ $im=imagecreatetruecolor(55, 24); $bg=imagecolorallocate($im, 0, 0, 0); $fg=imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $bg); imagestring($im, 5, 5, 5, $code, $fg); echo ''; - echo ''.hidden('challenge', $randid).''; + echo ''.hidden('challenge', $randid).''; } function send_setup(){ global $C, $H, $I, $U; - $ga=get_setting('guestaccess'); + $ga=(int) get_setting('guestaccess'); print_start('setup'); - echo "

$I[setup]

<$H[form]>".hidden('action', 'setup').hidden('do', 'save').hidden('session', $U['session']).hidden('lang', $C['lang']).''; + echo "

$I[setup]

<$H[form]>$H[commonform]".hidden('action', 'setup').hidden('do', 'save'); + if(!isSet($_REQUEST['session'])) echo hidden('session', $U['session']); + echo '
'; thr(); - echo "
'; thr(); - $englobal=get_setting('englobalpass'); - echo "
$I[guestacc]"; + echo "
$I[guestacc]"; echo '
$I[globalloginpass]"; - echo ''; + $englobal=(int) get_setting('englobalpass'); + echo "'; thr(); - echo "
$I[globalloginpass]"; + echo ''; echo ''; echo ''; echo '
 
$I[sysmessages]"; - echo ''; - foreach($C['msg_settings'] as $setting) echo ''; + echo "'; foreach($C['text_settings'] as $setting){ thr(); - echo ''; + echo ''; } foreach($C['colour_settings'] as $setting){ thr(); - echo ''; + echo ''; } thr(); - echo "
 '.$I[$setting]." 
$I[sysmessages]"; + echo ''; + foreach($C['msg_settings'] as $setting) echo "'; echo '
 $I[$setting] 
'.$I[$setting].''; - echo ''; - echo "'; - echo '
'.$I[$setting].''; + echo "'; + echo '
'.$I[$setting].''; - echo ''; - echo "'; - echo '
'.$I[$setting].''; + echo "'; + echo '
$I[captcha]"; - echo ''; + echo "'; foreach($C['textarea_settings'] as $setting){ thr(); - echo ''; + echo ''; } foreach($C['number_settings'] as $setting){ thr(); - echo ''; + echo ''; } foreach($C['bool_settings'] as $setting){ thr(); - echo ''; + echo ''; } thr(); - echo '
$I[captcha]"; + echo ''; echo ''; echo '
'.$I[$setting].''; - echo ''; - echo "'; - echo '
'.$I[$setting].''; + echo "'; + echo '
'.$I[$setting].''; - echo ''; - echo "'; - echo '
'.$I[$setting].''; + echo "'; + echo '
'.$I[$setting].''; - echo ''; - echo "
'.$I[$setting].''; + echo "
'.submit($I['apply']).'

'; + echo '
'.submit($I['apply']).'

'; if($U['status']==8){ - echo ''; - echo "'; - echo "
<$H[form]>".hidden('action', 'setup').hidden('do', 'backup').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['backuprestore']).'<$H[form]>".hidden('action', 'setup').hidden('do', 'destroy').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['destroy'], 'class="delbutton"').'

'; + echo ''; + echo "'; + echo "
<$H[form]>$H[commonform]".hidden('action', 'setup').hidden('do', 'backup'); + if(!isSet($_REQUEST['session'])) hidden('session', $U['session']); + echo submit($I['backuprestore']).'<$H[form]>$H[commonform]".hidden('action', 'setup').hidden('do', 'destroy'); + if(!isSet($_REQUEST['session'])) hidden('session', $U['session']); + echo submit($I['destroy'], 'class="delbutton"').'

'; } - echo "
<$H[form]>".hidden('action', 'logout').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['logout'], 'id="exitbutton"')."
$H[credit]"; + echo "<$H[form]>$H[commonform]".hidden('action', 'logout'); + if(!isSet($_REQUEST['session'])) hidden('session', $U['session']); + echo submit($I['logout'], 'id="exitbutton"')."$H[credit]"; print_end(); } @@ -492,13 +483,13 @@ function restore_backup(){ } } if(isSet($_REQUEST['filter']) && (isSet($code['filters']) || isSet($code['linkfilters']))){ - $db->exec("DELETE FROM `$C[prefix]filter`"); - $db->exec("DELETE FROM `$C[prefix]linkfilter`"); - $stmt=$db->prepare("INSERT INTO `$C[prefix]filter` (`match`, `replace`, `allowinpm`, `regex`, `kick`) VALUES (?, ?, ?, ?, ?)"); + $db->exec("DELETE FROM $C[prefix]filter;"); + $db->exec("DELETE FROM $C[prefix]linkfilter;"); + $stmt=$db->prepare("INSERT INTO $C[prefix]filter (filtermatch, filterreplace, allowinpm, regex, kick) VALUES (?, ?, ?, ?, ?);"); foreach($code['filters'] as $filter){ $stmt->execute(array($filter['match'], $filter['replace'], $filter['allowinpm'], $filter['regex'], $filter['kick'])); } - $stmt=$db->prepare("INSERT INTO `$C[prefix]linkfilter` (`match`, `replace`, `regex`) VALUES (?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]linkfilter (filtermatch, filterreplace, regex) VALUES (?, ?, ?);"); foreach($code['linkfilters'] as $filter){ $stmt->execute(array($filter['match'], $filter['replace'], $filter['regex'])); } @@ -506,16 +497,16 @@ function restore_backup(){ if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]linkfilter"); } if(isSet($_REQUEST['members']) && isSet($code['members'])){ - $db->exec("DELETE FROM `$C[prefix]members`"); - $stmt=$db->prepare("INSERT INTO `$C[prefix]members` (`nickname`, `passhash`, `status`, `refresh`, `bgcolour`, `boxwidth`, `boxheight`, `notesboxwidth`, `notesboxheight`, `regedby`, `lastlogin`, `timestamps`, `embed`, `incognito`, `style`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $db->exec("DELETE FROM $C[prefix]members;"); + $stmt=$db->prepare("INSERT INTO $C[prefix]members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, notesboxwidth, notesboxheight, regedby, lastlogin, timestamps, embed, incognito, style) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); foreach($code['members'] as $member){ $stmt->execute(array($member['nickname'], $member['passhash'], $member['status'], $member['refresh'], $member['bgcolour'], $member['boxwidth'], $member['boxheight'], $member['notesboxwidth'], $member['notesboxheight'], $member['regedby'], $member['lastlogin'], $member['timestamps'], $member['embed'], $member['incognito'], $member['style'])); } if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]members"); } if(isSet($_REQUEST['notes']) && isSet($code['notes'])){ - $db->exec("DELETE FROM `$C[prefix]notes`"); - $stmt=$db->prepare("INSERT INTO `$C[prefix]notes` (`type`, `lastedited`, `editedby`, `text`) VALUES (?, ?, ?, ?)"); + $db->exec("DELETE FROM $C[prefix]notes;"); + $stmt=$db->prepare("INSERT INTO $C[prefix]notes (type, lastedited, editedby, text) VALUES (?, ?, ?, ?);"); foreach($code['notes'] as $note){ $stmt->execute(array($note['type'], $note['lastedited'], $note['editedby'], $note['text'])); } @@ -523,24 +514,34 @@ function restore_backup(){ } function send_backup(){ - global $C, $H, $I, $U, $db; + global $C, $H, $I, $db; $code=array(); - if($_REQUEST['do']=='backup'){ - if(isSet($_REQUEST['settings'])) foreach($C['settings'] as $setting) $code['settings'][$setting]=get_setting($setting); + if($_REQUEST['do']==='backup'){ + if(isSet($_REQUEST['settings'])){ + foreach($C['settings'] as $setting) $code['settings'][$setting]=get_setting($setting); + } if(isSet($_REQUEST['filter'])){ - $result=$db->query("SELECT `match`, `replace`, `allowinpm`, `regex`, `kick` FROM `$C[prefix]filter`"); - while($filter=$result->fetch(PDO::FETCH_ASSOC)) $code['filters'][]=$filter; - $result=$db->query("SELECT `match`, `replace`, `regex` FROM `$C[prefix]linkfilter`"); - while($filter=$result->fetch(PDO::FETCH_ASSOC)) $code['linkfilters'][]=$filter; + $result=$db->query("SELECT filtermatch, filterreplace, allowinpm, regex, kick FROM $C[prefix]filter;"); + $result->bindColumn(1, $filter['match']); + $result->bindColumn(2, $filter['replace']); + $result->bindColumn(3, $filter['allowinpm']); + $result->bindColumn(4, $filter['regex']); + $result->bindColumn(5, $filter['kick']); + while($result->fetch(PDO::FETCH_BOUND)) $code['filters'][]=$filter; + $result=$db->query("SELECT filtermatch, filterreplace, regex FROM $C[prefix]linkfilter;"); + $result->bindColumn(1, $filter['match']); + $result->bindColumn(2, $filter['replace']); + $result->bindColumn(3, $filter['regex']); + while($result->fetch(PDO::FETCH_BOUND)) $code['linkfilters'][]=$filter; } if(isSet($_REQUEST['members'])){ - $result=$db->query("SELECT `nickname`, `passhash`, `status`, `refresh`, `bgcolour`, `boxwidth`, `boxheight`, `notesboxwidth`, `notesboxheight`, `regedby`, `lastlogin`, `timestamps`, `embed`, `incognito`, `style` FROM `$C[prefix]members`"); + $result=$db->query("SELECT nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, notesboxwidth, notesboxheight, regedby, lastlogin, timestamps, embed, incognito, style FROM $C[prefix]members;"); while($member=$result->fetch(PDO::FETCH_ASSOC)) $code['members'][]=$member; } if(isSet($_REQUEST['notes'])){ - $result=$db->query("SELECT `type`, `lastedited`, `editedby`, `text` FROM `$C[prefix]notes` WHERE `type`='admin' ORDER BY `id` DESC LIMIT 1"); + $result=$db->query("SELECT type, lastedited, editedby, text FROM $C[prefix]notes WHERE type='admin' ORDER BY id DESC LIMIT 1;"); $code['notes'][]=$result->fetch(PDO::FETCH_ASSOC); - $result=$db->query("SELECT `type`, `lastedited`, `editedby`, `text` FROM `$C[prefix]notes` WHERE `type`='staff' ORDER BY `id` DESC LIMIT 1"); + $result=$db->query("SELECT type, lastedited, editedby, text FROM $C[prefix]notes WHERE type='staff' ORDER BY id DESC LIMIT 1;"); $code['notes'][]=$result->fetch(PDO::FETCH_ASSOC); } } @@ -549,155 +550,156 @@ function send_backup(){ if(isSet($_REQUEST['members'])) $chkmembers=' checked'; else $chkmembers=''; if(isSet($_REQUEST['notes'])) $chknotes=' checked'; else $chknotes=''; print_start('backup'); - echo "

$I[backuprestore]

"; + echo "

$I[backuprestore]

"; thr(); - echo "'; thr(); - echo "'; thr(); - echo ""; + echo ""; echo '
<$H[form]>".hidden('action', 'setup').hidden('do', 'backup').hidden('session', $U['session']).hidden('lang', $C['lang']); - echo ''; + echo '
'; + echo "
<$H[form]>$H[commonform]".hidden('action', 'setup').hidden('do', 'backup'); + echo '
'; echo ""; echo ""; echo ""; echo ""; - echo ''.submit($I['backup']).'
'.submit($I['backup']).'
<$H[form]>".hidden('action', 'setup').hidden('do', 'restore').hidden('session', $U['session']).hidden('lang', $C['lang']); - echo ''; + echo "
<$H[form]>$H[commonform]".hidden('action', 'setup').hidden('do', 'restore'); + echo ''; echo "'; - echo "
"; + echo "
"; echo ""; echo ""; - echo ""; - echo submit($I['restore']).'
'; + echo ""; + echo '
'.submit($I['restore']).'
'; echo '
<$H[form]>".hidden('action', 'setup').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['initgosetup'], 'class="backbutton"')."
<$H[form]>$H[commonform]".hidden('action', 'setup').submit($I['initgosetup'], 'class="backbutton"')."
'; print_end(); } function send_destroy_chat(){ - global $C, $H, $I, $U; + global $H, $I; print_start('destroy_chat'); - echo "
$I[confirm]
"; - echo "<$H[form] target=\"_parent\">".hidden('action', 'setup').hidden('do', 'destroy').hidden('session', $U['session']).hidden('lang', $C['lang']).hidden('confirm', 'yes').submit($I['yes'], 'class="delbutton"').''; - echo "<$H[form]>".hidden('action', 'setup').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['no'], 'class="backbutton"').'
'; + echo "
$I[confirm]
"; + echo "<$H[form] target=\"_parent\">$H[commonform]".hidden('action', 'setup').hidden('do', 'destroy').hidden('confirm', 'yes').submit($I['yes'], 'class="delbutton"').''; + echo "<$H[form]>$H[commonform]".hidden('action', 'setup').submit($I['no'], 'class="backbutton"').'
'; print_end(); } function send_init(){ - global $C, $H, $I, $L; + global $H, $I, $L; print_start('init'); - echo "

$I[init]

"; - echo "<$H[form]>".hidden('action', 'init').hidden('lang', $C['lang'])."

$I[sulogin]

"; + echo "

$I[init]

"; + echo "<$H[form]>$H[commonform]".hidden('action', 'init')."

$I[sulogin]

"; echo ""; echo ""; echo ""; - echo '
$I[sunick]
$I[supass]
$I[suconfirm]

'.submit($I['initbtn']).'
'; + echo '

'.submit($I['initbtn']).'
'; echo "

$I[changelang]"; foreach($L as $lang=>$name){ echo " $name"; } - echo "

$H[credit]"; + echo "

$H[credit]"; print_end(); } function send_update(){ - global $C, $H, $I; + global $H, $I; print_start('update'); - echo "

$I[dbupdate]


<$H[form]>".hidden('action', 'setup').hidden('lang', $C['lang']).submit($I['initgosetup'])."
$H[credit]"; + echo "

$I[dbupdate]


<$H[form]>$H[commonform]".hidden('action', 'setup').submit($I['initgosetup'])."
$H[credit]
"; print_end(); } function send_alogin(){ - global $C, $H, $I, $L; + global $H, $I, $L; print_start('alogin'); - echo "
<$H[form]>".hidden('action', 'setup').hidden('lang', $C['lang']).''; - echo ""; - echo ""; + echo "
<$H[form]>$H[commonform]".hidden('action', 'setup').'
$I[nick]
$I[pass]
'; + echo ""; + echo ""; send_captcha(); - echo '
$I[nick]
$I[pass]
'.submit($I['login']).'
'; + echo '
'.submit($I['login']).'
'; echo "

$I[changelang]"; foreach($L as $lang=>$name){ echo " $name"; } - echo "

$H[credit]"; + echo "

$H[credit]"; print_end(); } function send_admin($arg=''){ - global $A, $C, $H, $I, $U, $db; - $ga=get_setting('guestaccess'); + global $A, $C, $H, $I, $P, $U, $db; + $ga=(int) get_setting('guestaccess'); print_start('admin'); - $lines=parse_sessions(); - foreach($lines as $temp){ - if($temp['entry']!=0 && $temp['status']!=0){ - $Present[$temp['nickname']]=[$temp['nickname'], $temp['status'], $temp['style']]; - } - } $chlist="'; - echo "

$I[admfunc]

$arg"; + echo "

$I[admfunc]

$arg
"; if($U['status']>=7){ thr(); - echo "'; + echo "'; } thr(); - echo "
"; - echo "<$H[form] target=\"view\">".hidden('action', 'setup').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['initgosetup']).'
<$H[form] target=\"view\">$H[commonform]".hidden('action', 'setup').submit($I['initgosetup']).'
$I[cleanmsgs]"; - echo frmadm('clean').''; thr(); - echo '
'; + echo "
$I[cleanmsgs]"; + frmadm('clean'); + echo '
'; echo " "; echo " 
"; echo " '; + echo ''; echo submit($I['clean'], 'class="delbutton"').'
'.sprintf($I['kickchat'], get_setting('kickpenalty')).'
'; - echo frmadm('kick').""; - echo "'; thr(); - echo "
$I[kickreason]  
$chlist"; + echo '
'.sprintf($I['kickchat'], get_setting('kickpenalty')).'
'; + frmadm('kick'); + echo ""; + echo "
$I[kickreason] 
$chlist"; echo submit($I['kick']).'
$I[logoutinact]"; - echo frmadm('logout')."'; $views=array('sessions', 'filter', 'linkfilter'); foreach($views as $view){ - thr(); - echo ''; + thr(); + echo ''; } thr(); - echo "'; + echo "
$chlist"; + echo "
$I[logoutinact]"; + frmadm('logout'); + echo "
$chlist"; echo submit($I['logout']).'
'.$I[$view].''; - echo frmadm($view).'
'.submit($I['view']).'
'.$I[$view].''; + frmadm($view); + echo submit($I['view']).'
'; + echo "
$I[admtopic]"; - echo frmadm('topic').''; thr(); - echo "'; + echo "'; thr(); if(get_setting('suguests')){ - echo "'; thr(); } if($U['status']>=7){ - echo "'; thr(); - echo "'; thr(); - echo "'; thr(); - echo "
'; + echo "
$I[topic]"; + frmadm('topic'); + echo '
'; echo submit($I['change']).'
$I[guestacc]"; - echo frmadm('guestaccess').''; - echo '
'.submit($I['change']).'
$I[guestacc]"; + frmadm('guestaccess'); + echo ''; + echo '
'.submit($I['change']).'
$I[addsuguest]"; - echo frmadm('superguest')."'; + echo '
$I[addsuguest]"; + frmadm('superguest'); + echo "
'.submit($I['register']).'
'.submit($I['register']).'
$I[admmembers]"; - echo frmadm('status')."'; + echo '
$I[admmembers]"; + frmadm('status'); + echo "
'.submit($I['change']).'
'.submit($I['change']).'
$I[passreset]"; - echo frmadm('passreset')."'; + echo '
$I[passreset]"; + frmadm('passreset'); + echo "
'.submit($I['change']).'
'.submit($I['change']).'
$I[regguest]"; - echo frmadm('register')."'; + echo '
$I[regguest]"; + frmadm('register'); + echo "
'.submit($I['register']).'
'.submit($I['register']).'
$I[regmem]
"; - echo frmadm('regnew').""; - echo "'; thr(); } - echo "
$I[nick] 
$I[pass]"; + echo "
$I[regmem]
"; + frmadm('regnew'); + echo ""; + echo "
$I[nick]  
$I[pass] "; echo submit($I['register']).'
$H[backtochat]"; + echo "
$H[backtochat]"; print_end(); } @@ -744,32 +749,39 @@ function send_sessions(){ global $H, $I, $U; $lines=parse_sessions(); print_start('sessions'); - echo "

$I[sessact]

"; - echo ""; - $trackip=get_setting('trackip'); - if($trackip) echo ""; - echo ""; + echo "

$I[sessact]

$I[sessnick]$I[sesstimeout]$I[sessua]$I[sesip]$I[actions]
"; + echo ""; + $trackip=(bool) get_setting('trackip'); + $memexpire=(int) get_setting('memberexpire'); + $guestexpire=(int) get_setting('guestexpire'); + if($trackip) echo ""; + echo ""; foreach($lines as $temp){ if($temp['status']!=0 && $temp['entry']!=0 && (!$temp['incognito'] || $temp['status']<$U['status'])){ - if($temp['status']==1 || $temp['status']==2) $s=' (G)'; + if($temp['status']<=2) $s=' (G)'; elseif($temp['status']==3) $s=''; elseif($temp['status']==5) $s=' (M)'; elseif($temp['status']==6) $s=' (SM)'; elseif($temp['status']==7) $s=' (A)'; elseif($temp['status']==8) $s=' (SA)'; - echo ''; - if($U['status']>$temp['status'] || $U['session']==$temp['session']){ - echo ""; - if($trackip) echo ""; - echo "'; + echo ''; + if($U['status']>$temp['status'] || $U['session']===$temp['session']){ + echo ""; + if($trackip) echo ""; + echo ''; }else{ - echo ''; - if($trackip) echo ''; - echo ''; + echo ''; + if($trackip) echo ''; + echo ''; } } } - echo "
$I[sessnick]$I[sesstimeout]$I[sessua]$I[sesip]$I[actions]
'.style_this($temp['nickname'].$s, $temp['style']).''.get_timeout($temp['lastpost'], $temp['status']).'$temp[useragent]$temp[ip]".frmadm('sessions').hidden('nick', $temp['nickname']).submit($I['kick']).'
'.style_this($temp['nickname'].$s, $temp['style']).''; + if($temp['status']>2) get_timeout($temp['lastpost'], $memexpire); + else get_timeout($temp['lastpost'], $guestexpire); + echo '$temp[useragent]$temp[ip]'; + frmadm('sessions'); + echo hidden('nick', $temp['nickname']).submit($I['kick']).'
---
---

$H[backtochat]
"; + echo "

$H[backtochat]"; print_end(); } @@ -790,16 +802,16 @@ function manage_filter(){ else $kick=0; if(preg_match('/^[0-9]*$/', $_REQUEST['id'])){ if(empty($_REQUEST['match'])){ - $stmt=$db->prepare("DELETE FROM `$C[prefix]filter` WHERE `id`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]filter WHERE id=?;"); $stmt->execute(array($_REQUEST['id'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]filter"); }else{ - $stmt=$db->prepare("UPDATE `$C[prefix]filter` SET `match`=?, `replace`=?, `allowinpm`=?, `regex`=?, `kick`=? WHERE `id`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]filter SET filtermatch=?, filterreplace=?, allowinpm=?, regex=?, kick=? WHERE id=?;"); $stmt->execute(array($_REQUEST['match'], $_REQUEST['replace'], $pm, $reg, $kick, $_REQUEST['id'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]filter"); } }elseif(preg_match('/^\+$/', $_REQUEST['id'])){ - $stmt=$db->prepare("INSERT INTO `$C[prefix]filter` (`match`, `replace`, `allowinpm`, `regex`, `kick`) VALUES (?, ?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]filter (filtermatch, filterreplace, allowinpm, regex, kick) VALUES (?, ?, ?, ?, ?);"); $stmt->execute(array($_REQUEST['match'], $_REQUEST['replace'], $pm, $reg, $kick)); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]filter"); } @@ -819,16 +831,16 @@ function manage_linkfilter(){ } if(preg_match('/^[0-9]*$/', $_REQUEST['id'])){ if(empty($_REQUEST['match'])){ - $stmt=$db->prepare("DELETE FROM `$C[prefix]linkfilter` WHERE `id`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]linkfilter WHERE id=?;"); $stmt->execute(array($_REQUEST['id'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]linkfilter"); }else{ - $stmt=$db->prepare("UPDATE `$C[prefix]linkfilter` SET `match`=?, `replace`=?, `regex`=? WHERE `id`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]linkfilter SET filtermatch=?, filterreplace=?, regex=? WHERE id=?;"); $stmt->execute(array($_REQUEST['match'], $_REQUEST['replace'], $reg, $_REQUEST['id'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]linkfilter"); } }elseif(preg_match('/^\+$/', $_REQUEST['id'])){ - $stmt=$db->prepare("INSERT INTO `$C[prefix]linkfilter` (`match`, `replace`, `regex`) VALUES (?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]linkfilter (filtermatch, filterreplace, regex) VALUES (?, ?, ?);"); $stmt->execute(array($_REQUEST['match'], $_REQUEST['replace'], $reg)); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]linkfilter"); } @@ -838,92 +850,113 @@ function manage_linkfilter(){ function send_filter($arg=''){ global $C, $H, $I, $U, $db, $memcached; print_start('filter'); - echo "

$I[filter]

$arg"; + echo "

$I[filter]

$arg
"; thr(); - echo ""; + echo ""; if($C['memcached']) $filters=$memcached->get("$C[dbname]-$C[prefix]filter"); - if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){ + if(!$C['memcached'] || $memcached->getResultCode()!==Memcached::RES_SUCCESS){ $filters=array(); - $result=$db->query("SELECT * FROM `$C[prefix]filter`"); - while($filter=$result->fetch(PDO::FETCH_ASSOC)) $filters[]=$filter; + $result=$db->query("SELECT id, filtermatch, filterreplace, allowinpm, regex, kick FROM $C[prefix]filter;"); + $result->bindColumn(1, $filter['id']); + $result->bindColumn(2, $filter['match']); + $result->bindColumn(3, $filter['replace']); + $result->bindColumn(4, $filter['allowinpm']); + $result->bindColumn(5, $filter['regex']); + $result->bindColumn(6, $filter['kick']); + while($result->fetch(PDO::FETCH_BOUND)) $filters[]=$filter; if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]filter", $filters); } foreach($filters as $filter){ if($filter['allowinpm']==1) $check=' checked'; else $check=''; if($filter['regex']==1) $checked=' checked'; - else $checked=''; + else{ + $checked=''; + $filter['match']=preg_replace('/(\\\\(.))/', "$2", $filter['match']); + } if($filter['kick']==1) $checkedk=' checked'; else $checkedk=''; - if($filter['regex']==0) $filter['match']=preg_replace('/(\\\\(.))/', "$2", $filter['match']); - echo ''; + echo ''; } - echo ''; - echo "
"; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
$I[fid]
$I[match]
$I[replace]
$I[allowpm]
$I[regex]
$I[kick]
$I[apply]
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
$I[fid]$I[match]$I[replace]$I[allowpm]$I[regex]$I[kick]$I[apply]
'.frmadm('filter').hidden('id', $filter['id']); - echo ""; - echo ""; - echo '"; - echo ""; - echo ""; - echo ""; - echo '
$I[filter] $filter[id]:'.submit($I['change']).'
'; + frmadm('filter'); + echo hidden('id', $filter['id']); + echo ""; + echo ""; + echo '"; + echo ""; + echo ""; + echo ""; + echo '
$I[filter] $filter[id]:'.submit($I['change']).'
'.frmadm('filter').hidden('id', '+'); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo '
$I[newfilter]'.submit($I['add']).'

$H[backtochat]
"; + echo '
'; + frmadm('filter'); + echo hidden('id', '+'); + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo '
$I[newfilter]'.submit($I['add']).'

$H[backtochat]"; print_end(); } function send_linkfilter($arg=''){ global $C, $H, $I, $U, $db, $memcached; print_start('linkfilter'); - echo "

$I[linkfilter]

$arg"; + echo "

$I[linkfilter]

$arg
"; thr(); - echo ""; + echo ""; if($C['memcached']) $filters=$memcached->get("$C[dbname]-$C[prefix]linkfilter"); - if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){ + if(!$C['memcached'] || $memcached->getResultCode()!==Memcached::RES_SUCCESS){ $filters=array(); - $result=$db->query("SELECT * FROM `$C[prefix]linkfilter`"); - while($filter=$result->fetch(PDO::FETCH_ASSOC)) $filters[]=$filter; + $result=$db->query("SELECT id, filtermatch, filterreplace, regex FROM $C[prefix]linkfilter;"); + $result->bindColumn(1, $filter['id']); + $result->bindColumn(2, $filter['match']); + $result->bindColumn(3, $filter['replace']); + $result->bindColumn(4, $filter['regex']); + while($result->fetch(PDO::FETCH_BOUND)) $filters[]=$filter; if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]linkfilter", $filters); } foreach($filters as $filter){ if($filter['regex']==1) $checked=' checked'; - else $checked=''; - if($filter['regex']==0) $filter['match']=preg_replace('/(\\\\(.))/', "$2", $filter['match']); - echo ''; + else{ + $checked=''; + $filter['match']=preg_replace('/(\\\\(.))/', "$2", $filter['match']); + } + echo ''; } - echo ''; - echo "
"; - echo ""; - echo ""; - echo ""; - echo "
$I[fid]
$I[match]
$I[replace]
$I[regex]
$I[apply]
"; + echo ""; + echo ""; + echo ""; + echo "
$I[fid]$I[match]$I[replace]$I[regex]$I[apply]
'.frmadm('linkfilter').hidden('id', $filter['id']); - echo ""; - echo ""; - echo '"; - echo ""; - echo '
$I[filter] $filter[id]:'.submit($I['change']).'
'; + frmadm('linkfilter'); + echo hidden('id', $filter['id']); + echo ""; + echo ""; + echo '"; + echo ""; + echo '
$I[filter] $filter[id]:'.submit($I['change']).'
'.frmadm('linkfilter').hidden('id', '+'); - echo ""; - echo ""; - echo ""; - echo ""; - echo '
$I[newfilter]'.submit($I['add']).'

$H[backtochat]
"; + echo '
'; + frmadm('linkfilter'); + echo hidden('id', '+'); + echo ""; + echo ""; + echo ""; + echo ""; + echo '
$I[newfilter]'.submit($I['add']).'

$H[backtochat]"; print_end(); } function send_frameset(){ global $C, $H, $I, $U; - header('Content-Type: text/html; charset=UTF-8'); header('Pragma: no-cache'); header('Cache-Control: no-cache'); header('Expires: 0'); echo "$H[meta_html]"; echo ''.get_setting('chatname').''; print_stylesheet(); @@ -950,96 +983,102 @@ function send_messages($js){ } echo ''; echo '
'; - $topic=get_setting('topic'); - if(!empty($topic)) echo sprintf($I['topic'], $topic); + echo get_setting('topic'); echo '
'; print_chatters(); - echo "
$I[bottom]
"; + echo "
$I[bottom]
"; print_messages(); echo '
'; if($js) echo ""; - echo "$I[top]"; + echo "$I[top]"; print_end(); } function send_notes($type){ global $C, $H, $I, $U, $db; print_start('notes'); - echo '
'; + echo '
'; if($U['status']>=6){ - echo "'; - echo "
<$H[form] target=\"view\">".hidden('action', 'notes').hidden('do', 'admin').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['admnotes']).'<$H[form] target=\"view\">".hidden('action', 'notes').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['notes']).'
'; + echo "'; + echo "
<$H[form] target=\"view\">$H[commonform]".hidden('action', 'notes').hidden('do', 'admin').submit($I['admnotes']).'<$H[form] target=\"view\">$H[commonform]".hidden('action', 'notes').submit($I['notes']).'
'; } - if($type=='staff') echo "

$I[staffnotes]

"; - else echo "

$I[adminnotes]

"; + if($type==='staff') echo "

$I[staffnotes]

"; + else echo "

$I[adminnotes]

"; if(isset($_REQUEST['text'])){ if($C['msgencrypted']) $_REQUEST['text']=openssl_encrypt($_REQUEST['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); $time=time(); - $stmt=$db->prepare("INSERT INTO `$C[prefix]notes` (`type`, `lastedited`, `editedby`, `text`) VALUES (?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]notes (type, lastedited, editedby, text) VALUES (?, ?, ?, ?);"); $stmt->execute(array($type, $time, $U['nickname'], $_REQUEST['text'])); - $db->exec("DELETE FROM `$C[prefix]notes` WHERE `type`='$type' AND `id` NOT IN (SELECT * FROM (SELECT `id` FROM `$C[prefix]notes` WHERE `type`='$type' ORDER BY `id` DESC LIMIT ".get_setting('numnotes').') t )'); + $offset=get_setting('numnotes'); + $stmt=$db->prepare("SELECT id FROM $C[prefix]notes WHERE type=? ORDER BY id DESC LIMIT 1 OFFSET $offset;"); + $stmt->execute(array($type)); + if($id=$stmt->fetch(PDO::FETCH_NUM)){ + $stmt=$db->prepare("DELETE FROM $C[prefix]notes WHERE type=? AND id <=?;"); + $stmt->execute(array($type, $id[0])); + } echo "$I[notessaved] "; } $dateformat=get_setting('dateformat'); - $stmt=$db->prepare("SELECT COUNT(*) FROM `$C[prefix]notes` WHERE `type`=?"); + $stmt=$db->prepare("SELECT COUNT(*) FROM $C[prefix]notes WHERE type=?;"); $stmt->execute(array($type)); $num=$stmt->fetch(PDO::FETCH_NUM); if(!empty($_REQUEST['revision'])) $revision=intval($_REQUEST['revision']); else $revision=0; - $stmt=$db->prepare("SELECT * FROM `$C[prefix]notes` WHERE `type`=? ORDER BY `id` DESC LIMIT $revision, 1"); + $stmt=$db->prepare("SELECT * FROM $C[prefix]notes WHERE type=? ORDER BY id DESC LIMIT 1 OFFSET $revision;"); $stmt->execute(array($type)); if($note=$stmt->fetch(PDO::FETCH_ASSOC)) printf($I['lastedited'], $note['editedby'], date($dateformat, $note['lastedited'])); else $note['text']=''; - echo "

<$H[form]>"; if($C['msgencrypted']) $note['text']=openssl_decrypt($note['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); - if($type=='admin') echo hidden('do', 'admin'); - echo hidden('action', 'notes').hidden('session', $U['session']).hidden('lang', $C['lang'])."
'; + echo "

<$H[form]>$H[commonform]"; + if($type==='admin') echo hidden('do', 'admin'); + echo hidden('action', 'notes')."
'; echo submit($I['savenotes']).'
'; if($num[0]>1){ - echo "
"; + echo "
$I[revisions]
"; if($revision<$num[0]-1){ - echo "'; } if($revision>0){ - echo "'; } echo '
$I[revisions]<$H[form]>".hidden('action', 'notes').hidden('session', $U['session']).hidden('lang', $C['lang']).hidden('revision', $revision+1); - if($type=='admin') echo hidden('do', 'admin'); + echo "<$H[form]>$H[commonform]".hidden('action', 'notes').hidden('revision', $revision+1); + if($type==='admin') echo hidden('do', 'admin'); echo submit($I['older']).'<$H[form]>".hidden('action', 'notes').hidden('session', $U['session']).hidden('lang', $C['lang']).hidden('revision', $revision-1); - if($type=='admin') echo hidden('do', 'admin'); + echo "<$H[form]>$H[commonform]".hidden('action', 'notes').hidden('revision', $revision-1); + if($type==='admin') echo hidden('do', 'admin'); echo submit($I['newer']).'
'; } - echo '
'; + echo '
'; print_end(); } function send_approve_waiting(){ global $C, $H, $I, $db; print_start('approve_waiting'); - echo "

$I[waitingroom]

"; - $result=$db->query("SELECT * FROM `$C[prefix]sessions` WHERE `entry`=='0' AND `status`='1' ORDER BY `id`"); - if($result->rowCount()>0){ - echo frmadm('approve').''; - echo ""; - while($temp=$result->fetch(PDO::FETCH_ASSOC)){ - echo ''.hidden('alls[]', $temp['nickname']).""; + echo "

$I[waitingroom]

"; + $result=$db->query("SELECT * FROM $C[prefix]sessions WHERE entry=0 AND status=1 ORDER BY id;"); + if($tmp=$result->fetchAll(PDO::FETCH_ASSOC)){ + frmadm('approve'); + echo '
$I[sessnick]$I[sessua]
$temp[useragent]
'; + echo ""; + foreach($tmp as $temp){ + echo ''.hidden('alls[]', $temp['nickname']).""; } - echo "
$I[sessnick]$I[sessua]
$temp[useragent]

"; - echo ""; - echo ""; - echo ""; - echo '
$I[denymessage]
'.submit($I['butallowdeny']).'
'; + echo "

"; + echo ""; + echo ""; + echo ""; + echo '
$I[denymessage]
'.submit($I['butallowdeny']).'
'; }else{ echo "$I[waitempty]
"; } - echo "
$H[backtochat]"; + echo "
$H[backtochat]"; print_end(); } function send_waiting_room(){ global $C, $H, $I, $U, $countmods, $db; parse_sessions(); - $ga=get_setting('guestaccess'); - if($ga==3 && $countmods>0) $wait=false; + $ga=(int) get_setting('guestaccess'); + if($ga===3 && $countmods>0) $wait=false; else $wait=true; if(!isSet($U['session'])){ setcookie($C['cookiename'], false); @@ -1050,15 +1089,15 @@ function send_waiting_room(){ send_error("$I[kicked]
$U[kickmessage]"); } $timeleft=get_setting('entrywait')-(time()-$U['lastpost']); - if($wait && ($timeleft<=0 || $ga==1)){ + if($wait && ($timeleft<=0 || $ga===1)){ $U['entry']=$U['lastpost']; - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `entry`=`lastpost` WHERE `session`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET entry=lastpost WHERE session=?;"); $stmt->execute(array($U['session'])); send_frameset(); }elseif(!$wait && $U['entry']!=0){ send_frameset(); }else{ - $refresh=get_setting('defaultrefresh'); + $refresh=(int) get_setting('defaultrefresh'); if(isSet($_COOKIE['test'])){ header("Refresh: $refresh; URL=$_SERVER[SCRIPT_NAME]?action=wait"); print_start('waitingroom', $refresh, "$_SERVER[SCRIPT_NAME]?action=wait"); @@ -1066,16 +1105,24 @@ function send_waiting_room(){ header("Refresh: $refresh; URL=$_SERVER[SCRIPT_NAME]?action=wait&session=$U[session]"); print_start('waitingroom', $refresh, "$_SERVER[SCRIPT_NAME]?action=wait&session=$U[session]&lang=$C[lang]"); } + echo "

$I[waitingroom]

"; if($wait){ - echo "

$I[waitingroom]

".sprintf($I['waittext'], style_this($U['nickname'], $U['style']), $timeleft).'


'.sprintf($I['waitreload'], $refresh).'



'; + printf($I['waittext'], style_this($U['nickname'], $U['style']), $timeleft); }else{ - echo "

$I[waitingroom]

".sprintf($I['admwaittext'], style_this($U['nickname'], $U['style'])).'


'.sprintf($I['waitreload'], $refresh).'



'; + printf($I['admwaittext'], style_this($U['nickname'], $U['style'])); } - echo "
<$H[form]>".hidden('action', 'wait').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['reload']).'
'; - echo "<$H[form]>".hidden('action', 'logout').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['exit'], 'id="exitbutton"').''; + echo '


'; + printf($I['waitreload'], $refresh); + echo '



'; + echo "
<$H[form]>$H[commonform]"; + if(!isSet($_REQUEST['session'])) hidden('session', $U['session']); + echo hidden('action', 'wait').submit($I['reload']).'
'; + echo "<$H[form]>$H[commonform]"; + if(!isSet($_REQUEST['session'])) hidden('session', $U['session']); + echo hidden('action', 'logout').submit($I['exit'], 'id="exitbutton"').''; $rulestxt=get_setting('rulestxt'); if(!empty($rulestxt)) echo "

$I[rules]

$rulestxt"; - echo '
'; + echo '
'; print_end(); } } @@ -1083,7 +1130,8 @@ function send_waiting_room(){ function send_choose_messages(){ global $H, $I, $U; print_start('choose_messages'); - echo frmadm('clean').hidden('what', 'selected').submit($I['delselmes'], 'class="delbutton"').'

'; + frmadm('clean'); + echo hidden('what', 'selected').submit($I['delselmes'], 'class="delbutton"').'

'; print_messages($U['status']); echo "
$H[backtochat]"; print_end(); @@ -1092,11 +1140,15 @@ function send_choose_messages(){ function send_del_confirm(){ global $I; print_start('del_confirm'); - if(!isSet($_REQUEST['multi'])) $_REQUEST['multi']=''; - if(!isSet($_REQUEST['sendto'])) $_REQUEST['sendto']=''; - echo "
$I[confirm]
"; - echo frmpst('delete').hidden('sendto', $_REQUEST['sendto']).hidden('multi', $_REQUEST['multi']).hidden('confirm', 'yes').hidden('what', $_REQUEST['what']).submit($I['yes'], 'class="delbutton"').''; - echo frmpst('post').hidden('sendto', $_REQUEST['sendto']).hidden('multi', $_REQUEST['multi']).submit($I['no'], 'class="backbutton"').'
'; + echo "
$I[confirm]
"; + frmpst('delete'); + if(isSet($_REQUEST['multi'])) echo hidden('multi', 'on'); + if(isSet($_REQUEST['sendto'])) echo hidden('sendto', $_REQUEST['sendto']); + echo hidden('confirm', 'yes').hidden('what', $_REQUEST['what']).submit($I['yes'], 'class="delbutton"').''; + frmpst('post'); + if(isSet($_REQUEST['multi'])) echo hidden('multi', 'on'); + if(isSet($_REQUEST['sendto'])) echo hidden('sendto', $_REQUEST['sendto']); + echo submit($I['no'], 'class="backbutton"').'
'; print_end(); } @@ -1104,63 +1156,73 @@ function send_post(){ global $I, $P, $U, $countmods; $U['postid']=substr(time(), -6); print_start('post'); - if(!isSet($_REQUEST['multi'])) $_REQUEST['multi']=''; if(!isSet($_REQUEST['sendto'])) $_REQUEST['sendto']=''; - echo '
'; + echo '
'.frmpst('post').hidden('postid', $U['postid']).hidden('multi', $_REQUEST['multi']); - echo ''; + echo '
'.style_this($U['nickname'], $U['style']).':
'; + frmpst('post'); + echo hidden('postid', $U['postid']); + if(isSet($_REQUEST['multi'])) echo hidden('multi', 'on'); + echo ''; if(!isSet($U['rejected'])) $U['rejected']=''; - if(isSet($_REQUEST['multi']) && $_REQUEST['multi']=='on'){ - echo ""; + if(isSet($_REQUEST['multi'])){ + echo ""; }else{ - echo ""; + echo ""; } - echo '
'.style_this($U['nickname'], $U['style']).':'.submit($I['talkto']).''.submit($I['talkto']).''; - if($U['status']>=5 || (get_setting('memkick') && $countmods==0 && $U['status']>=3)){ + if($U['status']>=5 || ($U['status']>=3 && $countmods===0 && get_setting('memkick'))){ echo ""; echo ""; } - echo '
'; - echo frmpst('delete', 'last').submit($I['dellast'], 'class="delbutton"').''.frmpst('delete', 'all').submit($I['delall'], 'class="delbutton"').''; - if($_REQUEST['multi']=='on'){ - $switch=$I['switchsingle']; - $multi=''; + echo '
'; - echo '
'; + frmpst('delete'); + if(isSet($_REQUEST['multi'])) echo hidden('multi', 'on'); + echo hidden('sendto', $_REQUEST['sendto']).hidden('what', 'last'); + echo submit($I['dellast'], 'class="delbutton"').''; + frmpst('delete', 'all'); + if(isSet($_REQUEST['multi'])) echo hidden('multi', 'on'); + echo hidden('sendto', $_REQUEST['sendto']).hidden('what', 'all'); + echo submit($I['delall'], 'class="delbutton"').''; + frmpst('post'); + if(isSet($_REQUEST['multi'])){ + echo submit($I['switchsingle']); }else{ - $switch=$I['switchmulti']; - $multi='on'; + echo hidden('multi', 'on').submit($I['switchmulti']); } - echo frmpst('post').hidden('sendto', $_REQUEST['sendto']).hidden('multi', $multi).submit($switch).'
'; + echo hidden('sendto', $_REQUEST['sendto']).'
'; print_end(); } @@ -1178,196 +1240,200 @@ function send_help(){ if($U['status']>=7) echo "
$I[helpadm]
"; } } - echo "

$H[backtochat]$H[credit]
"; + echo "

$H[backtochat]$H[credit]
"; print_end(); } function send_profile($arg=''){ - global $C, $F, $H, $I, $P, $U; + global $C, $F, $H, $I, $P, $U, $db; print_start('profile'); - echo "
<$H[form]>".hidden('action', 'profile').hidden('do', 'save').hidden('session', $U['session']).hidden('lang', $C['lang'])."

$I[profile]

$arg"; + echo "
<$H[form]>$H[commonform]".hidden('action', 'profile').hidden('do', 'save')."

$I[profile]

$arg
"; thr(); array_multisort(array_map('strtolower', array_keys($P)), SORT_ASC, SORT_STRING, $P); $ignored=array(); $ignore=get_ignored(); foreach($ignore as $ign){ - if($ign['by']==$U['nickname']) $ignored[]=$ign['ignored']; + if($ign['by']===$U['nickname']) $ignored[]=$ign['ignored']; } if(count($ignored)>0){ - echo "'; thr(); } if(count($P)-count($ignored)>1){ - echo "'; thr(); } - echo ""; + echo ""; thr(); - if(!isSet($_COOKIE[$C['cookiename']])) $session='&session=$U[session]'; else $session=''; + if(!isSet($_COOKIE[$C['cookiename']])) $param="&session=$U[session]&lang=$C[lang]"; else $param=''; preg_match('/#([0-9a-f]{6})/i', $U['style'], $matches); - $U['colour']=$matches[1]; - echo ""; + echo ""; thr(); - echo ""; + echo ""; thr(); if($U['status']>=3){ - echo ""; thr(); } - echo ''; + echo ''; thr(); - echo ""; thr(); if(get_setting('imgembed')){ - echo ""; thr(); } if($U['status']>=5 && get_setting('incognito')){ - echo ""; thr(); } - echo ""; + if($ga===0) echo ""; + echo '
'; + echo '
$I[unignore]"; - echo "
 
$I[unignore]"; + echo "
'; + echo '
$I[ignore]"; - echo "
 
$I[ignore]"; + echo "
$I[refreshrate]"; - echo "
 
$I[refreshrate]"; + echo "
$I[fontcolour] ($I[viewexample])"; - echo "
 
$I[fontcolour] ($I[viewexample])"; + echo "
$I[bgcolour] ($I[viewexample])"; - echo "
 
$I[bgcolour] ($I[viewexample])"; + echo "
$I[fontface]"; + echo ""; + if(strpos($U['style'], 'font-weight:bold;')!==false) echo ' checked'; + echo ">
$I[fontface]"; echo "
   
 
'.style_this("$U[nickname] : $I[fontexample]", $U['style']).'
'.style_this("$U[nickname] : $I[fontexample]", $U['style']).'
"; + echo ">
$I[timestamps]"; - echo '
 
$I[timestamps]"; + echo '
"; + echo ">
$I[embed]"; - echo '
 
$I[embed]"; + echo '
"; + echo ">
$I[incognito]"; - echo '
 
$I[incognito]"; + echo '
"; - if($ga==0) echo ""; - echo '
$I[pbsize]"; + echo "'; thr(); if($U['status']>=5){ - echo "
$I[pbsize]"; echo ""; echo ""; echo '
 $I[width] $I[height]
$I[nbsize]"; + echo "'; thr(); } if($U['status']>=2){ - echo ""; + echo ""; thr(); } - echo '
$I[nbsize]"; echo ""; echo ""; echo '
 $I[width] $I[height]
"; - echo "
$I[changepass]
"; - echo ""; - echo "
 $I[oldpass]
 $I[newpass]
 $I[confirmpass]
"; + echo "
$I[changepass]
"; + echo ""; + echo "
 $I[oldpass]
 $I[newpass]
 $I[confirmpass]
'.submit($I['savechanges'])."

$H[backtochat]"; + echo '
'.submit($I['savechanges'])."

$H[backtochat]"; print_end(); } function send_controls(){ - global $C, $H, $I, $U; + global $H, $I, $U; print_start('controls'); - echo '
'; - echo "'; - echo "'; - echo "'; - if($U['status']>=5) echo "'; - if($U['status']>=5) echo "'; - if($U['status']>=3) echo "'; - echo "'; - echo "'; - echo '
<$H[form] target=\"post\">".hidden('action', 'post').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['reloadpb']).'<$H[form] target=\"view\">".hidden('action', 'view').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['reloadmsgs']).'<$H[form] target=\"view\">".hidden('action', 'profile').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['chgprofile']).'<$H[form] target=\"view\">".hidden('action', 'admin').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['adminbtn']).'<$H[form] target=\"view\">".hidden('action', 'notes').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['notes']).'<$H[form] target=\"_blank\">".hidden('action', 'login').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['clone']).'<$H[form] target=\"view\">".hidden('action', 'help').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['randh']).'<$H[form] target=\"_parent\">".hidden('action', 'logout').hidden('session', $U['session']).hidden('lang', $C['lang']).submit($I['exit'], 'id="exitbutton"').'
'; + echo ''; + echo "'; + echo "'; + echo "'; + if($U['status']>=5) echo "'; + if($U['status']>=5) echo "'; + if($U['status']>=3) echo "'; + echo "'; + echo "'; + echo '
<$H[form] target=\"post\">$H[commonform]".hidden('action', 'post').submit($I['reloadpb']).'<$H[form] target=\"view\">$H[commonform]".hidden('action', 'view').submit($I['reloadmsgs']).'<$H[form] target=\"view\">$H[commonform]".hidden('action', 'profile').submit($I['chgprofile']).'<$H[form] target=\"view\">$H[commonform]".hidden('action', 'admin').submit($I['adminbtn']).'<$H[form] target=\"view\">$H[commonform]".hidden('action', 'notes').submit($I['notes']).'<$H[form] target=\"_blank\">$H[commonform]".hidden('action', 'login').submit($I['clone']).'<$H[form] target=\"view\">$H[commonform]".hidden('action', 'help').submit($I['randh']).'<$H[form] target=\"_parent\">$H[commonform]".hidden('action', 'logout').submit($I['exit'], 'id="exitbutton"').'
'; print_end(); } function send_logout(){ global $H, $I, $U; print_start('logout'); - echo '

'.sprintf($I['bye'], style_this($U['nickname'], $U['style']))."

$H[backtologin]
"; + echo '

'.sprintf($I['bye'], style_this($U['nickname'], $U['style']))."

$H[backtologin]
"; print_end(); } function send_colours(){ - global $C, $H, $I; + global $H, $I; print_start('colours'); - echo "

$I[colourtable]

"; + echo "

$I[colourtable]

"; for($red=0x00;$red<=0xFF;$red+=0x33){ for($green=0x00;$green<=0xFF;$green+=0x33){ for($blue=0x00;$blue<=0xFF;$blue+=0x33){ $hcol=sprintf('%02X', $red).sprintf('%02X', $green).sprintf('%02X', $blue); - echo "$hcol "; + echo "$hcol "; } echo '
'; } echo '
'; } - echo "
<$H[form]>".hidden('action', 'profile').hidden('session', $_REQUEST['session']).hidden('lang', $C['lang']).submit($I['backtoprofile'], ' class="backbutton"').'
'; + echo "<$H[form]>$H[commonform]".hidden('action', 'profile').submit($I['backtoprofile'], ' class="backbutton"').''; print_end(); } function send_login(){ - global $C, $H, $I, $L; + global $H, $I, $L; setcookie('test', '1'); print_start('login'); - $ga=get_setting('guestaccess'); - $englobal=get_setting('englobalpass'); - echo '

'.get_setting('chatname').'

'; - echo "<$H[form] target=\"_parent\">".hidden('action', 'login').hidden('lang', $C['lang']); - if($englobal==1 && isSet($_POST['globalpass'])) echo hidden('globalpass', $_POST['globalpass']); - echo ''; - if($englobal!=1 || (isSet($_POST['globalpass']) && $_POST['globalpass']==get_setting('globalpass'))){ - echo ""; - echo ""; + $ga=(int) get_setting('guestaccess'); + $englobal=(int) get_setting('englobalpass'); + echo '

'.get_setting('chatname').'

'; + echo "<$H[form] target=\"_parent\">$H[commonform]".hidden('action', 'login'); + if($englobal===1 && isSet($_POST['globalpass'])) echo hidden('globalpass', $_POST['globalpass']); + echo '
$I[nick]
$I[pass]
'; + if($englobal!==1 || (isSet($_POST['globalpass']) && $_POST['globalpass']==get_setting('globalpass'))){ + echo ""; + echo ""; send_captcha(); - if($ga!=0){ - if($englobal==2) echo ""; - echo ""; + echo "'; }else{ - echo ""; + echo ""; } - echo '
$I[nick]
$I[pass]
$I[globalloginpass]
$I[choosecol]
$I[globalloginpass]
$I[choosecol]
$I[noguests]
$I[noguests]
'.submit($I['enter']).'
'; + echo '
'.submit($I['enter']).'
'; get_nowchatting(); + echo '

'; + echo get_setting('topic'); + echo '
'; $rulestxt=get_setting('rulestxt'); if(!empty($rulestxt)) echo "

$I[rules]

$rulestxt
"; }else{ - echo "
$I[globalloginpass]
$I[noguests]
'.submit($I['enter']).'
'; + echo "
$I[globalloginpass]
$I[noguests]
'.submit($I['enter']).'
'; } echo "

$I[changelang]"; foreach($L as $lang=>$name){ echo " $name"; } - echo "

$H[credit]
"; + echo "

$H[credit]"; print_end(); } @@ -1379,18 +1445,27 @@ function send_error($err){ } function print_chatters(){ - global $C, $G, $I, $M, $U, $db; - echo ''; + global $C, $I, $P, $U, $db; + echo '
'; if($U['status']>=5 && get_setting('guestaccess')==3){ - $result=$db->query("SELECT COUNT(*) FROM `$C[prefix]sessions` WHERE `entry`='0' AND `status`='1'"); + $result=$db->query("SELECT COUNT(*) FROM $C[prefix]sessions WHERE entry=0 AND status=1;"); $temp=$result->fetch(PDO::FETCH_NUM); - if($temp[0]>0) echo ''; + if($temp[0]>0) echo ''; + } + foreach($P as $user){ + if($user[2]<=2){ + $G[]=style_this($user[0], $user[1]); + }else{ + $M[]=style_this($user[0], $user[1]); + } } if(!empty($M)){ - echo "'; + echo "'; if(!empty($G)) echo ''; } - if(!empty($G)) echo "'; + if(!empty($G)) echo "'; echo '
'.frmadm('approve').submit(sprintf($I['approveguests'], $temp[0])).' '; + frmadm('approve'); + echo submit(sprintf($I['approveguests'], $temp[0])).' $I[members]: ".implode('   ', $M).'$I[members]: ".implode('   ', $M).'  $I[guests]: ".implode('   ', $G).'$I[guests]: ".implode('   ', $G).'
'; } @@ -1400,20 +1475,18 @@ function create_session($setup){ global $C, $I, $U, $db, $memcached; $U['nickname']=preg_replace('/\s+/', '', $_REQUEST['nick']); $U['passhash']=md5(sha1(md5($U['nickname'].$_REQUEST['pass']))); - if(isSet($_REQUEST['colour'])) $U['colour']=$_REQUEST['colour']; else $U['colour']=''; - $U['status']=1; - check_member(); - add_user_defaults(); - if($setup) $U['incognito']=true; + if(!check_member()) add_user_defaults(); + $U['entry']=$U['lastpost']=time(); + if($setup) $U['incognito']=1; if(get_setting('captcha')>0 && ($U['status']==1 || get_setting('dismemcaptcha')==0)){ if(!isSet($_REQUEST['challenge'])) send_error($I['wrongcaptcha']); if(!$C['memcached']){ - $stmt=$db->prepare("SELECT `code` FROM `$C[prefix]captcha` WHERE `id`=?"); + $stmt=$db->prepare("SELECT code FROM $C[prefix]captcha WHERE id=?;"); $stmt->execute(array($_REQUEST['challenge'])); $stmt->bindColumn(1, $code); if(!$stmt->fetch(PDO::FETCH_BOUND)) send_error($I['captchaexpire']); $timeout=time()-get_setting('captchatime'); - $stmt=$db->prepare("DELETE FROM `$C[prefix]captcha` WHERE `id`=? OR `time`prepare("DELETE FROM $C[prefix]captcha WHERE id=? OR timeexecute(array($_REQUEST['challenge'], $timeout)); }else{ if(!$code=$memcached->get("$C[dbname]-$C[prefix]captcha-$_REQUEST[challenge]")) send_error($I['captchaexpire']); @@ -1422,9 +1495,11 @@ function create_session($setup){ if($_REQUEST['captcha']!=$code) send_error($I['wrongcaptcha']); } if($U['status']==1){ + $ga=(int) get_setting('guestaccess'); if(!valid_nick($U['nickname'])) send_error(sprintf($I['invalnick'], get_setting('maxname'))); if(!valid_pass($_REQUEST['pass'])) send_error(sprintf($I['invalpass'], get_setting('minpass'))); - if(get_setting('guestaccess')==0) send_error($I['noguests']); + if($ga===0) send_error($I['noguests']); + if($ga===3) $U['entry']=0; if(get_setting('englobalpass')!=0 && isSet($_REQUEST['globalpass']) && $_REQUEST['globalpass']!=get_setting('globalpass')) send_error($I['wrongglobalpass']); } write_new_session(); @@ -1432,13 +1507,12 @@ function create_session($setup){ function write_new_session(){ global $C, $I, $U, $db; - // read and update current sessions $lines=parse_sessions(); $sids; $reentry=false; foreach($lines as $temp){ $sids[$temp['session']]=true;// collect all existing ids - if($temp['nickname']==$U['nickname']){// nick already here? - if($U['passhash']==$temp['passhash']){ + if($temp['nickname']===$U['nickname']){// nick already here? + if($U['passhash']===$temp['passhash']){ $U=$temp; if($U['status']==0){ setcookie($C['cookiename'], false); @@ -1455,13 +1529,13 @@ function write_new_session(){ // create new session: if(!$reentry){ do{ - $U['session']=md5(time().rand().$U['nickname']); + $U['session']=md5(time().mt_rand().$U['nickname']); }while(isSet($sids[$U['session']]));// check for hash collision if(isSet($_SERVER['HTTP_USER_AGENT'])) $useragent=htmlspecialchars($_SERVER['HTTP_USER_AGENT']); else $useragent=''; if(get_setting('trackip')) $ip=$_SERVER['REMOTE_ADDR']; else $ip=''; - $stmt=$db->prepare("INSERT INTO `$C[prefix]sessions` (`session`, `nickname`, `status`, `refresh`, `style`, `lastpost`, `passhash`, `boxwidth`, `boxheight`, `useragent`, `bgcolour`, `notesboxwidth`, `notesboxheight`, `entry`, `timestamps`, `embed`, `incognito`, `ip`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]sessions (session, nickname, status, refresh, style, lastpost, passhash, boxwidth, boxheight, useragent, bgcolour, notesboxwidth, notesboxheight, entry, timestamps, embed, incognito, ip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); $stmt->execute(array($U['session'], $U['nickname'], $U['status'], $U['refresh'], $U['style'], $U['lastpost'], $U['passhash'], $U['boxwidth'], $U['boxheight'], $useragent, $U['bgcolour'], $U['notesboxwidth'], $U['notesboxheight'], $U['entry'], $U['timestamps'], $U['embed'], $U['incognito'], $ip)); setcookie($C['cookiename'], $U['session']); if($U['status']>=3 && !$U['incognito']) add_system_message(sprintf(get_setting('msgenter'), style_this($U['nickname'], $U['style']))); @@ -1471,27 +1545,29 @@ function write_new_session(){ function approve_session(){ global $C, $db; if(isSet($_REQUEST['what'])){ - if($_REQUEST['what']=='allowchecked' && isSet($_REQUEST['csid'])){ - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `entry`=`lastpost` WHERE `nickname`=?"); + if($_REQUEST['what']==='allowchecked' && isSet($_REQUEST['csid'])){ + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET entry=lastpost WHERE nickname=?;"); foreach($_REQUEST['csid'] as $nick) $stmt->execute(array($nick)); - }elseif($_REQUEST['what']=='allowall' && isSet($_REQUEST['alls'])){ - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `entry`=`lastpost` WHERE `nickname`=?"); + }elseif($_REQUEST['what']==='allowall' && isSet($_REQUEST['alls'])){ + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET entry=lastpost WHERE nickname=?;"); foreach($_REQUEST['alls'] as $nick) $stmt->execute(array($nick)); - }elseif($_REQUEST['what']=='denychecked' && isSet($_REQUEST['csid'])){ - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `lastpost`='".(60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time())."', `status`='0', `kickmessage`=? WHERE `nickname`=? AND `status`='1'"); - foreach($_REQUEST['csid'] as $nick) $stmt->execute(array($_REQUEST['kickmessage'], $nick)); - }elseif($_REQUEST['what']=='denyall' && isSet($_REQUEST['alls'])){ - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `lastpost`='".(60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time())."', `status`='0', `kickmessage`=? WHERE `nickname`=? AND `status`='1'"); - foreach($_REQUEST['alls'] as $nick) $stmt->execute(array($_REQUEST['kickmessage'], $nick)); + }elseif($_REQUEST['what']==='denychecked' && isSet($_REQUEST['csid'])){ + $time=60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time(); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET lastpost=?, status=0, kickmessage=? WHERE nickname=? AND status=1;"); + foreach($_REQUEST['csid'] as $nick) $stmt->execute(array($time, $_REQUEST['kickmessage'], $nick)); + }elseif($_REQUEST['what']==='denyall' && isSet($_REQUEST['alls'])){ + $time=60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time(); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET lastpost=?, status=0, kickmessage=? WHERE nickname=? AND status=1;"); + foreach($_REQUEST['alls'] as $nick) $stmt->execute(array($time, $_REQUEST['kickmessage'], $nick)); } } } function check_login(){ global $C, $I, $U, $db; - $ga=get_setting('guestaccess'); + $ga=(int) get_setting('guestaccess'); if(isSet($_POST['session'])){ - $stmt=$db->prepare("SELECT * FROM `$C[prefix]sessions` WHERE `session`=?"); + $stmt=$db->prepare("SELECT * FROM $C[prefix]sessions WHERE session=?;"); $stmt->execute(array($_POST['session'])); if($U=$stmt->fetch(PDO::FETCH_ASSOC)){ if($U['status']==0){ @@ -1513,10 +1589,9 @@ function check_login(){ create_session(false); } if($U['status']==1){ - if($ga==2 || $ga==3){ - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `entry`='0' WHERE `session`=?"); + if($ga===2 || $ga===3){ + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET entry=0 WHERE session=?;"); $stmt->execute(array($U['session'])); - $_REQUEST['session']=$U['session']; send_waiting_room(); } } @@ -1528,15 +1603,16 @@ function kill_session(){ setcookie($C['cookiename'], false); if(!isSet($U['session'])) send_error($I['expire']); if($U['status']==0) send_error("$I[kicked]
$U[kickmessage]"); - $stmt=$db->prepare("DELETE FROM `$C[prefix]sessions` WHERE `session`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]sessions WHERE session=?;"); $stmt->execute(array($U['session'])); if($U['status']==1){ - $stmt=$db->prepare("UPDATE `$C[prefix]messages` SET `poster`='' WHERE `poster`=? AND `poststatus`='9'"); + $stmt=$db->prepare("UPDATE $C[prefix]messages SET poster='' WHERE poster=? AND poststatus=9;"); $stmt->execute(array($U['nickname'])); - $stmt=$db->prepare("UPDATE `$C[prefix]messages` SET `recipient`='' WHERE `recipient`=? AND `poststatus`='9'"); + $stmt=$db->prepare("UPDATE $C[prefix]messages SET recipient='' WHERE recipient=? AND poststatus=9;"); $stmt->execute(array($U['nickname'])); - $stmt=$db->prepare("DELETE FROM `$C[prefix]ignored` WHERE `ignored`=? OR `by`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]ignored WHERE ign=? OR ignby=?;"); $stmt->execute(array($U['nickname'], $U['nickname'])); + $db->exec("DELETE FROM $C[prefix]messages WHERE poster='' AND recipient='' AND poststatus=9;"); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]ignored"); } elseif($U['status']>=3 && !$U['incognito']) add_system_message(sprintf(get_setting('msgexit'), style_this($U['nickname'], $U['style']))); @@ -1546,12 +1622,13 @@ function kick_chatter($names, $mes, $purge){ global $C, $P, $U, $db; $lonick=''; $lines=parse_sessions(); - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `lastpost`='".(60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time())."', `status`='0', `kickmessage`=? WHERE `session`=? AND `status`!='0'"); + $time=60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time(); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET lastpost=?, status=0, kickmessage=? WHERE session=? AND status!=0;"); $i=0; foreach($names as $name){ foreach($lines as $temp){ - if(($temp['nickname']==$U['nickname'] && $U['nickname']==$name) || ($U['status']>$temp['status'] && (($temp['nickname']==$name && $temp['status']>0) || ($name=='&' && $temp['status']==1)))){ - $stmt->execute(array($mes, $temp['session'])); + if(($temp['nickname']===$U['nickname'] && $U['nickname']===$name) || ($U['status']>$temp['status'] && (($temp['nickname']===$name && $temp['status']>0) || ($name==='&' && $temp['status']==1)))){ + $stmt->execute(array($time, $mes, $temp['session'])); if($purge) del_all_messages($temp['nickname'], 10, 0); $lonick.=style_this($temp['nickname'], $temp['style']).', '; ++$i; @@ -1560,7 +1637,7 @@ function kick_chatter($names, $mes, $purge){ } } if(!empty($lonick)){ - if($names[0]=='&'){ + if($names[0]==='&'){ add_system_message(get_setting('msgallkick')); }else{ $lonick=preg_replace('/\,\s$/','',$lonick); @@ -1578,13 +1655,13 @@ function kick_chatter($names, $mes, $purge){ function logout_chatter($names){ global $C, $P, $U, $db, $memcached; $lines=parse_sessions(); - $stmt=$db->prepare("DELETE FROM `$C[prefix]sessions` WHERE `session`=? AND `status`prepare("UPDATE `$C[prefix]messages` SET `poster`='' WHERE `poster`=? AND `poststatus`='9'"); - $stmt2=$db->prepare("UPDATE `$C[prefix]messages` SET `recipient`='' WHERE `recipient`=? AND `poststatus`='9'"); - $stmt3=$db->prepare("DELETE FROM `$C[prefix]ignored` WHERE `ignored`=? OR `by`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]sessions WHERE session=? AND statusprepare("UPDATE $C[prefix]messages SET poster='' WHERE poster=? AND poststatus=9;"); + $stmt2=$db->prepare("UPDATE $C[prefix]messages SET recipient='' WHERE recipient=? AND poststatus=9;"); + $stmt3=$db->prepare("DELETE FROM $C[prefix]ignored WHERE ign=? OR ignby=?;"); foreach($names as $name){ foreach($lines as $temp){ - if($temp['nickname']==$name || ($name=='&' && $temp['status']==1)){ + if($temp['nickname']===$name || ($name==='&' && $temp['status']==1)){ $stmt->execute(array($temp['session'], $U['status'])); if($temp['status']==1){ $stmt1->execute(array($temp['nickname'])); @@ -1596,6 +1673,7 @@ function logout_chatter($names){ } } } + $db->exec("DELETE FROM $C[prefix]messages WHERE poster='' AND recipient='' AND poststatus=9;"); } function check_session(){ @@ -1615,20 +1693,26 @@ function check_session(){ } function get_nowchatting(){ - global $G, $I, $M, $P; + global $I, $P; parse_sessions(); - echo sprintf($I['curchat'], count($P)).'
'.implode('   ', $M).'   '.implode('   ', $G); + echo sprintf($I['curchat'], count($P)).'
'; + foreach($P as $user){ + echo style_this($user[0], $user[1]).'   '; + } } function parse_sessions(){ - global $C, $G, $M, $P, $U, $countmods, $db, $memcached; - $result=$db->query("SELECT `nickname`, `status`, `session` FROM `$C[prefix]sessions` WHERE (`status`<='2' AND `lastpost`<'".(time()-60*get_setting('guestexpire'))."') OR (`status`>'2' AND `lastpost`<'".(time()-60*get_setting('memberexpire'))."')"); - if($result->rowCount()>0){ - $stmt=$db->prepare("DELETE FROM `$C[prefix]sessions` WHERE `nickname`=?"); - $stmt1=$db->prepare("UPDATE `$C[prefix]messages` SET `poster`='' WHERE `poster`=? AND `poststatus`='9'"); - $stmt2=$db->prepare("UPDATE `$C[prefix]messages` SET `recipient`='' WHERE `recipient`=? AND `poststatus`='9'"); - $stmt3=$db->prepare("DELETE FROM `$C[prefix]ignored` WHERE `ignored`=? OR `by`=?"); - while($temp=$result->fetch(PDO::FETCH_ASSOC)){ + global $C, $P, $U, $countmods, $db, $memcached; + $guestexpire=time()-60*get_setting('guestexpire'); + $memberexpire=time()-60*get_setting('memberexpire'); + $result=$db->prepare("SELECT nickname, status FROM $C[prefix]sessions WHERE (status<=2 AND lastpost2 AND lastpostexecute(array($guestexpire, $memberexpire)); + if($tmp=$result->fetchAll(PDO::FETCH_ASSOC)){ + $stmt=$db->prepare("DELETE FROM $C[prefix]sessions WHERE nickname=?;"); + $stmt1=$db->prepare("UPDATE $C[prefix]messages SET poster='' WHERE poster=? AND poststatus=9;"); + $stmt2=$db->prepare("UPDATE $C[prefix]messages SET recipient='' WHERE recipient=? AND poststatus=9;"); + $stmt3=$db->prepare("DELETE FROM $C[prefix]ignored WHERE ign=? OR ignby=?;"); + foreach($tmp as $temp){ $stmt->execute(array($temp['nickname'])); if($temp['status']<=1){ $stmt1->execute(array($temp['nickname'])); @@ -1637,34 +1721,26 @@ function parse_sessions(){ if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]ignored"); } } + $db->exec("DELETE FROM $C[prefix]messages WHERE poster='' AND recipient='' AND poststatus=9;"); } - $lines=array(); - $result=$db->query("SELECT * FROM `$C[prefix]sessions` ORDER BY `status` DESC, `lastpost` DESC"); - while($line=$result->fetch(PDO::FETCH_ASSOC)) $lines[]=$line; - if(!empty($_REQUEST['session'])){ + $result=$db->query("SELECT * FROM $C[prefix]sessions ORDER BY status DESC, lastpost DESC;"); + if(!$lines=$result->fetchAll(PDO::FETCH_ASSOC)) $lines=array(); + if(isSet($_REQUEST['session'])){ foreach($lines as $temp){ - if($temp['session']==$_REQUEST['session']){ + if($temp['session']===$_REQUEST['session']){ $U=$temp; break; } } } $countmods=0; - $G=array(); - $M=array(); $P=array(); foreach($lines as $temp){ if($temp['entry']!=0){ - if($temp['status']==1 || $temp['status']==2){ - $P[$temp['nickname']]=[$temp['nickname'], $temp['style']]; - $G[]=style_this($temp['nickname'], $temp['style']); - }elseif($temp['status']>2){ - if(!$temp['incognito']){ - $P[$temp['nickname']]=[$temp['nickname'], $temp['style']]; - $M[]=style_this($temp['nickname'], $temp['style']); - } - if($temp['status']>=5) ++$countmods; + if(!$temp['incognito']){ + $P[$temp['nickname']]=[$temp['nickname'], $temp['style'], $temp['status']]; } + if($temp['status']>=5) ++$countmods; } } return $lines; @@ -1674,25 +1750,27 @@ function parse_sessions(){ function check_member(){ global $C, $I, $U, $db; - $stmt=$db->prepare("SELECT * FROM `$C[prefix]members` WHERE `nickname`=?"); + $stmt=$db->prepare("SELECT * FROM $C[prefix]members WHERE nickname=?;"); $stmt->execute(array($U['nickname'])); if($temp=$stmt->fetch(PDO::FETCH_ASSOC)){ - if($temp['passhash']==$U['passhash']){ + if($temp['passhash']===$U['passhash']){ $U=$temp; $time=time(); - $stmt=$db->prepare("UPDATE `$C[prefix]members` SET `lastlogin`=? WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]members SET lastlogin=? WHERE nickname=?;"); $stmt->execute(array($time, $U['nickname'])); + return true; }else{ send_error($I['wrongpass']); } } + return false; } function read_members(){ global $A, $C, $db, $memcached; if($C['memcached']) $A=$memcached->get("$C[dbname]-$C[prefix]members"); - if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){ - $result=$db->query("SELECT * FROM `$C[prefix]members`"); + if(!$C['memcached'] || $memcached->getResultCode()!==Memcached::RES_SUCCESS){ + $result=$db->query("SELECT * FROM $C[prefix]members;"); while($temp=$result->fetch(PDO::FETCH_ASSOC)){ $A[$temp['nickname']][0]=$temp['nickname']; $A[$temp['nickname']][1]=$temp['status']; @@ -1708,16 +1786,17 @@ function register_guest($status){ if(!isSet($P[$_REQUEST['name']])) send_admin(sprintf($I['cantreg'], $_REQUEST['name'])); read_members(); if(isSet($A[$_REQUEST['name']])) send_admin(sprintf($I['alreadyreged'], $_REQUEST['name'])); - $stmt=$db->prepare("SELECT * FROM `$C[prefix]sessions` WHERE `nickname`=? AND `status`='1'"); + $stmt=$db->prepare("SELECT * FROM $C[prefix]sessions WHERE nickname=? AND status=1;"); $stmt->execute(array($_REQUEST['name'])); if($reg=$stmt->fetch(PDO::FETCH_ASSOC)){ $reg['status']=$status; - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `status`=? WHERE `session`=?"); + $P[$_REQUEST['name']][2]=$status; + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET status=? WHERE session=?;"); $stmt->execute(array($reg['status'], $reg['session'])); }else{ send_admin(sprintf($I['cantreg'], $_REQUEST['name'])); } - $stmt=$db->prepare("INSERT INTO `$C[prefix]members` (`nickname`, `passhash`, `status`, `refresh`, `bgcolour`, `boxwidth`, `boxheight`, `regedby`, `timestamps`, `embed`, `style`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, regedby, timestamps, embed, style) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); $stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['boxwidth'], $reg['boxheight'], $U['nickname'], $reg['timestamps'], $reg['embed'], $reg['style'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]members"); if($reg['status']==3) add_system_message(sprintf(get_setting('msgmemreg'), style_this($reg['nickname'], $reg['style']))); @@ -1744,32 +1823,34 @@ function register_new(){ 'timestamps' =>get_setting('timestamps'), 'style' =>'color:#'.get_setting('coltxt').';' ); - $stmt=$db->prepare("INSERT INTO `$C[prefix]members` (`nickname`, `passhash`, `status`, `refresh`, `bgcolour`, `regedby`, `timestamps`, `style`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]members (nickname, passhash, status, refresh, bgcolour, regedby, timestamps, style) VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); $stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['regedby'], $reg['timestamps'], $reg['style'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]members"); send_admin(sprintf($I['successreg'], $reg['nickname'])); } function change_status(){ - global $C, $I, $U, $db, $memcached; + global $C, $I, $P, $U, $db, $memcached; if(empty($_REQUEST['name'])) send_admin(); if($U['status']<=$_REQUEST['set'] || !preg_match('/^[023567\-]$/', $_REQUEST['set'])) send_admin(sprintf($I['cantchgstat'], $_REQUEST['name'])); - $stmt=$db->prepare("SELECT * FROM `$C[prefix]members` WHERE `nickname`=? AND `status`prepare("SELECT * FROM $C[prefix]members WHERE nickname=? AND statusexecute(array($_REQUEST['name'], $U['status'])); - if($stmt->rowCount()>0){ - if($_REQUEST['set']=='-'){ - $stmt=$db->prepare("DELETE FROM `$C[prefix]members` WHERE `nickname`=?"); + if($stmt->fetch(PDO::FETCH_ASSOC)){ + if($_REQUEST['set']==='-'){ + $stmt=$db->prepare("DELETE FROM $C[prefix]members WHERE nickname=?;"); $stmt->execute(array($_REQUEST['name'])); - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `status`='1' WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET status=1 WHERE nickname=?;"); $stmt->execute(array($_REQUEST['name'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]members"); + if(isSet($P[$_REQUEST['name']])) $P[$_REQUEST['name']][2]=1; send_admin(sprintf($I['succdel'], $_REQUEST['name'])); }else{ - $stmt=$db->prepare("UPDATE `$C[prefix]members` SET `status`=? WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]members SET status=? WHERE nickname=?;"); $stmt->execute(array($_REQUEST['set'], $_REQUEST['name'])); - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `status`=? WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET status=? WHERE nickname=?;"); $stmt->execute(array($_REQUEST['set'], $_REQUEST['name'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]members"); + if(isSet($P[$_REQUEST['name']])) $P[$_REQUEST['name']][2]=$_REQUEST['set']; send_admin(sprintf($I['succchg'], $_REQUEST['name'])); } }else{ @@ -1780,13 +1861,13 @@ function change_status(){ function passreset(){ global $C, $I, $U, $db; if(empty($_REQUEST['name'])) send_admin(); - $stmt=$db->prepare("SELECT * FROM `$C[prefix]members` WHERE `nickname`=? AND `status`prepare("SELECT * FROM $C[prefix]members WHERE nickname=? AND statusexecute(array($_REQUEST['name'], $U['status'])); - if($stmt->rowCount()>0){ + if($stmt->fetch(PDO::FETCH_ASSOC)){ $passhash=md5(sha1(md5($_REQUEST['name'].$_REQUEST['pass']))); - $stmt=$db->prepare("UPDATE `$C[prefix]members` SET `passhash`=? WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]members SET passhash=? WHERE nickname=?;"); $stmt->execute(array($passhash, $_REQUEST['name'])); - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `passhash`=? WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET passhash=? WHERE nickname=?;"); $stmt->execute(array($passhash, $_REQUEST['name'])); send_admin(sprintf($I['succpassreset'], $_REQUEST['name'])); }else{ @@ -1814,12 +1895,12 @@ function amend_profile(){ if($_REQUEST['boxheight']>0 && $_REQUEST['boxheight']<1000) $U['boxheight']=$_REQUEST['boxheight']; if(isSet($_REQUEST['notesboxwidth']) && $_REQUEST['notesboxwidth']>0 && $_REQUEST['notesboxwidth']<1000) $U['notesboxwidth']=$_REQUEST['notesboxwidth']; if(isSet($_REQUEST['notesboxheight']) && $_REQUEST['notesboxheight']>0 && $_REQUEST['notesboxheight']<1000) $U['notesboxheight']=$_REQUEST['notesboxheight']; - if(isSet($_REQUEST['timestamps'])) $U['timestamps']=true; - else $U['timestamps']=false; - if(isSet($_REQUEST['embed'])) $U['embed']=true; - else $U['embed']=false; - if($U['status']>=5 && isSet($_REQUEST['incognito']) && get_setting('incognito')) $U['incognito']=true; - else $U['incognito']=false; + if(isSet($_REQUEST['timestamps'])) $U['timestamps']=1; + else $U['timestamps']=0; + if(isSet($_REQUEST['embed'])) $U['embed']=1; + else $U['embed']=0; + if($U['status']>=5 && isSet($_REQUEST['incognito']) && get_setting('incognito')) $U['incognito']=1; + else $U['incognito']=0; } function save_profile(){ @@ -1838,20 +1919,20 @@ function save_profile(){ if($U['passhash']!==$U['oldhash']) send_profile($I['wrongpass']); $U['passhash']=$U['newhash']; amend_profile(); - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `refresh`=?, `style`=?, `passhash`=?, `boxwidth`=?, `boxheight`=?, `bgcolour`=?, `notesboxwidth`=?, `notesboxheight`=?, `timestamps`=?, `embed`=?, `incognito`=? WHERE `session`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET refresh=?, style=?, passhash=?, boxwidth=?, boxheight=?, bgcolour=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=? WHERE session=?;"); $stmt->execute(array($U['refresh'], $U['style'], $U['passhash'], $U['boxwidth'], $U['boxheight'], $U['bgcolour'], $U['notesboxwidth'], $U['notesboxheight'], $U['timestamps'], $U['embed'], $U['incognito'], $U['session'])); if($U['status']>=2){ - $stmt=$db->prepare("UPDATE `$C[prefix]members` SET `passhash`=?, `refresh`=?, `bgcolour`=?, `boxwidth`=?, `boxheight`=?, `notesboxwidth`=?, `notesboxheight`=?, `timestamps`=?, `embed`=?, `incognito`=?, `style`=? WHERE `nickname`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]members SET passhash=?, refresh=?, bgcolour=?, boxwidth=?, boxheight=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=?, style=? WHERE nickname=?;"); $stmt->execute(array($U['passhash'], $U['refresh'], $U['bgcolour'], $U['boxwidth'], $U['boxheight'], $U['notesboxwidth'], $U['notesboxheight'], $U['timestamps'], $U['embed'], $U['incognito'], $U['style'], $U['nickname'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]members"); } if(!empty($_REQUEST['unignore'])){ - $stmt=$db->prepare("DELETE FROM `$C[prefix]ignored` WHERE `ignored`=? AND `by`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]ignored WHERE ign=? AND ignby=?;"); $stmt->execute(array($_REQUEST['unignore'], $U['nickname'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]ignored"); } if(!empty($_REQUEST['ignore'])){ - $stmt=$db->prepare("INSERT INTO `$C[prefix]ignored` (`ignored`, `by`) VALUES (?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]ignored (ign, ignby) VALUES (?, ?);"); $stmt->execute(array($_REQUEST['ignore'], $U['nickname'])); if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]ignored"); } @@ -1860,22 +1941,24 @@ function save_profile(){ function add_user_defaults(){ global $U; - if(!isSet($U['refresh'])) $U['refresh']=get_setting('defaultrefresh'); - if(!isSet($U['bgcolour'])) $U['bgcolour']=get_setting('colbg'); - if(!isSet($U['style']) && !preg_match('/^[a-f0-9]{6}$/i', $U['colour'])){ + $U['refresh']=get_setting('defaultrefresh'); + $U['bgcolour']=get_setting('colbg'); + if(!isSet($_REQUEST['colour']) || !preg_match('/^[a-f0-9]{6}$/i', $_REQUEST['colour'])){ do{ - $U['colour']=sprintf('%02X', rand(0, 256)).sprintf('%02X', rand(0, 256)).sprintf('%02X', rand(0, 256)); + $U['colour']=sprintf('%02X', mt_rand(0, 256)).sprintf('%02X', mt_rand(0, 256)).sprintf('%02X', mt_rand(0, 256)); }while(abs(greyval($U['colour'])-greyval(get_setting('colbg')))<75); + }else{ + $U['colour']=$_REQUEST['colour']; } - if(!isSet($U['style'])) $U['style']=get_style("#$U[colour]"); - if(!isSet($U['boxwidth'])) $U['boxwidth']=40; - if(!isSet($U['boxheight'])) $U['boxheight']=3; - if(!isSet($U['notesboxwidth'])) $U['notesboxwidth']=80; - if(!isSet($U['notesboxheight'])) $U['notesboxheight']=30; - if(!isSet($U['timestamps'])) $U['timestamps']=get_setting('timestamps'); - if(!isSet($U['embed'])) $U['embed']=true; - if(!isSet($U['incognito'])) $U['incognito']=false; - $U['entry']=$U['lastpost']=time(); + $U['style']=get_style("#$U[colour]"); + $U['boxwidth']=40; + $U['boxheight']=3; + $U['notesboxwidth']=80; + $U['notesboxheight']=30; + $U['timestamps']=get_setting('timestamps'); + $U['embed']=1; + $U['incognito']=0; + $U['status']=1; } // message handling @@ -1885,11 +1968,11 @@ function validate_input(){ $maxmessage=get_setting('maxmessage'); $U['message']=substr($_REQUEST['message'], 0, $maxmessage); $U['rejected']=substr($_REQUEST['message'], $maxmessage); - if($U['postid']==$_REQUEST['postid']){// ignore double post=reload from browser or proxy - $_REQUEST['message']=''; + if($U['postid']===$_REQUEST['postid']){// ignore double post=reload from browser or proxy + $U['message']=''; }elseif((time()-$U['lastpost'])<=1){// time between posts too short, reject! $U['rejected']=$_REQUEST['message']; - $_REQUEST['message']=''; + $U['message']=''; } if(preg_match('/&[^;]{0,8}$/', $U['message']) && preg_match('/^([^;]{0,8};)/', $U['rejected'], $match)){ $U['message'].=$match[0]; @@ -1901,42 +1984,42 @@ function validate_input(){ } $U['message']=htmlspecialchars($U['message']); $U['message']=preg_replace("/(\r?\n|\r\n?)/", '
', $U['message']); - if(isSet($_REQUEST['multi']) && $_REQUEST['multi']=='on'){ + if(isSet($_REQUEST['multi'])){ $U['message']=preg_replace('/\s*
/', '
', $U['message']); $U['message']=preg_replace('/
(
)+/', '

', $U['message']); $U['message']=preg_replace('/

\s*$/', '
', $U['message']); $U['message']=preg_replace('/^
\s*$/', '', $U['message']); }else{ - $U['message']=preg_replace('/
/', ' ', $U['message']); + $U['message']=str_replace('
', ' ', $U['message']); } $U['message']=trim($U['message']); $U['message']=preg_replace('/\s+/', ' ', $U['message']); $U['delstatus']=$U['status']; $U['recipient']=''; - if($_REQUEST['sendto']=='*'){ + if($_REQUEST['sendto']==='*'){ $U['poststatus']='1'; $U['displaysend']=sprintf(get_setting('msgsendall'), style_this($U['nickname'], $U['style'])); - }elseif($_REQUEST['sendto']=='?' && $U['status']>=3){ + }elseif($_REQUEST['sendto']==='?' && $U['status']>=3){ $U['poststatus']='3'; $U['displaysend']=sprintf(get_setting('msgsendmem'), style_this($U['nickname'], $U['style'])); - }elseif($_REQUEST['sendto']=='#' && $U['status']>=5){ + }elseif($_REQUEST['sendto']==='#' && $U['status']>=5){ $U['poststatus']='5'; $U['displaysend']=sprintf(get_setting('msgsendmod'), style_this($U['nickname'], $U['style'])); - }elseif($_REQUEST['sendto']=='&' && $U['status']>=6){ + }elseif($_REQUEST['sendto']==='&' && $U['status']>=6){ $U['poststatus']='6'; $U['displaysend']=sprintf(get_setting('msgsendadm'), style_this($U['nickname'], $U['style'])); }else{// known nick in room? $ignored=get_ignored(); $ignore=false; foreach($ignored as $ign){ - if($ign['by']==$U['nickname'] && $ign['ignored']==$_REQUEST['sendto'] || ($ign['by']==$_REQUEST['sendto'] && $ign['ignored']==$U['nickname'])){ + if($ign['by']===$U['nickname'] && $ign['ignored']===$_REQUEST['sendto'] || ($ign['by']===$_REQUEST['sendto'] && $ign['ignored']===$U['nickname'])){ $ignore=true; break; } } if(!$ignore){ foreach($P as $chatter){ - if($_REQUEST['sendto']==$chatter[0]){ + if($_REQUEST['sendto']===$chatter[0]){ $U['recipient']=$chatter[0]; $U['displayrecp']=style_this($chatter[0], $chatter[1]); break; @@ -1958,7 +2041,7 @@ function validate_input(){ apply_linkfilter(); if(add_message()){ $U['lastpost']=time(); - $stmt=$db->prepare("UPDATE `$C[prefix]sessions` SET `lastpost`=?, `postid`=? WHERE `session`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]sessions SET lastpost=?, postid=? WHERE session=?;"); $stmt->execute(array($U['lastpost'], $_REQUEST['postid'], $U['session'])); } @@ -1967,7 +2050,7 @@ function validate_input(){ function apply_filter(){ global $C, $I, $U, $db, $memcached; - if($U['poststatus']!=9 && preg_match('~^/me~i', $U['message'])){ + if($U['poststatus']!==9 && preg_match('~^/me~i', $U['message'])){ $U['displaysend']=substr($U['displaysend'], 0, -3); $U['message']=preg_replace("~^/me~i", '', $U['message']); } @@ -1975,21 +2058,27 @@ function apply_filter(){ global $A, $P; if(isSet($P[$matched[1]])) return style_this($matched[0], $P[$matched[1]][1]); $nick=strtolower($matched[1]); - foreach($P as $user){ if(strtolower($user[0])==$nick) return style_this($matched[0], $user[1]);} + foreach($P as $user){ if(strtolower($user[0])===$nick) return style_this($matched[0], $user[1]);} read_members(); if(isSet($A[$matched[1]])) return style_this($matched[0], $A[$matched[1]][2]); - foreach($A as $user){ if(strtolower($user[0])==$nick) return style_this($matched[0], $user[2]);} + foreach($A as $user){ if(strtolower($user[0])===$nick) return style_this($matched[0], $user[2]);} return "$matched[0]"; }, $U['message']); if($C['memcached']) $filters=$memcached->get("$C[dbname]-$C[prefix]filter"); - if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){ + if(!$C['memcached'] || $memcached->getResultCode()!==Memcached::RES_SUCCESS){ $filters=array(); - $result=$db->query("SELECT * FROM `$C[prefix]filter`"); - while($filter=$result->fetch(PDO::FETCH_ASSOC)) $filters[]=$filter; + $result=$db->query("SELECT id, filtermatch, filterreplace, allowinpm, regex, kick FROM $C[prefix]filter;"); + $result->bindColumn(1, $filter['id']); + $result->bindColumn(2, $filter['match']); + $result->bindColumn(3, $filter['replace']); + $result->bindColumn(4, $filter['allowinpm']); + $result->bindColumn(5, $filter['regex']); + $result->bindColumn(6, $filter['kick']); + while($result->fetch(PDO::FETCH_BOUND)) $filters[]=$filter; if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]filter", $filters); } foreach($filters as $filter){ - if($U['poststatus']!=9) $U['message']=preg_replace("/$filter[match]/i", $filter['replace'], $U['message'], -1, $count); + if($U['poststatus']!==9) $U['message']=preg_replace("/$filter[match]/i", $filter['replace'], $U['message'], -1, $count); elseif(!$filter['allowinpm']) $U['message']=preg_replace("/$filter[match]/i", $filter['replace'], $U['message'], -1, $count); if(isSet($count) && $count>0 && $filter['kick']){ kick_chatter(array($U['nickname']), '', false); @@ -2001,24 +2090,27 @@ function apply_filter(){ function apply_linkfilter(){ global $C, $U, $db, $memcached; if($C['memcached']) $filters=$memcached->get("$C[dbname]-$C[prefix]linkfilter"); - if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){ + if(!$C['memcached'] || $memcached->getResultCode()!==Memcached::RES_SUCCESS){ $filters=array(); - $result=$db->query("SELECT * FROM `$C[prefix]linkfilter`"); - while($filter=$result->fetch(PDO::FETCH_ASSOC)) $filters[]=$filter; + $result=$db->query("SELECT id, filtermatch, filterreplace, regex FROM $C[prefix]linkfilter;"); + $result->bindColumn(1, $filter['id']); + $result->bindColumn(2, $filter['match']); + $result->bindColumn(3, $filter['replace']); + $result->bindColumn(4, $filter['regex']); + while($result->fetch(PDO::FETCH_BOUND)) $filters[]=$filter; if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]linkfilter", $filters); } foreach($filters as $filter){ - $U['message']=preg_replace_callback("/(.*?(?=<\/a>))<\/a>/i", function ($matched) use(&$filter){ return "".preg_replace("/$filter[match]/i", $filter['replace'], $matched[2]).'';}, $U['message']); + $U['message']=preg_replace_callback("/([^<]+)<\/a>/i", function ($matched) use(&$filter){ return "".preg_replace("/$filter[match]/i", $filter['replace'], $matched[2]).'';}, $U['message']); } $redirect=get_setting('redirect'); - if(get_setting('imgembed')) $U['message']=preg_replace_callback('/\[img\]\s?(.*?(?=<\/a>))<\/a>/i', function ($matched){ return str_ireplace('[/img]', '', "

");}, $U['message']); + if(get_setting('imgembed')) $U['message']=preg_replace_callback('/\[img\]\s?([^<]+)<\/a>/i', function ($matched){ return str_ireplace('[/img]', '', "

");}, $U['message']); if(empty($redirect)) $redirect="$_SERVER[SCRIPT_NAME]?action=redirect&url="; - if(get_setting('forceredirect')) $U['message']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use($redirect){ return "$matched[2]";}, $U['message']); - elseif(preg_match_all('/(.*?(?=<\/a>))<\/a>/', $U['message'], $matches)){ + if(get_setting('forceredirect')) $U['message']=preg_replace_callback('/([^<]+)<\/a>/', function ($matched) use($redirect){ return "$matched[2]";}, $U['message']); + elseif(preg_match_all('/([^<]+)<\/a>/', $U['message'], $matches)){ foreach($matches[1] as $match){ if(!preg_match('~^http(s)?://~', $match)){ - $U['message']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use($redirect){ return "$matched[2]";}, $U['message']); - break; + $U['message']=preg_replace_callback('/([^<]+)<\/a>/', function ($matched) use($redirect){ return "$matched[2]";}, $U['message']); } } } @@ -2037,7 +2129,7 @@ function create_hotlinks(){ $U['message']=preg_replace('~((?:[a-z0-9\-]+\.)*[a-z2-7]{16}\.onion)(?![^<>]*>)~i', "<<$1>>", $U['message']);// *.onion $U['message']=preg_replace('~([a-z0-9\-]+(?:\.[a-z0-9\-]+)+(?:\.(?!rar|zip|exe|gz|7z|bat|doc)[a-z]{2,}))(?=[^a-z0-9\-\.]|$)(?![^<>]*>)~i', "<<$1>>", $U['message']);// xxx.yyy.zzz // Convert every <<....>> into proper links: - $U['message']=preg_replace_callback('/<<([^<>]+)>>/', function ($matches){if(strpos($matches[1], '://')==false){ return "$matches[1]";}else{ return "$matches[1]"; }}, $U['message']); + $U['message']=preg_replace_callback('/<<([^<>]+)>>/', function ($matches){if(strpos($matches[1], '://')===false){ return "$matches[1]";}else{ return "$matches[1]"; }}, $U['message']); } function add_message(){ @@ -2048,7 +2140,7 @@ function add_message(){ 'poststatus' =>$U['poststatus'], 'poster' =>$U['nickname'], 'recipient' =>$U['recipient'], - 'text' =>$U['displaysend'].style_this($U['message'], $U['style']), + 'text' =>"$U[displaysend]".style_this($U['message'], $U['style']).'', 'delstatus' =>$U['delstatus'] ); write_message($newmessage); @@ -2062,7 +2154,7 @@ function add_system_message($mes){ 'poststatus' =>1, 'poster' =>'', 'recipient' =>'', - 'text' =>$mes, + 'text' =>"$mes", 'delstatus' =>9 ); write_message($sysmessage); @@ -2071,11 +2163,14 @@ function add_system_message($mes){ function write_message($message){ global $C, $db; if($C['msgencrypted']) $message['text']=openssl_encrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); - $stmt=$db->prepare("INSERT INTO `$C[prefix]messages` (`postdate`, `poststatus`, `poster`, `recipient`, `text`, `delstatus`) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]messages (postdate, poststatus, poster, recipient, text, delstatus) VALUES (?, ?, ?, ?, ?, ?);"); $stmt->execute(array($message['postdate'], $message['poststatus'], $message['poster'], $message['recipient'], $message['text'], $message['delstatus'])); $limit=$C['keeplimit']*get_setting('messagelimit'); - // Delete old messages - ignore possible deadlock warning - @$db->exec("DELETE FROM `$C[prefix]messages` WHERE `id` NOT IN (SELECT * FROM (SELECT `id` FROM `$C[prefix]messages` ORDER BY `id` DESC LIMIT $limit) t )"); + $stmt=$db->query("SELECT id FROM $C[prefix]messages ORDER BY id DESC LIMIT 1 OFFSET $limit"); + if($id=$stmt->fetch(PDO::FETCH_NUM)){ + $stmt=$db->prepare("DELETE FROM $C[prefix]messages WHERE id<=?;"); + $stmt->execute(array($id[0])); + } if($C['sendmail'] && $message['poststatus']<9){ $subject='New Chat message'; $headers="From: $C[mailsender]\r\nX-Mailer: PHP/".phpversion()."\r\nContent-Type: text/html; charset=UTF-8\r\n"; @@ -2086,7 +2181,7 @@ function write_message($message){ function clean_room(){ global $C, $db; - $db->query("DELETE FROM `$C[prefix]messages`"); + $db->query("DELETE FROM $C[prefix]messages;"); $msg=get_setting('msgclean'); add_system_message(sprintf($msg, get_setting('chatname'))); } @@ -2094,16 +2189,16 @@ function clean_room(){ function clean_selected(){ global $C, $db; if(isSet($_REQUEST['mid'])){ - $stmt=$db->prepare("DELETE FROM `$C[prefix]messages` WHERE `id`=?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]messages WHERE id=?;"); foreach($_REQUEST['mid'] as $mid) $stmt->execute(array($mid)); } } function del_all_messages($nick, $status, $entry){ global $C, $U, $db; - if($nick==$U['nickname']) $status=10; + if($nick===$U['nickname']) $status=10; if($U['status']>1) $entry=0; - $stmt=$db->prepare("DELETE FROM `$C[prefix]messages` WHERE `poster`=? AND `delstatus`?"); + $stmt=$db->prepare("DELETE FROM $C[prefix]messages WHERE poster=? AND delstatus?;"); $stmt->execute(array($nick, $status, $entry)); } @@ -2111,57 +2206,63 @@ function del_last_message(){ global $C, $U, $db; if($U['status']>1) $entry=0; else $entry=$U['entry']; - $stmt=$db->prepare("DELETE FROM `$C[prefix]messages` WHERE `poster`=? AND `postdate`>? ORDER BY `id` DESC LIMIT 1"); + $stmt=$db->prepare("SELECT id FROM $C[prefix]messages WHERE poster=? AND postdate>? ORDER BY id DESC LIMIT 1;"); $stmt->execute(array($U['nickname'], $entry)); + if($id=$stmt->fetch(PDO::FETCH_NUM)){ + $stmt=$db->prepare("DELETE FROM $C[prefix]messages WHERE id=?;"); + $stmt->execute(array($id[0])); + } } function print_messages($delstatus=''){ global $C, $U, $db; $dateformat=get_setting('dateformat'); - $messagelimit=get_setting('messagelimit'); + $messagelimit=(int) get_setting('messagelimit'); if(!isSet($_COOKIE[$C['cookiename']]) && get_setting('forceredirect')==0){ $injectRedirect=true; $redirect=get_setting('redirect'); if(empty($redirect)) $redirect="$_SERVER[SCRIPT_NAME]?action=redirect&url="; }else $injectRedirect=false; if(get_setting('imgembed') && (!$U['embed'] || !isSet($_COOKIE[$C['cookiename']]))) $removeEmbed=true; else $removeEmbed=false; - // Delete old messages - ignore possible deadlock warning - @$db->exec("DELETE FROM `$C[prefix]messages` WHERE (`poster`='' AND `recipient`='' AND `poststatus`='9') OR `postdate`<='".(time()-60*get_setting('messageexpire'))."'"); + if($U['timestamps'] && !empty($dateformat)) $timestamps=true; else $timestamps=false; + $expire=time()-60*get_setting('messageexpire'); + $stmt=$db->prepare("DELETE FROM $C[prefix]messages WHERE postdateexecute(array($expire)); if(!empty($delstatus)){ - $stmt=$db->prepare("SELECT `postdate`, `id`, `text` FROM `$C[prefix]messages` WHERE ". - "`id` IN (SELECT * FROM (SELECT `id` FROM `$C[prefix]messages` WHERE `poststatus`='1' ORDER BY `id` DESC LIMIT $messagelimit) AS t) ". - "OR (`poststatus`>'1' AND (`poststatus`prepare("SELECT postdate, id, text FROM $C[prefix]messages WHERE ". + "id IN (SELECT * FROM (SELECT id FROM $C[prefix]messages WHERE poststatus=1 ORDER BY id DESC LIMIT $messagelimit) AS t) ". + "OR (poststatus>1 AND (poststatusexecute(array($U['status'], $U['nickname'], $U['nickname'])); while($message=$stmt->fetch(PDO::FETCH_ASSOC)){ if($C['msgencrypted']) $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); if($injectRedirect){ - $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use ($redirect){ return "$matched[2]";}, $message['text']); + $message['text']=preg_replace_callback('/([^<]+)<\/a>/', function ($matched) use ($redirect){ return "$matched[2]";}, $message['text']); } if($removeEmbed){ - $message['text']=preg_replace_callback('//', function ($matched){ return $matched[1];}, $message['text']); + $message['text']=preg_replace_callback('/<\/a>/', function ($matched){ return "$matched[1]";}, $message['text']); } echo "
"; } }else{ if(!isSet($_REQUEST['id'])) $_REQUEST['id']=0; - $stmt=$db->prepare("SELECT `id`, `postdate`, `text` FROM `$C[prefix]messages` WHERE (". - "`id` IN (SELECT * FROM (SELECT `id` FROM `$C[prefix]messages` WHERE `poststatus`='1' ORDER BY `id` DESC LIMIT $messagelimit) AS t) ". - "OR (`poststatus`>'1' AND `poststatus`<=?) ". - "OR (`poststatus`='9' AND ( (`poster`=? AND `recipient` NOT IN (SELECT `ignored` FROM `$C[prefix]ignored` WHERE `by`=?) ) OR `recipient`=?) )". - ") AND `poster` NOT IN (SELECT `ignored` FROM `$C[prefix]ignored` WHERE `by`=?) AND `id`>? ORDER BY `id` DESC"); + $stmt=$db->prepare("SELECT id, postdate, text FROM $C[prefix]messages WHERE (". + "id IN (SELECT * FROM (SELECT id FROM $C[prefix]messages WHERE poststatus=1 ORDER BY id DESC LIMIT $messagelimit) AS t) ". + "OR (poststatus>1 AND poststatus<=?) ". + "OR (poststatus=9 AND ( (poster=? AND recipient NOT IN (SELECT ign FROM $C[prefix]ignored WHERE ignby=?) ) OR recipient=?) )". + ") AND poster NOT IN (SELECT ign FROM $C[prefix]ignored WHERE ignby=?) AND id>? ORDER BY id DESC;"); $stmt->execute(array($U['status'], $U['nickname'], $U['nickname'], $U['nickname'], $U['nickname'], $_REQUEST['id'])); while($message=$stmt->fetch(PDO::FETCH_ASSOC)){ if($C['msgencrypted']) $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); if($injectRedirect){ - $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use($redirect) { return "$matched[2]";}, $message['text']); + $message['text']=preg_replace_callback('/([^<]+)<\/a>/', function ($matched) use($redirect) { return "$matched[2]";}, $message['text']); } if($removeEmbed){ - $message['text']=preg_replace_callback('//', function ($matched){ return $matched[1];}, $message['text']); + $message['text']=preg_replace_callback('/<\/a>/', function ($matched){ return "$matched[1]";}, $message['text']); } echo '
'; - if($U['timestamps']) echo ''.date($dateformat, $message['postdate']).' - '; + if($timestamps) echo ''.date($dateformat, $message['postdate']).' - '; echo "$message[text]
"; if($_REQUEST['id']<$message['id']) $_REQUEST['id']=$message['id']; } @@ -2173,10 +2274,12 @@ function print_messages($delstatus=''){ function get_ignored(){ global $C, $db, $memcached; if($C['memcached']) $ignored=$memcached->get("$C[dbname]-$C[prefix]ignored"); - if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){ + if(!$C['memcached'] || $memcached->getResultCode()!==Memcached::RES_SUCCESS){ $ignored=array(); - $result=$db->query("SELECT * FROM `$C[prefix]ignored`"); - while($tmp=$result->fetch(PDO::FETCH_ASSOC)) $ignored[]=$tmp; + $result=$db->query("SELECT ign, ignby FROM $C[prefix]ignored;"); + $result->bindColumn(1, $tmp['ignored']); + $result->bindColumn(2, $tmp['by']); + while($result->fetch(PDO::FETCH_BOUND)) $ignored[]=$tmp; if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]ignored", $ignored); } return $ignored; @@ -2184,7 +2287,7 @@ function get_ignored(){ function valid_admin(){ global $U; - if(!empty($_REQUEST['session'])){ + if(isSet($_REQUEST['session'])){ check_session(); } elseif(isSet($_REQUEST['nick']) && isSet($_REQUEST['pass'])){ @@ -2202,18 +2305,18 @@ function valid_pass($pass){ return preg_match('/^.{'.get_setting('minpass').',}$/', $pass); } -function get_timeout($lastpost, $status){ // lastpost, status - if($status>2) $expire=get_setting('memberexpire'); - else $expire=get_setting('guestexpire'); +function get_timeout($lastpost, $expire){ $s=($lastpost+60*$expire)-time(); - $m=$s/60;$m=floor($m);$s-=$m*60; - $h=$m/60;$h=floor($h);$m-=$h*60; - $s=substr('0'.$s, -2, 2); + $m=floor($s/60); + $s-=$m*60; + $h=floor($m/60); + $m-=$h*60; + $s=substr("0$s", -2, 2); if($h>0){ - $m=substr('0'.$m, -2, 2); - return "$h:$m:$s"; + $m=substr("0$m", -2, 2); + echo "$h:$m:$s"; } - return "$m:$s"; + echo "$m:$s"; } function print_colours(){ @@ -2223,7 +2326,7 @@ function print_colours(){ $colours=array('Beige'=>'F5F5DC', 'Black'=>'000000', 'Blue'=>'0000FF', 'BlueViolet'=>'8A2BE2', 'Brown'=>'A52A2A', 'Cyan'=>'00FFFF', 'DarkBlue'=>'00008B', 'DarkGreen'=>'006400', 'DarkRed'=>'8B0000', 'DarkViolet'=>'9400D3', 'DeepSkyBlue'=>'00BFFF', 'Gold'=>'FFD700', 'Grey'=>'808080', 'Green'=>'008000', 'HotPink'=>'FF69B4', 'Indigo'=>'4B0082', 'LightBlue'=>'ADD8E6', 'LightGreen'=>'90EE90', 'LimeGreen'=>'32CD32', 'Magenta'=>'FF00FF', 'Olive'=>'808000', 'Orange'=>'FFA500', 'OrangeRed'=>'FF4500', 'Purple'=>'800080', 'Red'=>'FF0000', 'RoyalBlue'=>'4169E1', 'SeaGreen'=>'2E8B57', 'Sienna'=>'A0522D', 'Silver'=>'C0C0C0', 'Tan'=>'D2B48C', 'Teal'=>'008080', 'Violet'=>'EE82EE', 'White'=>'FFFFFF', 'Yellow'=>'FFFF00', 'YellowGreen'=>'9ACD32'); $greybg=greyval(get_setting('colbg')); foreach($colours as $name=>$colour){ - if(abs($greybg-greyval($colour))>75) echo ""; + if(abs($greybg-greyval($colour))>75) echo ""; } } @@ -2234,8 +2337,8 @@ function greyval($colour){ function get_style($styleinfo){ $fbold=preg_match('/(|:bold)/', $styleinfo); $fitalic=preg_match('/(|:italic)/', $styleinfo); - $fsmall=preg_match('/:smaller/', $styleinfo); - preg_match('/(#.{6})/i', $styleinfo, $match); + $fsmall=strpos($styleinfo, ':smaller'); + preg_match('/(#[a-f0-9]{6})/i', $styleinfo, $match); if(isSet($match[0])) $fcolour=$match[0]; preg_match('/font-family:([^;]+);/', $styleinfo, $match); if(isSet($match[1])) $sface=$match[1]; @@ -2249,14 +2352,18 @@ function get_style($styleinfo){ } function style_this($text, $styleinfo){ - return "$text"; + return "$text"; } function check_init(){ global $C, $db, $memcached; if(!$C['memcached'] || !$found=$memcached->get("$C[dbname]-$C[prefix]num-tables")){ - $result=$db->query("SHOW TABLES LIKE '$C[prefix]settings'"); - $found=($result->rowCount()>0); + if($C['dbdriver']===0){ + $result=$db->query("SHOW TABLES LIKE '$C[prefix]settings';"); + $found=($result->fetch(PDO::FETCH_ASSOC)!==false); + }else{ + $found=$db->query("SELECT * FROM $C[prefix]settings LIMIT 1;"); + } if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]num-tables", $found); } return $found; @@ -2266,7 +2373,15 @@ function destroy_chat(){ global $C, $H, $I,$db; setcookie($C['cookiename'], false); print_start('destory'); - $db->exec("DROP TABLE `$C[prefix]captcha`, `$C[prefix]filter`, `$C[prefix]ignored`, `$C[prefix]linkfilter`, `$C[prefix]members`, `$C[prefix]messages`, `$C[prefix]notes`, `$C[prefix]sessions`, `$C[prefix]settings`"); + $db->exec("DROP TABLE $C[prefix]captcha;"); + $db->exec("DROP TABLE $C[prefix]filter;"); + $db->exec("DROP TABLE $C[prefix]ignored;"); + $db->exec("DROP TABLE $C[prefix]linkfilter;"); + $db->exec("DROP TABLE $C[prefix]members;"); + $db->exec("DROP TABLE $C[prefix]messages;"); + $db->exec("DROP TABLE $C[prefix]notes;"); + $db->exec("DROP TABLE $C[prefix]sessions;"); + $db->exec("DROP TABLE $C[prefix]settings;"); if($C['memcached']){ $memcached->delete("$C[dbname]-$C[prefix]num-tables"); $memcached->delete("$C[dbname]-$C[prefix]filter"); @@ -2277,8 +2392,8 @@ function destroy_chat(){ $memcached->delete("$C[dbname]-$C[prefix]settings-dbversion"); $memcached->delete("$C[dbname]-$C[prefix]settings-msgencrypted"); } - echo "

$I[destroyed]





"; - echo "<$H[form]>".hidden('action', 'setup').hidden('lang', $C['lang']).submit($I['init'])."$H[credit]
"; + echo "

$I[destroyed]




"; + echo "<$H[form]>".hidden('lang', $C['lang']).hidden('action', 'setup').submit($I['init'])."$H[credit]
"; print_end(); } @@ -2287,8 +2402,8 @@ function init_chat(){ $suwrite=''; if(check_init()){ $suwrite=$I['initdbexist']; - $result=$db->query("SELECT * FROM `$C[prefix]members` WHERE `status`='8'"); - if($result->rowCount()>0){ + $result=$db->query("SELECT * FROM $C[prefix]members WHERE status=8;"); + if($result->fetch(PDO::FETCH_ASSOC)){ $suwrite=$I['initsuexist']; } }elseif(!preg_match('/^[a-z0-9]{1,20}$/i', $_REQUEST['sunick'])){ @@ -2298,16 +2413,58 @@ function init_chat(){ }elseif($_REQUEST['supass']!==$_REQUEST['supassc']){ $suwrite=$I['noconfirm']; }else{ - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]captcha` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `time` int(10) unsigned NOT NULL, `code` char(5) NOT NULL, PRIMARY KEY (`id`) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]filter` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `match` varchar(255) NOT NULL, `replace` varchar(20000) NOT NULL, `allowinpm` tinyint(1) unsigned NOT NULL, `regex` tinyint(1) unsigned NOT NULL, `kick` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`id`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]ignored` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ignored` varchar(50) NOT NULL, `by` varchar(50) NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX(`ignored`) USING BTREE, INDEX(`by`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]linkfilter` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `match` varchar(255) NOT NULL, `replace` varchar(255) NOT NULL, `regex` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`id`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]members` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `nickname` varchar(50) NOT NULL, `passhash` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `status` tinyint(3) unsigned NOT NULL, `refresh` tinyint(3) unsigned NOT NULL, `bgcolour` char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `boxwidth` tinyint(3) unsigned NOT NULL DEFAULT '40', `boxheight` tinyint(3) unsigned NOT NULL DEFAULT '3', `notesboxheight` tinyint(3) unsigned NOT NULL DEFAULT '30', `notesboxwidth` tinyint(3) unsigned NOT NULL DEFAULT '80', `regedby` varchar(50) NOT NULL, `lastlogin` int(10) unsigned NOT NULL, `timestamps` tinyint(1) unsigned NOT NULL, `embed` tinyint(1) unsigned NOT NULL DEFAULT '1', `incognito` tinyint(1) unsigned NOT NULL DEFAULT '0', `style` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE(`nickname`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]messages` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `postdate` int(10) unsigned NOT NULL, `poststatus` tinyint(3) unsigned NOT NULL, `poster` varchar(50) NOT NULL, `recipient` varchar(50) NOT NULL, `text` varchar(20000) NOT NULL, `delstatus` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX(`poster`) USING BTREE, INDEX(`recipient`) USING BTREE, INDEX(`postdate`) USING BTREE, INDEX(`poststatus`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]notes` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `type` char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `lastedited` int(10) unsigned NOT NULL, `editedby` varchar(50) NOT NULL, `text` varchar(20000) NOT NULL, PRIMARY KEY (`id`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]sessions` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `session` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `nickname` varchar(50) NOT NULL, `status` tinyint(3) unsigned NOT NULL, `refresh` tinyint(3) unsigned NOT NULL, `style` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `lastpost` int(10) unsigned NOT NULL, `passhash` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `postid` char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '000000', `boxwidth` tinyint(3) unsigned NOT NULL DEFAULT '40', `boxheight` tinyint(3) unsigned NOT NULL DEFAULT '3', `useragent` varchar(255) NOT NULL, `kickmessage` varchar(255) NOT NULL, `bgcolour` char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `notesboxheight` tinyint(3) unsigned NOT NULL DEFAULT '30', `notesboxwidth` tinyint(3) unsigned NOT NULL DEFAULT '80', `entry` int(10) unsigned NOT NULL, `timestamps` tinyint(1) unsigned NOT NULL, `embed` tinyint(1) unsigned NOT NULL DEFAULT '1', `incognito` tinyint(1) unsigned NOT NULL DEFAULT '0', `ip` varchar(15) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE(`session`) USING BTREE, UNIQUE(`nickname`) USING BTREE, INDEX(`status`) USING BTREE, INDEX(`lastpost`) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]settings` (`setting` varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `value` varchar(20000) NOT NULL, PRIMARY KEY (`setting`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`,`value`) VALUES ('guestaccess', '0'), ('globalpass', ''), ('englobalpass', '0'), ('captcha', '0'), ('dateformat', 'm-d H:i:s'), ('rulestxt', ''), ('msgencrypted', '0'), ('msgenter', '$I[entermsg]'), ('msgexit', '$I[exitmsg]'), ('msgmemreg', '$I[memregmsg]'), ('msgsureg', '$I[suregmsg]'), ('msgkick', '$I[kickmsg]'), ('msgmultikick', '$I[multikickmsg]'), ('msgallkick', '$I[allkickmsg]'), ('msgclean', '$I[cleanmsg]'), ('dbversion', '$C[dbversion]'), ('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), ('memberexpire', '60'), ('guestexpire', '15'), ('kickpenalty', '10'), ('entrywait', '120'), ('messageexpire', '14400'), ('messagelimit', '150'), ('maxmessage', 2000), ('captchatime', '600'), ('colbg', '000000'), ('coltxt', 'FFFFFF'), ('maxname', '20'), ('minpass', '5'), ('defaultrefresh', '20'), ('dismemcaptcha', '0'), ('suguests', '0'), ('imgembed', '1'), ('timestamps', '1'), ('trackip', '0'), ('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ('memkick', '1'), ('forceredirect', '0'), ('redirect', ''), ('incognito', '1'), ('enablejs', '0'), ('chatname', 'My Chat'), ('topic', ''), ('msgsendall', '$I[sendallmsg]'), ('msgsendmem', '$I[sendmemmsg]'), ('msgsendmod', '$I[sendmodmsg]'), ('msgsendadm', '$I[sendadmmsg]'), ('msgsendprv', '$I[sendprvmsg]'), ('numnotes', '3');"); + if($C['dbdriver']===0){//MySQL + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]captcha (id int(10) unsigned NOT NULL AUTO_INCREMENT, time int(10) unsigned NOT NULL, code char(5) NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=MEMORY DEFUALT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]filter (id int(10) unsigned NOT NULL AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(20000) NOT NULL, allowinpm tinyint(1) unsigned NOT NULL, regex tinyint(1) unsigned NOT NULL, kick tinyint(1) unsigned NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]ignored (id int(10) unsigned NOT NULL AUTO_INCREMENT, ign varchar(50) NOT NULL, ignby varchar(50) NOT NULL, PRIMARY KEY (id) USING BTREE, INDEX(ign) USING BTREE, INDEX(ignby) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]linkfilter (id int(10) unsigned NOT NULL AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex tinyint(1) unsigned NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]members (id int(10) unsigned NOT NULL AUTO_INCREMENT, nickname varchar(50) NOT NULL, passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, status tinyint(3) unsigned NOT NULL, refresh tinyint(3) unsigned NOT NULL, bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, boxwidth tinyint(3) unsigned NOT NULL DEFAULT 40, boxheight tinyint(3) unsigned NOT NULL DEFAULT 3, notesboxheight tinyint(3) unsigned NOT NULL DEFAULT 30, notesboxwidth tinyint(3) unsigned NOT NULL DEFAULT 80, regedby varchar(50) NOT NULL, lastlogin int(10) unsigned NOT NULL, timestamps tinyint(1) unsigned NOT NULL, embed tinyint(1) unsigned NOT NULL DEFAULT 1, incognito tinyint(1) unsigned NOT NULL DEFAULT 0, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, PRIMARY KEY (id) USING BTREE, UNIQUE(nickname) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]messages (id int(10) unsigned NOT NULL AUTO_INCREMENT, postdate int(10) unsigned NOT NULL, poststatus tinyint(3) unsigned NOT NULL, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text varchar(20000) NOT NULL, delstatus tinyint(3) unsigned NOT NULL, PRIMARY KEY (id) USING BTREE, INDEX(poster) USING BTREE, INDEX(recipient) USING BTREE, INDEX(postdate) USING BTREE, INDEX(poststatus) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]notes (id int(10) unsigned NOT NULL AUTO_INCREMENT, type char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastedited int(10) unsigned NOT NULL, editedby varchar(50) NOT NULL, text varchar(20000) NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]sessions (id int(10) unsigned NOT NULL AUTO_INCREMENT, session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, nickname varchar(50) NOT NULL, status tinyint(3) unsigned NOT NULL, refresh tinyint(3) unsigned NOT NULL, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastpost int(10) unsigned NOT NULL, passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, postid char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '000000', boxwidth tinyint(3) unsigned NOT NULL DEFAULT 40, boxheight tinyint(3) unsigned NOT NULL DEFAULT 3, useragent varchar(255) NOT NULL, kickmessage varchar(255) NOT NULL, bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, notesboxheight tinyint(3) unsigned NOT NULL DEFAULT 30, notesboxwidth tinyint(3) unsigned NOT NULL DEFAULT 80, entry int(10) unsigned NOT NULL, timestamps tinyint(1) unsigned NOT NULL, embed tinyint(1) unsigned NOT NULL DEFAULT 1, incognito tinyint(1) unsigned NOT NULL DEFAULT 0, ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, PRIMARY KEY (id) USING BTREE, UNIQUE(session) USING BTREE, UNIQUE(nickname) USING BTREE, INDEX(status) USING BTREE, INDEX(lastpost) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]settings (setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, value varchar(20000) NOT NULL, PRIMARY KEY (setting) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); + }elseif($C['dbdriver']===1){//PostgreSQL + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]captcha (id serial PRIMARY KEY, time integer NOT NULL, code char(5) NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]filter (id serial PRIMARY KEY, filtermatch varchar(255) NOT NULL, filterreplace varchar(20000) NOT NULL, allowinpm smallint NOT NULL, regex smallint NOT NULL, kick smallint NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]ignored (id serial PRIMARY KEY, ign varchar(50) NOT NULL, ignby varchar(50) NOT NULL);"); + $db->exec("CREATE INDEX ign ON $C[prefix]ignored (ign);"); + $db->exec("CREATE INDEX ignby ON $C[prefix]ignored (ignby);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]linkfilter (id serial PRIMARY KEY, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex smallint NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]members (id serial PRIMARY KEY, nickname varchar(50) NOT NULL UNIQUE, passhash char(32) NOT NULL, status smallint NOT NULL, refresh smallint NOT NULL, bgcolour char(6) NOT NULL, boxwidth smallint NOT NULL DEFAULT 40, boxheight smallint NOT NULL DEFAULT 3, notesboxheight smallint NOT NULL DEFAULT 30, notesboxwidth smallint NOT NULL DEFAULT 80, regedby varchar(50) DEFAULT '', lastlogin integer DEFAULT 0, timestamps smallint NOT NULL, embed smallint DEFAULT 1, incognito smallint DEFAULT 0, style varchar(255) NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]messages (id serial PRIMARY KEY, postdate integer NOT NULL, poststatus smallint NOT NULL, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text varchar(20000) NOT NULL, delstatus smallint NOT NULL);"); + $db->exec("CREATE INDEX poster ON $C[prefix]messages (poster);"); + $db->exec("CREATE INDEX recipient ON $C[prefix]messages (recipient);"); + $db->exec("CREATE INDEX postdate ON $C[prefix]messages (postdate);"); + $db->exec("CREATE INDEX poststatus ON $C[prefix]messages (poststatus);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]notes (id serial PRIMARY KEY, type char(5) NOT NULL, lastedited integer NOT NULL, editedby varchar(50) NOT NULL, text varchar(20000) NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]sessions (id serial PRIMARY KEY, session char(32) NOT NULL UNIQUE, nickname varchar(50) NOT NULL UNIQUE, status smallint NOT NULL, refresh smallint NOT NULL, style varchar(255) NOT NULL, lastpost integer NOT NULL, passhash char(32) NOT NULL, postid char(6) NOT NULL DEFAULT '000000', boxwidth smallint NOT NULL DEFAULT 40, boxheight smallint NOT NULL DEFAULT 3, useragent varchar(255) NOT NULL, kickmessage varchar(255) DEFAULT '', bgcolour char(6) NOT NULL, notesboxheight smallint NOT NULL DEFAULT 30, notesboxwidth smallint NOT NULL DEFAULT 80, entry integer NOT NULL, timestamps smallint NOT NULL, embed smallint DEFAULT 1, incognito smallint DEFAULT 0, ip varchar(45) NOT NULL);"); + $db->exec("CREATE INDEX status ON $C[prefix]sessions (status);"); + $db->exec("CREATE INDEX lastpost ON $C[prefix]sessions (lastpost);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]settings (setting varchar(50) PRIMARY KEY, value varchar(20000) NOT NULL);"); + }else{//sqlite + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]captcha (id INTEGER PRIMARY KEY, time INTEGER NOT NULL, code TEXT NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]filter (id INTEGER PRIMARY KEY, filtermatch TEXT NOT NULL, filterreplace TEXT NOT NULL, allowinpm INTEGER NOT NULL, regex INTEGER NOT NULL, kick INTEGER NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]ignored (id INTEGER PRIMARY KEY, ign TEXT NOT NULL, ignby TEXT NOT NULL);"); + $db->exec("CREATE INDEX IF NOT EXISTS ign ON $C[prefix]ignored (ign);"); + $db->exec("CREATE INDEX IF NOT EXISTS ignby ON $C[prefix]ignored (ignby);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]linkfilter (id INTEGER PRIMARY KEY, filtermatch TEXT NOT NULL, filterreplace TEXT NOT NULL, regex INTEGER NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]members (id INTEGER PRIMARY KEY, nickname TEXT NOT NULL UNIQUE, passhash TEXT NOT NULL, status INTEGER NOT NULL, refresh INTEGER NOT NULL, bgcolour TEXT NOT NULL, boxwidth INTEGER NOT NULL DEFAULT 40, boxheight INTEGER NOT NULL DEFAULT 3, notesboxheight INTEGER NOT NULL DEFAULT 30, notesboxwidth INTEGER NOT NULL DEFAULT 80, regedby TEXT DEFAULT '', lastlogin INTEGER DEFAULT 0, timestamps INTEGER NOT NULL, embed INTEGER NOT NULL DEFAULT 1, incognito INTEGER NOT NULL DEFAULT 0, style TEXT NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]messages (id INTEGER PRIMARY KEY, postdate INTEGER NOT NULL, poststatus INTEGER NOT NULL, poster TEXT NOT NULL, recipient TEXT NOT NULL, text TEXT NOT NULL, delstatus INTEGER NOT NULL);"); + $db->exec("CREATE INDEX IF NOT EXISTS poster ON $C[prefix]messages (poster);"); + $db->exec("CREATE INDEX IF NOT EXISTS recipient ON $C[prefix]messages (recipient);"); + $db->exec("CREATE INDEX IF NOT EXISTS postdate ON $C[prefix]messages (postdate);"); + $db->exec("CREATE INDEX IF NOT EXISTS poststatus ON $C[prefix]messages (poststatus);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]notes (id INTEGER PRIMARY KEY, type TEXT NOT NULL, lastedited INTEGER NOT NULL, editedby TEXT NOT NULL, text TEXT NOT NULL);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]sessions (id INTEGER PRIMARY KEY, session TEXT NOT NULL UNIQUE, nickname TEXT NOT NULL UNIQUE, status INTEGER NOT NULL, refresh INTEGER NOT NULL, style TEXT NOT NULL, lastpost INTEGER NOT NULL, passhash TEXT NOT NULL, postid TEXT NOT NULL DEFAULT '000000', boxwidth INTEGER NOT NULL DEFAULT 40, boxheight INTEGER NOT NULL DEFAULT 3, useragent TEXT NOT NULL, kickmessage TEXT DEFAULT '', bgcolour TEXT NOT NULL, notesboxheight INTEGER NOT NULL DEFAULT 30, notesboxwidth INTEGER NOT NULL DEFAULT 80, entry INTEGER NOT NULL, timestamps INTEGER NOT NULL, embed INTEGER NOT NULL DEFAULT 1, incognito INTEGER NOT NULL DEFAULT 0, ip TEXT NOT NULL);"); + $db->exec("CREATE INDEX IF NOT EXISTS status ON $C[prefix]sessions (status);"); + $db->exec("CREATE INDEX IF NOT EXISTS lastpost ON $C[prefix]sessions (lastpost);"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]settings (setting TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);"); + } + $settings=array(array('guestaccess', '0'), array('globalpass', ''), array('englobalpass', '0'), array('captcha', '0'), array('dateformat', 'm-d H:i:s'), array('rulestxt', ''), array('msgencrypted', '0'), array('dbversion', '$C[dbversion]'), array('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), array('memberexpire', '60'), array('guestexpire', '15'), array('kickpenalty', '10'), array('entrywait', '120'), array('messageexpire', '14400'), array('messagelimit', '150'), array('maxmessage', 2000), array('captchatime', '600'), array('colbg', '000000'), array('coltxt', 'FFFFFF'), array('maxname', '20'), array('minpass', '5'), array('defaultrefresh', '20'), array('dismemcaptcha', '0'), array('suguests', '0'), array('imgembed', '1'), array('timestamps', '1'), array('trackip', '0'), array('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), array('memkick', '1'), array('forceredirect', '0'), array('redirect', ''), array('incognito', '1'), array('enablejs', '0'), array('chatname', 'My Chat'), array('topic', ''), array('msgsendall', $I['sendallmsg']), array('msgsendmem', $I['sendmemmsg']), array('msgsendmod', $I['sendmodmsg']), array('msgsendadm', $I['sendadmmsg']), array('msgsendprv', $I['sendprvmsg']), array('msgenter', $I['entermsg']), array('msgexit', $I['exitmsg']), array('msgmemreg', $I['memregmsg']), array('msgsureg', $I['suregmsg']), array('msgkick', $I['kickmsg']), array('msgmultikick', $I['multikickmsg']), array('msgallkick', $I['allkickmsg']), array('msgclean', $I['cleanmsg']), array('numnotes', '3')); + $stmt=$db->prepare("INSERT INTO $C[prefix]settings (setting, value) VALUES (?, ?);"); + foreach($settings as $pair){ + $stmt->execute($pair); + } if($C['memcached']) $memcached->delete("$C[dbname]-$C[prefix]num-tables"); $reg=array( 'nickname' =>$_REQUEST['sunick'], @@ -2315,109 +2472,117 @@ function init_chat(){ 'status' =>8, 'refresh' =>20, 'bgcolour' =>'000000', - 'timestamps' =>true, + 'timestamps' =>1, 'style' =>'color:#FFFFFF;' ); - $stmt=$db->prepare("INSERT INTO `$C[prefix]members` (`nickname`, `passhash`, `status`, `refresh`, `bgcolour`, `timestamps`, `style`) VALUES (?, ?, ?, ?, ?, ?, ?)"); + $stmt=$db->prepare("INSERT INTO $C[prefix]members (nickname, passhash, status, refresh, bgcolour, timestamps, style) VALUES (?, ?, ?, ?, ?, ?, ?);"); $stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['timestamps'], $reg['style'])); $suwrite=$I['susuccess']; } print_start('init'); - echo "

$I[init]


$I[sulogin]

$suwrite


"; - echo "<$H[form]>".hidden('action', 'setup').hidden('lang', $C['lang']).submit($I['initgosetup'])."$H[credit]
"; + echo "

$I[init]


$I[sulogin]

$suwrite


"; + echo "<$H[form]>$H[commonform]".hidden('action', 'setup').submit($I['initgosetup'])."$H[credit]
"; print_end(); } function update_db(){ global $C, $F, $I, $db; - $dbversion=get_setting('dbversion'); + $dbversion=(int) get_setting('dbversion'); if($dbversion<$C['dbversion'] || get_setting('msgencrypted')!=$C['msgencrypted']){ if($dbversion<2){ - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]ignored` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ignored` tinytext NOT NULL, `by` tinytext NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]ignored (id int(10) unsigned NOT NULL AUTO_INCREMENT, ignored tinytext NOT NULL, `by` tinytext NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); } if($dbversion<3){ - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`, `value`) VALUES ('rulestxt', '')"); + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('rulestxt', '');"); } if($dbversion<4){ - $db->exec("ALTER TABLE `$C[prefix]members` ADD `incognito` TINYINT(1) UNSIGNED NOT NULL"); - $db->exec("ALTER TABLE `$C[prefix]sessions` ADD `incognito` TINYINT(1) UNSIGNED NOT NULL"); + $db->exec("ALTER TABLE $C[prefix]members ADD incognito TINYINT(1) UNSIGNED NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]sessions ADD incognito TINYINT(1) UNSIGNED NOT NULL;"); } if($dbversion<5){ - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`, `value`) VALUES ('globalpass', '')"); + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('globalpass', '');"); } if($dbversion<6){ - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`, `value`) VALUES ('dateformat', 'm-d H:i:s')"); + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('dateformat', 'm-d H:i:s');"); } if($dbversion<7){ - $db->exec("ALTER TABLE `$C[prefix]captcha` ADD `code` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); + $db->exec("ALTER TABLE $C[prefix]captcha ADD code TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"); } if($dbversion<8){ - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`, `value`) VALUES ('captcha', '0'), ('englobalpass', '0')"); - $ga=get_setting('guestaccess'); - if($ga==-1){ + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('captcha', '0'), ('englobalpass', '0');"); + $ga=(int) get_setting('guestaccess'); + if($ga===-1){ update_setting('guestaccess', 0); update_setting('englobalpass', 1); - }elseif($ga==4){ + }elseif($ga===4){ update_setting('guestaccess', 1); update_setting('englobalpass', 2); } } if($dbversion<9){ - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`,`value`) VALUES ('msgencrypted', '0')"); - $db->exec("ALTER TABLE `$C[prefix]settings` MODIFY `value` text NOT NULL"); - $db->exec("ALTER TABLE `$C[prefix]messages` DROP `postid`"); + $db->exec("INSERT INTO $C[prefix]settings (setting,value) VALUES ('msgencrypted', '0');"); + $db->exec("ALTER TABLE $C[prefix]settings MODIFY value text NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]messages DROP postid;"); } if($dbversion<10){ - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`, `value`) VALUES ('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), ('memberexpire', '60'), ('guestexpire', '15'), ('kickpenalty', '10'), ('entrywait', '120'), ('messageexpire', '14400'), ('messagelimit', '150'), ('maxmessage', 2000), ('captchatime', '600')"); - $db->exec("ALTER TABLE `$C[prefix]sessions` ADD `ip` tinytext NOT NULL"); + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), ('memberexpire', '60'), ('guestexpire', '15'), ('kickpenalty', '10'), ('entrywait', '120'), ('messageexpire', '14400'), ('messagelimit', '150'), ('maxmessage', 2000), ('captchatime', '600');"); + $db->exec("ALTER TABLE $C[prefix]sessions ADD ip tinytext NOT NULL;"); } if($dbversion<11){ - $db->exec("ALTER TABLE `$C[prefix]captcha` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]filter` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]ignored` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]members` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]messages` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]notes` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]sessions` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]settings` CHARACTER SET utf8 COLLATE utf8_bin"); - $db->exec("CREATE TABLE IF NOT EXISTS `$C[prefix]linkfilter` (`id` int(10) unsigned NOT NULL, `match` tinytext NOT NULL, `replace` tinytext NOT NULL, `regex` tinyint(1) unsigned NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin"); - $db->exec("ALTER TABLE `$C[prefix]linkfilter` ADD PRIMARY KEY (`id`), MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT"); - $db->exec("ALTER TABLE `$C[prefix]sessions` DROP `fontinfo`, DROP `displayname`"); - $db->exec("ALTER TABLE `$C[prefix]members` ADD `style` TEXT NOT NULL"); - $result=$db->query("SELECT * FROM `$C[prefix]members`"); - $stmt=$db->prepare("UPDATE `$C[prefix]members` SET `style`=? WHERE `id`=?"); + $db->exec("ALTER TABLE $C[prefix]captcha CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]filter CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]ignored CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]members CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]messages CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]notes CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]sessions CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]settings CHARACTER SET utf8 COLLATE utf8_bin;"); + $db->exec("CREATE TABLE IF NOT EXISTS $C[prefix]linkfilter (id int(10) unsigned NOT NULL, `match` tinytext NOT NULL, `replace` tinytext NOT NULL, regex tinyint(1) unsigned NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;"); + $db->exec("ALTER TABLE $C[prefix]linkfilter ADD PRIMARY KEY (id), MODIFY id int(10) unsigned NOT NULL AUTO_INCREMENT;"); + $db->exec("ALTER TABLE $C[prefix]sessions DROP fontinfo, DROP displayname;"); + $db->exec("ALTER TABLE $C[prefix]members ADD style TEXT NOT NULL;"); + $result=$db->query("SELECT * FROM $C[prefix]members;"); + $stmt=$db->prepare("UPDATE $C[prefix]members SET style=? WHERE id=?;"); while($temp=$result->fetch(PDO::FETCH_ASSOC)){ - $style=@get_style("#$temp[colour] {$F[$temp['fontface']]} <$temp[fonttags]>"); + if(isSet($F[$temp['fontface']])) $fontface=$F[$temp['fontface']]; + else $fontface=''; + $style=get_style("#$temp[colour] $fontface <$temp[fonttags]>"); $stmt->execute(array($style, $temp['id'])); } - $db->exec("ALTER TABLE `$C[prefix]members` DROP `colour`, DROP `fontface`, DROP `fonttags`;"); - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`, `value`) VALUES ('colbg', '000000'), ('coltxt', 'FFFFFF'), ('maxname', '20'), ('minpass', '5'), ('defaultrefresh', '20'), ('dismemcaptcha', '0'), ('suguests', '0'), ('imgembed', '1'), ('timestamps', '1'), ('trackip', '0'), ('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ('memkick', '1'), ('forceredirect', '0'), ('redirect', ''), ('incognito', '1')"); + $db->exec("ALTER TABLE $C[prefix]members DROP colour, DROP fontface, DROP fonttags;"); + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('colbg', '000000'), ('coltxt', 'FFFFFF'), ('maxname', '20'), ('minpass', '5'), ('defaultrefresh', '20'), ('dismemcaptcha', '0'), ('suguests', '0'), ('imgembed', '1'), ('timestamps', '1'), ('trackip', '0'), ('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ('memkick', '1'), ('forceredirect', '0'), ('redirect', ''), ('incognito', '1');"); } if($dbversion<12){ - $db->exec("ALTER TABLE `$C[prefix]captcha` MODIFY `code` char(5) NOT NULL, DROP INDEX `id`, ADD PRIMARY KEY (`id`) USING BTREE"); - $db->exec("ALTER TABLE `$C[prefix]captcha` ENGINE=MEMORY"); - $db->exec("ALTER TABLE `$C[prefix]filter` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT, MODIFY `match` varchar(255) NOT NULL, MODIFY `replace` varchar(20000) NOT NULL"); - $db->exec("ALTER TABLE `$C[prefix]ignored` MODIFY `ignored` varchar(50) NOT NULL, MODIFY `by` varchar(50) NOT NULL, ADD INDEX(`ignored`) USING BTREE, ADD INDEX(`by`) USING BTREE"); - $db->exec("ALTER TABLE `$C[prefix]linkfilter` MODIFY `match` varchar(255) NOT NULL, MODIFY `replace` varchar(255) NOT NULL"); - $db->exec("ALTER TABLE `$C[prefix]members` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT, MODIFY `nickname` varchar(50) NOT NULL, MODIFY `passhash` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `bgcolour` char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `boxwidth` tinyint(3) NOT NULL DEFAULT '40', MODIFY `boxheight` tinyint(3) NOT NULL DEFAULT '3', MODIFY `notesboxheight` tinyint(3) NOT NULL DEFAULT '30', MODIFY `notesboxwidth` tinyint(3) NOT NULL DEFAULT '80', MODIFY `regedby` varchar(50) NOT NULL, MODIFY `embed` tinyint(1) NOT NULL DEFAULT '1', MODIFY `incognito` tinyint(1) NOT NULL DEFAULT '0', MODIFY `style` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, ADD UNIQUE(`nickname`) USING BTREE"); - $db->exec("ALTER TABLE `$C[prefix]messages` MODIFY `poster` varchar(50) NOT NULL, MODIFY `recipient` varchar(50) NOT NULL, MODIFY `text` varchar(20000) NOT NULL, ADD INDEX(`poster`) USING BTREE, ADD INDEX(`recipient`) USING BTREE, ADD INDEX(`postdate`) USING BTREE, ADD INDEX(`poststatus`) USING BTREE"); - $db->exec("ALTER TABLE `$C[prefix]notes` MODIFY `type` char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `editedby` varchar(50) NOT NULL, MODIFY `text` varchar(20000) NOT NULL"); - $db->exec("ALTER TABLE `$C[prefix]sessions` MODIFY `session` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `nickname` varchar(50) NOT NULL, MODIFY `style` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `passhash` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `postid` char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '000000', MODIFY `boxwidth` tinyint(3) unsigned NOT NULL DEFAULT '40', MODIFY `boxheight` tinyint(3) unsigned NOT NULL DEFAULT '3', MODIFY `notesboxheight` tinyint(3) unsigned NOT NULL DEFAULT '30', MODIFY `notesboxwidth` tinyint(3) unsigned NOT NULL DEFAULT '80', MODIFY `bgcolour` char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `useragent` varchar(255) NOT NULL, MODIFY `kickmessage` varchar(255) NOT NULL, MODIFY `embed` tinyint(1) unsigned NOT NULL DEFAULT '1', MODIFY `incognito` tinyint(1) unsigned NOT NULL DEFAULT '0', MODIFY `ip` varchar(15) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, ADD UNIQUE(`session`) USING BTREE, ADD UNIQUE(`nickname`) USING BTREE, ADD INDEX(`status`) USING BTREE, ADD INDEX(`lastpost`) USING BTREE"); - $db->exec("ALTER TABLE `$C[prefix]sessions` ENGINE=MEMORY"); - $db->exec("ALTER TABLE `$C[prefix]settings` MODIFY `id` int(10) unsigned NOT NULL, MODIFY `setting` varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY `value` varchar(20000) NOT NULL"); - $db->exec("ALTER TABLE `$C[prefix]settings` DROP PRIMARY KEY, DROP `id`, ADD PRIMARY KEY(`setting`) USING BTREE"); - $db->exec("INSERT INTO `$C[prefix]settings` (`setting`,`value`) VALUES ('enablejs', '0'), ('chatname', 'My Chat'), ('topic', ''), ('msgsendall', '$I[sendallmsg]'), ('msgsendmem', '$I[sendmemmsg]'), ('msgsendmod', '$I[sendmodmsg]'), ('msgsendadm', '$I[sendadmmsg]'), ('msgsendprv', '$I[sendprvmsg]'), ('numnotes', '3')"); + $db->exec("ALTER TABLE $C[prefix]captcha MODIFY code char(5) NOT NULL, DROP INDEX id, ADD PRIMARY KEY (id) USING BTREE;"); + $db->exec("ALTER TABLE $C[prefix]captcha ENGINE=MEMORY;"); + $db->exec("ALTER TABLE $C[prefix]filter MODIFY id int(10) unsigned NOT NULL AUTO_INCREMENT, MODIFY `match` varchar(255) NOT NULL, MODIFY replace varchar(20000) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]ignored MODIFY ignored varchar(50) NOT NULL, MODIFY `by` varchar(50) NOT NULL, ADD INDEX(ignored) USING BTREE, ADD INDEX(`by`) USING BTREE;"); + $db->exec("ALTER TABLE $C[prefix]linkfilter MODIFY match varchar(255) NOT NULL, MODIFY replace varchar(255) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]members MODIFY id int(10) unsigned NOT NULL AUTO_INCREMENT, MODIFY nickname varchar(50) NOT NULL, MODIFY passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY boxwidth tinyint(3) NOT NULL DEFAULT '40', MODIFY boxheight tinyint(3) NOT NULL DEFAULT '3', MODIFY notesboxheight tinyint(3) NOT NULL DEFAULT '30', MODIFY notesboxwidth tinyint(3) NOT NULL DEFAULT '80', MODIFY regedby varchar(50) NOT NULL, MODIFY embed tinyint(1) NOT NULL DEFAULT '1', MODIFY incognito tinyint(1) NOT NULL DEFAULT '0', MODIFY style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, ADD UNIQUE(nickname) USING BTREE;"); + $db->exec("ALTER TABLE $C[prefix]messages MODIFY poster varchar(50) NOT NULL, MODIFY recipient varchar(50) NOT NULL, MODIFY text varchar(20000) NOT NULL, ADD INDEX(poster) USING BTREE, ADD INDEX(recipient) USING BTREE, ADD INDEX(postdate) USING BTREE, ADD INDEX(poststatus) USING BTREE;"); + $db->exec("ALTER TABLE $C[prefix]notes MODIFY type char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY editedby varchar(50) NOT NULL, MODIFY text varchar(20000) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]sessions MODIFY session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY nickname varchar(50) NOT NULL, MODIFY style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY postid char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '000000', MODIFY boxwidth tinyint(3) unsigned NOT NULL DEFAULT '40', MODIFY boxheight tinyint(3) unsigned NOT NULL DEFAULT '3', MODIFY notesboxheight tinyint(3) unsigned NOT NULL DEFAULT '30', MODIFY notesboxwidth tinyint(3) unsigned NOT NULL DEFAULT '80', MODIFY bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY useragent varchar(255) NOT NULL, MODIFY kickmessage varchar(255) NOT NULL, MODIFY embed tinyint(1) unsigned NOT NULL DEFAULT '1', MODIFY incognito tinyint(1) unsigned NOT NULL DEFAULT '0', MODIFY ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, ADD UNIQUE(session) USING BTREE, ADD UNIQUE(nickname) USING BTREE, ADD INDEX(status) USING BTREE, ADD INDEX(lastpost) USING BTREE;"); + $db->exec("ALTER TABLE $C[prefix]sessions ENGINE=MEMORY;"); + $db->exec("ALTER TABLE $C[prefix]settings MODIFY id int(10) unsigned NOT NULL, MODIFY setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY value varchar(20000) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]settings DROP PRIMARY KEY, DROP id, ADD PRIMARY KEY(setting) USING BTREE;"); + $db->exec("INSERT INTO $C[prefix]settings (setting, value) VALUES ('enablejs', '0'), ('chatname', 'My Chat'), ('topic', ''), ('msgsendall', '$I[sendallmsg]'), ('msgsendmem', '$I[sendmemmsg]'), ('msgsendmod', '$I[sendmodmsg]'), ('msgsendadm', '$I[sendadmmsg]'), ('msgsendprv', '$I[sendprvmsg]'), ('numnotes', '3');"); + } + if($dbversion<13){ + $db->exec("ALTER TABLE $C[prefix]filter CHANGE `match` filtermatch varchar(255) NOT NULL, CHANGE `replace` filterreplace varchar(20000) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]ignored CHANGE ignored ign varchar(50) NOT NULL, CHANGE `by` ignby varchar(50) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]linkfilter CHANGE `match` filtermatch varchar(255) NOT NULL, CHANGE `replace` filterreplace varchar(255) NOT NULL;"); + $db->exec("ALTER TABLE $C[prefix]sessions MODIFY ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL;"); } if(get_setting('msgencrypted')!=$C['msgencrypted']){ - $result=$db->query("SELECT `id`, `text` FROM `$C[prefix]messages`"); - $stmt=$db->prepare("UPDATE `$C[prefix]messages` SET `text`=? WHERE `id`=?"); + $result=$db->query("SELECT id, text FROM $C[prefix]messages;"); + $stmt=$db->prepare("UPDATE $C[prefix]messages SET text=? WHERE id=?;"); while($message=$result->fetch(PDO::FETCH_ASSOC)){ if($C['msgencrypted']) $message['text']=openssl_encrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); else $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); $stmt->execute(array($message['text'], $message['id'])); } - $result=$db->query("SELECT `id`, `text` FROM `$C[prefix]notes`"); - $stmt=$db->prepare("UPDATE `$C[prefix]notes` SET `text`=? WHERE `id`=?"); + $result=$db->query("SELECT id, text FROM $C[prefix]notes;"); + $stmt=$db->prepare("UPDATE $C[prefix]notes SET text=? WHERE id=?;"); while($message=$result->fetch(PDO::FETCH_ASSOC)){ if($C['msgencrypted']) $message['text']=openssl_encrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); else $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456'); @@ -2433,7 +2598,7 @@ function update_db(){ function get_setting($setting){ global $C, $db, $memcached; if(!$C['memcached'] || !$value=$memcached->get("$C[dbname]-$C[prefix]settings-$setting")){ - $stmt=$db->prepare("SELECT `value` FROM `$C[prefix]settings` WHERE `setting`=?"); + $stmt=$db->prepare("SELECT value FROM $C[prefix]settings WHERE setting=?;"); $stmt->execute(array($setting)); $stmt->bindColumn(1, $value); $stmt->fetch(PDO::FETCH_BOUND); @@ -2444,13 +2609,33 @@ function get_setting($setting){ function update_setting($setting, $value){ global $C, $db, $memcached; - $stmt=$db->prepare("UPDATE `$C[prefix]settings` SET `value`=? WHERE `setting`=?"); + $stmt=$db->prepare("UPDATE $C[prefix]settings SET value=? WHERE setting=?;"); $stmt->execute(array($value, $setting)); if($C['memcached']) $memcached->set("$C[dbname]-$C[prefix]settings-$setting", $value); } // configuration, defaults and internals +function check_db(){ + global $C, $I, $db, $memcached; + $options=array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>$C['persistent']); + try{ + if($C['dbdriver']===0) $db=new PDO("mysql:host=$C[dbhost];dbname=$C[dbname]", $C['dbuser'], $C['dbpass'], $options); + elseif($C['dbdriver']===1) $db=new PDO("pgsql:host=$C[dbhost];dbname=$C[dbname]", $C['dbuser'], $C['dbpass'], $options); + else $db=new PDO("sqlite:$C[sqlitedbfile]", NULL, NULL, $options); + }catch(PDOException $e){ + if(isSet($_REQUEST['action']) && $_REQUEST['action']==='setup'){ + die($I['nodbsetup']); + }else{ + die($I['nodb']); + } + } + if($C['memcached']){ + $memcached=new Memcached(); + $memcached->addServer($C['memcachedhost'], $C['memcachedport']); + } +} + function load_fonts(){ global $F; $F=array( @@ -2476,32 +2661,16 @@ function load_html(){ $H=array(// default HTML 'form' =>"form action=\"$_SERVER[SCRIPT_NAME]\" method=\"post\"", 'meta_html' =>"", - 'credit' =>"

LE CHAT-PHP - $C[version]
" + 'credit' =>"

LE CHAT-PHP - $C[version]
", + 'commonform' =>hidden('lang', $C['lang']) ); + if(isSet($_REQUEST['session'])) $H['commonform'].=hidden('session', $_REQUEST['session']); $H=$H+array( 'backtologin' =>"<$H[form] target=\"_parent\">".hidden('lang', $C['lang']).submit($I['backtologin'], 'class="backbutton"').'', - 'backtochat' =>"<$H[form]>".hidden('action', 'view').hidden('session', $_REQUEST['session']).hidden('lang', $C['lang']).submit($I['backtochat'], 'class="backbutton"').'' + 'backtochat' =>"<$H[form]>$H[commonform]".hidden('action', 'view').submit($I['backtochat'], 'class="backbutton"').'' ); } -function check_db(){ - global $C, $I, $db, $memcached; - $options=array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>$C['persistent']); - try{ - $db=new PDO("mysql:host=$C[dbhost];dbname=$C[dbname]", $C['dbuser'], $C['dbpass'], $options); - }catch(PDOException $e){ - if(isSet($_REQUEST['action']) && $_REQUEST['action']=='setup'){ - die($I['nodbsetup']); - }else{ - die($I['nodb']); - } - } - if($C['memcached']){ - $memcached=new Memcached(); - $memcached->addServer($C['memcachedhost'], $C['memcachedport']); - } -} - function load_lang(){ global $C, $I, $L; $L=array( @@ -2525,8 +2694,8 @@ function load_lang(){ function load_config(){ global $C; $C=array( - 'version' =>'1.13.1', // Script version - 'dbversion' =>12, // Database version + 'version' =>'1.14', // Script version + 'dbversion' =>13, // Database version 'keeplimit' =>3, // Amount of messages to keep in the database (multiplied with max messages displayed) - increase if you have many private messages 'msgencrypted' =>false, // Store messages encrypted in the database to prevent other database users from reading them - true/false - visit the setup page after editing! 'encryptkey' =>'MY_KEY', // Encryption key for messages @@ -2534,18 +2703,18 @@ function load_config(){ 'dbuser' =>'www-data', // Database user 'dbpass' =>'YOUR_DB_PASS', // Database password 'dbname' =>'public_chat', // Database - 'persistent' =>'true', // Use persistent database conection true/false - 'prefix' =>'', // Prefix - Set this to a unique value for every chat, if you have more than 1 chats on the same database or domain + 'persistent' =>true, // Use persistent database conection true/false + 'prefix' =>'', // Prefix - Set this to a unique value for every chat, if you have more than 1 chats on the same database or domain - use only alpha-numeric values (A-Z, a-z, 0-9, or _) other symbols might break the queries 'memcached' =>false, // Enable/disable memcached caching true/false - needs php5-memcached and a memcached server. 'memcachedhost' =>'localhost', // Memcached server 'memcachedport' =>'11211', // Memcached server 'sendmail' =>false, // Send mail on new message - only activate on low traffic chat or your inbox will fill up very fast! 'mailsender' =>'www-data ', // Send mail using this e-Mail address 'mailreceiver' =>'Webmaster ', // Send mail to this e-Mail address - 'lang' =>'en' // Default language - ); - $C=$C+array( - 'cookiename' =>"$C[prefix]chat_session" // Cookie name storing the session information + 'lang' =>'en', // Default language + 'dbdriver' =>0, // Selects the database driver to use - 0=MySQL, 1=PostgreSQL, 2=sqlite + 'sqlitedbfile' =>'public_chat.sqlite' // Filepath of the sqlite database, if sqlite is used - make sure it is writable for the webserver user ); + $C['cookiename']="$C[prefix]chat_session"; // Cookie name storing the session information } ?> diff --git a/lang_de.php b/lang_de.php index 41bac47..4cebe69 100644 --- a/lang_de.php +++ b/lang_de.php @@ -279,8 +279,7 @@ $T=array( 'chatname' => 'Chatname', 'destroy' => 'Chat zerstören', 'destroyed' => 'Chat erfolgreich zerstört', - 'topic' => 'Thema: %s', - 'admtopic' => 'Thema', + 'topic' => 'Thema', 'passreset' => 'Passwort zurücksetzen', 'cantresetpass' => 'Passwort kann nicht zurückgesetzt werden', 'succpassreset' => 'Password erfolgreich zurückgesetzt', diff --git a/lang_en.php b/lang_en.php index e094f1e..c9a06c3 100644 --- a/lang_en.php +++ b/lang_en.php @@ -20,8 +20,8 @@ //Language: English $I=array( - 'nodb' => 'No Connection to Database!', - 'nodbsetup' => 'No Connection to Database, please create a database and edit the script to use the correct database with given username and password!', + 'nodb' => 'No connection to database!', + 'nodbsetup' => 'No connection to database, please create a database and edit the script to use the correct database with given username and password!', 'changelang' => 'Change language:', 'expire' => 'Invalid/expired session', 'kicked' => 'Kicked!', @@ -280,8 +280,7 @@ $I=array( 'chatname' => 'Chat name', 'destroy' => 'Destroy chat', 'destroyed' => 'Successfully destroyed chat', - 'topic' => 'Topic: %s', - 'admtopic' => 'Topic', + 'topic' => 'Topic', 'passreset' => 'Reset password', 'cantresetpass' => 'Can\'t reset password', 'succpassreset' => 'Successfully reset password',