Revision [16410]

This is an old revision of WikkaWithphpBB made by PvgEo0 on 2007-04-19 08:32:00.

 

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.

Please note that for suggested changes phpBB and wikka should use the same database - otherwise it is necessary to give rights to wikka's database to read phpBB's database - and to write name of phpBB's database before its tables.


Method 1


/Wikka.php (in Wikka 1.1.6.2 its /libs/Wakka.class.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("user_name", $user["name"]); $this->SetPersistentCookie("pass", $user["password"]); }


Replace with:
 function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("user_name", $user["username"]); $this->SetPersistentCookie("pass", $user["user_password"]); }


/handlers/page/acls.php
Find:
 echo "\t".'<option value="'.$this->htmlspecialchars_ent($user['name']).'">'.$user['name'].'</option>'."\n";


Replace with:
 echo "\t".'<option value="'.$this->htmlspecialchars_ent($user['username']).'">'.$user['username'].'</option>'."\n";


added by KiltanneN - feel free to remove or correct
/actions/usersettings.php
Find:
 case (md5($_POST['password']) != $existingUser['password']):


Replace with:
 case (md5($_POST['password']) != $existingUser['user_password']):


added by EniBevoli - fix to show the name of the user again in the User Settings page

Find:
 <td>Hello, <?php echo $this->Link($user['name']) ?>!</td>


Replace with:
 <td>Hello, <?php echo $this->Link($user['username']) ?>!</td>




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)
<?php
# highscores.php
Top 10 contributor(s)
rank user pages owned percentage
1.  DarTar 190 10.8%
2.  BrianKoontz 110 6.3%
3.  JavaWoman 103 5.9%
4.  NilsLindenberg 82 4.7%
5.  JsnX 74 4.2%
6.  PivWan 35 2%
7.  YanB 32 1.8%
8.  ChristianBarthelemy 30 1.7%
9.  GmBowen 29 1.7%
10.  MasinAlDujaili 19 1.1%

# 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.
There are 30 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki