News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Restarting SMF integration with PHP Nuke

Started by spottedhog, June 10, 2005, 01:47:31 PM

Previous topic - Next topic

spottedhog

Integration completed.....  go here:   http://www.smf-nuke.com to see it in action

Yes...  going to try PHP Nuke integration....again....

Just restarted today, but I ran into a question already...  This is probably a no-brainer, but I cannot find the answer anywhere....

Where is "$scripturl" first called?

I cannot find it in Settings.php, and I just cannot find where it is defined anywhere.  :-( 

I need $scripturl to be: "modules.php?name=Forums".  Right now $scripturl displays "index.php".  When it shows index.php, PHPNuke gives the error of not being able to access the file directly.

In other words, right now using the $scripturl gives this:
index.php?actions=admin

But I now need this:
modules.php?name=Forums&actions=admin

Any suggestions?

thanks...

[Unknown]

Quote from: spottedhog on June 10, 2005, 01:47:31 PM
Where is "$scripturl" first called?

QueryString.php.

I suggest you look at the Mambo bridge.

-[Unknown]

mennou


spottedhog

ahhhhh yess.....  querystring.php had it!!!!   yeah!!! thanks!!!! 

I know you said to look at the bridge, but unfortunately I think I/we will need to slightly modify the smf code.  By slightly I mean I will need to replace all the "?actions" "?boards" and "?topics" with &actions, etc. so they will display within the nuke module.  I think this will be about all I need to change within smf.......   

For the phpNuke, I will try to replace their user signin with smf code.....  I would also need to change the cookiedecode for phpNuke.

Any ideas or suggestions would be appreciated....

[Unknown]

Like I said, the Mambo Bridge has roughly the same requirements, and manages it without modifying SMF much at all.

I would suggest using the output buffer.

-[Unknown]

armdoggy

#5
I'm very interested in what you come up with. In the meanwhile, I've attempted to cobble together an integration that keeps the two databases in synch, here is VERY ROUGH code that you might put into smf's register.php (apologies if the formatting is all screwy):



// SMF Validation complete!
updateMemberData($row['ID_MEMBER'], array('is_activated' => 1, 'validation_code' => '\'\''));

///////////////////////////////////////////
//PHP NUKE INTEGRATION BEGIN//
///////////////////////////////////////////


//get the latest and greatest from the SMF db
$phpnuke_request = db_query("
SELECT ID_MEMBER,memberName, realName, emailAddress, passwd, avatar,  DATE_FORMAT(NOW(), '%b %d %Y') AS dateRegistered 
FROM {$db_prefix}members
WHERE ID_MEMBER='".$row['ID_MEMBER']."'
", __FILE__, __LINE__);

$phpnuke_row = mysql_fetch_object($phpnuke_request);
//and now stick it into the phpnuke db

$phpnuke_insert = db_query("
INSERT INTO nuke.nuke_users (user_id, username, user_email, user_password, user_avatar, user_avatar_type, user_regdate)
VALUES ($phpnuke_row->ID_MEMBER, '$phpnuke_row->memberName', '$phpnuke_row- >emailAddress', '$phpnuke_row->passwd', 'gallery/blank.gif', '3', '$phpnuke_row- >dateRegistered')", __FILE__, __LINE__);

spottedhog

#6
Maybe I should make my intentions a little more clear....  I am trying to intregrate SMF into phpNuke.  I am wanting to make it a module with nuke headers and footers, keeing the SMF footer intact.  I am not interested in a bridge or having 2 members tables.  I want only the one member table, the SMF one. 

If I saw things correctly, the Mambo bridge is just that, a bridge.....  and I really do not want to keep tables in sync.....  I can see some inherent issues there, but of course I may be wrong and have been wrong many times before.....

Here is a link to what I have so far:

Integration now complete.....  go here:    http://www.smf-nuke.com

So far, here is what I have done:

-Changed "is_admin" in all nuke files to "is_nukeadmin" to avoid conflict with SMF "is_admin".
-Added the few lines of code to make the index.php file be the module file for nuke.
---when I did that, I had the initial problem I listed above in my first posting...
-Made $scripturl = modules.php?name=Forums   so the links will work in the SMF code
-Replaced all ?action ?board ?topic with &action &board &topic so the nuke code would display those pages

Now all the links and pages work, except for one thing.  When I login (after I have logged out) and click on the Login submit button, it will initially go to the:
&action=login2 
but then it goes to: 
?action=login2;sa=check;member=1     

Since the ? does not work with the nuke code, I get a blank page with the error of file does not exist.  However....  It does log me in and all is well.....

Soooo, my next question is:   Where is the code that displays that ?action when the Login submit button is clicked?

[Unknown]

Unfortunately, that's just about everywhere.  What I would suggest is setting $scripturl to:

modules.php?name=Forums&

And, then, the URLs will end up like this:

modules.php?name=Forums&?action=login2

This is the same way the Mambo bridge works.  The next step would be to clean it up by removing the ?.  In an output buffering function, or after retrieving the buffer, simply do this:

$buffer = strtr($buffer, array('&?' => '&'));

This is safe because an entity cannot start with ?, so if ever there is a &?, it really should be & ;).

You'll next need to modify redirectexit(), which is your current hurdle.  The URL passed to it will need similar changes (but instead of &, just & of course...)  This function is in the large file Subs.php.

-[Unknown]

Orstio

Spottedhog:

Having gone through all of this already, (and I'd just like to add that you are catching on quite well), I just want to say that you should work on getting the URLs parsing correctly first.  Once that's working satisfactorily, you can work on how the tables and data are handled.  (You seem to be on the right track.)

QuoteIf I saw things correctly, the Mambo bridge is just that, a bridge.....  and I really do not want to keep tables in sync.....  I can see some inherent issues there, but of course I may be wrong and have been wrong many times before.....

Actually, the tables are synched only once, and only if the admin chooses to synch the users from Mambo to SMF.  Otherwise, the Mambo user table and the SMF member table operate as if they were completely independent.  This has its ups and downs:  member-specific details are more configurable, but in turn more complicated to manage.  But, I am also working on that.  :)

My advice:  Keep asking questions here.  I ran into a number of issues that I would never have worked out were it not for guidance from people like [Unknown].  Good luck, and keep at it.  You'll get it.  :)

spottedhog

#9
thanks [Unknown] !!!   

As you have guessed, I am not a coder and do not play one on tv... lol.  But I have worked with a ton of phpNuke code and files.  Guess this is a learning process, and I now understand your buffer comment earlier....  yes, it takes a while.

I do like the idea of minimizing code modification, and your $buffer should do the trick with the URL parsing issue.  I will get right to that....  after uploading the original untouched files again... lol.  (lessons learned)

I will try the suggestions and be back with probably another question...

Orstio....  thanks for your words of encouragement.  Maybe this attempt for me will actually be a full blown integration.....  who knows....

thanks again!

[Unknown]

Yeah.... the issue with modifying ever darn URL means that upgrades are nearly impossible, and themes have to be ported.  That's definately not desirable, yes?

-[Unknown]

spottedhog

#11
on the soapbox now....  :-)   PHPNuke, well, the founder, has pretty much gone off the deep end and puts out unsecure code and rarely if ever listens.  It is really becoming a big joke.  The code could be good with subtle changes and patches and upgraded modules, etc....  I think the combination of good Nuke code coupled with the excellent SMF code can be a very good marriage.

ok,..... that being said, yes, I agree that only minimal changes is best especially because one of the great qualities of SMF is the upgrading from within the application.  Pretty much a no brainer really.

So far if what I understand is correct, I only need to slightly modify 3 files:

index.php  (to add the nuke module code)
QueryString.php   (to change the $scripturl and adding the new $buffer line)
Subs.php  (replacing "?" with "&" in the funciton redirectexit)

I did all of those changes and everything seems to work OK.  Now on those redirects, and for the "Home" link, the URL comes up modules.php?name=Forums&   but it opens the right page, so maybe that is just something to live with......

If anyone is interested, here is a link to a working PHP Nuke module using SMF as the Forums:

Integration now complete......  go here:    http://www.smf-nuke.com

Well, at least right now SMF can be used, but there are still 2 user tables.......

OK.....  Now onto the removing the PHP Nuke user signin/login and replacing it with SMF code, and also changing the PHP Nuke cookiedecode.

Any thoughts?  (yes, I am looking at it and experimenting on my own)  ;-)

spottedhog

#12
Here are the modifications I made to get SMF as a PHP Nuke module.  I used SMF 1.05 and PHPNuke 7.6 with Patched 3.0.   Go to this link to view: 

Integration now complete..... go here:     http://www.smf-nuke.com

What you see in the link above here is exactly the changes listed below....

SMF File Modifications:

in index.php

-After    "<? php"    add:

global $hideleft; //code to hide left blocks
$hideleft = 1;

if ( !defined('MODULE_FILE') )
{
die("You can't access this file directly...");
}
if(!IsSet($mainfile)) { include ("mainfile.php"); }

include("header.php");


-before "?>"  add:

include("footer.php");


in QueryString.php

delete lines 76-77-78-79 and replace with this:   ($nukeurl is the PHP Nuke absolute path)

global $board, $topic, $boardurl, $scripturl, $nukeurl;

// Makes it easier to refer to things this way.
$scripturl = $nukeurl . '/modules.php?name=Forums&';


around line 322 add:
$buffer = strtr($buffer, array('&?' => '&amp;'));


in Subs.php

around line 1240 replace and add this code:
elseif ($add)
$setLocation = $scripturl . ($setLocation != '' ? '&' . $setLocation : '');  //replaced "?" with "&" SMF Nuke change


in SSI.php  replace all instances of:  ?action  ?board  ?topic       with:   action     board     topic

(in other words, remove the ? from the beginning of those 3 separate words in the entire file)   This is necessary especially to make links work properly in a PHP Nuke module or blocks that use the SSI.php scripts.

You may want to remove the logo code in the Themes/themename/index.template.php file.

PHP Nuke files needing Modifications:
To make SMF work as a PHP Nuke module, there are some Nuke files needing to be modified.  In the following files, replace  is_admin  with  is_nukeadmin 

files:  index.php  admin.php  footer.php  header.php  modules.php  mainfile.php 
block files:  blocks-Modules.php
admin files:  admin/modules/authors.php
module files:  nearly all index.php files of the modules

This will make SMF a PHP Nuke module but it still uses separate database tables.

This is about as far as I want to take this.  The more I have looked, the less I see a need to integrate the database tables.  Really the only functionality you are losing by keeping 2 separate tables is that a visitor will need to now register in the forums to be able to use the forums.  This is not a big deal since it takes less than a minute to register-login and set the cookie to "Forever".

[Unknown]

Quote from: spottedhog on June 11, 2005, 09:31:51 PM
The next challenge will be to change the PHP Nuke code to use SMF database tables.....

Sounds like fun ;).

The only suggestion I have is to make $scripturl, if possible, an absolute URL, not a relative one.

-[Unknown]

Orstio

QuoteThe only suggestion I have is to make $scripturl, if possible, an absolute URL, not a relative one.

I agree.  $scripturl is also used in SMF for things like links in registration emails and notification emails, so it is important that you include the entire URL within the variable. 

spottedhog

ahhhhh.... yes....  That makes sense.....(big dummy me)    I added $nukeurl  so now the code is this:

$scripturl = $nukeurl . '/modules.php?name=Forums&';

As you can imagine, $nukeurl is the absolute path already in PHP Nuke.

Now I am in the middle of renaming field names, etc. in PHP Nuke to correspond with the SMF users table.  My thought is to first not touch any of the Nuke code initially, and see if renaming things will still allow Nuke to do its thing.  I will probably need to change a lot, but not really. 

Right now Nuke uses the config.php file like SMF uses Settings.php.  I have Nuke working now using Settings.php and I think I will go ahead and rename the database name, etc. to what SMF uses since both will be using the same database anyway.

QUESTION:  When you have updates, updates that can be handled thru the package manager, are the following files normally changed during each update?  index.php  QueryString.php  Subs.php      I think you may understand why I am asking this.   :)   

TheDel

Oh man is this what I've been waiting to hear!
Ive been using phpnuke for my main page and and smf since yabbse days and have been trying to streamline my site and haven't been too thrilled with the security issues w/nuke.

But Ive also been using an older version because one of my favorite modules doesnt work in 7.5.

Also my members would be very happy to use a regular post to do news and not the current news module.

You have a timeline and would it be possible and simple to upgrade from my current phpnuke/smf? (note mine aren't ported- I run the smf separately and don't allow users to register in nuke- boy, would this make my life easier!)

:D

spottedhog

#17
Actually, I have the code and steps listed above to make SMF a PHP Nuke module, however, SMF still uses its own database tables.  From what I understand of what you said, this is maybe what you want anyway.

There are 3 files in SMF to modify, and then you will need to replace "is_admin" with "is_nukeadmin"  in all the PHP Nuke files.  The reason for that is SMF and PHP Nuke both use is_admin and you will see a conflict when trying to open the Forums module if you do not replace it.

Timetable for the full integration?  Depends upon how well the changes in the PHP Nuke Your_Account goes and some other changes in PHP Nuke code naming. 

My overall goal is to change as little as possible to the SMF code, so upgrades can still happen thru the application.

Here is a link to a test website that has SMF as a module and is using SMF for the News module.  Also I created a Forum Postings block and a Today's Events block that pulls data from SMF.  The Forum Postings block omits content from the News and Calendar boards.

Integration now complete.....  go here:     http://www.smf-nuke.com

spottedhog

#18
I have a login problem for the admin.......   when I enter a password and hit Login, it goes to this url:

modules.php?name=Forums&name=Forums;action=admin

Then it is not adding me in as admin.....

Yesterday, after I first made the changes to QueryString.php and Subs.php, I had a similar problem, then I hit the browser Refresh and I was able to see all the Admin functions.

My modifications are listed above.......

I am a bit lost on this.......  Help!

####################################################

MAYBE IT IS JUST A BUG OR ME......

......but now after I replaced the one "?" with a "&" on line 1241 of the SMF 1.04 version (as I have listed in an earlier post)   and I logout and then login, I can access the admin area just fine.....   

:-\   wow......   Well, it is working, but maybe that is how it is supposed to work, or maybe this is how it is supposed to work when wrapped in Nuke....   

####################################################

Yeppers....  I let the admin session time out and then tried to access the admin via the login box and it gave me that funky stuff  as I stated above.  But I logged out and then logged back in, and all was OK and I was able to access the admin area.

Any ideas what can be done?

thanks....

TheDel

Quote from: spottedhog on June 13, 2005, 12:59:56 PM
Actually, I have the code and steps listed above to make SMF a PHP Nuke module, however, SMF still uses its own database tables.  From what I understand of what you said, this is maybe what you want anyway.

There are 3 files in SMF to modify, and then you will need to replace "is_admin" with "is_nukeadmin"  in all the PHP Nuke files.  The reason for that is SMF and PHP Nuke both use is_admin and you will see a conflict when trying to open the Forums module if you do not replace it.

Timetable for the full integration?  Depends upon how well the changes in the PHP Nuke Your_Account goes and some other changes in PHP Nuke code naming. 

My overall goal is to change as little as possible to the SMF code, so upgrades can still happen thru the application.

Here is a link to a test website that has SMF as a module and is using SMF for the News module.  Also I created a Forum Postings block and a Today's Events block that pulls data from SMF.  The Forum Postings block omits content from the News and Calendar boards.

http://www.portals-are.us/smfnuketest/index.php
no, I do want them together. I get confused when I enter change the staff around.

Advertisement: