|
Cookbook /
SimplemachinesIntegrationSummary: How to use the authentification of the Simplemachines forum to control the access to a PmWiki installation
Version: 2006-1-21
Prerequisites: PmWiki 2.1
Status:
Maintainer: Anno
Categories: Integration, Security
QuestionHow can I use the user authentification of the Simplemachines forum to control the access to my pmwiki installation? AnswerThis recipe enables all registered users on a Simplemachines forum to edit the wiki pages. The wiki pages in the Site group can only be edited by the users with the status administrator. The recipe currently requires to edit the pmwiki.php file, as it wouldn't work when included only from the config.php file. Installation instructions1. create a file called forumauth.php with this content: <?php
//Simplemachines authentication
$pos = strpos($_SERVER['REQUEST_URI'], "action=edit");
if (is_numeric($pos)){
require_once('/path/to/your/forum/SSI.php');
if (!$user_info['username']) {
echo "You have to be registered and logged in at the Forums
in order to edit this wiki document.<br /><br />
1.) First <a href='http://www.yoursite.com/forum/index.php'?action=login'
target='_blank'>click here</a>
to open a new window where you can log in at the Forums,
(leave that window open after you logged in)<br />
2.) Then <a href='{$_SERVER['REQUEST_URI']}'>click
here</a> to edit the wiki page.";
exit;
}
}
Modify /path/to/your/forum/SSI.php and http://www.yoursite.com/forum/index.php to fit your forum. Copy the file forumauth.php to the pmwiki local/ directory. 2. Edit Site.EditForm and (:input e_author:) with: {$Author}
3. Add this to your local/config.php file:
4. Add this to the top of the local/config.php file, immediately after <?php require_once('forumauth.php');
Notes
ReleasesAnno 2006-1-21 Version 1.0 CommentsSorry, but this does not work, at least on my server. How to debug??? I have pmwiki installed at wiki.example.com and SMF is on example.com/smf/ - will this still work then? It should, as long you set the paths correctly. Anno May 19, 2007, at 05:52 AM Also I wonder how to follow your steps, because if I follow 1 - 3, I can not edit Site.EditForm anymore, because it asks me to be logged in (and that, in return, does not work)... I changed the directions to first change the Site.EditForm Anno May 19, 2007, at 05:52 AM Hi! how do I get it to work also for read authorisation? If I add it will not work and ask me for a password. Any easy fix so that you need to be a forum member to be able to read and write? If you want to give permission to edit pages only to SMF Forum Administrator(s), add this to your local/config.php file :
instead of this:
Hi there, the recipe above made editing a bit annoying, because all single quotes were framed in backslashes like this: \'\ Installation instructions1. Create forumauth.php as described above with this content: <?php
//Simplemachines authentication
$pos = strpos($_SERVER['REQUEST_URI'], "action=edit");
if (is_numeric($pos)){
if(!require_once('/path/to/your/forum/smf_api.php'))
die('Unable to connect to authentication database: Please try again later');
smf_authenticateUser();
if (!$smf_user_info['username']) {
echo "You need to be registered and logged in at the Forums
in order to edit this wiki document.<br /><br />
1.) First <a href='http://www.yoursite.com/forum/index.php'?action=login'
target='_blank'>click here</a>
to open a new window where you can log in at the Forums,
(leave that window open after you logged in)<br />
2.) Then <a href='{$_SERVER['REQUEST_URI']}'>click
here</a> to edit the wiki page.";
exit;
}
}
Modify /path/to/your/forum/smf_api.php and http://www.yoursite.com/forum/index.php to fit your forum. Place forumauth.php inside your local/ directory. 2. Edit Site.EditForm and (:input e_author:) with: {$Author}
3. Add this to your local/config.php file: require_once('forumauth.php');
If you like to give edit permission just to one or more groups in your forum instead to all registered and logged-in users, you can use these lines instead: require_once('forumauth.php');
You have to replace the # with the group-ID. You can get the group-ID on the membergroup-site in your forums. 4. You need the smf_api.php-File in version 1.1, so don't waste your time to download it from the SMF-Homepage (at least as long as that site isn't updated): Get it in the SMF-Forum. You need to be registered to see the attached file. That's it. Greetings! TrashQueen See AlsoContributors |