On the Daimonin test site http://static.88-198…ents.your-server.de i have installed my new low level bridge for SMF which i call a DB/Session-Hook - because it don't integrates SMF into Postnuke but syncronizing the DB and sessions.
You can download the needed files here: *I removed the zip file, please use the code posts at the bottom *
I had written a also included readme - which i now post:
Postnuke SMF DB/Session-Hook 0.1
Warning: TESTING VERSION ONLY - DON'T INSTALL ON A LIVE OR PRODUCTION SITE
USE A TEST INSTALLATION OR BACKUP FIRST
THIS MAY EXPLODE YOUR COMPUTER AND DESTROY THE UNIVERSE
Your are warned
Warning: This is only tested with postnuke .8 RC1 and SMF 1.1.4
What it does
------------
This DB/Session-Hook is very special kind of bridge which will fully integrate
SMF under Postnuke 0.8 on Session and Database (user) level but NOT
on the higher level functions like theme engine, cache or module
handling.
That means SMF is NOT integrated in postnuke - its remote controlled on
user, DB and session level. If you are logged in postnuke, then you will
be also loged in SMF. You can't login on the SMF site, you don't have
even there valid passwords. If you register in postnuke you will automatically
added to smf when you access it.
There are 3 interfaces for avatars, email and profile settings which allow
to set that on postnuke site. The interfaces for that on SMF side are closed.
SMF will be under full "remote control" of postnuke but don't know it.
For that, SMF will always "overtake" the postnuke session and automatically
login the user, even adding the user to the SMF DB when needed and sync the
session and DB.
The advantages:
- SMF use their own caching and template system
- Fully and total user & session sync.
- both have still their own DB
- one login, one logout, one registration
- no URL fixing, no output fixing
- the fastest way to connect both without touching their DB
- NO changes to postnuke except a changed entry file setting
- only a few changes in SMF code to close interfaces and redirect
- all extensions for SMF should work
- very secure because SMF isn't callable direct without postnuke
The disadvantages:
- SMF use their own caching & template - no integration possible on that level
- harder to install as a normal bridge but then nearly flawless
How to install
--------------
BE WARNED! This is not a normal bridge installation. It use a few tricks to speed things
up and give postnuke & SMF the impression they are not connected. In fact they don't notice
each other. Both have still their DB entries unchanged, both have still an own session just
synchron with the same user.
For the session thingy we must ensure that postnuke and SMF think they are installed on the same
root. To avoid the installation of SMF folder over the postnuke folder, we have to do a small
trick, calling postnuke not by their default index.php but through a different file.
The index.php is a hook part - that file will call postnukes login procedure, setup the user and
then calling SMF, which is in a different root (directory). There it is including the original
SMF index.php and starting the forum normally, just sneaking in at one point the postnuke user.
Step-by-Step
------------
ANOTHER WARNING: please use exactly the names and directory names i give here because in the
current version most things are hard coded in the hook.
1.) install postnuke .8 where you want with DB name you want (for example pntest). Create the "admin" user
2.) install SMF INSIDE the directory where you installed postnuke in the directory /smf.
NOTE: Create the admin user in SMF with SAME name and password as in postnuke!
3.) IMPORTANT: use the same database name as for postnuke (for example pntest)
4.) you can change the DB prefix to what you want, just be sure its not the same as for postnuke
At this point you have 2 not connected installations - postnuke and SMF. Now we connect them.
5.) find the original index.php in the postnuke root and COPY it
6.) name the copy pn.php and copy it next to the index.php
7.) Login as admin to postnuke and go to admin area. Go there to System/Settings
8.) find the colum "Start Page Settings" and there the entry "Site entry point (Default: index.php)"
9.) change the entry there from index.php to pn.php and safe. Test Postnuke - it should now be called through pn.php
At this point we still have nothing really changed - that was the basic setup and we still have 2 not connected installs.
Now we start to apply changes.
10.) copy the index.php and pnsmf.php from the hook zip into the postnuke root directory. The postnuke index.php should be overwritten by that
11.) Now you have 2 choices:
11a.) copy the pnsmf.diff and apply it! That should work with other SMF as 1.1.4 perhaps too - test it.
11b.) use the files from the smf1.1.4.changes.zip and copy them over the SMF files in your /smf folder - BEWARE: it must be 1.1.4 unchanged!
12.) go into your /smf folder and find the file Settings.php
13.) find the line "$boardurl = ..." which should show like "$boardurl = 'http:///smf'" or something
14.) change that line to "$boardurl = ''" so it points to the postnuke root
15.) Done!
Now test it.
should show your postnuke site.
http:///pn.php should also show your postnuke site
http:///index.php should show your SMF Forum
Now login or register a new user in postnuke and go to your SMF forum. You should be loged in automatically now,
as you it should be done from a bridge too.
The Hook comes with 3 functions to copy every profile change done in postnuke to SMF.
That works on my example site but because the current postnuke .8 is a RC and under
heavy development i don't give examples where to add it now. But the functions
are pretty self explaining, look into the pnsmf.php.
-----------------------------------------------------------
Well, thats how to install it - again you can visit it on the link at the top of this thread.
I have fully added the SMF profile settings and avatar to the postnuke ones.
I used for that the Avatar module and a modified Profile standard module, using
the hooks in pnsmf.php.
ATM it works flawless - but i am not a very experienced SMF or Postnuke developer.
I have posted this text to both dev forums - Postnuke and SMF.
The other thread is here: http://www.simplemachines.org/community/index.php?topic=198703.0
If there are interest or when you have questions, please let me know.
I also very interested that some smf and postnuke gurus give the code a look
to see what can be done better.
One problem is that we have ONE $_SESSION array - SMF is storing some into it.
It seems not to make any bad problems but i would like to be sure.
The great, great big advantage of this kind of special bridge is not only the
speed but also that is nearly 100% compatible. As you can see i installed on the
demo site SEO4SMF. There was no problems or side effects to install it.
Except i had to copy the bridge index.php and name the copy seo4smf-redirect.php,
calling the real seo4smf-redirect.php into the /smf directory. But thats how
it should work. And it works as you can see.
The great thing is, that the SMF forum is really closed to outside. You can't
call it direct through the /smf/index.php without using a bridge entry from
above. Thats important to avoid attacks targeting the SMF/Postnuke DB sync.
Well, i like to hear what you people think - ATM i want use this on my own,
but when i get enough response i will make a real package.
On the SMF side, you can see the autologin function inside the pnsmf.php file.
The code patches are in the pnsmf.diff - as you can see its only the hook
into the index.php to login/logout the postnuke users and some redirect and
returns to close interfaces we have now on postnuke side.
The Postnuke code is small as it can be, using the unchanged startup interface:
Code
include 'includes/pnAPI.php';
include 'pnsmf.php';
pnInit(PN_CORE_ALL & ~(PN_CORE_AJAX|PN_CORE_LANGS|PN_CORE_MODS|PN_CORE_TOOLS|PN_CORE_DECODEURLS|PN_CORE_THEME));
// we store the user data in a neutral variable for moving it to SMF
$pnuser = pnUserGetVars(pnUserGetVar('uid'));
// hook into SMF
define('PNSMFEXT', 1);
require_once('smf/index.php');
include 'pnsmf.php';
pnInit(PN_CORE_ALL & ~(PN_CORE_AJAX|PN_CORE_LANGS|PN_CORE_MODS|PN_CORE_TOOLS|PN_CORE_DECODEURLS|PN_CORE_THEME));
// we store the user data in a neutral variable for moving it to SMF
$pnuser = pnUserGetVars(pnUserGetVar('uid'));
// hook into SMF
define('PNSMFEXT', 1);
require_once('smf/index.php');
cu
MT
edited by: michtoen, Oct 05, 2007 - 07:49 AM