diff --git a/CHANGELOG b/CHANGELOG
index 1553347..dfb3d0f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 1.12.2 - Aug. 18, 2015
+Fix redirection and image embedding
+
Version 1.12.1 - Aug. 17, 2015
Fix update query
diff --git a/chat.php b/chat.php
index e525280..2283c19 100755
--- a/chat.php
+++ b/chat.php
@@ -2046,7 +2046,6 @@ function apply_filter(){
function apply_linkfilter(){
global $C, $U, $memcached, $mysqli;
- if(get_setting('imgembed')) $U['message']=preg_replace_callback('/\[img\]\s?(.*?(?=<\/a>))<\/a>/i', function ($matched){ return str_ireplace('[/img]', '', "

");}, $U['message']);
if($C['memcached']) $filters=$memcached->get("$C[dbname]-$C[prefix]linkfilter");
if(!$C['memcached'] || $memcached->getResultCode()!=Memcached::RES_SUCCESS){
$filters=array();
@@ -2058,12 +2057,13 @@ function apply_linkfilter(){
$U['message']=preg_replace_callback("/(.*?(?=<\/a>))<\/a>/i", function ($matched) use(&$filter){ return "".preg_replace("/$filter[match]/i", $filter['replace'], $matched[2]).'';}, $U['message']);
}
$redirect=get_setting('redirect');
+ if(get_setting('imgembed')) $U['message']=preg_replace_callback('/\[img\]\s?(.*?(?=<\/a>))<\/a>/i', function ($matched){ return str_ireplace('[/img]', '', "

");}, $U['message']);
if(empty($redirect)) $redirect="$_SERVER[SCRIPT_NAME]?action=redirect&url=";
- if(get_setting('forceredirect')) $U['message']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched){ global $C; return "$matched[2]";}, $U['message']);
+ if(get_setting('forceredirect')) $U['message']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use($redirect){ return "$matched[2]";}, $U['message']);
elseif(preg_match_all('/(.*?(?=<\/a>))<\/a>/', $U['message'], $matches)){
foreach($matches[1] as $match){
if(!preg_match('~^http(s)?://~', $match)){
- $U['message']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched){ global $C; return "$matched[2]";}, $U['message']);
+ $U['message']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use($redirect){ return "$matched[2]";}, $U['message']);
break;
}
}
@@ -2203,7 +2203,7 @@ function print_messages($delstatus=''){
while(mysqli_stmt_fetch($stmt)){
if($C['msgencrypted']) $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456');
if($injectRedirect){
- $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched){ global $C; return "$matched[2]";}, $message['text']);
+ $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use ($redirect){ return "$matched[2]";}, $message['text']);
}
if($removeEmbed){
$message['text']=preg_replace_callback('/
/', function ($matched){ return $matched[1];}, $message['text']);
@@ -2224,7 +2224,7 @@ function print_messages($delstatus=''){
while(mysqli_stmt_fetch($stmt)){
if($C['msgencrypted']) $message['text']=openssl_decrypt($message['text'], 'aes-256-cbc', $C['encryptkey'], 0, '1234567890123456');
if($injectRedirect){
- $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched){ global $C; return "$matched[2]";}, $message['text']);
+ $message['text']=preg_replace_callback('/(.*?(?=<\/a>))<\/a>/', function ($matched) use($redirect) { return "$matched[2]";}, $message['text']);
}
if($removeEmbed){
$message['text']=preg_replace_callback('/
/', function ($matched){ return $matched[1];}, $message['text']);
@@ -2597,7 +2597,7 @@ function load_lang(){
function load_config(){
global $C;
$C=array(
- 'version' =>'1.12.1', // Script version
+ 'version' =>'1.12.2', // Script version
'dbversion' =>11, // Database version
'chatname' =>'My Chat', // Chat Name
'keeplimit' =>3, // Amount of messages to keep in the database (multiplied with max messages displayed) - increase if you have many private messages