PHPMaker 4.3 + Simple Machines Forum SMF 1.1.5 Integration
May 16th, 2008 - GorkfuI thought I’d take the time and add my old, “PHPMaker (4.3) + Simple Machines Forum (1.1.5) Integration” Tutorial to the blog. I also optimized it, to make it a bit easier to follow.
There’s also a PHPMaker 5.0 + SMF 1.1.5 Tutorial available.
Please note the SMF package is no longer available for download. The following tutorial is for a manual install.
Note: You can use the SSI Login and Welcome functions for a register link in your PHPMaker template (open up ssi_examples.php from your forum folder to view examples and additional information).
Prerequistes:
SMF Files To Modify (2):
- smf_forum_folder\Sources\Load.php
- smf_forum_folder\Sources\LogInOut.php
Step #1 - Turn off Database Driven Sessions (In SMF)
A. Find the following option in SMF:
Admin –> Server Settings –> Feature Configuration –> Use database driven sessions
B. Make sure, “Use database driven sessions” IS UNCHECKED. This integration will not work with database sessions on.
Step #2 - Security Settings (In PHPMaker)
A. Security -> Use Existing Table ->
Table = smf_members
Login Name Field = memberName
Password Field = passwd
B. Hit Advanced tab, change User Level field to userlevel
C. Right click to add user level, name it Registered
D. Choose permissions you want this userlevel to have (This will be for normal users)
E. Edit/Add any other userlevels as you wish
F. Generate PHPMaker code
G. Download and use the package or continue on with the following steps.
Step #4 - Use the following query in phpmyadmin to Add userlevel field to smf_members table:
ALTER TABLE smf_members
ADD userlevel int(2) NOT NULL default ‘1′;
Note: This query will make all future accounts in smf as “normal” setting with PHPMaker. If you would like someone to have admin privileges you can manually change this in the database or setup a separate table in PHPMaker to control this in the backend.
Step #4 - Make Changes In LogInOut.php
Find this line 2 times:
SELECT passwd, ID_MEMBER, ID_GROUP, lngfile, is_activated, emailAddress, additionalGroups, memberName, passwordSalt
Change both to:
SELECT passwd, ID_MEMBER, ID_GROUP, lngfile, is_activated, emailAddress, additionalGroups, memberName, passwordSalt, userlevel
Next Find:
// Bam! Cookie set. A session too, just incase.
setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['ID_MEMBER'], sha1($user_settings['passwd'] . $user_settings['passwordSalt']));
Add after:
// PHPMaker 4 & SMF Integration Start
$_SESSION[ewSessionUserName] = $user_settings["memberName"];
$_SESSION[ewSessionSysAdmin] = 0; // Non System Administrator
$_SESSION[ewSessionUserID] = $user_settings["memberName"]; // User ID
$_SESSION[ewSessionUserLevel] = $user_settings["userlevel"]; // User Level
$_SESSION[ewSessionStatus] = “login”;
if ($_SESSION[ewSessionUserLevel] == -1) { // System Administrator
$_SESSION[ewSessionUserID] = -1;
}
// PHPMaker 4 & SMF Integration End
Next Find:
// Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
Add right before:
// PHPMaker 4 & SMF Integration Start
@session_unset();
@session_destroy();
// PHPMaker 4 & SMF Integration End
Step #5 Make Changes In Load.php
Find:
// Is the member data cached?
if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < 2 || ($user_settings = cache_get_data('user_settings-' . $ID_MEMBER, 60)) == null)
{
$request = db_query(”
SELECT mem.*, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = $ID_MEMBER)
WHERE mem.ID_MEMBER = $ID_MEMBER
LIMIT 1″, __FILE__, __LINE__);
$user_settings = mysql_fetch_assoc($request);
mysql_free_result($request);
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
cache_put_data(’user_settings-’ . $ID_MEMBER, $user_settings, 60);
}
Add After:
// PHPMaker 4 & SMF Integration Start
$_SESSION[ewSessionUserName] = $user_settings["memberName"];
$_SESSION[ewSessionSysAdmin] = 0; // Non System Administrator
$_SESSION[ewSessionUserID] = $user_settings["memberName"]; // User ID
$_SESSION[ewSessionUserLevel] = $user_settings["userlevel"]; // User Level
$_SESSION[ewSessionStatus] = “login”;
if ($_SESSION[ewSessionUserLevel] == -1) { // System Administrator
$_SESSION[ewSessionUserID] = -1;
}
// PHPMaker 4 & SMF Integration End
That’s all folks! If you have any questions, comments or need help with the integration then comment away!
Digg buttons brought to you by diggZ-ET (WordPress Plugin)
Tags: Forum, Integration, PHP, PHPMaker, SMF Forum, Tutorials
June 23rd, 2008 at 12:49 pm
anybody here know of a good site to find more info on Php _session? I’ve got this site bookmarked and im gonna keep checking it out, but i still would like to find a site that covers Php _session a little more thoroughly..thanks