From 7ea35c2e61d33e8098752093d547b65142d86c92 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 11 Mar 2014 09:36:49 +0900 Subject: [PATCH] Fix depricated /e for magic links regex callback. --- www/admin/class_test.php | 6 +++++- www/libs/Class.Basic.inc | 29 ++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/www/admin/class_test.php b/www/admin/class_test.php index 5c07821e..fb2d9101 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -133,7 +133,7 @@ while (($ret = $basic->db_check_async()) === true) { print "[ERR]: $ret
"; - sleep(5); +// sleep(5); } // search path check @@ -146,6 +146,10 @@ $status = $basic->db_exec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")"); print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."
"; + // magic links test + print $basic->magic_links('user@bubu.at').'
'; + print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'
'; + // print error messages print $basic->print_error_msg(); diff --git a/www/libs/Class.Basic.inc b/www/libs/Class.Basic.inc index b13eaa79..a72fc23d 100644 --- a/www/libs/Class.Basic.inc +++ b/www/libs/Class.Basic.inc @@ -716,16 +716,31 @@ // _5: (_3) parameters of url or tld part of email // _7: link name/email link name // _9: style sheet class - $output = preg_replace("/(href=\")?(\>)?\b($protRegex)([\w\.\-?&=+%#~,;\/]+)\b([\.\-?&=+%#~,;\/]*)(\|([^\||^#]+)(#([^\|]+))?\|)?/e", "\$this->create_url('\\1', '\\2', '\\3', '\\4', '\\5', $target, '\\7', '\\9')", $output); + $self = $this; +// $this->debug('URL', 'Before: '.$output); + $output = preg_replace_callback("/(href=\")?(\>)?\b($protRegex)([\w\.\-?&=+%#~,;\/]+)\b([\.\-?&=+%#~,;\/]*)(\|([^\||^#]+)(#([^\|]+))?\|)?/", + function ($matches) use ($self) + { + return $self->create_url($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[7], $matches[9]); + }, + $output + ); // find email-addresses, but not mailto prefix ones - $output = preg_replace("/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/e", "\$this->create_email('\\1', '\\2', '\\3', '\\4', '\\5', '\\7', '\\9')", $output); + $output = preg_replace_callback("/(mailto:)?(\>)?\b([\w\.-]+)@([\w\.\-]+)\.([a-zA-Z]{2,4})\b(\|([^\||^#]+)(#([^\|]+))?\|)?/", + function ($matches) use ($self) + { + return $self->create_email($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[7], $matches[9]); + }, + $output + ); -// $this->debug('URL', "$output"); + $this->debug('URL', 'After: '.$output); // // we have one slashes after the Protocol -> internal link no domain, strip out the proto // $output = preg_replace("/($protRegex)\/(.*)/e", "\\2", $ouput); // $this->debug('URL', "$output"); // post processing + $output = str_replace ("{TARGET}", $target, $output); $output = str_replace ("##LT##", "<", $output); $output = str_replace ("##GT##", ">", $output); $output = str_replace ("##QUOT##", "\"", $output); @@ -742,15 +757,19 @@ // DESCRIPTION // internal function, called by the magic url create functions. // checks if title $_4 exists, if not, set url as title - private function create_url($href, $atag, $_1, $_2, $_3, $target, $name, $class) + private function create_url($href, $atag, $_1, $_2, $_3, $name, $class) { -//echo "DEBUG: 1: $_1 - 2: $_2 - $_3 - atag: $atag - target: $target - name: $name - class: $class
"; +// $this->debug('URL', "1: $_1 - 2: $_2 - $_3 - atag: $atag - name: $name - class: $class"); // if $_1 ends with //, then we strip $_1 complete & target is also blanked (its an internal link) if (preg_match("/\/\/$/", $_1) && preg_match("/^\//", $_2)) { $_1 = ''; $target = ''; } + else + { + $target = '{TARGET}'; + } // if it is a link already just return the original link do not touch anything if (!$href && !$atag) return "##LT##a href=##QUOT##".$_1.$_2.$_3."##QUOT##".(($class) ? ' class=##QUOT##'.$class.'##QUOT##' : '').(($target) ? " target=##QUOT##".$target."##QUOT##" : '')."##GT##".(($name) ? $name : $_2.$_3)."##LT##/a##GT##";