De-duplicate code
This commit is contained in:
51
chat.php
51
chat.php
@ -1432,14 +1432,8 @@ function send_waiting_room(){
|
|||||||
}else{
|
}else{
|
||||||
$wait=true;
|
$wait=true;
|
||||||
}
|
}
|
||||||
if(!isSet($U['session'])){
|
check_expired();
|
||||||
setcookie(COOKIENAME, false);
|
check_kicked();
|
||||||
send_error($I['expire']);
|
|
||||||
}
|
|
||||||
if($U['status']==0){
|
|
||||||
setcookie(COOKIENAME, false);
|
|
||||||
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
||||||
}
|
|
||||||
$timeleft=get_setting('entrywait')-(time()-$U['lastpost']);
|
$timeleft=get_setting('entrywait')-(time()-$U['lastpost']);
|
||||||
if($wait && ($timeleft<=0 || $ga===1)){
|
if($wait && ($timeleft<=0 || $ga===1)){
|
||||||
$U['entry']=$U['lastpost'];
|
$U['entry']=$U['lastpost'];
|
||||||
@ -2006,12 +2000,8 @@ function write_new_session(){
|
|||||||
if($temp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
if($temp=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||||
if($U['passhash']===$temp['passhash']){
|
if($U['passhash']===$temp['passhash']){
|
||||||
$U=$temp;
|
$U=$temp;
|
||||||
if($U['status']==0){
|
check_kicked();
|
||||||
setcookie(COOKIENAME, false);
|
|
||||||
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
||||||
}
|
|
||||||
setcookie(COOKIENAME, $U['session']);
|
setcookie(COOKIENAME, $U['session']);
|
||||||
$reentry=true;
|
|
||||||
}else{
|
}else{
|
||||||
send_error("$I[userloggedin]<br>$I[wrongpass]");
|
send_error("$I[userloggedin]<br>$I[wrongpass]");
|
||||||
}
|
}
|
||||||
@ -2081,12 +2071,8 @@ function check_login(){
|
|||||||
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'sessions WHERE session=?;');
|
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'sessions WHERE session=?;');
|
||||||
$stmt->execute(array($_POST['session']));
|
$stmt->execute(array($_POST['session']));
|
||||||
if($U=$stmt->fetch(PDO::FETCH_ASSOC)){
|
if($U=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||||
if($U['status']==0){
|
check_kicked();
|
||||||
setcookie(COOKIENAME, false);
|
|
||||||
send_error("$I[kicked]<br>$U[kickmessage]");
|
|
||||||
}else{
|
|
||||||
setcookie(COOKIENAME, $U['session']);
|
setcookie(COOKIENAME, $U['session']);
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
setcookie(COOKIENAME, false);
|
setcookie(COOKIENAME, false);
|
||||||
send_error($I['expire']);
|
send_error($I['expire']);
|
||||||
@ -2125,15 +2111,11 @@ function check_login(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function kill_session(){
|
function kill_session(){
|
||||||
global $I, $U, $db;
|
global $U, $db;
|
||||||
parse_sessions();
|
parse_sessions();
|
||||||
|
check_expired();
|
||||||
|
check_kicked();
|
||||||
setcookie(COOKIENAME, false);
|
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=$db->prepare('DELETE FROM ' . PREFIX . 'sessions WHERE session=?;');
|
||||||
$stmt->execute(array($U['session']));
|
$stmt->execute(array($U['session']));
|
||||||
if($U['status']==1){
|
if($U['status']==1){
|
||||||
@ -2209,19 +2191,29 @@ function logout_chatter($names){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_session(){
|
function check_session(){
|
||||||
global $I, $U;
|
global $U;
|
||||||
parse_sessions();
|
parse_sessions();
|
||||||
|
check_expired();
|
||||||
|
check_kicked();
|
||||||
|
if($U['entry']==0){
|
||||||
|
send_waiting_room();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_expired(){
|
||||||
|
global $I, $U;
|
||||||
if(!isSet($U['session'])){
|
if(!isSet($U['session'])){
|
||||||
setcookie(COOKIENAME, false);
|
setcookie(COOKIENAME, false);
|
||||||
send_error($I['expire']);
|
send_error($I['expire']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_kicked(){
|
||||||
|
global $I, $U;
|
||||||
if($U['status']==0){
|
if($U['status']==0){
|
||||||
setcookie(COOKIENAME, false);
|
setcookie(COOKIENAME, false);
|
||||||
send_error("$I[kicked]<br>$U[kickmessage]");
|
send_error("$I[kicked]<br>$U[kickmessage]");
|
||||||
}
|
}
|
||||||
if($U['entry']==0){
|
|
||||||
send_waiting_room();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_nowchatting(){
|
function get_nowchatting(){
|
||||||
@ -2719,6 +2711,7 @@ function apply_filter(){
|
|||||||
}
|
}
|
||||||
if(isSet($count) && $count>0 && $filter['kick']){
|
if(isSet($count) && $count>0 && $filter['kick']){
|
||||||
kick_chatter(array($U['nickname']), '', false);
|
kick_chatter(array($U['nickname']), '', false);
|
||||||
|
setcookie(COOKIENAME, false);
|
||||||
send_error("$I[kicked]");
|
send_error("$I[kicked]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user