|
|
|
@ -47,9 +47,6 @@ if(!isset($_REQUEST['session']) && isset($_COOKIE[COOKIENAME])){
|
|
|
|
|
}
|
|
|
|
|
load_lang();
|
|
|
|
|
check_db();
|
|
|
|
|
if(!check_init()){
|
|
|
|
|
send_init();
|
|
|
|
|
}
|
|
|
|
|
cron();
|
|
|
|
|
route();
|
|
|
|
|
|
|
|
|
@ -57,7 +54,6 @@ route();
|
|
|
|
|
function route(){
|
|
|
|
|
global $U;
|
|
|
|
|
if(!isset($_REQUEST['action'])){
|
|
|
|
|
update_db();
|
|
|
|
|
send_login();
|
|
|
|
|
}elseif($_REQUEST['action']==='view'){
|
|
|
|
|
check_session();
|
|
|
|
@ -149,8 +145,6 @@ function route(){
|
|
|
|
|
send_admin(route_admin());
|
|
|
|
|
}elseif($_REQUEST['action']==='setup'){
|
|
|
|
|
route_setup();
|
|
|
|
|
}elseif($_REQUEST['action']==='init'){
|
|
|
|
|
init_chat();
|
|
|
|
|
}else{
|
|
|
|
|
send_login();
|
|
|
|
|
}
|
|
|
|
@ -225,7 +219,6 @@ function route_admin(){
|
|
|
|
|
|
|
|
|
|
function route_setup(){
|
|
|
|
|
global $U;
|
|
|
|
|
update_db();
|
|
|
|
|
if(!valid_admin()){
|
|
|
|
|
send_alogin();
|
|
|
|
|
}
|
|
|
|
@ -273,14 +266,15 @@ function print_stylesheet($init=false){
|
|
|
|
|
echo '.approve_waiting #action td:only-child,.help #backcredit,.login td:only-child,.alogin td:only-child,.init td:only-child{text-align:center;} .sessions td,.sessions th,.approve_waiting td,.approve_waiting th{padding: 5px;} ';
|
|
|
|
|
echo '.sessions td td{padding: 1px;} .messages #bottom_link{position:fixed;top:0.5em;right:0.5em;} .messages #top_link{position:fixed;bottom:0.5em;right:0.5em;} ';
|
|
|
|
|
echo '.post table,.controls table,.login table{border-spacing:0px;margin-left:auto;margin-right:auto;} .login table{border:2px solid;} .controls{overflow-y:none;} ';
|
|
|
|
|
echo '#manualrefresh{display:block;position:fixed;text-align:center;left:25%;width:50%;animation:timeout_messages ';
|
|
|
|
|
echo '#manualrefresh{display:block;position:fixed;text-align:center;left:25%;width:50%;top:-200%;animation:timeout_messages ';
|
|
|
|
|
if(isset($U['refresh'])){
|
|
|
|
|
echo $U['refresh']+20;
|
|
|
|
|
}else{
|
|
|
|
|
echo '160';
|
|
|
|
|
}
|
|
|
|
|
echo 's;z-index:2;background-color:#500000;border:2px solid #ff0000;} ';
|
|
|
|
|
echo '@keyframes timeout_messages{0%{top:-200%;} 99%{top:-200%;} 100%{top:0%;}}';
|
|
|
|
|
echo 's forwards;z-index:2;background-color:#500000;border:2px solid #ff0000;} ';
|
|
|
|
|
echo '@keyframes timeout_messages{0%{top:-200%;} 99%{top:-200%;} 100%{top:0%;}} ';
|
|
|
|
|
echo '.notes textarea{height:80vh;width:80%;}';
|
|
|
|
|
echo '</style>';
|
|
|
|
|
if($init){
|
|
|
|
|
return;
|
|
|
|
@ -753,7 +747,7 @@ function restore_backup($C){
|
|
|
|
|
if(isset($_REQUEST['members']) && isset($code['members'])){
|
|
|
|
|
$db->exec('DELETE FROM ' . PREFIX . 'inbox;');
|
|
|
|
|
$db->exec('DELETE FROM ' . PREFIX . 'members;');
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, notesboxwidth, notesboxheight, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
foreach($code['members'] as $member){
|
|
|
|
|
$new_settings=['nocache', 'tz', 'eninbox', 'sortupdown', 'hidechatters', 'nocache_old'];
|
|
|
|
|
foreach($new_settings as $setting){
|
|
|
|
@ -761,7 +755,7 @@ function restore_backup($C){
|
|
|
|
|
$member[$setting]=0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$stmt->execute([$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'], $member['nocache'], $member['tz'], $member['eninbox'], $member['sortupdown'], $member['hidechatters']]);
|
|
|
|
|
$stmt->execute([$member['nickname'], $member['passhash'], $member['status'], $member['refresh'], $member['bgcolour'], $member['regedby'], $member['lastlogin'], $member['timestamps'], $member['embed'], $member['incognito'], $member['style'], $member['nocache'], $member['tz'], $member['eninbox'], $member['sortupdown'], $member['hidechatters'], $member['nocache_old']]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isset($_REQUEST['notes']) && isset($code['notes'])){
|
|
|
|
@ -1575,14 +1569,11 @@ function send_notes($type){
|
|
|
|
|
}else{
|
|
|
|
|
$note['text']='';
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('SELECT notesboxwidth, notesboxheight FROM ' . PREFIX . 'members WHERE nickname=?;');
|
|
|
|
|
$stmt->execute([$U['nickname']]);
|
|
|
|
|
$settings=$stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
if(MSGENCRYPTED){
|
|
|
|
|
$note['text']=openssl_decrypt($note['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456');
|
|
|
|
|
}
|
|
|
|
|
echo "</p>".form('notes');
|
|
|
|
|
echo "$hiddendo<textarea name=\"text\" rows=\"$settings[notesboxheight]\" cols=\"$settings[notesboxwidth]\">".htmlspecialchars($note['text']).'</textarea><br>';
|
|
|
|
|
echo "$hiddendo<textarea name=\"text\">".htmlspecialchars($note['text']).'</textarea><br>';
|
|
|
|
|
echo submit($I['savenotes']).'</form><br>';
|
|
|
|
|
if($num[0]>1){
|
|
|
|
|
echo "<br><table><tr><td>$I[revisions]</td>";
|
|
|
|
@ -1718,9 +1709,9 @@ function send_post($rejected=''){
|
|
|
|
|
}
|
|
|
|
|
echo '<table><tr><td><table><tr id="firstline"><td>'.style_this(htmlspecialchars($U['nickname']), $U['style']).'</td><td>:</td>';
|
|
|
|
|
if(isset($_REQUEST['multi'])){
|
|
|
|
|
echo "<td><textarea name=\"message\" rows=\"$U[boxheight]\" cols=\"$U[boxwidth]\" style=\"$U[style]\" autofocus>$rejected</textarea></td>";
|
|
|
|
|
echo "<td><textarea name=\"message\" rows=\"3\" cols=\"40\" style=\"$U[style]\" autofocus>$rejected</textarea></td>";
|
|
|
|
|
}else{
|
|
|
|
|
echo "<td><input type=\"text\" name=\"message\" value=\"$rejected\" size=\"$U[boxwidth]\" style=\"$U[style]\" autofocus></td>";
|
|
|
|
|
echo "<td><input type=\"text\" name=\"message\" value=\"$rejected\" size=\"40\" style=\"$U[style]\" autofocus></td>";
|
|
|
|
|
}
|
|
|
|
|
echo '<td>'.submit($I['talkto']).'</td><td><select name="sendto" size="1">';
|
|
|
|
|
echo '<option ';
|
|
|
|
@ -1845,7 +1836,7 @@ function send_profile($arg=''){
|
|
|
|
|
echo form('profile', 'save')."<h2>$I[profile]</h2><i>$arg</i><table>";
|
|
|
|
|
thr();
|
|
|
|
|
$ignored=[];
|
|
|
|
|
$stmt=$db->prepare('SELECT ign FROM ' . PREFIX . 'ignored WHERE ignby=?;');
|
|
|
|
|
$stmt=$db->prepare('SELECT ign FROM ' . PREFIX . 'ignored WHERE ignby=? ORDER BY LOWER(ign);');
|
|
|
|
|
$stmt->execute([$U['nickname']]);
|
|
|
|
|
while($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
|
$ignored[]=htmlspecialchars($tmp['ign']);
|
|
|
|
@ -1861,7 +1852,7 @@ function send_profile($arg=''){
|
|
|
|
|
}
|
|
|
|
|
echo "<tr><td><table id=\"ignore\"><tr><th>$I[ignore]</th><td>";
|
|
|
|
|
echo "<select name=\"ignore\" size=\"1\"><option value=\"\">$I[choose]</option>";
|
|
|
|
|
$stmt=$db->prepare('SELECT poster, style FROM ' . PREFIX . 'messages INNER JOIN ' . PREFIX . 'sessions ON (' . PREFIX . 'messages.poster=' . PREFIX . 'sessions.nickname) WHERE poster!=? AND poster NOT IN (SELECT ign FROM ' . PREFIX . 'ignored WHERE ignby=?) GROUP BY poster;');
|
|
|
|
|
$stmt=$db->prepare('SELECT poster, style FROM ' . PREFIX . 'messages INNER JOIN (SELECT nickname, style FROM ' . PREFIX . 'sessions UNION SELECT nickname, style FROM ' . PREFIX . 'members) AS t ON (' . PREFIX . 'messages.poster=t.nickname) WHERE poster!=? AND poster NOT IN (SELECT ign FROM ' . PREFIX . 'ignored WHERE ignby=?) GROUP BY poster ORDER BY LOWER(poster);');
|
|
|
|
|
$stmt->execute([$U['nickname'], $U['nickname']]);
|
|
|
|
|
while($nick=$stmt->fetch(PDO::FETCH_NUM)){
|
|
|
|
|
echo '<option value="'.htmlspecialchars($nick[0])."\" style=\"$nick[1]\">".htmlspecialchars($nick[0]).'</option>';
|
|
|
|
@ -1960,21 +1951,6 @@ function send_profile($arg=''){
|
|
|
|
|
}
|
|
|
|
|
echo '</select></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
echo "<tr><td><table id=\"boxsize\"><tr><th>$I[pbsize]</th><td><table>";
|
|
|
|
|
echo "<tr><td> </td><td>$I[width]</td><td><input type=\"number\" name=\"boxwidth\" size=\"3\" maxlength=\"3\" value=\"$U[boxwidth]\"></td>";
|
|
|
|
|
echo "<td> </td><td>$I[height]</td><td><input type=\"number\" name=\"boxheight\" size=\"3\" maxlength=\"3\" value=\"$U[boxheight]\"></td>";
|
|
|
|
|
echo '</tr></table></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
if($U['status']>=5){
|
|
|
|
|
$stmt=$db->prepare('SELECT notesboxwidth, notesboxheight FROM ' . PREFIX . 'members WHERE nickname=?;');
|
|
|
|
|
$stmt->execute([$U['nickname']]);
|
|
|
|
|
$settings=$stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
echo "<tr><td><table id=\"notesboxsize\"><tr><th>$I[nbsize]</th><td><table>";
|
|
|
|
|
echo "<tr><td> </td><td>$I[width]</td><td><input type=\"number\" name=\"notesboxwidth\" size=\"3\" maxlength=\"3\" value=\"$settings[notesboxwidth]\"></td>";
|
|
|
|
|
echo "<td> </td><td>$I[height]</td><td><input type=\"number\" name=\"notesboxheight\" size=\"3\" maxlength=\"3\" value=\"$settings[notesboxheight]\"></td>";
|
|
|
|
|
echo '</tr></table></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
}
|
|
|
|
|
if($U['status']>=2){
|
|
|
|
|
echo "<tr><td><table id=\"changepass\"><tr><th>$I[changepass]</th></tr>";
|
|
|
|
|
echo '<tr><td><table>';
|
|
|
|
@ -2066,7 +2042,7 @@ function send_colours(){
|
|
|
|
|
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);
|
|
|
|
|
$hcol=sprintf('%02X%02X%02X', $red, $green, $blue);
|
|
|
|
|
echo "<span style=\"color:#$hcol\">$hcol</span> ";
|
|
|
|
|
}
|
|
|
|
|
echo '<br>';
|
|
|
|
@ -2214,7 +2190,7 @@ function create_session($setup, $nickname, $password){
|
|
|
|
|
add_user_defaults($password);
|
|
|
|
|
}
|
|
|
|
|
$U['entry']=$U['lastpost']=time();
|
|
|
|
|
if($setup){
|
|
|
|
|
if($setup && $U['status']>=7){
|
|
|
|
|
$U['incognito']=1;
|
|
|
|
|
}
|
|
|
|
|
$captcha=(int) get_setting('captcha');
|
|
|
|
@ -2298,8 +2274,8 @@ function write_new_session($password){
|
|
|
|
|
}else{
|
|
|
|
|
$ip='';
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'sessions (session, nickname, status, refresh, style, lastpost, passhash, boxwidth, boxheight, useragent, bgcolour, entry, timestamps, embed, incognito, ip, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt->execute([$U['session'], $U['nickname'], $U['status'], $U['refresh'], $U['style'], $U['lastpost'], $U['passhash'], $U['boxwidth'], $U['boxheight'], $useragent, $U['bgcolour'], $U['entry'], $U['timestamps'], $U['embed'], $U['incognito'], $ip, $U['nocache'], $U['tz'], $U['eninbox'], $U['sortupdown'], $U['hidechatters'], $U['nocache_old']]);
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'sessions (session, nickname, status, refresh, style, lastpost, passhash, useragent, bgcolour, entry, timestamps, embed, incognito, ip, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt->execute([$U['session'], $U['nickname'], $U['status'], $U['refresh'], $U['style'], $U['lastpost'], $U['passhash'], $useragent, $U['bgcolour'], $U['entry'], $U['timestamps'], $U['embed'], $U['incognito'], $ip, $U['nocache'], $U['tz'], $U['eninbox'], $U['sortupdown'], $U['hidechatters'], $U['nocache_old']]);
|
|
|
|
|
setcookie(COOKIENAME, $U['session']);
|
|
|
|
|
if($U['status']>=3 && !$U['incognito']){
|
|
|
|
|
add_system_message(sprintf(get_setting('msgenter'), style_this(htmlspecialchars($U['nickname']), $U['style'])));
|
|
|
|
@ -2566,8 +2542,8 @@ function register_guest($status, $nick){
|
|
|
|
|
}else{
|
|
|
|
|
return sprintf($I['cantreg'], htmlspecialchars($nick));
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, regedby, timestamps, embed, style, incognito, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt->execute([$reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['boxwidth'], $reg['boxheight'], $U['nickname'], $reg['timestamps'], $reg['embed'], $reg['style'], $reg['incognito'], $reg['nocache'], $reg['tz'], $reg['eninbox'], $reg['sortupdown'], $reg['hidechatters'], $reg['nocache_old']]);
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, regedby, timestamps, embed, style, incognito, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt->execute([$reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $U['nickname'], $reg['timestamps'], $reg['embed'], $reg['style'], $reg['incognito'], $reg['nocache'], $reg['tz'], $reg['eninbox'], $reg['sortupdown'], $reg['hidechatters'], $reg['nocache_old']]);
|
|
|
|
|
if($reg['status']==3){
|
|
|
|
|
add_system_message(sprintf(get_setting('msgmemreg'), style_this(htmlspecialchars($reg['nickname']), $reg['style'])));
|
|
|
|
|
}else{
|
|
|
|
@ -2705,22 +2681,6 @@ function amend_profile(){
|
|
|
|
|
$U['style'].='font-weight:bold;';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($_REQUEST['boxwidth']>0 && $_REQUEST['boxwidth']<1000){
|
|
|
|
|
$U['boxwidth']=$_REQUEST['boxwidth'];
|
|
|
|
|
}
|
|
|
|
|
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'];
|
|
|
|
|
}else{
|
|
|
|
|
$U['notesboxwidth']=80;
|
|
|
|
|
}
|
|
|
|
|
if(isset($_REQUEST['notesboxheight']) && $_REQUEST['notesboxheight']>0 && $_REQUEST['notesboxheight']<1000){
|
|
|
|
|
$U['notesboxheight']=$_REQUEST['notesboxheight'];
|
|
|
|
|
}else{
|
|
|
|
|
$U['notesboxheight']=30;
|
|
|
|
|
}
|
|
|
|
|
if($U['status']>=5 && isset($_REQUEST['incognito']) && get_setting('incognito')){
|
|
|
|
|
$U['incognito']=1;
|
|
|
|
|
}else{
|
|
|
|
@ -2748,18 +2708,18 @@ function amend_profile(){
|
|
|
|
|
function save_profile(){
|
|
|
|
|
global $I, $U, $db;
|
|
|
|
|
amend_profile();
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET refresh=?, style=?, boxwidth=?, boxheight=?, bgcolour=?, timestamps=?, embed=?, incognito=?, nocache=?, tz=?, eninbox=?, sortupdown=?, hidechatters=? WHERE session=?;');
|
|
|
|
|
$stmt->execute([$U['refresh'], $U['style'], $U['boxwidth'], $U['boxheight'], $U['bgcolour'], $U['timestamps'], $U['embed'], $U['incognito'], $U['nocache'], $U['tz'], $U['eninbox'], $U['sortupdown'], $U['hidechatters'], $U['session']]);
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET refresh=?, style=?, bgcolour=?, timestamps=?, embed=?, incognito=?, nocache=?, tz=?, eninbox=?, sortupdown=?, hidechatters=? WHERE session=?;');
|
|
|
|
|
$stmt->execute([$U['refresh'], $U['style'], $U['bgcolour'], $U['timestamps'], $U['embed'], $U['incognito'], $U['nocache'], $U['tz'], $U['eninbox'], $U['sortupdown'], $U['hidechatters'], $U['session']]);
|
|
|
|
|
if($U['status']>=2){
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'members SET refresh=?, bgcolour=?, boxwidth=?, boxheight=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=?, style=?, nocache=?, tz=?, eninbox=?, sortupdown=?, hidechatters=? WHERE nickname=?;');
|
|
|
|
|
$stmt->execute([$U['refresh'], $U['bgcolour'], $U['boxwidth'], $U['boxheight'], $U['notesboxwidth'], $U['notesboxheight'], $U['timestamps'], $U['embed'], $U['incognito'], $U['style'], $U['nocache'], $U['tz'], $U['eninbox'], $U['sortupdown'], $U['hidechatters'], $U['nickname']]);
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'members SET refresh=?, bgcolour=?, timestamps=?, embed=?, incognito=?, style=?, nocache=?, tz=?, eninbox=?, sortupdown=?, hidechatters=? WHERE nickname=?;');
|
|
|
|
|
$stmt->execute([$U['refresh'], $U['bgcolour'], $U['timestamps'], $U['embed'], $U['incognito'], $U['style'], $U['nocache'], $U['tz'], $U['eninbox'], $U['sortupdown'], $U['hidechatters'], $U['nickname']]);
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['unignore'])){
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'ignored WHERE ign=? AND ignby=?;');
|
|
|
|
|
$stmt->execute([$_REQUEST['unignore'], $U['nickname']]);
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['ignore'])){
|
|
|
|
|
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'sessions WHERE nickname=? AND nickname NOT IN (SELECT ign FROM ' . PREFIX . 'ignored WHERE ignby=?);');
|
|
|
|
|
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'messages WHERE poster=? AND poster NOT IN (SELECT ign FROM ' . PREFIX . 'ignored WHERE ignby=?);');
|
|
|
|
|
$stmt->execute([$_REQUEST['ignore'], $U['nickname']]);
|
|
|
|
|
if($U['nickname']!==$_REQUEST['ignore'] && $stmt->fetch(PDO::FETCH_NUM)){
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'ignored (ign, ignby) VALUES (?, ?);');
|
|
|
|
@ -2838,14 +2798,12 @@ function add_user_defaults($password){
|
|
|
|
|
$U['bgcolour']=get_setting('colbg');
|
|
|
|
|
if(!isset($_REQUEST['colour']) || !preg_match('/^[a-f0-9]{6}$/i', $_REQUEST['colour']) || abs(greyval($_REQUEST['colour'])-greyval(get_setting('colbg')))<75){
|
|
|
|
|
do{
|
|
|
|
|
$colour=sprintf('%02X', mt_rand(0, 256)).sprintf('%02X', mt_rand(0, 256)).sprintf('%02X', mt_rand(0, 256));
|
|
|
|
|
$colour=sprintf('%06X', mt_rand(0, 16581375));
|
|
|
|
|
}while(abs(greyval($colour)-greyval(get_setting('colbg')))<75);
|
|
|
|
|
}else{
|
|
|
|
|
$colour=$_REQUEST['colour'];
|
|
|
|
|
}
|
|
|
|
|
$U['style']="color:#$colour;";
|
|
|
|
|
$U['boxwidth']=40;
|
|
|
|
|
$U['boxheight']=3;
|
|
|
|
|
$U['timestamps']=get_setting('timestamps');
|
|
|
|
|
$U['embed']=1;
|
|
|
|
|
$U['incognito']=0;
|
|
|
|
@ -2925,8 +2883,8 @@ function validate_input(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($poststatus!==9 && preg_match('~^/me~iu', $message)){
|
|
|
|
|
$displaysend=style_this(htmlspecialchars($U['nickname']), $U['style']);
|
|
|
|
|
$message=preg_replace("~^/me~iu", '', $message);
|
|
|
|
|
$displaysend=style_this(htmlspecialchars("$U[nickname] "), $U['style']);
|
|
|
|
|
$message=preg_replace("~^/me\s?~iu", '', $message);
|
|
|
|
|
}
|
|
|
|
|
$message=apply_filter($message, $poststatus, $U['nickname']);
|
|
|
|
|
$message=create_hotlinks($message);
|
|
|
|
@ -3459,6 +3417,7 @@ function cron(){
|
|
|
|
|
if(get_setting('nextcron')>$time){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
update_setting('nextcron', $time+10);
|
|
|
|
|
// delete old sessions
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'sessions WHERE (status<=2 AND lastpost<(?-60*(SELECT value FROM ' . PREFIX . "settings WHERE setting='guestexpire'))) OR (status>2 AND lastpost<(?-60*(SELECT value FROM " . PREFIX . "settings WHERE setting='memberexpire')));");
|
|
|
|
|
$stmt->execute([$time, $time]);
|
|
|
|
@ -3472,9 +3431,17 @@ function cron(){
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'messages WHERE id IN (SELECT * FROM (SELECT id FROM ' . PREFIX . 'messages WHERE postdate<(?-60*(SELECT value FROM ' . PREFIX . "settings WHERE setting='messageexpire'))) AS t);");
|
|
|
|
|
$stmt->execute([$time]);
|
|
|
|
|
// delete expired ignored people
|
|
|
|
|
$db->exec('DELETE FROM ' . PREFIX . 'ignored WHERE ign NOT IN (SELECT nickname FROM ' . PREFIX . 'sessions UNION SELECT nickname FROM ' . PREFIX . 'members UNION SELECT poster FROM ' . PREFIX . 'messages) OR ignby NOT IN (SELECT nickname FROM ' . PREFIX . 'sessions UNION SELECT nickname FROM ' . PREFIX . 'members UNION SELECT poster FROM ' . PREFIX . 'messages);');
|
|
|
|
|
$result=$db->query('SELECT id FROM ' . PREFIX . 'ignored WHERE ign NOT IN (SELECT nickname FROM ' . PREFIX . 'sessions UNION SELECT nickname FROM ' . PREFIX . 'members UNION SELECT poster FROM ' . PREFIX . 'messages) OR ignby NOT IN (SELECT nickname FROM ' . PREFIX . 'sessions UNION SELECT nickname FROM ' . PREFIX . 'members UNION SELECT poster FROM ' . PREFIX . 'messages);');
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'ignored WHERE id=?;');
|
|
|
|
|
while($tmp=$result->fetch(PDO::FETCH_NUM)){
|
|
|
|
|
$stmt->execute($tmp);
|
|
|
|
|
}
|
|
|
|
|
// delete files that do not belong to any message
|
|
|
|
|
$db->exec('DELETE FROM ' . PREFIX . 'files WHERE postid NOT IN (SELECT id FROM ' . PREFIX . 'messages UNION SELECT postid FROM ' . PREFIX . 'inbox);');
|
|
|
|
|
$result=$db->query('SELECT id FROM ' . PREFIX . 'files WHERE postid NOT IN (SELECT id FROM ' . PREFIX . 'messages UNION SELECT postid FROM ' . PREFIX . 'inbox);');
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'files WHERE id=?;');
|
|
|
|
|
while($tmp=$result->fetch(PDO::FETCH_NUM)){
|
|
|
|
|
$stmt->execute($tmp);
|
|
|
|
|
}
|
|
|
|
|
// delete old notes
|
|
|
|
|
$limit=get_setting('numnotes');
|
|
|
|
|
$db->exec('DELETE FROM ' . PREFIX . 'notes WHERE type!=2 AND id NOT IN (SELECT * FROM ( (SELECT id FROM ' . PREFIX . "notes WHERE type=0 ORDER BY id DESC LIMIT $limit) UNION (SELECT id FROM " . PREFIX . "notes WHERE type=1 ORDER BY id DESC LIMIT $limit) ) AS t);");
|
|
|
|
@ -3483,7 +3450,6 @@ function cron(){
|
|
|
|
|
while($tmp=$result->fetch(PDO::FETCH_NUM)){
|
|
|
|
|
$stmt->execute([$tmp[0], $tmp[0]]);
|
|
|
|
|
}
|
|
|
|
|
update_setting('nextcron', $time+10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function destroy_chat($C){
|
|
|
|
@ -3565,7 +3531,7 @@ function init_chat(){
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'inbox_poster ON ' . PREFIX . 'inbox(poster);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'inbox_recipient ON ' . PREFIX . 'inbox(recipient);');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "linkfilter (id $primary, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex smallint NOT NULL)$diskengine$charset;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id $primary, nickname varchar(50) NOT NULL UNIQUE, passhash varchar(255) 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 NOT NULL, incognito smallint NOT NULL, style varchar(255) NOT NULL, nocache smallint NOT NULL, tz varchar(255) NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL, nocache_old smallint NOT NULL)$diskengine$charset;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id $primary, nickname varchar(50) NOT NULL UNIQUE, passhash varchar(255) NOT NULL, status smallint NOT NULL, refresh smallint NOT NULL, bgcolour char(6) NOT NULL, regedby varchar(50) DEFAULT '', lastlogin integer DEFAULT 0, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, style varchar(255) NOT NULL, nocache smallint NOT NULL, tz varchar(255) NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL, nocache_old smallint NOT NULL)$diskengine$charset;");
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'inbox ADD FOREIGN KEY (recipient) REFERENCES ' . PREFIX . 'members(nickname) ON DELETE CASCADE ON UPDATE CASCADE;');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "messages (id $primary, postdate integer NOT NULL, poststatus smallint NOT NULL, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text text NOT NULL, delstatus smallint NOT NULL)$diskengine$charset;");
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'poster ON ' . PREFIX . 'messages (poster);');
|
|
|
|
@ -3575,7 +3541,7 @@ function init_chat(){
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "notes (id $primary, type smallint NOT NULL, lastedited integer NOT NULL, editedby varchar(50) NOT NULL, text text NOT NULL)$diskengine$charset;");
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'notes_type ON ' . PREFIX . 'notes(type);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'notes_editedby ON ' . PREFIX . 'notes(editedby);');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "sessions (id $primary, 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 varchar(255) 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 NOT NULL, incognito smallint NOT NULL, ip varchar(45) NOT NULL, nocache smallint NOT NULL, tz varchar(255) NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL, nocache_old smallint NOT NULL)$memengine$charset;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "sessions (id $primary, 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 varchar(255) NOT NULL, postid char(6) NOT NULL DEFAULT '000000', useragent varchar(255) NOT NULL, kickmessage varchar(255) DEFAULT '', bgcolour char(6) NOT NULL, entry integer NOT NULL, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, ip varchar(45) NOT NULL, nocache smallint NOT NULL, tz varchar(255) NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL, nocache_old smallint NOT NULL)$memengine$charset;");
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'status ON ' . PREFIX . 'sessions(status);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'lastpost ON ' . PREFIX . 'sessions(lastpost);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'incognito ON ' . PREFIX . 'sessions(incognito);');
|
|
|
|
@ -3667,7 +3633,7 @@ function init_chat(){
|
|
|
|
|
'incognito' =>0,
|
|
|
|
|
'nocache' =>0,
|
|
|
|
|
'nocache_old' =>1,
|
|
|
|
|
'tz' =>0,
|
|
|
|
|
'tz' =>'UTC',
|
|
|
|
|
'eninbox' =>0,
|
|
|
|
|
'sortupdown' =>0,
|
|
|
|
|
'hidechatters' =>0,
|
|
|
|
@ -3753,7 +3719,6 @@ function update_db(){
|
|
|
|
|
$db->exec('ALTER TABLE ' , PREFIX . 'captcha CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'filter CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'ignored CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'messages CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'notes CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'settings CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
@ -3775,7 +3740,6 @@ function update_db(){
|
|
|
|
|
}
|
|
|
|
|
$stmt->execute([$style, $temp['id']]);
|
|
|
|
|
}
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members DROP colour, DROP fontface, DROP fonttags;');
|
|
|
|
|
$db->exec('INSERT INTO ' . 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){
|
|
|
|
@ -3784,7 +3748,6 @@ function update_db(){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'filter MODIFY id integer unsigned NOT NULL AUTO_INCREMENT, MODIFY `match` varchar(255) NOT NULL, MODIFY replace varchar(20000) NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'ignored MODIFY ignored varchar(50) NOT NULL, MODIFY `by` varchar(50) NOT NULL, ADD INDEX(ignored), ADD INDEX(`by`);');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'linkfilter MODIFY match varchar(255) NOT NULL, MODIFY replace varchar(255) NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . "members MODIFY id integer unsigned NOT NULL AUTO_INCREMENT, MODIFY nickname varchar(50) NOT NULL UNIQUE, 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 smallint NOT NULL DEFAULT 40, MODIFY boxheight smallint NOT NULL DEFAULT 3, MODIFY notesboxheight smallint NOT NULL DEFAULT 30, MODIFY notesboxwidth smallint NOT NULL DEFAULT 80, MODIFY regedby varchar(50) NOT NULL, MODIFY embed smallint NOT NULL DEFAULT 1, MODIFY incognito smallint NOT NULL DEFAULT 0, MODIFY style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL;");
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'messages MODIFY poster varchar(50) NOT NULL, MODIFY recipient varchar(50) NOT NULL, MODIFY text varchar(20000) NOT NULL, ADD INDEX(poster), ADD INDEX(recipient), ADD INDEX(postdate), ADD INDEX(poststatus);');
|
|
|
|
|
$db->exec('ALTER TABLE ' . 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 ' . PREFIX . 'settings MODIFY id integer unsigned NOT NULL, MODIFY setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY value varchar(20000) NOT NULL;');
|
|
|
|
@ -3907,11 +3870,11 @@ function update_db(){
|
|
|
|
|
foreach($data as $tmp){
|
|
|
|
|
$stmt->execute($tmp);
|
|
|
|
|
}
|
|
|
|
|
$result=$olddb->query('SELECT nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, notesboxwidth, notesboxheight, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz, eninbox, sortupdown, hidechatters FROM ' . PREFIX . 'members;');
|
|
|
|
|
$result=$olddb->query('SELECT nickname, passhash, status, refresh, bgcolour, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz, eninbox, sortupdown, hidechatters FROM ' . PREFIX . 'members;');
|
|
|
|
|
$data=$result->fetchAll(PDO::FETCH_NUM);
|
|
|
|
|
$db->exec('DROP TABLE ' . PREFIX . 'members;');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id integer PRIMARY KEY AUTO_INCREMENT, 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 NOT NULL, incognito smallint NOT NULL, style varchar(255) NOT NULL, nocache smallint NOT NULL, tz smallint NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, notesboxwidth, notesboxheight, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz, eninbox, sortupdown, hidechatters) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id integer PRIMARY KEY AUTO_INCREMENT, nickname varchar(50) NOT NULL UNIQUE, passhash char(32) NOT NULL, status smallint NOT NULL, refresh smallint NOT NULL, bgcolour char(6) NOT NULL, regedby varchar(50) DEFAULT '', lastlogin integer DEFAULT 0, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, style varchar(255) NOT NULL, nocache smallint NOT NULL, tz smallint NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz, eninbox, sortupdown, hidechatters) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
foreach($data as $tmp){
|
|
|
|
|
$stmt->execute($tmp);
|
|
|
|
|
}
|
|
|
|
@ -3951,25 +3914,11 @@ function update_db(){
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<34){
|
|
|
|
|
$msg.="<br>$I[cssupdate]";
|
|
|
|
|
$db->exec('DROP TABLE ' . PREFIX . 'sessions;');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "sessions (id integer PRIMARY KEY AUTO_INCREMENT, 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, entry integer NOT NULL, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, ip varchar(45) NOT NULL, nocache smallint NOT NULL, nocache_old smallint NOT NULL, tz smallint NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL)$memengine$charset;");
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'status ON ' . PREFIX . 'sessions(status);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'lastpost ON ' . PREFIX . 'sessions(lastpost);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'incognito ON ' . PREFIX . 'sessions(incognito);');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD COLUMN nocache_old smallint NOT NULL DEFAULT 0;');
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<35){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'inbox ADD FOREIGN KEY (recipient) REFERENCES ' . PREFIX . 'members(nickname) ON DELETE CASCADE ON UPDATE CASCADE;');
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<36){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members MODIFY passhash varchar(255) NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions MODIFY passhash varchar(255) NOT NULL;');
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<37){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members MODIFY tz varchar(255) NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions MODIFY tz varchar(255) NOT NULL;');
|
|
|
|
|
$db->exec('UPDATE ' . PREFIX . "members SET tz='UTC';");
|
|
|
|
|
$db->exec('UPDATE ' . PREFIX . "sessions SET tz='UTC';");
|
|
|
|
|
$db->exec('UPDATE ' . PREFIX . "settings SET value='UTC' WHERE setting='defaulttz';");
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<38){
|
|
|
|
@ -3998,6 +3947,32 @@ function update_db(){
|
|
|
|
|
if($dbversion<40){
|
|
|
|
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('filtermodkick', '1');");
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<41){
|
|
|
|
|
$db->exec('DROP TABLE ' . PREFIX . 'sessions;');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "sessions (id $primary, 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 varchar(255) NOT NULL, postid char(6) NOT NULL DEFAULT '000000', useragent varchar(255) NOT NULL, kickmessage varchar(255) DEFAULT '', bgcolour char(6) NOT NULL, entry integer NOT NULL, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, ip varchar(45) NOT NULL, nocache smallint NOT NULL, tz varchar(255) NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL, nocache_old smallint NOT NULL)$memengine$charset;");
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'status ON ' . PREFIX . 'sessions(status);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'lastpost ON ' . PREFIX . 'sessions(lastpost);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'incognito ON ' . PREFIX . 'sessions(incognito);');
|
|
|
|
|
$result=$db->query('SELECT nickname, passhash, status, refresh, bgcolour, regedby, lastlogin, timestamps, embed, incognito, style, nocache, nocache_old, tz, eninbox, sortupdown, hidechatters FROM ' . PREFIX . 'members;');
|
|
|
|
|
$members=$result->fetchAll(PDO::FETCH_NUM);
|
|
|
|
|
$result=$db->query('SELECT postdate, postid, poster, recipient, text FROM ' . PREFIX . 'inbox;');
|
|
|
|
|
$inbox=$result->fetchAll(PDO::FETCH_NUM);
|
|
|
|
|
$db->exec('DROP TABLE ' . PREFIX . 'inbox;');
|
|
|
|
|
$db->exec('DROP TABLE ' . PREFIX . 'members;');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id $primary, nickname varchar(50) NOT NULL UNIQUE, passhash varchar(255) NOT NULL, status smallint NOT NULL, refresh smallint NOT NULL, bgcolour char(6) NOT NULL, regedby varchar(50) DEFAULT '', lastlogin integer DEFAULT 0, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, style varchar(255) NOT NULL, nocache smallint NOT NULL, nocache_old smallint NOT NULL, tz varchar(255) NOT NULL, eninbox smallint NOT NULL, sortupdown smallint NOT NULL, hidechatters smallint NOT NULL)$diskengine$charset");
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, regedby, lastlogin, timestamps, embed, incognito, style, nocache, nocache_old, tz, eninbox, sortupdown, hidechatters) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
foreach($members as $tmp){
|
|
|
|
|
$stmt->execute($tmp);
|
|
|
|
|
}
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "inbox (id $primary, postdate integer NOT NULL, postid integer NOT NULL UNIQUE, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text text NOT NULL)$diskengine$charset;");
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'inbox (postdate, postid, poster, recipient, text) VALUES(?, ?, ?, ?, ?);');
|
|
|
|
|
foreach($inbox as $tmp){
|
|
|
|
|
$stmt->execute($tmp);
|
|
|
|
|
}
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'inbox_poster ON ' . PREFIX . 'inbox(poster);');
|
|
|
|
|
$db->exec('CREATE INDEX ' . PREFIX . 'inbox_recipient ON ' . PREFIX . 'inbox(recipient);');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'inbox ADD FOREIGN KEY (recipient) REFERENCES ' . PREFIX . 'members(nickname) ON DELETE CASCADE ON UPDATE CASCADE;');
|
|
|
|
|
}
|
|
|
|
|
update_setting('dbversion', DBVERSION);
|
|
|
|
|
if($msgencrypted!==MSGENCRYPTED){
|
|
|
|
|
if(!extension_loaded('openssl')){
|
|
|
|
@ -4113,6 +4088,14 @@ function check_db(){
|
|
|
|
|
$memcached=new Memcached();
|
|
|
|
|
$memcached->addServer(MEMCACHEDHOST, MEMCACHEDPORT);
|
|
|
|
|
}
|
|
|
|
|
if(!isset($_REQUEST['action']) || $_REQUEST['action']==='setup'){
|
|
|
|
|
if(!check_init()){
|
|
|
|
|
send_init();
|
|
|
|
|
}
|
|
|
|
|
}elseif($_REQUEST['action']==='init'){
|
|
|
|
|
init_chat();
|
|
|
|
|
}
|
|
|
|
|
update_db();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function load_fonts(){
|
|
|
|
@ -4167,8 +4150,8 @@ function load_lang(){
|
|
|
|
|
|
|
|
|
|
function load_config(){
|
|
|
|
|
mb_internal_encoding('UTF-8');
|
|
|
|
|
define('VERSION', '1.23'); // Script version
|
|
|
|
|
define('DBVERSION', 40); // Database layout version
|
|
|
|
|
define('VERSION', '1.23.4'); // Script version
|
|
|
|
|
define('DBVERSION', 41); // Database layout version
|
|
|
|
|
define('MSGENCRYPTED', false); // Store messages encrypted in the database to prevent other database users from reading them - true/false - visit the setup page after editing!
|
|
|
|
|
define('ENCRYPTKEY', 'MY_KEY'); // Encryption key for messages
|
|
|
|
|
define('DBHOST', 'localhost'); // Database host
|
|
|
|
|