Revision history for WikkaWithphpBB


Revision [23350]

Last edited on 2016-05-20 07:38:47 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Additions:
~-[[WikkaWithphpBB3 | Using Wikka with phpBB3]]
Note: these methods are used to integrate phpBB 2.x. For phpBB 3.x, see [[WikkaWithphpBB3 | Using Wikka with phpBB3]]
Deletions:
~-[[WikkaWithphpBB3 Using Wikka with phpBB3]]
Note: these methods are used to integrate phpBB 2.x. For phpBB 3.x, see [[WikkaWithphpBB3 Using Wikka with phpBB3]]


Revision [19912]

Edited on 2008-05-12 18:47:21 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Additions:
Note: these methods are used to integrate phpBB 2.x. For phpBB 3.x, see [[WikkaWithphpBB3 Using Wikka with phpBB3]]
Deletions:
====**Using PHPBB 2.x**====


Revision [19911]

Edited on 2008-05-12 18:46:01 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Additions:
~-[[WikkaWithphpBB3 Using Wikka with phpBB3]]
Deletions:
~-[Using Wikka with phpBB3|WikkaWithphpBB3]


Revision [19910]

Edited on 2008-05-12 18:40:52 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Additions:
~-[Using Wikka with phpBB3|WikkaWithphpBB3]
Deletions:
WikkaWithphpBB3


Revision [19909]

Edited on 2008-05-12 18:25:24 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Additions:
WikkaWithphpBB3


Revision [19908]

Edited on 2008-05-12 18:24:12 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Deletions:
====**Using PHPBB 3.x**====
Contributed by Paul Young, using the example code by JeremyCoates in Method 2 below.
phpBB3 changed its user authentication mechanism. phpBB3 no longer stores MD5 hashes of passwords; instead it does a "true" one-way, one-time, non-recoverable hash of the password using [http://www.openwall.com/phpass/|phpass]. The output of the hash is different each time, so you can't just select the password in the phpBB database and do a compare against a MD5 of the submitted password anymore - you have to algorithmically compare them using phpass. They also changed how and where they indicate if a user is active or inactive.
It's not difficult, but you will need to bring in code from phpBB to your Wikka files.
One final note, this code works for me on my server, but could stand to be further tested. Feel free to correct if you find a bug.
/**
* PHPBB Integration
*
* 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"); }
*/
function LoadUser($name, $password = 0) {
$user = $this->LoadSingle("select
p.username as name
from ".phpbb3_."users p
where p.username = '".mysql_real_escape_string($name)."' and p.user_type != 1 limit 1");

}
return $user;%%

Replace With:
%%(php) /**
* PHPBB Integration
*
* function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
*/
from ".phpbb3_."users p
where p.user_type != 1
order by username");
Finally, copy and paste these phpass functions from phpBB into the bottom of file, before the "?>"
/**
*
* @version Version 0.1 / $Id: functions.php 8491 2008-04-04 11:41:58Z acydburn $
*
* Portable PHP password hashing framework.
*
* Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
* the public domain.
*
* There's absolutely no warranty.
*
* The homepage URL for this framework is:
*
* http://www.openwall.com/phpass/
*
* Please be sure to update the Version line if you edit this file in any way.
* It is suggested that you leave the main version number intact, but indicate
* your project name (after the slash) and add your own revision information.
*
* Please do not change the "private" password hashing method implemented in
* here, thereby making your hashes incompatible. However, if you must, please
* change the hash type identifier (the "$P$") to something different.
*
* Obviously, since this code is in the public domain, the above are not
* requirements (there can be none), but merely suggestions.
*
*
* Hash the password
*/
function phpbb_hash($password)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$random_state = unique_id();
$random = '';
$count = 6;
if (($fh = @fopen('/dev/urandom', 'rb')))
$random = fread($fh, $count);
fclose($fh);
if (strlen($random) < $count)
$random = '';
for ($i = 0; $i < $count; $i += 16)
{
$random_state = md5(unique_id() . $random_state);
$random .= pack('H*', md5($random_state));
$random = substr($random, 0, $count);
$hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
if (strlen($hash) == 34)
return $hash;
return md5($password);
}
/**
* Check for correct password
*/
function phpbb_check_hash($password, $hash)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (strlen($hash) == 34)
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
return (md5($password) === $hash) ? true : false;
}
/**
* Generate salt for hash generation
*/
function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
{
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$output = '$H$';
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
$output .= _hash_encode64($input, 6, $itoa64);
return $output;
}
/**
* Encode hash
*/
function _hash_encode64($input, $count, &$itoa64)
{
$output = '';
$i = 0;
do
$value = ord($input[$i++]);
$output .= $itoa64[$value & 0x3f];
if ($i < $count)
{
$value |= ord($input[$i]) << 8;
$output .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
{
break;
if ($i < $count)
{
$value |= ord($input[$i]) << 16;
$output .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
{
break;
$output .= $itoa64[($value >> 18) & 0x3f];
while ($i < $count);
return $output;
}
/**
* The crypt function/replacement
*/
function _hash_crypt_private($password, $setting, &$itoa64)
{
$output = '*';
// Check for correct hash
if (substr($setting, 0, 3) != '$H$')
return $output;
$count_log2 = strpos($itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
* We're kind of forced to use MD5 here since it's the only
* cryptographic primitive available in all versions of PHP
* currently in use. To implement our own low-level crypto
* in PHP would result in much worse performance and
* consequently in lower iteration counts and hashes that are
* quicker to crack (by non-PHP code).
*/
if (PHP_VERSION >= 5)
$hash = md5($salt . $password, true);
do
{
$hash = md5($hash . $password, true);
while (--$count);
else
$hash = pack('H*', md5($salt . $password));
do
{
$hash = pack('H*', md5($hash . $password));
while (--$count);
$output = substr($setting, 0, 12);
$output .= _hash_encode64($hash, 16, $itoa64);
return $output;
}
/**
* Return unique id
* @param string $extra additional entropy
*/
function unique_id($extra = 'c')
{
static $dss_seeded = false;
global $config;
$val = $config['rand_seed'] . microtime();
$val = md5($val);
/*
$config['rand_seed'] = md5($config['rand_seed'] . $val . $extra);
if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10)))
set_config('rand_seed', $config['rand_seed'], true);
set_config('rand_seed_last_update', time(), true);
$dss_seeded = true;
*/
return substr($val, 4, 16);
}%%
default: // input is valid
* PHPBB Integration
*
* Insert the user into the Wakka users table
*/
* End PHPBB Integration
*/

case (md5($_POST['password']) != $existingUser['password']):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;%%
Replace With:
case (!phpbb_check_hash($_POST['password'],$existingUser['password'])):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;%%


Revision [19907]

Edited on 2008-05-12 18:22:39 by WebHorn [Replaces old-style internal links with new pipe-split links.]
Additions:
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_" ("phpbb3_" for the v3.0 examples) and that their names have not been edited.
====**Using PHPBB 3.x**====
Contributed by Paul Young, using the example code by JeremyCoates in Method 2 below.
phpBB3 changed its user authentication mechanism. phpBB3 no longer stores MD5 hashes of passwords; instead it does a "true" one-way, one-time, non-recoverable hash of the password using [http://www.openwall.com/phpass/|phpass]. The output of the hash is different each time, so you can't just select the password in the phpBB database and do a compare against a MD5 of the submitted password anymore - you have to algorithmically compare them using phpass. They also changed how and where they indicate if a user is active or inactive.
It's not difficult, but you will need to bring in code from phpBB to your Wikka files.
One final note, this code works for me on my server, but could stand to be further tested. Feel free to correct if you find a bug.
/**
* PHPBB Integration
*
* 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"); }
*/
function LoadUser($name, $password = 0) {
$user = $this->LoadSingle("select
p.username as name
from ".phpbb3_."users p
where p.username = '".mysql_real_escape_string($name)."' and p.user_type != 1 limit 1");

}
return $user;%%

Replace With:
%%(php) /**
* PHPBB Integration
*
* function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
*/
from ".phpbb3_."users p
where p.user_type != 1
order by username");
Finally, copy and paste these phpass functions from phpBB into the bottom of file, before the "?>"
/**
*
* @version Version 0.1 / $Id: functions.php 8491 2008-04-04 11:41:58Z acydburn $
*
* Portable PHP password hashing framework.
*
* Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
* the public domain.
*
* There's absolutely no warranty.
*
* The homepage URL for this framework is:
*
* http://www.openwall.com/phpass/
*
* Please be sure to update the Version line if you edit this file in any way.
* It is suggested that you leave the main version number intact, but indicate
* your project name (after the slash) and add your own revision information.
*
* Please do not change the "private" password hashing method implemented in
* here, thereby making your hashes incompatible. However, if you must, please
* change the hash type identifier (the "$P$") to something different.
*
* Obviously, since this code is in the public domain, the above are not
* requirements (there can be none), but merely suggestions.
*
*
* Hash the password
*/
function phpbb_hash($password)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$random_state = unique_id();
$random = '';
$count = 6;
if (($fh = @fopen('/dev/urandom', 'rb')))
$random = fread($fh, $count);
fclose($fh);
if (strlen($random) < $count)
$random = '';
for ($i = 0; $i < $count; $i += 16)
{
$random_state = md5(unique_id() . $random_state);
$random .= pack('H*', md5($random_state));
$random = substr($random, 0, $count);
$hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
if (strlen($hash) == 34)
return $hash;
return md5($password);
}
/**
* Check for correct password
*/
function phpbb_check_hash($password, $hash)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (strlen($hash) == 34)
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
return (md5($password) === $hash) ? true : false;
}
/**
* Generate salt for hash generation
*/
function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
{
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$output = '$H$';
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
$output .= _hash_encode64($input, 6, $itoa64);
return $output;
}
/**
* Encode hash
*/
function _hash_encode64($input, $count, &$itoa64)
{
$output = '';
$i = 0;
do
$value = ord($input[$i++]);
$output .= $itoa64[$value & 0x3f];
if ($i < $count)
{
$value |= ord($input[$i]) << 8;
$output .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
{
break;
if ($i < $count)
{
$value |= ord($input[$i]) << 16;
$output .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
{
break;
$output .= $itoa64[($value >> 18) & 0x3f];
while ($i < $count);
return $output;
}
/**
* The crypt function/replacement
*/
function _hash_crypt_private($password, $setting, &$itoa64)
{
$output = '*';
// Check for correct hash
if (substr($setting, 0, 3) != '$H$')
return $output;
$count_log2 = strpos($itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
* We're kind of forced to use MD5 here since it's the only
* cryptographic primitive available in all versions of PHP
* currently in use. To implement our own low-level crypto
* in PHP would result in much worse performance and
* consequently in lower iteration counts and hashes that are
* quicker to crack (by non-PHP code).
*/
if (PHP_VERSION >= 5)
$hash = md5($salt . $password, true);
do
{
$hash = md5($hash . $password, true);
while (--$count);
else
$hash = pack('H*', md5($salt . $password));
do
{
$hash = pack('H*', md5($hash . $password));
while (--$count);
$output = substr($setting, 0, 12);
$output .= _hash_encode64($hash, 16, $itoa64);
return $output;
}
/**
* Return unique id
* @param string $extra additional entropy
*/
function unique_id($extra = 'c')
{
static $dss_seeded = false;
global $config;
$val = $config['rand_seed'] . microtime();
$val = md5($val);
/*
$config['rand_seed'] = md5($config['rand_seed'] . $val . $extra);
if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10)))
set_config('rand_seed', $config['rand_seed'], true);
set_config('rand_seed_last_update', time(), true);
$dss_seeded = true;
*/
return substr($val, 4, 16);
}%%
default: // input is valid
* PHPBB Integration
*
* Insert the user into the Wakka users table
*/
* End PHPBB Integration
*/

case (md5($_POST['password']) != $existingUser['password']):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;%%
Replace With:
case (!phpbb_check_hash($_POST['password'],$existingUser['password'])):
$error = ERROR_WRONG_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;%%
====**Using PHPBB 2.x**====
Deletions:
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.


Revision [19079]

Edited on 2008-01-28 00:14:02 by BrianKoontz [Modified links pointing to docs server]

No Differences

Revision [16436]

Edited on 2007-04-19 09:14:49 by BrianKoontz [Restored]
Additions:
$i++;
$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>" );
?>%%
<<>>
====Method 2====
Added by JeremyCoates
Advantages over Method 1:
- Better SQL reduces number of code changes required
- Still allows use of Wakka user settings
- Shows how to enforce Wiki Names in phpBB code
%%(php)
/**
* PHPBB Integration
*
* 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"); }
*/
function LoadUser($name, $password = 0) { $user = $this->LoadSingle("select
p.username as name
,p.user_password as password
,p.user_email as email
,p.user_regdate as signuptime
,w.revisioncount
,w.changescount
,w.doubleclickedit
,w.show_comments
from ".phpbb_."users p
left join " . $this->config['table_prefix'] . "users w ON p.username = w.name
where p.username = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and p.user_password = '".mysql_real_escape_string($password)."'")." and p.user_active = 1 limit 1");
if (isset($user['signuptime'])) {
$user['signuptime'] = date('Y-m-d H:i:s', $user['signuptime']);
}
return $user;
}%%
%%(php)
/**
* PHPBB Integration
*
* function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
*/
function LoadUsers() { $users = $this->LoadAll("select
p.username as name
,p.user_password as password
,p.user_email as email
,p.user_regdate as signuptime
,w.revisioncount
,w.changescount
,w.doubleclickedit
,w.show_comments
from ".phpbb_."users p
left join " . $this->config['table_prefix'] . "users w ON p.username = w.name
where p.user_active = 1
order by username");
foreach ($users as $key => $user) {
if (isset($user['signuptime'])) {
$user['signuptime'] = date('Y-m-d H:i:s', $user['signuptime']);
}
$users[$key] = $user;
}
return $users;
}%%
default: // input is valid
$this->Query('UPDATE '.$this->config['table_prefix'].'users SET '.
"email = '".mysql_real_escape_string($email)."', ".
"doubleclickedit = '".mysql_real_escape_string($doubleclickedit)."', ".
"show_comments = '".mysql_real_escape_string($show_comments)."', ".
"revisioncount = '".mysql_real_escape_string($revisioncount)."', ".
"changescount = '".mysql_real_escape_string($changescount)."' ".
"WHERE name = '".$user['name']."' LIMIT 1");%%
default: // input is valid
/**
* PHPBB Integration
*
* Insert the user into the Wakka users table
*/
$tmpUser = $this->LoadUser($user['name']);
if (is_null($tmpUser['show_comments'])) {
$this->Query("INSERT INTO ".$this->config['table_prefix']."users SET ".
"signuptime = '".mysql_real_escape_string($user['signuptime'])."',".
"name = '".mysql_real_escape_string($user['name'])."', ".
"email = '".mysql_real_escape_string($user['email'])."'");
}
/**
* End PHPBB Integration
*/
$this->Query('UPDATE '.$this->config['table_prefix'].'users SET '.
"email = '".mysql_real_escape_string($email)."', ".
"doubleclickedit = '".mysql_real_escape_string($doubleclickedit)."', ".
"show_comments = '".mysql_real_escape_string($show_comments)."', ".
"revisioncount = '".mysql_real_escape_string($revisioncount)."', ".
"changescount = '".mysql_real_escape_string($changescount)."' ".
"WHERE name = '".$user['name']."' LIMIT 1");%%
$str = 'SELECT Count(*) AS cnt, `name` FROM ';
$str .= $this->config["table_prefix"] . 'users, ' ;
$str .= "WHERE `name` = `owner` AND `latest` = 'Y' GROUP BY name ORDER BY cnt DESC;";%%
$str = 'SELECT Count(*) AS cnt, `username` AS name FROM phpbb_users, ' ;
$str .= "WHERE `username` = `owner` AND `latest` = 'Y' GROUP BY username ORDER BY cnt DESC;";%%
Configuration to disable UserRegistration is still required, either patch for 1.1.6.2 or update config setting in 1.1.6.3 (or later) see UserRegistration for more details.
----
===PHPBB 2.0.x===
If you want to force Wiki names in PHPBB logins (it will save pain later!)
==/includes/functions_validate.php==
Find (in function validate_username):
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160)))
{
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
}
return array('error' => false, 'error_msg' => '');%%
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160)))
{
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
}
/**
* Wikka Integration
* Wiki Username validation
*/
$include_path = get_include_path();
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'));
include_once('wikka.config.php');
include_once('libs/Wakka.class.php');
class WakkaPHPBBHack extends Wakka {
function WakkaPHPBBHack($config) {
parent::Wakka($config);
ob_start();
include_once('actions/usersettings.php');
ob_end_clean();
}
}
$wakka = new WakkaPHPBBHack($wakkaConfig);
set_include_path($include_path);
// Check for wiki names
if (!$wakka->IsWikiName($username)) {
return array('error' => true, 'error_msg' => preg_replace('`[#"]`', '', ERROR_WIKINAME));
}
// Check for reserved pages in wiki
if ($wakka->ExistsPage($username)) {
return array('error' => true, 'error_msg' => ERROR_RESERVED_PAGENAME);
}
/**
* End Wikka integration
*/
return array('error' => false, 'error_msg' => '');%%
>>
::c::
----
=====Wikka Wiki and phpBB: using phpBB user information and allow Wikka-specific user settings=====
Added on July 29, 2005 by EniBevoli
I 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
- handlers/page/acls.php
- handlers/page/show.php (to fix the double click edit bug)
- actions/usersettings.php
- actions/highscore.php
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
Deletions:
$i ;
$str .= "<td>$i.


Revision [16410]

Edited on 2007-04-19 08:32:00 by PvgEo0 [Restored]
Additions:
$i ;
$str .= "<td>$i.
Deletions:
$i++;
$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>" );
?>%%
<<>>
====Method 2====
Added by JeremyCoates
Advantages over Method 1:
- Better SQL reduces number of code changes required
- Still allows use of Wakka user settings
- Shows how to enforce Wiki Names in phpBB code
%%(php)
/**
* PHPBB Integration
*
* 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"); }
*/
function LoadUser($name, $password = 0) { $user = $this->LoadSingle("select
p.username as name
,p.user_password as password
,p.user_email as email
,p.user_regdate as signuptime
,w.revisioncount
,w.changescount
,w.doubleclickedit
,w.show_comments
from ".phpbb_."users p
left join " . $this->config['table_prefix'] . "users w ON p.username = w.name
where p.username = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and p.user_password = '".mysql_real_escape_string($password)."'")." and p.user_active = 1 limit 1");
if (isset($user['signuptime'])) {
$user['signuptime'] = date('Y-m-d H:i:s', $user['signuptime']);
}
return $user;
}%%
%%(php)
/**
* PHPBB Integration
*
* function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
*/
function LoadUsers() { $users = $this->LoadAll("select
p.username as name
,p.user_password as password
,p.user_email as email
,p.user_regdate as signuptime
,w.revisioncount
,w.changescount
,w.doubleclickedit
,w.show_comments
from ".phpbb_."users p
left join " . $this->config['table_prefix'] . "users w ON p.username = w.name
where p.user_active = 1
order by username");
foreach ($users as $key => $user) {
if (isset($user['signuptime'])) {
$user['signuptime'] = date('Y-m-d H:i:s', $user['signuptime']);
}
$users[$key] = $user;
}
return $users;
}%%
default: // input is valid
$this->Query('UPDATE '.$this->config['table_prefix'].'users SET '.
"email = '".mysql_real_escape_string($email)."', ".
"doubleclickedit = '".mysql_real_escape_string($doubleclickedit)."', ".
"show_comments = '".mysql_real_escape_string($show_comments)."', ".
"revisioncount = '".mysql_real_escape_string($revisioncount)."', ".
"changescount = '".mysql_real_escape_string($changescount)."' ".
"WHERE name = '".$user['name']."' LIMIT 1");%%
default: // input is valid
/**
* PHPBB Integration
*
* Insert the user into the Wakka users table
*/
$tmpUser = $this->LoadUser($user['name']);
if (is_null($tmpUser['show_comments'])) {
$this->Query("INSERT INTO ".$this->config['table_prefix']."users SET ".
"signuptime = '".mysql_real_escape_string($user['signuptime'])."',".
"name = '".mysql_real_escape_string($user['name'])."', ".
"email = '".mysql_real_escape_string($user['email'])."'");
}
/**
* End PHPBB Integration
*/
$this->Query('UPDATE '.$this->config['table_prefix'].'users SET '.
"email = '".mysql_real_escape_string($email)."', ".
"doubleclickedit = '".mysql_real_escape_string($doubleclickedit)."', ".
"show_comments = '".mysql_real_escape_string($show_comments)."', ".
"revisioncount = '".mysql_real_escape_string($revisioncount)."', ".
"changescount = '".mysql_real_escape_string($changescount)."' ".
"WHERE name = '".$user['name']."' LIMIT 1");%%
$str = 'SELECT Count(*) AS cnt, `name` FROM ';
$str .= $this->config["table_prefix"] . 'users, ' ;
$str .= "WHERE `name` = `owner` AND `latest` = 'Y' GROUP BY name ORDER BY cnt DESC;";%%
$str = 'SELECT Count(*) AS cnt, `username` AS name FROM phpbb_users, ' ;
$str .= "WHERE `username` = `owner` AND `latest` = 'Y' GROUP BY username ORDER BY cnt DESC;";%%
Configuration to disable UserRegistration is still required, either patch for 1.1.6.2 or update config setting in 1.1.6.3 (or later) see UserRegistration for more details.
----
===PHPBB 2.0.x===
If you want to force Wiki names in PHPBB logins (it will save pain later!)
==/includes/functions_validate.php==
Find (in function validate_username):
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160)))
{
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
}
return array('error' => false, 'error_msg' => '');%%
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160)))
{
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
}
/**
* Wikka Integration
* Wiki Username validation
*/
$include_path = get_include_path();
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'));
include_once('wikka.config.php');
include_once('libs/Wakka.class.php');
class WakkaPHPBBHack extends Wakka {
function WakkaPHPBBHack($config) {
parent::Wakka($config);
ob_start();
include_once('actions/usersettings.php');
ob_end_clean();
}
}
$wakka = new WakkaPHPBBHack($wakkaConfig);
set_include_path($include_path);
// Check for wiki names
if (!$wakka->IsWikiName($username)) {
return array('error' => true, 'error_msg' => preg_replace('`[#"]`', '', ERROR_WIKINAME));
}
// Check for reserved pages in wiki
if ($wakka->ExistsPage($username)) {
return array('error' => true, 'error_msg' => ERROR_RESERVED_PAGENAME);
}
/**
* End Wikka integration
*/
return array('error' => false, 'error_msg' => '');%%
>>
::c::
----
=====Wikka Wiki and phpBB: using phpBB user information and allow Wikka-specific user settings=====
Added on July 29, 2005 by EniBevoli
I 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
- handlers/page/acls.php
- handlers/page/show.php (to fix the double click edit bug)
- actions/usersettings.php
- actions/highscore.php
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


Revision [15997]

Edited on 2007-01-25 04:13:33 by JeremyCoates [Minor correction to call constructor for hack function]
Additions:
function WakkaPHPBBHack($config) {
Deletions:
function WakkaHack($config) {


Revision [15912]

Edited on 2007-01-17 11:56:00 by JeremyCoates [SQL example change: only work with active users]
Additions:
where p.username = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and p.user_password = '".mysql_real_escape_string($password)."'")." and p.user_active = 1 limit 1");
where p.user_active = 1
Deletions:
where p.username = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and p.user_password = '".mysql_real_escape_string($password)."'")." limit 1");


Revision [15907]

Edited on 2007-01-16 12:56:25 by JeremyCoates [Added new improved integration method]
Additions:
<<
====Method 1====
<<>>
====Method 2====
Added by JeremyCoates
Advantages over Method 1:
- Better SQL reduces number of code changes required
- Still allows use of Wakka user settings
- Shows how to enforce Wiki Names in phpBB code
%%(php)
/**
* PHPBB Integration
*
* 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"); }
*/
function LoadUser($name, $password = 0) { $user = $this->LoadSingle("select
p.username as name
,p.user_password as password
,p.user_email as email
,p.user_regdate as signuptime
,w.revisioncount
,w.changescount
,w.doubleclickedit
,w.show_comments
from ".phpbb_."users p
left join " . $this->config['table_prefix'] . "users w ON p.username = w.name
where p.username = '".mysql_real_escape_string($name)."' ".($password === 0 ? "" : "and p.user_password = '".mysql_real_escape_string($password)."'")." limit 1");
if (isset($user['signuptime'])) {
$user['signuptime'] = date('Y-m-d H:i:s', $user['signuptime']);
}
return $user;
}%%
%%(php)
/**
* PHPBB Integration
*
* function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
*/
function LoadUsers() { $users = $this->LoadAll("select
p.username as name
,p.user_password as password
,p.user_email as email
,p.user_regdate as signuptime
,w.revisioncount
,w.changescount
,w.doubleclickedit
,w.show_comments
from ".phpbb_."users p
left join " . $this->config['table_prefix'] . "users w ON p.username = w.name
order by username");
foreach ($users as $key => $user) {
if (isset($user['signuptime'])) {
$user['signuptime'] = date('Y-m-d H:i:s', $user['signuptime']);
}
$users[$key] = $user;
}
return $users;
}%%
default: // input is valid
$this->Query('UPDATE '.$this->config['table_prefix'].'users SET '.
"email = '".mysql_real_escape_string($email)."', ".
"doubleclickedit = '".mysql_real_escape_string($doubleclickedit)."', ".
"show_comments = '".mysql_real_escape_string($show_comments)."', ".
"revisioncount = '".mysql_real_escape_string($revisioncount)."', ".
"changescount = '".mysql_real_escape_string($changescount)."' ".
"WHERE name = '".$user['name']."' LIMIT 1");%%
default: // input is valid
/**
* PHPBB Integration
*
* Insert the user into the Wakka users table
*/
$tmpUser = $this->LoadUser($user['name']);
if (is_null($tmpUser['show_comments'])) {
$this->Query("INSERT INTO ".$this->config['table_prefix']."users SET ".
"signuptime = '".mysql_real_escape_string($user['signuptime'])."',".
"name = '".mysql_real_escape_string($user['name'])."', ".
"email = '".mysql_real_escape_string($user['email'])."'");
}
/**
* End PHPBB Integration
*/
$this->Query('UPDATE '.$this->config['table_prefix'].'users SET '.
"email = '".mysql_real_escape_string($email)."', ".
"doubleclickedit = '".mysql_real_escape_string($doubleclickedit)."', ".
"show_comments = '".mysql_real_escape_string($show_comments)."', ".
"revisioncount = '".mysql_real_escape_string($revisioncount)."', ".
"changescount = '".mysql_real_escape_string($changescount)."' ".
"WHERE name = '".$user['name']."' LIMIT 1");%%
$str = 'SELECT Count(*) AS cnt, `name` FROM ';
$str .= $this->config["table_prefix"] . 'users, ' ;
$str .= "WHERE `name` = `owner` AND `latest` = 'Y' GROUP BY name ORDER BY cnt DESC;";%%
$str = 'SELECT Count(*) AS cnt, `username` AS name FROM phpbb_users, ' ;
$str .= "WHERE `username` = `owner` AND `latest` = 'Y' GROUP BY username ORDER BY cnt DESC;";%%
Configuration to disable UserRegistration is still required, either patch for 1.1.6.2 or update config setting in 1.1.6.3 (or later) see UserRegistration for more details.
===PHPBB 2.0.x===
If you want to force Wiki names in PHPBB logins (it will save pain later!)
==/includes/functions_validate.php==
Find (in function validate_username):
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160)))
{
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
return array('error' => false, 'error_msg' => '');%%
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160)))
{
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
/**
* Wikka Integration
* Wiki Username validation
*/
$include_path = get_include_path();
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'));
include_once('wikka.config.php');
include_once('libs/Wakka.class.php');
class WakkaPHPBBHack extends Wakka {
function WakkaHack($config) {
parent::Wakka($config);
ob_start();
include_once('actions/usersettings.php');
ob_end_clean();
}
$wakka = new WakkaPHPBBHack($wakkaConfig);
set_include_path($include_path);
// Check for wiki names
if (!$wakka->IsWikiName($username)) {
return array('error' => true, 'error_msg' => preg_replace('`[#"]`', '', ERROR_WIKINAME));
// Check for reserved pages in wiki
if ($wakka->ExistsPage($username)) {
return array('error' => true, 'error_msg' => ERROR_RESERVED_PAGENAME);
/**
* End Wikka integration
*/
return array('error' => false, 'error_msg' => '');%%
>>
::c::


Revision [15662]

Edited on 2006-11-20 09:40:44 by Jack063 [Added new improved integration method]
Additions:
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.
%%(php) function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("user_name", $user["name"]); $this->SetPersistentCookie("pass", $user["password"]); }%%
%%(php) function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("user_name", $user["username"]); $this->SetPersistentCookie("pass", $user["user_password"]); }%%
%%(php) echo "\t".'<option value="'.$this->htmlspecialchars_ent($user['name']).'">'.$user['name'].'</option>'."\n";%%
%%(php) echo "\t".'<option value="'.$this->htmlspecialchars_ent($user['username']).'">'.$user['username'].'</option>'."\n";%%
%%(php) case (md5($_POST['password']) != $existingUser['password']):%%
%%(php) case (md5($_POST['password']) != $existingUser['user_password']):%%
%%(php) <td>Hello, <?php echo $this->Link($user['name']) ?>!</td>%%
%%(php) <td>Hello, <?php echo $this->Link($user['username']) ?>!</td>%%
Deletions:
%%(php) function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }%%
%%(php) function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }%%
%%(php) print("<option value=\"".$this->htmlspecialchars_ent($user["name"])."\">".$user["name"]."</option>\n");%%
%%(php) print("<option value=\"".$this->htmlspecialchars_ent($user["username"])."\">".$user["username"]."</option>\n");%%
// check password
if ($existingUser["password"] == md5($_POST["password"]))%%
// check password
if ($existingUser["user_password"] == md5($_POST["password"]))%%

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

<td>Hello, <?php echo $this->Link($user["username"]) ?>!</td>%%


Revision [14679]

Edited on 2006-06-23 14:08:52 by YodaHome [Added new improved integration method]
Additions:
==/Wikka.php (in Wikka 1.1.6.2 its /libs/Wakka.class.php)==
Deletions:
==/Wikka.php==


Revision [10246]

Edited on 2005-07-29 15:37:38 by EniBevoli [Missed to include acls.php in the list of files to change]
Additions:
- handlers/page/acls.php


Revision [10245]

Edited on 2005-07-29 15:35:28 by EniBevoli [Missed to include acls.php in the list of files to change]
Additions:
=====Wikka Wiki and phpBB: using phpBB user information and allow Wikka-specific user settings=====
Added on July 29, 2005 by EniBevoli
I 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!


Revision [10244]

Edited on 2005-07-29 12:16:01 by EniBevoli [fix to show the name of the user again in the User Settings page]
Additions:
added by EniBevoli - fix to show the name of the user again in the User Settings page

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

<td>Hello, <?php echo $this->Link($user["username"]) ?>!</td>%%


Revision [10203]

Edited on 2005-07-24 17:12:23 by DarTar [adding seealso box]
Additions:
>>**See also:**
~-WikkaIntegration
>>::c::
$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 );
Deletions:
$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 );


Revision [8366]

Edited on 2005-05-22 03:59:15 by KiltanneN [adding seealso box]
Additions:
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>" );
?>%%


Revision [8169]

Edited on 2005-05-15 02:49:25 by KiltanneN [adding seealso box]
Additions:
added by KiltanneN - feel free to remove or correct
==/actions/usersettings.php==
%%(php)
// check password
if ($existingUser["password"] == md5($_POST["password"]))%%
%%(php)
// check password
if ($existingUser["user_password"] == md5($_POST["password"]))%%


Revision [8139]

Edited on 2005-05-14 14:57:29 by NilsLindenberg [header + category]
Additions:
=====Using the phpBB users table for logging in=====
----
CategoryUserContributions


Revision [8026]

Edited on 2005-05-11 13:45:27 by OfficeRabbit [Syntax colouring, line numbers to follow]
Additions:
%%(php) 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"); }%%
%%(php) 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"); }%%
%%(php) function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }%%
%%(php) function LoadUsers() { return $this->LoadAll("select * from ".phpbb_."users order by username"); }%%
%%(php) function GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(php) function GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(php) function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }%%
%%(php) function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }%%
%%(php) print("<option value=\"".$this->htmlspecialchars_ent($user["name"])."\">".$user["name"]."</option>\n");%%
%%(php) print("<option value=\"".$this->htmlspecialchars_ent($user["username"])."\">".$user["username"]."</option>\n");%%
Deletions:
%%(php 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"); }%%
%%(php 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"); }%%
%%(php function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }%%
%%(php function LoadUsers() { return $this->LoadAll("select * from ".phpbb_."users order by username"); }%%
%%(php function GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(php function GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(php function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }%%
%%(php function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }%%
%%(php print("<option value=\"".$this->htmlspecialchars_ent($user["name"])."\">".$user["name"]."</option>\n");%%
%%(php print("<option value=\"".$this->htmlspecialchars_ent($user["username"])."\">".$user["username"]."</option>\n");%%


Revision [8023]

Edited on 2005-05-11 13:41:34 by OfficeRabbit [Syntax colouring, line numbers to follow]
Additions:
This will allow users from your phpBB forum to login to your wiki with their existing username and password.


Revision [8022]

Edited on 2005-05-11 13:40:57 by OfficeRabbit [All done]
Additions:
==/Wikka.php==
%%(php function GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(php function GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(php function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }%%
%%(php function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }%%
==/handlers/page/acls.php==
%%(php print("<option value=\"".$this->htmlspecialchars_ent($user["name"])."\">".$user["name"]."</option>\n");%%
%%(php print("<option value=\"".$this->htmlspecialchars_ent($user["username"])."\">".$user["username"]."</option>\n");%%
Deletions:
==Wikka.php==
%%(phpfunction GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(phpfunction GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
%%(phpfunction SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }%%
%%(phpfunction SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }%%
----


Revision [8021]

Edited on 2005-05-11 13:36:04 by OfficeRabbit [All done]
Additions:
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.
Deletions:
This is a very simple hack to get Wikka to read from the users table of a phpBB database rather than its own.


Revision [8020]

Edited on 2005-05-11 13:34:46 by OfficeRabbit [All done]
Additions:
This is a very simple hack to get Wikka to read from the users table of a phpBB database rather than its own.
==Wikka.php==
Find:
%%(php 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:
%%(php 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:
%%(php function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }%%
Replace with:
%%(php function LoadUsers() { return $this->LoadAll("select * from ".phpbb_."users order by username"); }%%
Find:
%%(phpfunction GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
Replace with:
%%(phpfunction GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }%%
Find:
%%(phpfunction SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }%%
Replace with:
%%(phpfunction SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }%%
Deletions:
Wikka.php
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"); }
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"); }
function LoadUsers() { return $this->LoadAll("select * from ".$this->config['table_prefix']."users order by name"); }
function LoadUsers() { return $this->LoadAll("select * from ".phpbb_."users order by username"); }
function GetUserName() { if ($user = $this->GetUser()) $name = $user["name"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }
function GetUserName() { if ($user = $this->GetUser()) $name = $user["username"]; else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) $name = $_SERVER["REMOTE_ADDR"]; return $name; }
function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["name"]); $this->SetPersistentCookie("wikka_pass", $user["password"]); }
function SetUser($user) { $_SESSION["user"] = $user; $this->SetPersistentCookie("wikka_user_name", $user["username"]); $this->SetPersistentCookie("wikka_pass", $user["user_password"]); }


Revision [8018]

The oldest known version of this page was created on 2005-05-11 13:27:32 by OfficeRabbit [All done]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki