From e454b44f2bea1715d45d00489b9fb19691b7be81 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sat, 30 Apr 2016 15:29:41 +0200 Subject: [PATCH] de-duplicate code --- chat.php | 76 +++++++++++++++++++------------------------------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/chat.php b/chat.php index 7213502..13c4344 100644 --- a/chat.php +++ b/chat.php @@ -1354,6 +1354,7 @@ function send_inbox(){ } }else{ $injectRedirect=false; + $redirect=''; } if(get_setting('imgembed') && (!$U['embed'] || !isSet($_COOKIE[COOKIENAME]))){ $removeEmbed=true; @@ -1373,23 +1374,7 @@ function send_inbox(){ $stmt=$db->prepare('SELECT id, postdate, text FROM ' . PREFIX . 'inbox WHERE recipient=? ORDER BY id DESC;'); $stmt->execute(array($U['nickname'])); while($message=$stmt->fetch(PDO::FETCH_ASSOC)){ - if(MSGENCRYPTED){ - $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456'); - } - if($injectRedirect){ - $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', - function ($matched) use ($redirect){ - return "$matched[2]"; - } - , $message['text']); - } - if($removeEmbed){ - $message['text']=preg_replace_callback('/<\/a>/', - function ($matched){ - return "$matched[1]"; - } - , $message['text']); - } + prepare_message_print($message, $injectRedirect, $redirect, $removeEmbed); echo "