The following tutorial is for integrating PHPMaker 4.3 (generated web files) with Simple Machines Forum 1.1.8. This tutorial is for integration between PHPMaker generated website files and SMF 1.x.x forum software.
There’s also a newer tutorial available for PHPMaker 5.0
Notes
- This tutorial is outdated and may or may not work on newer versions of the software.
- The SMF package is no longer available for download. The following tutorial is for a manual install only.
- 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_folderSourcesLoad.php
- smf_forum_folderSourcesLogInOut.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 #3 – 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!