diff --git a/CHANGELOG b/CHANGELOG
index 1c3d678..a2dbb79 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,12 @@
+Version 1.13 - Sep. 15, 2015
+Switch from mysqli to PDO
+More optimizations
+Match case-insensitive @mention and also non-present members
+Added topic field
+Member password resetting by admins
+Note revisioning
+Added optional tiny JavaScript code to transfer less data with JavaScript enabled browsers
+
Version 1.12.3 - Aug. 18, 2015
Fix member registration
diff --git a/README b/README
index b95bfe0..b6fb262 100644
--- a/README
+++ b/README
@@ -29,7 +29,7 @@ It may even be the French word for "the" if you prefer. Translated from French t
FEATURES:
Optimized for TOR
-No JavaScript
+No JavaScript needed
Cookies supported, but not needed
Captcha
Multiple languages
@@ -54,6 +54,7 @@ And more
INSTALLATION INSTRUCTIONS:
You'll need to have mysql, php and a web-server installed. For the captcha feature, you also need php5-gd.
+If you want to make the script even faster, install a memcached server and php5-memcached and change the configuaration to use memcached. This will lessen the database load.
When you have everything installed, you'll have to create a database and a user for the chat in mysql.
Then edit the configuration at the bottom of the script to reflect the appropriate database settings and to modify the chat settings the way you like them.
Then copy the script to your web-server directory and call the script in your browser with a parameter like this:
@@ -65,7 +66,7 @@ Note: If you updated the script, please visit http://(server)/(script-name).php?
TRANSLATING:
Copy lang_en.php and rename it to lang_YOUR_LANGCODE.php
-Then edit the file and translate the messages into your language.
+Then edit the file and translate the messages into your language and change $I to $T at the top.
If you ever use a ' character, you have to escape it by using \' instead or the script will fail.
When you are done, you have to edit the chat script, to include your translation. Simply add a line with
'lang_code' =>'Language name',
diff --git a/README.md b/README.md
index 8b498ce..0afbe94 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Features:
---------
* Optimized for TOR
-* No JavaScript
+* No JavaScript needed
* Cookies supported, but not needed
* Captcha
* Multiple languages
@@ -39,6 +39,7 @@ Installation Instructions:
--------------------------
You'll need to have mysql, php and a web-server installed. For the captcha feature, you also need php5-gd.
+If you want to make the script even faster, install a memcached server and php5-memcached and change the configuaration to use memcached. This will lessen the database load.
When you have everything installed, you'll have to create a database and a user for the chat in mysql.
Then edit the configuration at the bottom of the script to reflect the appropriate database settings and to modify the chat settings the way you like them.
Then copy the script to your web-server directory and call the script in your browser with a parameter like this:
@@ -51,7 +52,7 @@ Translating:
------------
Copy lang_en.php and rename it to lang_YOUR_LANGCODE.php
-Then edit the file and translate the messages into your language.
+Then edit the file and translate the messages into your language and change $I to $T at the top.
If you ever use a ' character, you have to escape it by using \' instead or the script will fail.
When you are done, you have to edit the chat script, to include your translation. Simply add a line with
'lang_code' =>'Language name',
diff --git a/chat.php b/chat.php
index a9ecb18..2701c2b 100755
--- a/chat.php
+++ b/chat.php
@@ -31,14 +31,14 @@ $M=array();// Members: display names
$P=array();// All present users
$U=array();// This user data
$countmods=0;// Present moderators
+$db;// Database connection
$memcached;// Memcached connection
-$mysqli;// MySQL database connection
load_config();
// set session variable to cookie if cookies are enabled
-if(!isSet($_REQUEST['session']) && isSet($_COOKIE[$C['cookiename']])){
- $_REQUEST['session']=$_COOKIE[$C['cookiename']];
+if(!isSet($_REQUEST['session'])){
+ if(isSet($_COOKIE[$C['cookiename']])) $_REQUEST['session']=$_COOKIE[$C['cookiename']];
+ else $_REQUEST['session']='';
}
-elseif(!isSet($_REQUEST['session'])) $_REQUEST['session']='';
load_fonts();
load_lang();
load_html();
@@ -46,11 +46,25 @@ check_db();
// main program: decide what to do based on queries
if(!isSet($_REQUEST['action'])){
- if(check_init()<7) send_init();
+ if(!check_init()) send_init();
send_login();
}elseif($_REQUEST['action']=='view'){
check_session();
- send_messages();
+ send_messages(false);
+}elseif($_REQUEST['action']=='jsview'){
+ check_session();
+ send_messages(true);
+}elseif($_REQUEST['action']=='jsrefresh'){
+ check_session();
+ ob_start();
+ print_messages();
+ $msgs=ob_get_clean();
+ 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'])){
send_redirect();
}elseif($_REQUEST['action']=='wait'){
@@ -92,46 +106,35 @@ if(!isSet($_REQUEST['action'])){
send_colours();
}elseif($_REQUEST['action']=='notes'){
check_session();
+ 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'){
check_session();
send_help();
-}elseif($_REQUEST['action']=='admnotes'){
- check_session();
- if($U['status']<6) send_login();
- send_notes('admin');
}elseif($_REQUEST['action']=='admin'){
check_session();
if($U['status']<5) send_login();
- if(!isSet($_REQUEST['do'])){
- send_admin();
+ 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);
- send_admin();
}elseif($_REQUEST['do']=='kick'){
if(!isSet($_REQUEST['name'])) send_admin();
if(isSet($_REQUEST['what']) && $_REQUEST['what']=='purge') kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], true);
else kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], false);
- send_admin();
}elseif($_REQUEST['do']=='logout'){
if(!isSet($_REQUEST['name'])) send_admin();
logout_chatter($_REQUEST['name']);
- send_admin();
}elseif($_REQUEST['do']=='sessions'){
if(isSet($_REQUEST['nick'])) kick_chatter(array($_REQUEST['nick']), '', false);
send_sessions();
}elseif($_REQUEST['do']=='register'){
register_guest(3);
- check_session();
- send_admin();
}elseif($_REQUEST['do']=='superguest'){
register_guest(2);
- check_session();
- send_admin();
}elseif($_REQUEST['do']=='status'){
change_status();
}elseif($_REQUEST['do']=='regnew'){
@@ -149,28 +152,51 @@ if(!isSet($_REQUEST['action'])){
}elseif($_REQUEST['do']=='linkfilter'){
manage_linkfilter();
send_linkfilter();
+ }elseif($_REQUEST['do']=='topic'){
+ if(isSet($_REQUEST['topic'])) update_setting('topic', htmlspecialchars($_REQUEST['topic']));
+ }elseif($_REQUEST['do']=='passreset'){
+ passreset();
}
send_admin();
}elseif($_REQUEST['action']=='setup'){
- if(check_init()<7) send_init();
+ if(!check_init()) send_init();
update_db();
if(!valid_admin()) send_alogin();
- $settings=array('guestaccess', 'englobalpass', 'globalpass', 'msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'dateformat', 'captcha', 'colbg', 'coltxt', 'css', 'memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'dismemcaptcha', 'suguests', 'imgembed', 'timestamps', 'trackip', 'captchachars', 'memkick', 'forceredirect', 'redirect', 'incognito', 'rulestxt');
- if(!isSet($_REQUEST['do'])){
+ $C['bool_settings']=array('suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'enablejs');
+ $C['colour_settings']=array('colbg', 'coltxt');
+ $C['msg_settings']=array('msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'msgsendall', 'msgsendmem', 'msgsendmod', 'msgsendadm', 'msgsendprv');
+ $C['number_settings']=array('memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes');
+ $C['textarea_settings']=array('rulestxt', 'css');
+ $C['text_settings']=array('dateformat', 'captchachars', 'redirect', 'chatname');
+ $C['settings']=array('guestaccess', 'englobalpass', 'globalpass', 'captcha', 'dismemcaptcha', 'topic')+$C['bool_settings']+$C['colour_settings']+$C['msg_settings']+$C['number_settings']+$C['text_settings']; // All settings in the database
+ if(empty($_REQUEST['do'])){
+ }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']);
+ $_REQUEST['chatname']=htmlspecialchars($_REQUEST['chatname']);
+ if(!preg_match('/^[a-f0-9]{6}$/i', $_REQUEST['colbg'])) unset($_REQUEST['colbg']);
+ if(!preg_match('/^[a-f0-9]{6}$/i', $_REQUEST['coltxt'])) unset($_REQUEST['coltxt']);
+ if($_REQUEST['memberexpire']<5) $_REQUEST['memberexpire']=5;
+ if($_REQUEST['captchatime']<30) $_REQUEST['memberexpire']=30;
+ if($_REQUEST['defaultrefresh']<5) $_REQUEST['defaultrefresh']=5;
+ elseif($_REQUEST['defaultrefresh']>150) $_REQUEST['defaultrefresh']=150;
+ if($_REQUEST['maxname']<1) $_REQUEST['maxname']=1;
+ elseif($_REQUEST['maxname']>50) $_REQUEST['maxname']=50;
+ if($_REQUEST['maxmessage']<1) $_REQUEST['maxmessage']=1;
+ elseif($_REQUEST['maxmessage']>20000) $_REQUEST['maxmessage']=20000;
+ if($_REQUEST['numnotes']<1) $_REQUEST['numnotes']=1;
+ foreach($C['settings'] as $setting){
+ if(isSet($_REQUEST[$setting])) update_setting($setting, $_REQUEST[$setting]);
+ }
}elseif($_REQUEST['do']=='backup' && $U['status']==8){
send_backup();
}elseif($_REQUEST['do']=='restore' && $U['status']==8){
restore_backup();
send_backup();
- }elseif($_REQUEST['do']=='save'){
- $_REQUEST['rulestxt']=preg_replace("/(\r?\n|\r\n?)/", '
', $_REQUEST['rulestxt']);
- if($_REQUEST['memberexpire']<5) $_REQUEST['memberexpire']=5;
- if($_REQUEST['captchatime']<30) $_REQUEST['memberexpire']=30;
- if($_REQUEST['defaultrefresh']<5) $_REQUEST['defaultrefresh']=5;
- if($_REQUEST['defaultrefresh']>150) $_REQUEST['defaultrefresh']=150;
- foreach($settings as $setting){
- if(isSet($_REQUEST[$setting])) update_setting($setting, $_REQUEST[$setting]);
- }
+ }elseif($_REQUEST['do']=='destroy' && $U['status']==8){
+ if(isSet($_REQUEST['confirm'])) destroy_chat();
+ else send_destroy_chat();
}
send_setup();
}elseif($_REQUEST['action']=='init'){
@@ -178,7 +204,6 @@ if(!isSet($_REQUEST['action'])){
}else{
send_login();
}
-mysqli_close($mysqli);
exit;
// html output subs
@@ -190,9 +215,7 @@ function print_stylesheet(){
}
function print_end(){
- global $mysqli;
echo '