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: 1318
Location: Germany

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

Note: I noticed that the mysql-functions are removed in php7 - it's supporting mysqli only. That means the whole INSTALLATION process is broken in php7! I'm working on a package for RavenNuke 2.5.1, which will work also with php7. For a fresh installation please don't use php7 as long the new package is released.

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, php7.0.10 and php7.1.11 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 Nov 05, 2017 10:13 am; edited 3 times in total 
View user's profile Send private message
kguske
Site Admin


Joined: Jun 04, 2004
Posts: 6383

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: 9

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

Interesting. Noted. Thanks for these tips.
 
View user's profile Send private message
neralex
PostPosted: Tue Oct 10, 2017 11:32 am Reply with quote

To prevent php7.x warnings caused by deprecated function names of class constructors, I prepared a "little" to-do list.

-----------------------

Open /classes/class.legal_doctypes.php

find:

php Code:
function Legal_DocTypes($modName='', $lang='')

replace it with:

php Code:
function __construct($modName='', $lang='')


-----------------------

Open /classes/class.legal_document.php

find:

php Code:
function Legal_Document($srcModule='')

replace it with:

php Code:
function __construct($srcModule='')


-----------------------

Open /classes/class.paginator.php

find:

php Code:
function Paginator($page, $num_rows, $per_page)

replace it with:

php Code:
function __construct($page, $num_rows, $per_page)


-----------------------

Open /includes/NukeSEO/content/content.php

find:

php Code:
function seoContent ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/Downloads_GR.php

find:

php Code:
function Downloads_GR ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/Encyclopedia.php

find:

php Code:
function seoEncyclopedia ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/FAQ.php

find:

php Code:
function seoFAQ ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/Forums.php

find:

php Code:
function seoForums ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/News.php

find:

php Code:
function seoNews ()


replace it with:
php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/Reviews.php

find:

php Code:
function seoReviews ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/content/Web_Links.php

find:

php Code:
function seoWeb_Links ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhAdmin.php

find:

php Code:
function dhAdmin ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhContent.php

find:

php Code:
function dhContent ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhDefault.php

find:

php Code:
function dhDefault ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhDownloads.php

find:

php Code:
function dhDownloads ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhEncyclopedia.php

find:

php Code:
function dhEncyclopedia ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhFAQ.php

find:

php Code:
function dhFAQ ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhFeeds.php

find:

php Code:
function dhFeeds ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhForums.php

find:

php Code:
function dhForums ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhGCalendar.php

find:

php Code:
function dhGCalendar ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhNews.php

find:

php Code:
function dhNews ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhReviews.php

find:

php Code:
function dhReviews ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhStories_Archive.php

find:

php Code:
function dhStories_Archive ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhSurveys.php

find:

php Code:
function dhSurveys ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/NukeSEO/dh/dhWeb_Links.php

find:

php Code:
function dhWeb_Links ()

replace it with:

php Code:
function __construct()


-----------------------

Open /includes/class.autokeyword.php

find:

php Code:
function autokeyword($params, $encoding)

replace it with:

php Code:
function __construct($params, $encoding)


-----------------------

Open /includes/class.php-captcha.php

find:

php Code:
function PhpCaptcha(

replace it with:

php Code:
function __construct(


Happy replacing. Shocked


Last edited by neralex on Sun Nov 05, 2017 2:57 am; edited 1 time in total 
kguske
PostPosted: Tue Oct 10, 2017 6:37 pm Reply with quote

Nice, and short Wink
 
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17084

PostPosted: Wed Oct 11, 2017 8:54 am Reply with quote

Nice job!
 
View user's profile Send private message
mike63740
Worker
Worker


Joined: Jun 21, 2010
Posts: 101

PostPosted: Fri Nov 03, 2017 8:42 am Reply with quote

I just upgraded XAMPP Version 1.8.2 to XAMPP Version 7.1.10 with this download:

xampp-win32-7.1.10-0-VC14-installer.exe
* Apache 2.4.28
* MariaDB 10.1.28
* PHP 7.1.10
* phpMyAdmin 4.7.4

The RavenNuke 2.51 database imported error free, but when I executed RavenNuke I got this error on white background:

Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in C:\xampp\htdocs\RavenNukeV2.51\rnconfig.php:282 Stack trace: #0 C:\xampp\htdocs\RavenNukeV2.51\config.php(80): require_once() #1 C:\xampp\htdocs\RavenNukeV2.51\mainfile.php(141): require_once('C:\\xampp\\htdocs...') #2 C:\xampp\htdocs\RavenNukeV2.51\index.php(23): require_once('C:\\xampp\\htdocs...') #3 {main} thrown in C:\xampp\htdocs\RavenNukeV2.51\rnconfig.php on line 282

I assumed from this topic that I should downgrade to a lesser verison of XAMPP.
 
View user's profile Send private message
Raven
PostPosted: Fri Nov 03, 2017 9:02 am Reply with quote

Mike, did you follow the instructions in the first post of this thread?
 
mike63740
PostPosted: Fri Nov 03, 2017 9:17 am Reply with quote

Yes Raven. After reading over this topic, I downloaded and installed:

xampp-win32-5.6.30-0-VC11-installer.exe
* Apache 2.4.25
* MariaDB 10.1.21
* PHP 5.6.30
* phpMyAdmin 4.6.5.2
 
Raven
PostPosted: Fri Nov 03, 2017 9:22 am Reply with quote

The first post explains how to get rid of the errors you posted in your original post about version 7. So the posted fixes don't work?
 
mike63740
PostPosted: Fri Nov 03, 2017 9:58 am Reply with quote

I decided from the first post if I install PHP 5.6.30, I would get no errors and have no additional settings to make. Everything is back to normal now.

Raven wrote:
The first post explains how to get rid of the errors you posted in your original post about version 7. So the posted fixes don't work?


I never tried the fixes for 7. It was a straight install without any editing.
 
mike63740
PostPosted: Fri Nov 03, 2017 10:08 am Reply with quote

Raven wrote:
Mike, did you follow the instructions in the first post of this thread?


Sorry. No I did not.
 
neralex
PostPosted: Sun Nov 05, 2017 10:09 am Reply with quote

Note: I noticed that the mysql-functions are removed in php7 - it's supporting mysqli only. That means the whole INSTALLATION process is broken with this version! I'm working on a package for RavenNuke 2.5.1, which will work also with php7. For a fresh installation please don't use it as long the new package is released.

I come closer to some SQL-Errors, which returns while using mysql 5.6+. Some important default-values has been changed.

Some new defaults are based on the TIMESTAMP and DATETIME improvements. That means, default-values like '0000-00-00 00:00:00' for DATETIME fields or '0000-00-00' for DATE fields are not more allowed. The supported range is '1000-01-01' to '9999-12-31'. This affects some queries in the INSTALLATION process (already fixed in my package) and it needs a big check to all affected modules with related INSERT queries.
Only registered users can see links on this board! Get registered or login! Only registered users can see links on this board! Get registered or login!

The 2nd big one is the default: sql_mode=only_full_group_by

Here an example of the Forums index:

Code:
SQL Error : 1055 Expression #29 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'rn251php7.t.topic_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_id, t.topic_title FROM ((( nuke_bbforums f LEFT JOIN nuke_bbposts p ON p.post_id = f.forum_last_post_id ) LEFT JOIN nuke_users u ON u.user_id = p.poster_id ) LEFT JOIN nuke_bbtopics t ON t.topic_last_post_id = f.forum_last_post_id) GROUP BY f.forum_id ORDER BY f.cat_id, f.forum_order


Here is the full query:

php Code:
$sql = "SELECT f.*, p.post_time, p.post_username,  u.username, u.user_id, t.topic_id, t.topic_title

FROM ((( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = f.forum_last_post_id)
GROUP BY f.forum_id ORDER BY f.cat_id, f.forum_order";


After checking the mysql-docs I figured it out, that the field t.topic_id must be placed also in the GROUP BY clause.
Only registered users can see links on this board! Get registered or login! Only registered users can see links on this board! Get registered or login!

php Code:
$sql = "SELECT f.*, p.post_time, p.post_username,  u.username, u.user_id, t.topic_id, t.topic_title

FROM ((( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = f.forum_last_post_id)
GROUP BY f.forum_id, t.topic_id ORDER BY f.cat_id, f.forum_order";
 
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 ©