Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x
Author Message
neralex
The Mouse Is Extension Of Arm


Joined: Aug 22, 2007
Posts: 1289
Location: Germany

PostPosted: Sun Jan 01, 2017 11:04 pm Reply with quote

php5.6 gets the last major update (v5.6.30) in the next time. With this release the development on php5.x will ends finally. After that it will get only security updates until 2019.

So I guess its time to test RN251 with php7. On my local box I'm testing currently with php5.6.28 and with php7.0.10 to compare possible issues. I will update this thread, if I get more issues.

Please note: All my changes are only related to my used php versions. No guarantee that will work with previous versions.

open rnconfig.php and find:

php Code:
if (!version_compare(phpversion(), '6.0.0') >= 0) {

@set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
@ini_set('allow_call_time_pass_reference', true); // PHP5 may/will throw a warning so this will suppress it
}


replace:

php Code:
if (!version_compare(phpversion(), '6.0.0') >= 0) {

@ini_set('magic_quotes_runtime', 0); // Disable magic_quotes_runtime
@ini_set('allow_call_time_pass_reference', true); // PHP5 may/will throw a warning so this will suppress it
}



open modules/Forums/common.php and find:

php Code:
@set_magic_quotes_runtime(0); // Disable magic_quotes_runtime


replace with:

php Code:
@ini_set('magic_quotes_runtime', 0); // Disable magic_quotes_runtime



open: modules/Forums/includes/bbcode.php:

find:

php Code:
$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

change it to:

php Code:
    # PHP7 fix

# http://php.net/manual/en/reference.pcre.pattern.modifiers.php
$text = preg_replace_callback(
"#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#si",
function ($m) use ($uid) {
return "[img:$uid]$m[1]" . str_replace(' ', '%20', $m[3]) . "[/img:$uid]";
},
$text
);



open includes/kses/kses.php:

find:

php Code:
function kses_split($string, $allowed_html, $allowed_protocols)

###############################################################################
# This function searches for HTML tags, no matter how malformed. It also
# matches stray ">" characters.
###############################################################################
{
return preg_replace('%(<'. # EITHER: <
'[^>]*'. # things that aren't >
'(>|$)'. # > or end of string
'|>)%e', # OR: just a >
"kses_split2('\\1', \$allowed_html, ".
'$allowed_protocols)',
$string);
} # function kses_split


replace with:

php Code:
function kses_split($string, $allowed_html, $allowed_protocols)

###############################################################################
# This function searches for HTML tags, no matter how malformed. It also
# matches stray ">" characters.
###############################################################################
{
$callback = function ($matches) use ($allowed_html, $allowed_protocols){
return kses_split2($matches[1], $allowed_html, $allowed_protocols);
};
return preg_replace_callback('%(<'. # EITHER: <
'[^>]*'. # things that aren't >
'(>|$)'. # > or end of string
'|>)%', # OR: just a >
$callback,
$string);
} # function kses_split



find:

php Code:
function kses_normalize_entities($string)

###############################################################################
# This function normalizes HTML entities. It will convert "AT&T" to the correct
# "AT&amp;T", ":" to ":", "&#XYZZY;" to "&amp;#XYZZY;" and so on.
###############################################################################
{
# Disarm all entities by converting & to &amp;

$string = str_replace('&', '&amp;', $string);

# Change back the allowed entities in our entity whitelist

$string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]{0,19});/',
'&\\1;', $string);
$string = preg_replace('/&amp;#0*([0-9]{1,5});/e',
'kses_normalize_entities2("\\1")', $string);
$string = preg_replace('/&amp;#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/',
'&#\\1\\2;', $string);

return $string;
} # function kses_normalize_entities


replace with:

php Code:
function kses_normalize_entities($string)

###############################################################################
# This function normalizes HTML entities. It will convert "AT&T" to the correct
# "AT&amp;T", ":" to ":", "&#XYZZY;" to "&amp;#XYZZY;" and so on.
###############################################################################
{
# Disarm all entities by converting & to &amp;

$string = str_replace('&', '&amp;', $string);

# Change back the allowed entities in our entity whitelist

$string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]{0,19});/',
'&\\1;', $string);
$callback = function (){
return kses_normalize_entities2("\\1");
};
$string = preg_replace_callback('/&amp;#0*([0-9]{1,5});/', $callback, $string);
$string = preg_replace('/&amp;#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/',
'&#\\1\\2;', $string);
return $string;
} # function kses_normalize_entities


Last edited by neralex on Sun Jun 25, 2017 4:32 pm; edited 1 time in total 
View user's profile Send private message
kguske
Site Admin


Joined: Jun 04, 2004
Posts: 6381

PostPosted: Wed Jan 04, 2017 9:49 pm Reply with quote

Thank you neralex

_________________
I google, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
helidoc
Hangin' Around


Joined: Jul 09, 2006
Posts: 47

PostPosted: Sun Jun 25, 2017 3:26 pm Reply with quote

Thanks Neralex, now to figure out what to do with the forums mod. since phpbb that comes with raven doesn't work with php7 Smile
 
View user's profile Send private message
neralex
PostPosted: Sun Jun 25, 2017 3:31 pm Reply with quote

You are right, there are issues with the bbcode.php.

open: modules/Forums/includes/bbcode.php and find:

php Code:
$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

change it to:

php Code:
    # PHP7 fix

# http://php.net/manual/en/reference.pcre.pattern.modifiers.php
$text = preg_replace_callback(
"#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#si",
function ($m) use ($uid) {
return "[img:$uid]$m[1]" . str_replace(' ', '%20', $m[3]) . "[/img:$uid]";
},
$text
);


Note: I added this also to the thread-opener.

I will check it in the next days because I guess there are more issues like that. I noticed also an SQL error in the index.php of the Forums module, which I will fix later.


Last edited by neralex on Sun Jun 25, 2017 4:40 pm; edited 1 time in total 
helidoc
PostPosted: Sun Jun 25, 2017 4:35 pm Reply with quote

Specific to the forums module, I'm finding that folks posts don't show, ie the the topic will post but with no body posted. Haven't drilled down the cause of it yet but it's only with php 7 running on the site, reverting back to 5.6 and posts show as normal. Thanks for the bbcode edits will keep an eye here for further updates and thanks for all the php7 edits Smile
 
neralex
PostPosted: Sun Jun 25, 2017 4:53 pm Reply with quote

Thank you for the report. Smile

Each report will help to get it sorted. All my 'live'-projects are running still on 5.6.x because this PHP version is very stable but for the future is it better to find all issues.
 
moekin
New Member
New Member


Joined: May 07, 2010
Posts: 1

PostPosted: Wed Aug 16, 2017 10:14 am Reply with quote

Thank you so much. This saved my bacon. Really appreciate the work you put into this and sharing it.
 
View user's profile Send private message
neralex
PostPosted: Thu Aug 17, 2017 5:11 pm Reply with quote

No problem, if you will find more issues, please let me know.
 
gravutrad
New Member
New Member


Joined: Feb 27, 2012
Posts: 6

PostPosted: Thu Aug 17, 2017 6:09 pm Reply with quote

Interesting. Noted. Thanks for these tips.
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©