Revision [10245]
This is an old revision of WikkaWithphpBB made by EniBevoli on 2005-07-29 15:35:28.
Using the phpBB users table for logging in
See also:
This is a very simple hack to get Wikka to read from the users table of a phpBB database rather than its own. It is assuming that you have installed your Wikka into the same database as phpBB and that your phpBB tables are prefixed with "phpbb_" and that their names have not been edited.
This will allow users from your phpBB forum to login to your wiki with their existing username and password.
/Wikka.php
Find: function LoadUser($name, $password = 0) { return $this->LoadSingle("select * from ".$this->config['table_prefix']."users where name = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and password = '".mysql_real_escape_string($password)."'")." limit 1"); }
Replace with:
function LoadUser($name, $password = 0) { return $this->LoadSingle("select * from ".phpbb_."users where username = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and user_password = '".mysql_real_escape_string($password)."'")." limit 1"); }
Find:
function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
Replace with:
function LoadUsers() { return $this->LoadAll("select * from ".phpbb_."users order by username"); }
Find:
function GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }
Replace with:
function GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }
Find:
function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }
Replace with:
function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }
/handlers/page/acls.php
Find: print("<option value=\"".$this->htmlspecialchars_ent($user["name"])."\">".$user["name"]."</option>\n");
Replace with:
print("<option value=\"".$this->htmlspecialchars_ent($user["username"])."\">".$user["username"]."</option>\n");
added by KiltanneN - feel free to remove or correct
/actions/usersettings.php
Find:Replace with:
added by EniBevoli - fix to show the name of the user again in the User Settings page
Find:
Replace with:
added by KiltanneN - feel free to remove or correct
I changed several things in the highscores.php code. Mostly they were changing the "name" to "username" but there was also the table prefix thing that had to be fixed up. Here's the full code:
/actions/highscores.php
<?php
# highscores.php {{HighScores}}
# by Chris Tessmer
# 19 Dec 2002
# license: GPL
$str = 'SELECT Count(*) AS cnt, `username` FROM phpbb_users, ' ;
$str .= $this->config["table_prefix"].'pages ';
$str .= "WHERE `username` = `owner` AND `latest` = 'Y' GROUP BY username ORDER BY cnt DESC;";
$rankQuery = $this->Query( $str );
$str = 'SELECT COUNT(*) FROM '.$this->config["table_prefix"].'pages WHERE `latest` = \'Y\' ';
$totalQuery = $this->Query( $str );
$total = mysql_result($totalQuery, 0);
print( "<blockquote><table>" );
$i = 0;
while( $row = mysql_fetch_array($rankQuery) )
{
$i++;
$str = '<tr>';
$str .= "<td>$i. </td>";
$str .= '<td>'. $this->Format( $row["username"] ) .'</td>';
$str .= '<td> </td>';
$str .= '<td> </td>';
$str .= '<td>'.$row["cnt"].'</td>';
$str .= '<td> </td>';
$str .= '<td>'. round( ($row["cnt"]/$total)*100, 2).'% </td>';
$str .= '</tr>';
print( $str );
}
print( "</table></blockquote>" );
?>
# highscores.php {{HighScores}}
# by Chris Tessmer
# 19 Dec 2002
# license: GPL
$str = 'SELECT Count(*) AS cnt, `username` FROM phpbb_users, ' ;
$str .= $this->config["table_prefix"].'pages ';
$str .= "WHERE `username` = `owner` AND `latest` = 'Y' GROUP BY username ORDER BY cnt DESC;";
$rankQuery = $this->Query( $str );
$str = 'SELECT COUNT(*) FROM '.$this->config["table_prefix"].'pages WHERE `latest` = \'Y\' ';
$totalQuery = $this->Query( $str );
$total = mysql_result($totalQuery, 0);
print( "<blockquote><table>" );
$i = 0;
while( $row = mysql_fetch_array($rankQuery) )
{
$i++;
$str = '<tr>';
$str .= "<td>$i. </td>";
$str .= '<td>'. $this->Format( $row["username"] ) .'</td>';
$str .= '<td> </td>';
$str .= '<td> </td>';
$str .= '<td>'.$row["cnt"].'</td>';
$str .= '<td> </td>';
$str .= '<td>'. round( ($row["cnt"]/$total)*100, 2).'% </td>';
$str .= '</tr>';
print( $str );
}
print( "</table></blockquote>" );
?>
Wikka Wiki and phpBB: using phpBB user information and allow Wikka-specific user settings
Added on July 29, 2005 by EniBevoliI still have to make a easily readable diff output (such as "Find" - "Replace with" above; I already translated some text strings to German, so diff'ing is currently a mess) so that other users can edit their own files, but since I have finally come to a solution outlined below, I thought it would be a beneficial for others to simply post my results right away. The existing work on the Wikka Wiki / phpBB integration was a big starting point; without this information, I wouldn't even had a clue what to do. :)
Features / How it works:
- Wikka uses phhBB for user logins, i.e. name and password of users are authenticated against the phpBB database
- Users can configure some Wikka-specific settings via the User Settings page (for some settings, there is no point in changing them at the User Settings page; e.g., the email or the password field: the user should change this in his phpBB profile)
- Whenever an existing phpBB user logs into Wikka, a Wikka user with the same name is created - if it does not already exist - for storing Wikka-specific settings (such as show_comments) as there is no counterpart for such settings in phpBB (and I don't want to alter the phpBB table structure)
Requirements:
- After the integration of Wikka Wiki and phpBB is done, user registration via Wikka Wiki must be disabled, new accounts should only be added via phpBB; see UserRegistration for more information about how to disable user registration
It took me quite some time to figure out why turning off "double click edit" didn't work - it is a bug with Wikka Wiki 1.1.6.0. :) I don't include the bug fix here, since it is already outlined in WikkaBugs.
Changed files:
- wikka.php
- actions/usersettings.php
- actions/highscore.php
- handlers/page/show.php (to fix the double click edit bug)
As I said, I'm still compiling the changes in an easily readable format and will update this page when I'm done.
To Do / Questions / Open Issues:
- phpBB users with non-camelcase usernames (e.g., "John") seem to work flawlessly on my installation even though I expected problems; any comments from the developers?
- I am quite sure that the code quality is...ahm..."suboptimal". I basically tried to get it to work in the first place (I downloaded WikkaWiki today for the first time), so please don't flame me; instead, help to fix it!
CategoryUserContributions