|
|
|
@ -209,7 +209,7 @@ function route_setup(){
|
|
|
|
|
$C['number_settings']=array('memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'keeplimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes');
|
|
|
|
|
$C['textarea_settings']=array('rulestxt', 'css', 'disabletext');
|
|
|
|
|
$C['text_settings']=array('dateformat', 'captchachars', 'redirect', 'chatname', 'mailsender', 'mailreceiver');
|
|
|
|
|
$C['settings']=array_merge(array('guestaccess', 'englobalpass', 'globalpass', 'captcha', 'dismemcaptcha', 'topic', 'guestreg'), $C['bool_settings'], $C['colour_settings'], $C['msg_settings'], $C['number_settings'], $C['textarea_settings'], $C['text_settings']); // All settings in the database
|
|
|
|
|
$C['settings']=array_merge(array('guestaccess', 'englobalpass', 'globalpass', 'captcha', 'dismemcaptcha', 'topic', 'guestreg', 'defaulttz'), $C['bool_settings'], $C['colour_settings'], $C['msg_settings'], $C['number_settings'], $C['textarea_settings'], $C['text_settings']); // All settings in the database
|
|
|
|
|
if(!isSet($_REQUEST['do'])){
|
|
|
|
|
}elseif($_REQUEST['do']==='save'){
|
|
|
|
|
save_setup();
|
|
|
|
@ -308,7 +308,7 @@ function send_redirect($url){
|
|
|
|
|
|
|
|
|
|
function send_access_denied(){
|
|
|
|
|
global $H, $I, $U;
|
|
|
|
|
header('HTTP/1.1 401 Forbidden');
|
|
|
|
|
header('HTTP/1.1 403 Forbidden');
|
|
|
|
|
print_start('access_denied');
|
|
|
|
|
echo "<h1>$I[accessdenied]</h1>".sprintf($I['loggedinas'], style_this($U['nickname'], $U['style']));
|
|
|
|
|
echo "<br><$H[form]>$H[commonform]".hidden('action', 'logout');
|
|
|
|
@ -565,6 +565,17 @@ function send_setup(){
|
|
|
|
|
echo '</select></td></tr>';
|
|
|
|
|
}
|
|
|
|
|
echo '</table></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
echo "<tr><td><table class=\"left-table\"><tr><th>$I[defaulttz]</th><td class=\"right\">";
|
|
|
|
|
echo "<select name=\"defaulttz\" id=\"defaulttz\">";
|
|
|
|
|
$tzs=[-12=>'-12', -11=>'-11', -10=>'-10', -9=>'-9', -8=>'-8', -7=>'-7', -6=>'-6', -5=>'-5', -4=>'-4', -3=>'-3', -2=>'-2', -1=>'-1', 0=>'', 1=>'+1', 2=>'+2', 3=>'+3', 4=>'+4', 5=>'+5', 6=>'+6', 7=>'+7', 8=>'+8', 9=>'+9', 10=>'+10', 11=>'+11', 12=>'+12', 13=>'+13', 14=>'+14'];
|
|
|
|
|
$defaulttz=get_setting('defaulttz');
|
|
|
|
|
foreach($tzs as $tz=>$name){
|
|
|
|
|
$select = $defaulttz==$tz ? ' selected' : '';
|
|
|
|
|
echo "<option value=\"$tz\"$select>UTC $name</option>";
|
|
|
|
|
}
|
|
|
|
|
echo '</select>';
|
|
|
|
|
echo '</td></tr></table></td></tr>';
|
|
|
|
|
foreach($C['textarea_settings'] as $setting){
|
|
|
|
|
thr();
|
|
|
|
|
echo '<tr><td><table class="left-table"><tr><th>'.$I[$setting].'</th><td class="right">';
|
|
|
|
@ -652,9 +663,16 @@ function restore_backup(){
|
|
|
|
|
}
|
|
|
|
|
if(isSet($_REQUEST['members']) && isSet($code['members'])){
|
|
|
|
|
$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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, notesboxwidth, notesboxheight, regedby, lastlogin, timestamps, embed, incognito, style, nocache, tz) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$defaulttz=get_setting('defaulttz');
|
|
|
|
|
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(!isSet($member['nocache'])){
|
|
|
|
|
$member['nocache']=0;
|
|
|
|
|
}
|
|
|
|
|
if(!isSet($member['tz'])){
|
|
|
|
|
$member['tz']=$defaulttz;
|
|
|
|
|
}
|
|
|
|
|
$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'], $member['nocache'], $member['tz']));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isSet($_REQUEST['notes']) && isSet($code['notes'])){
|
|
|
|
@ -960,8 +978,12 @@ function send_admin($arg=''){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function send_sessions(){
|
|
|
|
|
global $H, $I, $U;
|
|
|
|
|
$lines=parse_sessions();
|
|
|
|
|
global $H, $I, $U, $db;
|
|
|
|
|
$stmt=$db->prepare('SELECT nickname, style, lastpost, status, useragent, ip FROM ' . PREFIX . 'sessions WHERE status!=0 AND entry!=0 AND (incognito=0 OR status<?) ORDER BY status DESC, lastpost DESC;');
|
|
|
|
|
$stmt->execute(array($U['status']));
|
|
|
|
|
if(!$lines=$stmt->fetchAll(PDO::FETCH_ASSOC)){
|
|
|
|
|
$lines=array();
|
|
|
|
|
}
|
|
|
|
|
print_start('sessions');
|
|
|
|
|
echo "<h1>$I[sessact]</h1><table class=\"center-table\">";
|
|
|
|
|
echo "<tr><th class=\"padded\">$I[sessnick]</th><th class=\"padded\">$I[sesstimeout]</th><th class=\"padded\">$I[sessua]</th>";
|
|
|
|
@ -971,42 +993,40 @@ function send_sessions(){
|
|
|
|
|
if($trackip) echo "<th class=\"padded\">$I[sesip]</th>";
|
|
|
|
|
echo "<th class=\"padded\">$I[actions]</th></tr>";
|
|
|
|
|
foreach($lines as $temp){
|
|
|
|
|
if($temp['status']!=0 && $temp['entry']!=0 && (!$temp['incognito'] || $temp['status']<$U['status'])){
|
|
|
|
|
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)';
|
|
|
|
|
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 '<tr class="left"><td class="padded">'.style_this($temp['nickname'].$s, $temp['style']).'</td><td class="padded">';
|
|
|
|
|
if($temp['status']>2){
|
|
|
|
|
get_timeout($temp['lastpost'], $memexpire);
|
|
|
|
|
}else{
|
|
|
|
|
get_timeout($temp['lastpost'], $guestexpire);
|
|
|
|
|
}
|
|
|
|
|
echo '</td>';
|
|
|
|
|
if($U['status']>$temp['status'] || $U['nickname']===$temp['nickname']){
|
|
|
|
|
echo "<td class=\"padded\">$temp[useragent]</td>";
|
|
|
|
|
if($trackip){
|
|
|
|
|
echo "<td class=\"padded\">$temp[ip]</td>";
|
|
|
|
|
}
|
|
|
|
|
echo '<tr class="left"><td class="padded">'.style_this($temp['nickname'].$s, $temp['style']).'</td><td class="padded">';
|
|
|
|
|
if($temp['status']>2){
|
|
|
|
|
get_timeout($temp['lastpost'], $memexpire);
|
|
|
|
|
}else{
|
|
|
|
|
get_timeout($temp['lastpost'], $guestexpire);
|
|
|
|
|
}
|
|
|
|
|
echo '</td>';
|
|
|
|
|
if($U['status']>$temp['status'] || $U['session']===$temp['session']){
|
|
|
|
|
echo "<td class=\"padded\">$temp[useragent]</td>";
|
|
|
|
|
if($trackip){
|
|
|
|
|
echo "<td class=\"padded\">$temp[ip]</td>";
|
|
|
|
|
}
|
|
|
|
|
echo '<td class="padded">';
|
|
|
|
|
frmadm('sessions');
|
|
|
|
|
echo hidden('nick', $temp['nickname']).submit($I['kick']).'</form></td></tr>';
|
|
|
|
|
}else{
|
|
|
|
|
echo '<td class="padded">';
|
|
|
|
|
frmadm('sessions');
|
|
|
|
|
echo hidden('nick', $temp['nickname']).submit($I['kick']).'</form></td></tr>';
|
|
|
|
|
}else{
|
|
|
|
|
echo '<td class="padded">-</td>';
|
|
|
|
|
if($trackip){
|
|
|
|
|
echo '<td class="padded">-</td>';
|
|
|
|
|
if($trackip){
|
|
|
|
|
echo '<td class="padded">-</td>';
|
|
|
|
|
}
|
|
|
|
|
echo '<td class="padded">-</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
echo '<td class="padded">-</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo "</table><br>$H[backtochat]";
|
|
|
|
@ -1237,7 +1257,7 @@ function send_frameset(){
|
|
|
|
|
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\"><html><head>$H[meta_html]";
|
|
|
|
|
echo '<title>'.get_setting('chatname').'</title>';
|
|
|
|
|
print_stylesheet();
|
|
|
|
|
if(isSet($_COOKIE['test'])){
|
|
|
|
|
if(isSet($_COOKIE['language'])){
|
|
|
|
|
echo "</head><frameset rows=\"100,*,60\" border=\"3\" frameborder=\"3\" framespacing=\"3\"><frame name=\"post\" src=\"$_SERVER[SCRIPT_NAME]?action=post\"><frame name=\"view\" src=\"$_SERVER[SCRIPT_NAME]?action=view\"><frame name=\"controls\" src=\"$_SERVER[SCRIPT_NAME]?action=controls\"><noframes><body>$I[noframes]$H[backtologin]</body></noframes></frameset></html>";
|
|
|
|
|
}else{
|
|
|
|
|
echo "</head><frameset rows=\"100,*,60\" border=\"3\" frameborder=\"3\" framespacing=\"3\"><frame name=\"post\" src=\"$_SERVER[SCRIPT_NAME]?action=post&session=$U[session]&lang=$language\"><frame name=\"view\" src=\"$_SERVER[SCRIPT_NAME]?action=view&session=$U[session]&lang=$language\"><frame name=\"controls\" src=\"$_SERVER[SCRIPT_NAME]?action=controls&session=$U[session]&lang=$language\"><noframes><body>$I[noframes]$H[backtologin]</body></noframes></frameset></html>";
|
|
|
|
@ -1342,7 +1362,7 @@ function send_notes($type){
|
|
|
|
|
$stmt=$db->prepare('SELECT * FROM ' . 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']));
|
|
|
|
|
printf($I['lastedited'], $note['editedby'], date($dateformat, $note['lastedited']+3600*$U['tz']));
|
|
|
|
|
}else{
|
|
|
|
|
$note['text']='';
|
|
|
|
|
}
|
|
|
|
@ -1412,14 +1432,8 @@ function send_waiting_room(){
|
|
|
|
|
}else{
|
|
|
|
|
$wait=true;
|
|
|
|
|
}
|
|
|
|
|
if(!isSet($U['session'])){
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error($I['expire']);
|
|
|
|
|
}
|
|
|
|
|
if($U['status']==0){
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
|
|
|
}
|
|
|
|
|
check_expired();
|
|
|
|
|
check_kicked();
|
|
|
|
|
$timeleft=get_setting('entrywait')-(time()-$U['lastpost']);
|
|
|
|
|
if($wait && ($timeleft<=0 || $ga===1)){
|
|
|
|
|
$U['entry']=$U['lastpost'];
|
|
|
|
@ -1430,7 +1444,7 @@ function send_waiting_room(){
|
|
|
|
|
send_frameset();
|
|
|
|
|
}else{
|
|
|
|
|
$refresh=(int) get_setting('defaultrefresh');
|
|
|
|
|
if(isSet($_COOKIE['test'])){
|
|
|
|
|
if(isSet($_COOKIE['language'])){
|
|
|
|
|
print_start('waitingroom', $refresh, "$_SERVER[SCRIPT_NAME]?action=wait&nc=".substr(time(),-6));
|
|
|
|
|
}else{
|
|
|
|
|
print_start('waitingroom', $refresh, "$_SERVER[SCRIPT_NAME]?action=wait&session=$U[session]&lang=$language&nc=".substr(time(),-6));
|
|
|
|
@ -1722,6 +1736,15 @@ function send_profile($arg=''){
|
|
|
|
|
echo "><label for=\"$setting\"><b>$I[enabled]</b></label></td></tr></table></td></tr>";
|
|
|
|
|
thr();
|
|
|
|
|
}
|
|
|
|
|
echo "<tr><td><table class=\"left-table\"><tr><th>$I[tz]</th><td class=\"right\">";
|
|
|
|
|
echo "<select name=\"tz\" id=\"tz\">";
|
|
|
|
|
$tzs=[-12=>'-12', -11=>'-11', -10=>'-10', -9=>'-9', -8=>'-8', -7=>'-7', -6=>'-6', -5=>'-5', -4=>'-4', -3=>'-3', -2=>'-2', -1=>'-1', 0=>'', 1=>'+1', 2=>'+2', 3=>'+3', 4=>'+4', 5=>'+5', 6=>'+6', 7=>'+7', 8=>'+8', 9=>'+9', 10=>'+10', 11=>'+11', 12=>'+12', 13=>'+13', 14=>'+14'];
|
|
|
|
|
foreach($tzs as $tz=>$name){
|
|
|
|
|
$select = $U['tz']==$tz ? ' selected' : '';
|
|
|
|
|
echo "<option value=\"$tz\"$select>UTC $name</option>";
|
|
|
|
|
}
|
|
|
|
|
echo '</select></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
echo "<tr><td><table class=\"left-table\"><tr><th>$I[pbsize]</th><td><table class=\"right-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>";
|
|
|
|
@ -1740,12 +1763,7 @@ function send_profile($arg=''){
|
|
|
|
|
echo "<tr><td> </td><td>$I[oldpass]</td><td><input type=\"password\" name=\"oldpass\" size=\"20\"></td></tr>";
|
|
|
|
|
echo "<tr><td> </td><td>$I[newpass]</td><td><input type=\"password\" name=\"newpass\" size=\"20\"></td></tr>";
|
|
|
|
|
echo "<tr><td> </td><td>$I[confirmpass]</td><td><input type=\"password\" name=\"confirmpass\" size=\"20\"></td></tr>";
|
|
|
|
|
echo '</table></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
echo "<tr><td><table class=\"left-table\"><tr><th>$I[changenickname]</th></tr>";
|
|
|
|
|
echo '<tr><td><table class="right-table">';
|
|
|
|
|
echo "<tr><td> </td><td>$I[newnickname]</td><td><input type=\"text\" name=\"newnickname\" size=\"20\"></td></tr>";
|
|
|
|
|
echo "<tr><td> </td><td>$I[newpass]</td><td><input type=\"password\" name=\"new_pass\" size=\"20\"></td></tr>";
|
|
|
|
|
echo "<tr><td> </td><td>$I[newnickname]</td><td><input type=\"text\" name=\"newnickname\" size=\"20\" placeholder=\"$I[optional]\"></td></tr>";
|
|
|
|
|
echo '</table></td></tr></table></td></tr>';
|
|
|
|
|
thr();
|
|
|
|
|
}
|
|
|
|
@ -1810,7 +1828,6 @@ function send_login(){
|
|
|
|
|
if($ga===4){
|
|
|
|
|
send_chat_disabled();
|
|
|
|
|
}
|
|
|
|
|
setcookie('test', '1');
|
|
|
|
|
print_start('login');
|
|
|
|
|
$englobal=(int) get_setting('englobalpass');
|
|
|
|
|
echo '<h1>'.get_setting('chatname').'</h1>';
|
|
|
|
@ -1825,7 +1842,7 @@ function send_login(){
|
|
|
|
|
send_captcha();
|
|
|
|
|
if($ga!==0){
|
|
|
|
|
if(get_setting('guestreg')!=0){
|
|
|
|
|
echo "<tr><td class=\"left\">$I[regpass]</td><td class=\"right\"><input type=\"password\" name=\"regpass\" size=\"15\"></td></tr>";
|
|
|
|
|
echo "<tr><td class=\"left\">$I[regpass]</td><td class=\"right\"><input type=\"password\" name=\"regpass\" size=\"15\" placeholder=\"$I[optional]\"></td></tr>";
|
|
|
|
|
}
|
|
|
|
|
if($englobal===2){
|
|
|
|
|
echo "<tr><td class=\"left\">$I[globalloginpass]</td><td class=\"right\"><input type=\"password\" name=\"globalpass\" size=\"15\"></td></tr>";
|
|
|
|
@ -1976,27 +1993,24 @@ function create_session($setup){
|
|
|
|
|
|
|
|
|
|
function write_new_session(){
|
|
|
|
|
global $I, $P, $U, $db;
|
|
|
|
|
$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']){
|
|
|
|
|
$U=$temp;
|
|
|
|
|
if($U['status']==0){
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
|
|
|
}
|
|
|
|
|
setcookie(COOKIENAME, $U['session']);
|
|
|
|
|
$reentry=true;
|
|
|
|
|
break;
|
|
|
|
|
}else{
|
|
|
|
|
send_error($I['wrongpass']);
|
|
|
|
|
}
|
|
|
|
|
parse_sessions();
|
|
|
|
|
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'sessions WHERE nickname=?;');
|
|
|
|
|
$stmt->execute(array($U['nickname']));
|
|
|
|
|
if($temp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
|
if($U['passhash']===$temp['passhash']){
|
|
|
|
|
$U=$temp;
|
|
|
|
|
check_kicked();
|
|
|
|
|
setcookie(COOKIENAME, $U['session']);
|
|
|
|
|
}else{
|
|
|
|
|
send_error("$I[userloggedin]<br>$I[wrongpass]");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$sids=[];
|
|
|
|
|
// create new session
|
|
|
|
|
$stmt=$db->query('SELECT session FROM ' . PREFIX . 'sessions;');
|
|
|
|
|
while($temp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
|
$sids[$temp['session']]=true;// collect all existing ids
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// create new session:
|
|
|
|
|
if(!$reentry){
|
|
|
|
|
do{
|
|
|
|
|
$U['session']=md5(time().mt_rand().$U['nickname']);
|
|
|
|
|
}while(isSet($sids[$U['session']]));// check for hash collision
|
|
|
|
@ -2010,8 +2024,8 @@ function write_new_session(){
|
|
|
|
|
}else{
|
|
|
|
|
$ip='';
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . 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));
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'sessions (session, nickname, status, refresh, style, lastpost, passhash, boxwidth, boxheight, useragent, bgcolour, notesboxwidth, notesboxheight, entry, timestamps, embed, incognito, ip, nocache, tz) 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, $U['nocache'], $U['tz']));
|
|
|
|
|
setcookie(COOKIENAME, $U['session']);
|
|
|
|
|
if($U['status']>=3 && !$U['incognito']){
|
|
|
|
|
add_system_message(sprintf(get_setting('msgenter'), style_this($U['nickname'], $U['style'])));
|
|
|
|
@ -2056,12 +2070,8 @@ function check_login(){
|
|
|
|
|
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'sessions WHERE session=?;');
|
|
|
|
|
$stmt->execute(array($_POST['session']));
|
|
|
|
|
if($U=$stmt->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
|
if($U['status']==0){
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
|
|
|
}else{
|
|
|
|
|
setcookie(COOKIENAME, $U['session']);
|
|
|
|
|
}
|
|
|
|
|
check_kicked();
|
|
|
|
|
setcookie(COOKIENAME, $U['session']);
|
|
|
|
|
}else{
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error($I['expire']);
|
|
|
|
@ -2100,15 +2110,11 @@ function check_login(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function kill_session(){
|
|
|
|
|
global $I, $U, $db;
|
|
|
|
|
global $U, $db;
|
|
|
|
|
parse_sessions();
|
|
|
|
|
check_expired();
|
|
|
|
|
check_kicked();
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
if(!isSet($U['session'])){
|
|
|
|
|
send_error($I['expire']);
|
|
|
|
|
}
|
|
|
|
|
if($U['status']==0){
|
|
|
|
|
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'sessions WHERE session=?;');
|
|
|
|
|
$stmt->execute(array($U['session']));
|
|
|
|
|
if($U['status']==1){
|
|
|
|
@ -2127,18 +2133,17 @@ function kill_session(){
|
|
|
|
|
function kick_chatter($names, $mes, $purge){
|
|
|
|
|
global $P, $U, $db;
|
|
|
|
|
$lonick='';
|
|
|
|
|
$lines=parse_sessions();
|
|
|
|
|
$time=60*(get_setting('kickpenalty')-get_setting('guestexpire'))+time();
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET lastpost=?, status=0, kickmessage=? WHERE session=? AND status!=0;');
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET lastpost=?, status=0, kickmessage=? WHERE nickname=? 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($time, $mes, $temp['session']));
|
|
|
|
|
foreach($P as $temp){
|
|
|
|
|
if(($temp[0]===$U['nickname'] && $U['nickname']===$name) || ($U['status']>$temp[2] && (($temp[0]===$name && $temp[2]>0) || ($name==='&' && $temp[2]==1)))){
|
|
|
|
|
$stmt->execute(array($time, $mes, $name));
|
|
|
|
|
if($purge){
|
|
|
|
|
del_all_messages($temp['nickname'], 10, 0);
|
|
|
|
|
del_all_messages($name, 10, 0);
|
|
|
|
|
}
|
|
|
|
|
$lonick.=style_this($temp['nickname'], $temp['style']).', ';
|
|
|
|
|
$lonick.=style_this($name, $temp[1]).', ';
|
|
|
|
|
++$i;
|
|
|
|
|
unset($P[$name]);
|
|
|
|
|
}
|
|
|
|
@ -2164,19 +2169,18 @@ function kick_chatter($names, $mes, $purge){
|
|
|
|
|
|
|
|
|
|
function logout_chatter($names){
|
|
|
|
|
global $P, $U, $db;
|
|
|
|
|
$lines=parse_sessions();
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'sessions WHERE session=? AND status<? AND status!=0;');
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'sessions WHERE nickname=? AND status<? AND status!=0;');
|
|
|
|
|
$stmt1=$db->prepare('UPDATE ' . PREFIX . "messages SET poster='' WHERE poster=? AND poststatus=9;");
|
|
|
|
|
$stmt2=$db->prepare('UPDATE ' . PREFIX . "messages SET recipient='' WHERE recipient=? AND poststatus=9;");
|
|
|
|
|
$stmt3=$db->prepare('DELETE FROM ' . PREFIX . 'ignored WHERE ign=? OR ignby=?;');
|
|
|
|
|
foreach($names as $name){
|
|
|
|
|
foreach($lines as $temp){
|
|
|
|
|
if($temp['nickname']===$name || ($name==='&' && $temp['status']==1)){
|
|
|
|
|
$stmt->execute(array($temp['session'], $U['status']));
|
|
|
|
|
if($temp['status']==1){
|
|
|
|
|
$stmt1->execute(array($temp['nickname']));
|
|
|
|
|
$stmt2->execute(array($temp['nickname']));
|
|
|
|
|
$stmt3->execute(array($temp['nickname'], $temp['nickname']));
|
|
|
|
|
foreach($P as $temp){
|
|
|
|
|
if($temp[0]===$name || ($name==='&' && $temp[2]==1)){
|
|
|
|
|
$stmt->execute(array($name, $U['status']));
|
|
|
|
|
if($temp[2]==1){
|
|
|
|
|
$stmt1->execute(array($name));
|
|
|
|
|
$stmt2->execute(array($name));
|
|
|
|
|
$stmt3->execute(array($name, $name));
|
|
|
|
|
}
|
|
|
|
|
unset($P[$name]);
|
|
|
|
|
}
|
|
|
|
@ -2186,19 +2190,29 @@ function logout_chatter($names){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function check_session(){
|
|
|
|
|
global $I, $U;
|
|
|
|
|
global $U;
|
|
|
|
|
parse_sessions();
|
|
|
|
|
check_expired();
|
|
|
|
|
check_kicked();
|
|
|
|
|
if($U['entry']==0){
|
|
|
|
|
send_waiting_room();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function check_expired(){
|
|
|
|
|
global $I, $U;
|
|
|
|
|
if(!isSet($U['session'])){
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error($I['expire']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function check_kicked(){
|
|
|
|
|
global $I, $U;
|
|
|
|
|
if($U['status']==0){
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
|
|
|
}
|
|
|
|
|
if($U['entry']==0){
|
|
|
|
|
send_waiting_room();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_nowchatting(){
|
|
|
|
@ -2212,6 +2226,7 @@ function get_nowchatting(){
|
|
|
|
|
|
|
|
|
|
function parse_sessions(){
|
|
|
|
|
global $P, $U, $countmods, $db;
|
|
|
|
|
// delete old sessions
|
|
|
|
|
$guestexpire=time()-60*get_setting('guestexpire');
|
|
|
|
|
$memberexpire=time()-60*get_setting('memberexpire');
|
|
|
|
|
$result=$db->prepare('SELECT nickname, status FROM ' . PREFIX . 'sessions WHERE (status<=2 AND lastpost<?) OR (status>2 AND lastpost<?);');
|
|
|
|
@ -2231,31 +2246,26 @@ function parse_sessions(){
|
|
|
|
|
}
|
|
|
|
|
$db->exec('DELETE FROM ' . PREFIX . "messages WHERE poster='' AND recipient='' AND poststatus=9;");
|
|
|
|
|
}
|
|
|
|
|
$result=$db->query('SELECT * FROM ' . PREFIX . 'sessions ORDER BY status DESC, lastpost DESC;');
|
|
|
|
|
if(!$lines=$result->fetchAll(PDO::FETCH_ASSOC)){
|
|
|
|
|
$lines=array();
|
|
|
|
|
}
|
|
|
|
|
// look for our session
|
|
|
|
|
if(isSet($_REQUEST['session'])){
|
|
|
|
|
foreach($lines as $temp){
|
|
|
|
|
if($temp['session']===$_REQUEST['session']){
|
|
|
|
|
$U=$temp;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'sessions WHERE session=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['session']));
|
|
|
|
|
if($tmp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
|
$U=$tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// load other sessions
|
|
|
|
|
$countmods=0;
|
|
|
|
|
$P=array();
|
|
|
|
|
foreach($lines as $temp){
|
|
|
|
|
if($temp['entry']!=0 && $temp['status']>0){
|
|
|
|
|
if(!$temp['incognito']){
|
|
|
|
|
$P[$temp['nickname']]=[$temp['nickname'], $temp['style'], $temp['status']];
|
|
|
|
|
}
|
|
|
|
|
if($temp['status']>=5){
|
|
|
|
|
++$countmods;
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->query('SELECT nickname, style, status, incognito FROM ' . PREFIX . 'sessions WHERE entry!=0 AND status>0 ORDER BY status DESC, lastpost DESC;');
|
|
|
|
|
while($temp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
|
if(!$temp['incognito']){
|
|
|
|
|
$P[$temp['nickname']]=[$temp['nickname'], $temp['style'], $temp['status']];
|
|
|
|
|
}
|
|
|
|
|
if($temp['status']>=5){
|
|
|
|
|
++$countmods;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $lines;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// member handling
|
|
|
|
@ -2272,7 +2282,7 @@ function check_member(){
|
|
|
|
|
$stmt->execute(array($time, $U['nickname']));
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
send_error($I['wrongpass']);
|
|
|
|
|
send_error("$I[regednick]<br>$I[wrongpass]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
@ -2307,8 +2317,8 @@ function register_guest($status, $nick){
|
|
|
|
|
}else{
|
|
|
|
|
return sprintf($I['cantreg'], $nick);
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, regedby, timestamps, embed, style, incognito) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0);');
|
|
|
|
|
$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']));
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, boxwidth, boxheight, regedby, timestamps, embed, style, incognito, nocache, tz) 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'], $reg['incognito'], $reg['nocache'], $reg['tz']));
|
|
|
|
|
if($reg['status']==3){
|
|
|
|
|
add_system_message(sprintf(get_setting('msgmemreg'), style_this($reg['nickname'], $reg['style'])));
|
|
|
|
|
}else{
|
|
|
|
@ -2341,10 +2351,14 @@ function register_new($nick, $pass){
|
|
|
|
|
'bgcolour' =>get_setting('colbg'),
|
|
|
|
|
'regedby' =>$U['nickname'],
|
|
|
|
|
'timestamps' =>get_setting('timestamps'),
|
|
|
|
|
'style' =>'color:#'.get_setting('coltxt').';'
|
|
|
|
|
'style' =>'color:#'.get_setting('coltxt').';',
|
|
|
|
|
'embed' =>1,
|
|
|
|
|
'incognito' =>0,
|
|
|
|
|
'nocache' =>0,
|
|
|
|
|
'tz' =>get_setting('defaulttz')
|
|
|
|
|
);
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, regedby, timestamps, style, embed, incognito) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, 0);');
|
|
|
|
|
$stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['regedby'], $reg['timestamps'], $reg['style']));
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, regedby, timestamps, style, embed, incognito, nocache, tz) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['regedby'], $reg['timestamps'], $reg['style'], $reg['embed'], $reg['incognito'], $reg['nocache'], $reg['tz']));
|
|
|
|
|
return sprintf($I['successreg'], $reg['nickname']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2465,37 +2479,22 @@ function amend_profile(){
|
|
|
|
|
}else{
|
|
|
|
|
$U['nocache']=0;
|
|
|
|
|
}
|
|
|
|
|
if(isSet($_REQUEST['tz'])){
|
|
|
|
|
settype($_REQUEST['tz'], 'int');
|
|
|
|
|
if($_REQUEST['tz']>=-12 && $_REQUEST['tz']<=14){
|
|
|
|
|
$U['tz']=$_REQUEST['tz'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function save_profile(){
|
|
|
|
|
global $I, $U, $db;
|
|
|
|
|
if(!isSet($_REQUEST['oldpass'])){
|
|
|
|
|
$_REQUEST['oldpass']='';
|
|
|
|
|
}
|
|
|
|
|
if(!isSet($_REQUEST['newpass'])){
|
|
|
|
|
$_REQUEST['newpass']='';
|
|
|
|
|
}
|
|
|
|
|
if(!isSet($_REQUEST['confirmpass'])){
|
|
|
|
|
$_REQUEST['confirmpass']='';
|
|
|
|
|
}
|
|
|
|
|
if($_REQUEST['newpass']!==$_REQUEST['confirmpass']){
|
|
|
|
|
return $I['noconfirm'];
|
|
|
|
|
}elseif(!empty($_REQUEST['newpass']) && valid_pass($_REQUEST['newpass'])){
|
|
|
|
|
$U['oldhash']=md5(sha1(md5($U['nickname'].$_REQUEST['oldpass'])));
|
|
|
|
|
$U['newhash']=md5(sha1(md5($U['nickname'].$_REQUEST['newpass'])));
|
|
|
|
|
}else{
|
|
|
|
|
$U['oldhash']=$U['newhash']=$U['passhash'];
|
|
|
|
|
}
|
|
|
|
|
if($U['passhash']!==$U['oldhash']){
|
|
|
|
|
return $I['wrongpass'];
|
|
|
|
|
}
|
|
|
|
|
$U['passhash']=$U['newhash'];
|
|
|
|
|
amend_profile();
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET refresh=?, style=?, passhash=?, boxwidth=?, boxheight=?, bgcolour=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=?, nocache=? 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['nocache'], $U['session']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET refresh=?, style=?, boxwidth=?, boxheight=?, bgcolour=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=?, nocache=?, tz=? WHERE session=?;');
|
|
|
|
|
$stmt->execute(array($U['refresh'], $U['style'], $U['boxwidth'], $U['boxheight'], $U['bgcolour'], $U['notesboxwidth'], $U['notesboxheight'], $U['timestamps'], $U['embed'], $U['incognito'], $U['nocache'], $U['tz'], $U['session']));
|
|
|
|
|
if($U['status']>=2){
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'members SET passhash=?, refresh=?, bgcolour=?, boxwidth=?, boxheight=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=?, style=?, nocache=? 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['nocache'], $U['nickname']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'members SET refresh=?, bgcolour=?, boxwidth=?, boxheight=?, notesboxwidth=?, notesboxheight=?, timestamps=?, embed=?, incognito=?, style=?, nocache=?, tz=? WHERE nickname=?;');
|
|
|
|
|
$stmt->execute(array($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['nickname']));
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['unignore'])){
|
|
|
|
|
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'ignored WHERE ign=? AND ignby=?;');
|
|
|
|
@ -2505,45 +2504,59 @@ function save_profile(){
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'ignored (ign, ignby) VALUES (?, ?);');
|
|
|
|
|
$stmt->execute(array($_REQUEST['ignore'], $U['nickname']));
|
|
|
|
|
}
|
|
|
|
|
if($U['status']>1 && !empty($_REQUEST['newnickname'])){
|
|
|
|
|
$msg=set_new_nickname();
|
|
|
|
|
if($msg!==''){
|
|
|
|
|
return $msg;
|
|
|
|
|
if($U['status']>1 && !empty($_REQUEST['newpass'])){
|
|
|
|
|
if(!valid_pass($_REQUEST['newpass'])){
|
|
|
|
|
return sprintf($I['invalpass'], get_setting('minpass'));
|
|
|
|
|
}
|
|
|
|
|
if(!isSet($_REQUEST['oldpass'])){
|
|
|
|
|
$_REQUEST['oldpass']='';
|
|
|
|
|
}
|
|
|
|
|
if(!isSet($_REQUEST['confirmpass'])){
|
|
|
|
|
$_REQUEST['confirmpass']='';
|
|
|
|
|
}
|
|
|
|
|
if($_REQUEST['newpass']!==$_REQUEST['confirmpass']){
|
|
|
|
|
return $I['noconfirm'];
|
|
|
|
|
}else{
|
|
|
|
|
$U['oldhash']=md5(sha1(md5($U['nickname'].$_REQUEST['oldpass'])));
|
|
|
|
|
$U['newhash']=md5(sha1(md5($U['nickname'].$_REQUEST['newpass'])));
|
|
|
|
|
}
|
|
|
|
|
if($U['passhash']!==$U['oldhash']){
|
|
|
|
|
return $I['wrongpass'];
|
|
|
|
|
}
|
|
|
|
|
$U['passhash']=$U['newhash'];
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET passhash=? WHERE session=?;');
|
|
|
|
|
$stmt->execute(array($U['passhash'], $U['session']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'members SET passhash=? WHERE nickname=?;');
|
|
|
|
|
$stmt->execute(array($U['passhash'], $U['nickname']));
|
|
|
|
|
if(!empty($_REQUEST['newnickname'])){
|
|
|
|
|
$msg=set_new_nickname();
|
|
|
|
|
if($msg!==''){
|
|
|
|
|
return $msg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['newpass']) && !valid_pass($_REQUEST['newpass'])){
|
|
|
|
|
return sprintf($I['invalpass'], get_setting('minpass'));
|
|
|
|
|
}
|
|
|
|
|
return $I['succprofile'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function set_new_nickname(){
|
|
|
|
|
global $I, $U, $db;
|
|
|
|
|
if(!isSet($_REQUEST['new_pass']) || !valid_pass($_REQUEST['new_pass'])){
|
|
|
|
|
return sprintf($I['nopass'], get_setting('minpass'));
|
|
|
|
|
}
|
|
|
|
|
if(!valid_nick($_REQUEST['newnickname'])){
|
|
|
|
|
return sprintf($I['invalnick'], get_setting('maxname'));
|
|
|
|
|
}
|
|
|
|
|
$U['passhash']=md5(sha1(md5($_REQUEST['newnickname'].$_REQUEST['new_pass'])));
|
|
|
|
|
$U['passhash']=md5(sha1(md5($_REQUEST['newnickname'].$_REQUEST['newpass'])));
|
|
|
|
|
$stmt=$db->prepare('SELECT id FROM ' . PREFIX . 'sessions WHERE nickname=? UNION SELECT id FROM ' . PREFIX . 'members WHERE nickname=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $_REQUEST['newnickname']));
|
|
|
|
|
if($stmt->fetch(PDO::FETCH_NUM)){
|
|
|
|
|
return $I['nicknametaken'];
|
|
|
|
|
}else{
|
|
|
|
|
if($U['status']>1){
|
|
|
|
|
$entry=0;
|
|
|
|
|
}else{
|
|
|
|
|
$entry=$U['entry'];
|
|
|
|
|
}
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'members SET nickname=?, passhash=? WHERE nickname=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['passhash'], $U['nickname']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'sessions SET nickname=?, passhash=? WHERE nickname=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['passhash'], $U['nickname']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'messages SET poster=? WHERE poster=? AND postdate>?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['nickname'], $entry));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'messages SET recipient=? WHERE recipient=? AND postdate>?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['nickname'], $entry));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'messages SET poster=? WHERE poster=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['nickname']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'messages SET recipient=? WHERE recipient=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['nickname']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'ignored SET ignby=? WHERE ignby=?;');
|
|
|
|
|
$stmt->execute(array($_REQUEST['newnickname'], $U['nickname']));
|
|
|
|
|
$stmt=$db->prepare('UPDATE ' . PREFIX . 'ignored SET ign=? WHERE ign=?;');
|
|
|
|
@ -2573,6 +2586,8 @@ function add_user_defaults(){
|
|
|
|
|
$U['embed']=1;
|
|
|
|
|
$U['incognito']=0;
|
|
|
|
|
$U['status']=1;
|
|
|
|
|
$U['nocache']=0;
|
|
|
|
|
$U['tz']=get_setting('defaulttz');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// message handling
|
|
|
|
@ -2695,6 +2710,7 @@ function apply_filter(){
|
|
|
|
|
}
|
|
|
|
|
if(isSet($count) && $count>0 && $filter['kick']){
|
|
|
|
|
kick_chatter(array($U['nickname']), '', false);
|
|
|
|
|
setcookie(COOKIENAME, false);
|
|
|
|
|
send_error("$I[kicked]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2866,6 +2882,7 @@ function del_last_message(){
|
|
|
|
|
function print_messages($delstatus=''){
|
|
|
|
|
global $U, $db;
|
|
|
|
|
$dateformat=get_setting('dateformat');
|
|
|
|
|
$tz=3600*$U['tz'];
|
|
|
|
|
$messagelimit=(int) get_setting('messagelimit');
|
|
|
|
|
if(!isSet($_COOKIE[COOKIENAME]) && get_setting('forceredirect')==0){
|
|
|
|
|
$injectRedirect=true;
|
|
|
|
@ -2916,7 +2933,7 @@ function print_messages($delstatus=''){
|
|
|
|
|
}
|
|
|
|
|
echo "<div class=\"msg\"><input type=\"checkbox\" name=\"mid[]\" id=\"$message[id]\" value=\"$message[id]\"><label for=\"$message[id]\">";
|
|
|
|
|
if($timestamps){
|
|
|
|
|
echo ' <small>'.date($dateformat, $message['postdate']).' - </small>';
|
|
|
|
|
echo ' <small>'.date($dateformat, $message['postdate']+$tz).' - </small>';
|
|
|
|
|
}
|
|
|
|
|
echo " $message[text]</label></div>";
|
|
|
|
|
}
|
|
|
|
@ -2953,7 +2970,7 @@ function print_messages($delstatus=''){
|
|
|
|
|
}
|
|
|
|
|
echo '<div class="msg">';
|
|
|
|
|
if($timestamps){
|
|
|
|
|
echo '<small>'.date($dateformat, $message['postdate']).' - </small>';
|
|
|
|
|
echo '<small>'.date($dateformat, $message['postdate']+$tz).' - </small>';
|
|
|
|
|
}
|
|
|
|
|
echo "$message[text]</div>";
|
|
|
|
|
if($_REQUEST['id']<$message['id']){
|
|
|
|
@ -2993,6 +3010,10 @@ function save_setup(){
|
|
|
|
|
settype($_REQUEST['captcha'], 'int');
|
|
|
|
|
settype($_REQUEST['dismemcaptcha'], 'int');
|
|
|
|
|
settype($_REQUEST['guestreg'], 'int');
|
|
|
|
|
settype($_REQUEST['defaulttz'], 'int');
|
|
|
|
|
if($_REQUEST['defaulttz']<-12 || $_REQUEST['defaulttz']>14){
|
|
|
|
|
unset($_REQUEST['defaulttz']);
|
|
|
|
|
}
|
|
|
|
|
$_REQUEST['rulestxt']=preg_replace("/(\r?\n|\r\n?)/", '<br>', $_REQUEST['rulestxt']);
|
|
|
|
|
$_REQUEST['chatname']=htmlspecialchars($_REQUEST['chatname']);
|
|
|
|
|
$_REQUEST['redirect']=htmlspecialchars($_REQUEST['redirect']);
|
|
|
|
@ -3184,13 +3205,13 @@ function init_chat(){
|
|
|
|
|
}else{
|
|
|
|
|
if(DBDRIVER===0){//MySQL
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "captcha (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, time integer unsigned NOT NULL, code char(5) NOT NULL) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "filter (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(20000) NOT NULL, allowinpm smallint unsigned NOT NULL, regex smallint unsigned NOT NULL, kick smallint unsigned NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "filter (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(20000) NOT NULL, allowinpm smallint NOT NULL, regex smallint NOT NULL, kick smallint NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "ignored (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, ign varchar(50) NOT NULL, ignby varchar(50) NOT NULL, INDEX(ign), INDEX(ignby)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "linkfilter (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex smallint unsigned NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, nickname varchar(50) NOT NULL UNIQUE, passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, status smallint unsigned NOT NULL, refresh smallint unsigned NOT NULL, bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, boxwidth smallint unsigned NOT NULL DEFAULT 40, boxheight smallint unsigned NOT NULL DEFAULT 3, notesboxheight smallint unsigned NOT NULL DEFAULT 30, notesboxwidth smallint unsigned NOT NULL DEFAULT 80, regedby varchar(50) NOT NULL, lastlogin integer unsigned NOT NULL, timestamps smallint unsigned NOT NULL, embed smallint unsigned NOT NULL DEFAULT 1, incognito smallint unsigned NOT NULL DEFAULT 0, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, nocache smallint UNSIGNED NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "linkfilter (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex smallint NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, nickname varchar(50) NOT NULL UNIQUE, passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, status smallint unsigned NOT NULL, refresh smallint unsigned NOT NULL, bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, boxwidth smallint unsigned NOT NULL DEFAULT 40, boxheight smallint unsigned NOT NULL DEFAULT 3, notesboxheight smallint unsigned NOT NULL DEFAULT 30, notesboxwidth smallint unsigned NOT NULL DEFAULT 80, regedby varchar(50) NOT NULL, lastlogin integer unsigned NOT NULL, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, nocache smallint NOT NULL, tz smallint NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "messages (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, postdate integer unsigned NOT NULL, poststatus smallint unsigned NOT NULL, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text varchar(20000) NOT NULL, delstatus smallint unsigned NOT NULL, INDEX(poster), INDEX(recipient), INDEX(postdate), INDEX(poststatus)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "notes (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, type char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastedited integer unsigned NOT NULL, editedby varchar(50) NOT NULL, text varchar(20000) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "sessions (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL UNIQUE, nickname varchar(50) NOT NULL UNIQUE, status smallint unsigned NOT NULL, refresh smallint unsigned NOT NULL, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastpost integer 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 smallint unsigned NOT NULL DEFAULT 40, boxheight smallint 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 smallint unsigned NOT NULL DEFAULT 30, notesboxwidth smallint unsigned NOT NULL DEFAULT 80, entry integer unsigned NOT NULL, timestamps smallint unsigned NOT NULL, embed smallint unsigned NOT NULL DEFAULT 1, incognito smallint unsigned NOT NULL DEFAULT 0, ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, nocache smallint UNSIGNED NOT NULL DEFAULT 0, INDEX(status) USING BTREE, INDEX(lastpost) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "sessions (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL UNIQUE, nickname varchar(50) NOT NULL UNIQUE, status smallint unsigned NOT NULL, refresh smallint unsigned NOT NULL, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastpost integer 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 smallint unsigned NOT NULL DEFAULT 40, boxheight smallint 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 smallint unsigned NOT NULL DEFAULT 30, notesboxwidth smallint unsigned NOT NULL DEFAULT 80, entry integer NOT NULL, timestamps smallint NOT NULL, embed smallint NOT NULL, incognito smallint NOT NULL DEFAULT 0, ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, nocache smallint NOT NULL, tz smallint NOT NULL, INDEX(status) USING BTREE, INDEX(lastpost) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "settings (setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL PRIMARY KEY, value varchar(20000) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
|
|
|
|
|
}else{
|
|
|
|
|
if(DBDRIVER===1){//PostgreSQL
|
|
|
|
@ -3204,19 +3225,19 @@ function init_chat(){
|
|
|
|
|
$db->exec('CREATE INDEX ign ON ' . PREFIX . 'ignored (ign);');
|
|
|
|
|
$db->exec('CREATE INDEX ignby ON ' . PREFIX . 'ignored (ignby);');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "linkfilter (id $primary, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex smallint NOT NULL);");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id $primary, 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 DEFAULT 1, incognito smallint NOT NULL DEFAULT 0, style varchar(255) NOT NULL, nocache smallint UNSIGNED NOT NULL DEFAULT 0);");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "members (id $primary, 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);");
|
|
|
|
|
$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 varchar(20000) NOT NULL, delstatus smallint NOT NULL);");
|
|
|
|
|
$db->exec('CREATE INDEX poster ON ' . PREFIX . 'messages (poster);');
|
|
|
|
|
$db->exec('CREATE INDEX recipient ON ' . PREFIX . 'messages (recipient);');
|
|
|
|
|
$db->exec('CREATE INDEX postdate ON ' . PREFIX . 'messages (postdate);');
|
|
|
|
|
$db->exec('CREATE INDEX poststatus ON ' . PREFIX . 'messages (poststatus);');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "notes (id $primary, type char(5) NOT NULL, lastedited integer NOT NULL, editedby varchar(50) NOT NULL, text varchar(20000) NOT NULL);");
|
|
|
|
|
$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 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 NOT NULL DEFAULT 1, incognito smallint NOT NULL DEFAULT 0, ip varchar(45) NOT NULL, nocache smallint UNSIGNED NOT NULL DEFAULT 0);");
|
|
|
|
|
$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 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 NOT NULL, incognito smallint NOT NULL, ip varchar(45) NOT NULL, nocache smallint NOT NULL, tz smallint NOT NULL);");
|
|
|
|
|
$db->exec('CREATE INDEX status ON ' . PREFIX . 'sessions (status);');
|
|
|
|
|
$db->exec('CREATE INDEX lastpost ON ' . PREFIX . 'sessions (lastpost);');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "settings (setting varchar(50) NOT NULL PRIMARY KEY, value varchar(20000) 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', 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;} .center-table{margin-left:auto;margin-right:auto;} body{text-align:center;} .left-table{width:100%;text-align:left;} .right{text-align:right;} .left{text-align:left;} .right-table{border-spacing:0px;margin-left:auto;} .padded{padding:5px;} #chatters{max-height:100px;overflow-y:auto;} .center{text-align:center;}'), 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'), array('keeplimit', '3'), array('mailsender', 'www-data <www-data@localhost>'), array('mailreceiver', 'Webmaster <webmaster@localhost>'), array('sendmail', '0'), array('modfallback', '1'), array('guestreg', '0'), array('disablepm', '0'), array('disabletext', "<h1>$I[disabledtext]</h1>"));
|
|
|
|
|
$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', 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;} .center-table{margin-left:auto;margin-right:auto;} body{text-align:center;} .left-table{width:100%;text-align:left;} .right{text-align:right;} .left{text-align:left;} .right-table{border-spacing:0px;margin-left:auto;} .padded{padding:5px;} #chatters{max-height:100px;overflow-y:auto;} .center{text-align:center;}'), 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'), array('keeplimit', '3'), array('mailsender', 'www-data <www-data@localhost>'), array('mailreceiver', 'Webmaster <webmaster@localhost>'), array('sendmail', '0'), array('modfallback', '1'), array('guestreg', '0'), array('disablepm', '0'), array('disabletext', "<h1>$I[disabledtext]</h1>"), array('defaulttz', '0'));
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'settings (setting, value) VALUES (?, ?);');
|
|
|
|
|
foreach($settings as $pair){
|
|
|
|
|
$stmt->execute($pair);
|
|
|
|
@ -3228,10 +3249,14 @@ function init_chat(){
|
|
|
|
|
'refresh' =>20,
|
|
|
|
|
'bgcolour' =>'000000',
|
|
|
|
|
'timestamps' =>1,
|
|
|
|
|
'style' =>'color:#FFFFFF;'
|
|
|
|
|
'style' =>'color:#FFFFFF;',
|
|
|
|
|
'embed' =>1,
|
|
|
|
|
'incognito' =>0,
|
|
|
|
|
'nocache' =>0,
|
|
|
|
|
'tz' =>0
|
|
|
|
|
);
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, timestamps, style, embed, incognito) VALUES (?, ?, ?, ?, ?, ?, ?, 1, 0);');
|
|
|
|
|
$stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['timestamps'], $reg['style']));
|
|
|
|
|
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, timestamps, style, embed, incognito, nocache, tz) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
|
|
|
|
|
$stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['timestamps'], $reg['style'], $reg['embed'], $reg['incognito'], $reg['nocache'], $reg['tz']));
|
|
|
|
|
$suwrite=$I['susuccess'];
|
|
|
|
|
}
|
|
|
|
|
print_start('init');
|
|
|
|
@ -3251,8 +3276,8 @@ function update_db(){
|
|
|
|
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('rulestxt', '');");
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<4){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD incognito smallint UNSIGNED NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ADD incognito smallint UNSIGNED NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD incognito smallint NOT NULL;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ADD incognito smallint NOT NULL;');
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<5){
|
|
|
|
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('globalpass', '');");
|
|
|
|
@ -3292,7 +3317,7 @@ function update_db(){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'notes CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'settings CHARACTER SET utf8 COLLATE utf8_bin;');
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "linkfilter (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, `match` varchar(255) NOT NULL, `replace` varchar(255) NOT NULL, regex smallint unsigned NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;");
|
|
|
|
|
$db->exec('CREATE TABLE ' . PREFIX . "linkfilter (id integer unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, `match` varchar(255) NOT NULL, `replace` varchar(255) NOT NULL, regex smallint NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;");
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions DROP fontinfo, DROP displayname;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD style varchar(255) NOT NULL;');
|
|
|
|
|
$result=$db->query('SELECT * FROM ' . PREFIX . 'members;');
|
|
|
|
@ -3318,7 +3343,7 @@ function update_db(){
|
|
|
|
|
$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 . "sessions MODIFY session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL UNIQUE, MODIFY nickname varchar(50) NOT NULL UNIQUE, 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 smallint unsigned NOT NULL DEFAULT 40, MODIFY boxheight smallint unsigned NOT NULL DEFAULT 3, MODIFY notesboxheight smallint unsigned NOT NULL DEFAULT 30, MODIFY notesboxwidth smallint 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 smallint unsigned NOT NULL DEFAULT 1, MODIFY incognito smallint unsigned NOT NULL DEFAULT 0, MODIFY ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, ADD INDEX(status) USING BTREE, ADD INDEX(lastpost) USING BTREE;");
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . "sessions MODIFY session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL UNIQUE, MODIFY nickname varchar(50) NOT NULL UNIQUE, 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 smallint unsigned NOT NULL DEFAULT 40, MODIFY boxheight smallint unsigned NOT NULL DEFAULT 3, MODIFY notesboxheight smallint unsigned NOT NULL DEFAULT 30, MODIFY notesboxwidth smallint 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 smallint NOT NULL DEFAULT 1, MODIFY incognito smallint NOT NULL DEFAULT 0, MODIFY ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, ADD INDEX(status) USING BTREE, ADD INDEX(lastpost) USING BTREE;");
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ENGINE=MEMORY;');
|
|
|
|
|
$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;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'settings DROP PRIMARY KEY, DROP id, ADD PRIMARY KEY(setting);');
|
|
|
|
@ -3348,8 +3373,8 @@ function update_db(){
|
|
|
|
|
update_setting('css', $css);
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<17){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ADD COLUMN nocache smallint UNSIGNED NOT NULL DEFAULT 0;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD COLUMN nocache smallint UNSIGNED NOT NULL DEFAULT 0;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ADD COLUMN nocache smallint NOT NULL DEFAULT 0;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD COLUMN nocache smallint NOT NULL DEFAULT 0;');
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<18){
|
|
|
|
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('disablepm', '0');");
|
|
|
|
@ -3357,6 +3382,11 @@ function update_db(){
|
|
|
|
|
if($dbversion<19){
|
|
|
|
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('disabletext', '<h1>$I[disabledtext]</h1>');");
|
|
|
|
|
}
|
|
|
|
|
if($dbversion<20){
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'sessions ADD COLUMN tz smallint NOT NULL DEFAULT 0;');
|
|
|
|
|
$db->exec('ALTER TABLE ' . PREFIX . 'members ADD COLUMN tz smallint NOT NULL DEFAULT 0;');
|
|
|
|
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('defaulttz', '0');");
|
|
|
|
|
}
|
|
|
|
|
update_setting('dbversion', DBVERSION);
|
|
|
|
|
if(get_setting('msgencrypted')!=MSGENCRYPTED){
|
|
|
|
|
if(!extension_loaded('openssl')){
|
|
|
|
@ -3523,13 +3553,16 @@ function load_lang(){
|
|
|
|
|
'id' =>'Bahasa Indonesia',
|
|
|
|
|
'ru' =>'Русский'
|
|
|
|
|
);
|
|
|
|
|
if(isSet($_REQUEST['lang']) && array_key_exists($_REQUEST['lang'], $L)){
|
|
|
|
|
if(isSet($_REQUEST['lang']) && isSet($L[$_REQUEST['lang']])){
|
|
|
|
|
$language=$_REQUEST['lang'];
|
|
|
|
|
setcookie('language', $language);
|
|
|
|
|
}elseif(isSet($_COOKIE['language']) && array_key_exists($_COOKIE['language'], $L)){
|
|
|
|
|
if(!isSet($_COOKIE['language']) || $_COOKIE['language']!==$language){
|
|
|
|
|
setcookie('language', $language);
|
|
|
|
|
}
|
|
|
|
|
}elseif(isSet($_COOKIE['language']) && isSet($L[$_COOKIE['language']])){
|
|
|
|
|
$language=$_COOKIE['language'];
|
|
|
|
|
}else{
|
|
|
|
|
$language=LANG;
|
|
|
|
|
setcookie('language', $language);
|
|
|
|
|
}
|
|
|
|
|
include('lang_en.php'); //always include English
|
|
|
|
|
if($language!=='en'){
|
|
|
|
@ -3542,8 +3575,8 @@ function load_lang(){
|
|
|
|
|
|
|
|
|
|
function load_config(){
|
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
|
define('VERSION', '1.17'); // Script version
|
|
|
|
|
define('DBVERSION', 19); // Database version
|
|
|
|
|
define('VERSION', '1.18'); // Script version
|
|
|
|
|
define('DBVERSION', 20); // Database 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
|
|
|
|
|