tips:integrate_with_phpbb3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:integrate_with_phpbb3 [2013-04-05 10:33] – Ruined the page by mistake, now it's alright. 212.51.171.38 | tips:integrate_with_phpbb3 [2023-09-20 21:09] (current) – remove old auth backend docs, use plugin:authphpbb3 instead Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== phpBB 3 (authentication) integration ====== | ||
- | ===== Features ===== | ||
- | |||
- | * Completely using phpBB' | ||
- | * Using phpBB' | ||
- | * // | ||
- | * // | ||
- | * // | ||
- | |||
- | ==== Features missing ==== | ||
- | |||
- | * User registration | ||
- | * Full name display (phpBB doesn' | ||
- | * Integration with Mediamanager, | ||
- | * Language support | ||
- | |||
- | ===== Installation instructions ===== | ||
- | |||
- | //To get this to work with the most Release Candidate version of DokuWiki “Adora Bell 10-09-2912” and PHPBB3 only do the following steps marked with //**=Adora Bell=** | ||
- | |||
- | //To get this to work with the most recent stable version of DokuWiki “Angua 25-01-2012” and PHPBB3 only do the following steps marked with // | ||
- | |||
- | //To get this to work with the outdated version of DokuWiki “Rincewind” and PHPBB3 only do the following steps marked with // | ||
- | |||
- | To install this mod, you can: | ||
- | * use this [[http:// | ||
- | * follow these steps: | ||
- | - create '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - edit '' | ||
- | - [[#set configuration variables]] | ||
- | |||
- | ==== Create inc/ | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | \\ | ||
- | Create a file in the **inc/ | ||
- | <file php phpbb3.class.php><? | ||
- | /** | ||
- | * phpBB3 authentication backend | ||
- | * | ||
- | * Uses external Trust mechanism to check against phpBB' | ||
- | * user cookie. phpBB' | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | |||
- | define(' | ||
- | global $phpbb_root_path; | ||
- | global $db; | ||
- | global $cache; | ||
- | global $phpEx; | ||
- | global $user; | ||
- | global $config; | ||
- | global $conf; | ||
- | global $dbhost; | ||
- | global $dbport; | ||
- | global $dbname; | ||
- | global $dbuser; | ||
- | global $dbpasswd; | ||
- | global $table_prefix; | ||
- | global $phpbb_auth; | ||
- | |||
- | $phpEx = substr(strrchr(__FILE__, | ||
- | |||
- | if(strpos($_SERVER[' | ||
- | if(strpos($_SERVER[' | ||
- | |||
- | require_once(DOKU_INC.' | ||
- | require_once($phpbb_root_path.' | ||
- | |||
- | //config is loaded in common file, but $dbpasswd is unset there, too, so we have to reload it | ||
- | require($phpbb_root_path.' | ||
- | |||
- | $user-> | ||
- | |||
- | //$auth will be used by DokuWiki, so copy phpBB' | ||
- | $phpbb_auth = $auth; | ||
- | $phpbb_auth-> | ||
- | |||
- | class auth_phpbb3 extends auth_mysql | ||
- | { | ||
- | function auth_phpbb3() | ||
- | { | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | global $conf; | ||
- | |||
- | // get global vars from phpBB config | ||
- | global $dbhost; | ||
- | global $dbport; | ||
- | global $dbname; | ||
- | global $dbuser; | ||
- | global $dbpasswd; | ||
- | global $table_prefix; | ||
- | |||
- | // set group config vars | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | // now set up the mysql config strings | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | //unset $db* variables, so noone can hack them | ||
- | unset($dbpasswd); | ||
- | unset($dbuser); | ||
- | unset($dbhost); | ||
- | unset($dbport); | ||
- | unset($dbname); | ||
- | |||
- | $conf[' | ||
- | " | ||
- | " | ||
- | |||
- | $conf[' | ||
- | FROM {$table_prefix}users | ||
- | WHERE username=' | ||
- | |||
- | $conf[' | ||
- | FROM {$table_prefix}users | ||
- | WHERE username=' | ||
- | |||
- | $conf[' | ||
- | FROM {$table_prefix}groups g, {$table_prefix}users u, {$table_prefix}user_group ug | ||
- | WHERE u.user_id = ug.user_id | ||
- | AND g.group_id = ug.group_id | ||
- | AND u.username=' | ||
- | |||
- | |||
- | |||
- | $conf[' | ||
- | FROM {$table_prefix}users AS u | ||
- | LEFT JOIN {$table_prefix}user_group AS ug ON u.user_id=ug.user_id | ||
- | LEFT JOIN {$table_prefix}groups AS g ON ug.group_id=g.group_id"; | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | FROM {$table_prefix}users | ||
- | WHERE username=' | ||
- | |||
- | $conf[' | ||
- | FROM {$table_prefix}groups | ||
- | WHERE group_name=' | ||
- | |||
- | / | ||
- | | ||
- | | ||
- | |||
- | $conf[' | ||
- | | ||
- | |||
- | $conf[' | ||
- | | ||
- | |||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | // | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | WHERE group_id=' | ||
- | |||
- | $conf[' | ||
- | WHERE user_id=' | ||
- | |||
- | $conf[' | ||
- | WHERE user_id=' | ||
- | |||
- | $conf[' | ||
- | WHERE user_id=' | ||
- | AND group_id=' | ||
- | */ | ||
- | |||
- | // call mysql constructor | ||
- | $this-> | ||
- | } | ||
- | |||
- | |||
- | function trustExternal($username, | ||
- | { | ||
- | global $USERINFO; | ||
- | global $conf; | ||
- | global $user; | ||
- | global $phpbb_auth; | ||
- | |||
- | $sticky ? $sticky = true : $sticky = false; // sanity check | ||
- | |||
- | // someone used the login form | ||
- | if(!empty($username)) { | ||
- | // run phpBB' | ||
- | define(' | ||
- | $login = $phpbb_auth-> | ||
- | if($login[' | ||
- | } | ||
- | |||
- | if(!$user-> | ||
- | |||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | if($this-> | ||
- | $USERINFO[' | ||
- | } | ||
- | |||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | |||
- | return true; | ||
- | } | ||
- | |||
- | |||
- | function logoff() | ||
- | { | ||
- | global $user; | ||
- | $user-> | ||
- | } | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | Since **=Adora Belle=** you have to change this part: | ||
- | <code php> // call mysql constructor | ||
- | $this-> | ||
- | By this : | ||
- | <code php> // call mysql constructor | ||
- | $parent:: | ||
- | This is because the **auth_mysql** class is now in PHP5 and uses the new constructor. | ||
- | |||
- | |||
- | ==== Edit inc/ | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | \\ | ||
- | In the file **inc/ | ||
- | <code php> | ||
- | Comment it out by adding **%%//%%** in front of the line like this: | ||
- | <code php>// | ||
- | We have to do this because phpBB uses $_REQUEST for its cookies. | ||
- | |||
- | ==== Edit inc/ | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | |||
- | There are some functions in the file **inc/ | ||
- | * utf8_strlen | ||
- | * utf8_substr | ||
- | * utf8_strtolower | ||
- | * utf8_strtoupper | ||
- | * utf8_ucfirst | ||
- | * utf8_strpos | ||
- | * utf8_basename **=Adora Belle=** | ||
- | |||
- | So we only let DokuWiki define these functions if we're not using phpBB by adding an check around these function: <code php> | ||
- | |||
- | === Example: utf8_strlen === | ||
- | |||
- | replace: | ||
- | <code php> | ||
- | return strlen(utf8_decode($string)); | ||
- | }</ | ||
- | with: | ||
- | <code php> | ||
- | function utf8_strlen($string){ | ||
- | return strlen(utf8_decode($string)); | ||
- | } | ||
- | }</ | ||
- | |||
- | ==== Edit inc/ | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | |||
- | The last problem we have is that DokuWiki and phpBB both have a cache class. We can just rename this class in DokuWiki. To do so we open the file **inc/ | ||
- | <code php> | ||
- | replace this line with: | ||
- | <code php> | ||
- | |||
- | Search for: | ||
- | <code php> | ||
- | and replace it with: | ||
- | <code php> | ||
- | |||
- | Search for: | ||
- | <code php> | ||
- | and replace it with: | ||
- | <code php> | ||
- | |||
- | Search for: | ||
- | <code php> | ||
- | and replace it with: | ||
- | <code php> | ||
- | |||
- | ==== Edit feed.php ==== | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | |||
- | Knowing we have just renamed the cache class (see above) and knowing this class is called in feed.php, we also need to rename the calling to make RSS/Atom feeds works. | ||
- | Find: | ||
- | <code php> | ||
- | $cache = new cache($key, ' | ||
- | </ | ||
- | and replace with: | ||
- | <code php> | ||
- | $cache = new wiki_cache($key, | ||
- | </ | ||
- | |||
- | Otherwise you will have a very nice "XML Parsing Error" | ||
- | |||
- | ==== Edit lib/ | ||
- | |||
- | **=Angua=** **=Adora Belle=** **Do __Not__ do for Rincewind** | ||
- | |||
- | **=Angua=** | ||
- | |||
- | Knowing we have just renamed the cache class (see above) and knowing this class is called in lib/ | ||
- | Find: | ||
- | <code php> | ||
- | // The generated script depends on some dynamic options | ||
- | $cache = new cache(' | ||
- | </ | ||
- | and replace with: | ||
- | <code php> | ||
- | // The generated script depends on some dynamic options | ||
- | $cache = new wiki_cache(' | ||
- | </ | ||
- | |||
- | **=Adora Belle=** | ||
- | |||
- | Find: | ||
- | <code php> | ||
- | // The generated script depends on some dynamic options | ||
- | $cache = new cache(' | ||
- | </ | ||
- | and replace with: | ||
- | <code php> | ||
- | // The generated script depends on some dynamic options | ||
- | $cache = new wiki_cache(' | ||
- | </ | ||
- | |||
- | ==== Edit lib/ | ||
- | |||
- | **=Angua=** **=Adora Belle=** **Do __Not__ do for Rincewind** | ||
- | |||
- | Knowing we have just renamed the cache class (see above) and knowing this class is called in lib/ | ||
- | Find: | ||
- | <code php> | ||
- | // The generated script depends on some dynamic options | ||
- | $cache = new cache(' | ||
- | ' | ||
- | </ | ||
- | and replace with: | ||
- | <code php> | ||
- | // The generated script depends on some dynamic options | ||
- | $cache = new wiki_cache(' | ||
- | ' | ||
- | </ | ||
- | |||
- | ==== Edit inc/ | ||
- | |||
- | **=Angua=** **=Adora Belle=** **Do __Not__ do for Rincewind** | ||
- | |||
- | Knowing we have just renamed the cache class (see above) and knowing this class is in inc/ | ||
- | Find: | ||
- | <code php> | ||
- | ' | ||
- | </ | ||
- | and replace with: | ||
- | <code php> | ||
- | ' | ||
- | </ | ||
- | |||
- | ==== Edit inc/ | ||
- | |||
- | **=Adora Belle=** | ||
- | |||
- | I am not a php expert so I don't know how this affects things or security but between Angua and Adora Belle the mysql.class.php was re-written which I think affects the phpbb3.class.php file written at the top of this page so it needs to be re-written... if anyone can do that then please replace it but for now it appears to work if you replace the code with the previous Angua code... A temporary fix until someone with better php knowledge can help. djSupport | ||
- | |||
- | Replace the code in Andora Belle mysql.class.php: | ||
- | with the previous code below from Angua: | ||
- | <file php inc/ | ||
- | /** | ||
- | * MySQLP authentication backend | ||
- | * | ||
- | * @license | ||
- | * @author | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | |||
- | class auth_mysql extends auth_basic { | ||
- | |||
- | var $dbcon | ||
- | var $dbver | ||
- | var $dbrev | ||
- | var $dbsub | ||
- | var $cnf = null; | ||
- | var $defaultgroup = ""; | ||
- | |||
- | /** | ||
- | * Constructor | ||
- | * | ||
- | * checks if the mysql interface is available, otherwise it will | ||
- | * set the variable $success of the basis class to false | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function auth_mysql() { | ||
- | global $conf; | ||
- | $this-> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | if (method_exists($this, | ||
- | parent:: | ||
- | |||
- | |||
- | |||
- | if(!function_exists(' | ||
- | if ($this-> | ||
- | msg(" | ||
- | $this-> | ||
- | return; | ||
- | } | ||
- | |||
- | |||
- | // default to UTF-8, you rarely want something else | ||
- | if(!isset($this-> | ||
- | |||
- | |||
- | |||
- | |||
- | $this-> | ||
- | |||
- | // set capabilities based upon config strings set | ||
- | if (empty($this-> | ||
- | !isset($this-> | ||
- | if ($this-> | ||
- | msg(" | ||
- | |||
- | $this-> | ||
- | return; | ||
- | |||
- | } | ||
- | |||
- | $this-> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | $this-> | ||
- | |||
- | |||
- | |||
- | ' | ||
- | ' | ||
- | $this-> | ||
- | |||
- | |||
- | |||
- | ' | ||
- | ' | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | /* getGroups is not yet supported | ||
- | $this-> | ||
- | ' | ||
- | $this-> | ||
- | |||
- | |||
- | |||
- | ' | ||
- | ' | ||
- | $this-> | ||
- | } | ||
- | |||
- | /** | ||
- | * Check if the given config strings are set | ||
- | * | ||
- | * @author | ||
- | * @return | ||
- | */ | ||
- | function _chkcnf($keys, | ||
- | foreach ($keys as $key){ | ||
- | if (empty($this-> | ||
- | |||
- | } | ||
- | |||
- | /* write operation and lock array filled with tables names? */ | ||
- | if ($wop && (!is_array($this-> | ||
- | | ||
- | return false; | ||
- | |||
- | } | ||
- | |||
- | |||
- | return true; | ||
- | } | ||
- | |||
- | /** | ||
- | * Checks if the given user exists and the given plaintext password | ||
- | * is correct. Furtheron it might be checked wether the user is | ||
- | * member of the right group | ||
- | * | ||
- | * Depending on which SQL string is defined in the config, password | ||
- | * checking is done here (getpass) or by the database (passcheck) | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @return bool | ||
- | * | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | function checkPass($user, | ||
- | $rc = false; | ||
- | |||
- | if($this-> | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $result = $this-> | ||
- | |||
- | if($result !== false && count($result) == 1) { | ||
- | if($this-> | ||
- | |||
- | |||
- | $rc = true; | ||
- | else | ||
- | $rc = auth_verifyPassword($pass, | ||
- | |||
- | |||
- | } | ||
- | $this-> | ||
- | } | ||
- | return $rc; | ||
- | } | ||
- | |||
- | /** | ||
- | * [public function] | ||
- | * | ||
- | * Returns info about the given user needs to contain | ||
- | * at least these fields: | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | * @param $user | ||
- | * | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | function getUserData($user){ | ||
- | if($this-> | ||
- | $this-> | ||
- | $info = $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | } else | ||
- | $info = false; | ||
- | |||
- | return $info; | ||
- | } | ||
- | |||
- | /** | ||
- | * [public function] | ||
- | * | ||
- | * Create a new User. Returns false if the user already exists, | ||
- | * null when an error occurred and true if everything went well. | ||
- | * | ||
- | * The new user will be added to the default group by this | ||
- | * function if grps are not specified (default behaviour). | ||
- | * | ||
- | * @param $user nick of the user | ||
- | * @param $pwd clear text password | ||
- | * @param $name full name of the user | ||
- | * @param $mail email address | ||
- | * @param $grps array of groups the user should become member of | ||
- | * | ||
- | * @author | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | function createUser($user, | ||
- | if($this-> | ||
- | if (($info = $this-> | ||
- | return false; | ||
- | |||
- | // set defaultgroup if no groups were given | ||
- | if ($grps == null) | ||
- | $grps = array($this-> | ||
- | |||
- | $this-> | ||
- | $pwd = $this-> | ||
- | $rc = $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | if ($rc) return true; | ||
- | |||
- | } | ||
- | return null; // return error | ||
- | } | ||
- | |||
- | /** | ||
- | * Modify user data [public function] | ||
- | * | ||
- | * An existing user dataset will be modified. Changes are given in an array. | ||
- | * | ||
- | * The dataset update will be rejected if the user name should be changed | ||
- | * to an already existing one. | ||
- | * | ||
- | * The password must be provides unencrypted. Pasword cryption is done | ||
- | * automatically if configured. | ||
- | * | ||
- | * If one or more groups could' | ||
- | * this case the dataset might already be changed and we can't rollback | ||
- | * the changes. Transactions would be really usefull here. | ||
- | * | ||
- | * modifyUser() may be called without SQL statements defined that are | ||
- | * needed to change group membership (for example if only the user profile | ||
- | * should be modified). In this case we asure that we don't touch groups | ||
- | * even $changes[' | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | | ||
- | * @return | ||
- | * | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | function modifyUser($user, | ||
- | $rc = false; | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | if (!is_array($changes) || !count($changes)) | ||
- | return true; // nothing to change | ||
- | |||
- | |||
- | |||
- | if($this-> | ||
- | $this-> | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | if (($uid = $this-> | ||
- | $rc = $this-> | ||
- | |||
- | |||
- | |||
- | |||
- | if ($rc && isset($changes[' | ||
- | $groups = $this-> | ||
- | $grpadd = array_diff($changes[' | ||
- | $grpdel = array_diff($groups, | ||
- | |||
- | foreach($grpadd as $group) | ||
- | if (($this-> | ||
- | |||
- | |||
- | |||
- | $rc = false; | ||
- | |||
- | |||
- | |||
- | foreach($grpdel as $group) | ||
- | if (($this-> | ||
- | $rc = false; | ||
- | } | ||
- | } | ||
- | |||
- | $this-> | ||
- | $this-> | ||
- | } | ||
- | return $rc; | ||
- | } | ||
- | |||
- | /** | ||
- | * [public function] | ||
- | * | ||
- | * Remove one or more users from the list of registered users | ||
- | * | ||
- | * @param | ||
- | * @return | ||
- | * | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | function deleteUsers($users) { | ||
- | $count = 0; | ||
- | |||
- | if($this-> | ||
- | if (is_array($users) && count($users)) { | ||
- | $this-> | ||
- | foreach ($users as $user) { | ||
- | if ($this-> | ||
- | |||
- | |||
- | $count++; | ||
- | } | ||
- | $this-> | ||
- | |||
- | |||
- | } | ||
- | $this-> | ||
- | } | ||
- | return $count; | ||
- | } | ||
- | |||
- | /** | ||
- | * [public function] | ||
- | * | ||
- | * Counts users which meet certain $filter criteria. | ||
- | * | ||
- | * @param | ||
- | * @return count of found users. | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | function getUserCount($filter=array()) { | ||
- | $rc = 0; | ||
- | |||
- | if($this-> | ||
- | $sql = $this-> | ||
- | |||
- | if ($this-> | ||
- | $sql = substr($sql, | ||
- | $sql = " | ||
- | $this-> | ||
- | $result = $this-> | ||
- | $rc = $result[0][' | ||
- | } else if (($result = $this-> | ||
- | $rc = count($result); | ||
- | |||
- | $this-> | ||
- | |||
- | } | ||
- | return $rc; | ||
- | } | ||
- | |||
- | /** | ||
- | * Bulk retrieval of user data. [public function] | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @param | ||
- | * @return | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | function retrieveUsers($first=0, | ||
- | $out = array(); | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | if($this-> | ||
- | $this-> | ||
- | $sql = $this-> | ||
- | $sql .= " " | ||
- | $result = $this-> | ||
- | |||
- | |||
- | |||
- | if (!empty($result)) { | ||
- | foreach ($result as $user) | ||
- | if (($info = $this-> | ||
- | $out[$user[' | ||
- | } | ||
- | |||
- | $this-> | ||
- | $this-> | ||
- | } | ||
- | return $out; | ||
- | } | ||
- | |||
- | /** | ||
- | * Give user membership of a group [public function] | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @return | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | function joinGroup($user, | ||
- | $rc = false; | ||
- | |||
- | if ($this-> | ||
- | $this-> | ||
- | $rc = $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | } | ||
- | return $rc; | ||
- | } | ||
- | |||
- | /** | ||
- | * Remove user from a group [public function] | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @return | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | function leaveGroup($user, | ||
- | $rc = false; | ||
- | |||
- | if ($this-> | ||
- | $this-> | ||
- | $uid = $this-> | ||
- | $rc = $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | } | ||
- | return $rc; | ||
- | } | ||
- | |||
- | /** | ||
- | * MySQL is case-insensitive | ||
- | */ | ||
- | function isCaseSensitive(){ | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Adds a user to a group. | ||
- | * | ||
- | * If $force is set to ' | ||
- | * | ||
- | * The database connection must already be established. Otherwise | ||
- | * this function does nothing and returns ' | ||
- | * recommended to call this function only after all participating | ||
- | * tables (group and usergroup) have been locked. | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @param | ||
- | * @return | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _addUserToGroup($user, | ||
- | $newgroup = 0; | ||
- | |||
- | if (($this-> | ||
- | $gid = $this-> | ||
- | if (!$gid) { | ||
- | if ($force) { // create missing groups | ||
- | $sql = str_replace(' | ||
- | $gid = $this-> | ||
- | $newgroup = 1; // group newly created | ||
- | |||
- | } | ||
- | if (!$gid) return false; // group didn't exist and can't be created | ||
- | |||
- | } | ||
- | |||
- | $sql = $this-> | ||
- | if(strpos($sql,' | ||
- | $uid = $this-> | ||
- | $sql = str_replace(' | ||
- | |||
- | } | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | if ($this-> | ||
- | |||
- | if ($newgroup) { // remove previously created group on error | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $this-> | ||
- | |||
- | } | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Remove user from a group | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @return | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | function _delUserFromGroup($user, | ||
- | $rc = false; | ||
- | |||
- | |||
- | if (($this-> | ||
- | $sql = $this-> | ||
- | if(strpos($sql,' | ||
- | $uid = $this-> | ||
- | $sql = str_replace(' | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | } | ||
- | $gid = $this-> | ||
- | if ($gid) { | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $rc = $this-> | ||
- | } | ||
- | } | ||
- | return $rc; | ||
- | } | ||
- | |||
- | /** | ||
- | * Retrieves a list of groups the user is a member off. | ||
- | * | ||
- | * The database connection must already be established | ||
- | * for this function to work. Otherwise it will return | ||
- | * ' | ||
- | * | ||
- | * @param | ||
- | * @return bool false on error | ||
- | * @return array array containing all groups on success | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _getGroups($user) { | ||
- | $groups = array(); | ||
- | |||
- | if($this-> | ||
- | $sql = str_replace(' | ||
- | $result = $this-> | ||
- | |||
- | |||
- | if($result !== false && count($result)) { | ||
- | foreach($result as $row) | ||
- | $groups[] = $row[' | ||
- | |||
- | |||
- | } | ||
- | |||
- | return $groups; | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Retrieves the user id of a given user name | ||
- | * | ||
- | * The database connection must already be established | ||
- | * for this function to work. Otherwise it will return | ||
- | * ' | ||
- | * | ||
- | * @param | ||
- | * @return user id | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _getUserID($user) { | ||
- | if($this-> | ||
- | $sql = str_replace(' | ||
- | $result = $this-> | ||
- | return $result === false ? false : $result[0][' | ||
- | |||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Adds a new User to the database. | ||
- | * | ||
- | * The database connection must already be established | ||
- | * for this function to work. Otherwise it will return | ||
- | * ' | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @param | ||
- | * @param | ||
- | * @param | ||
- | * @return bool | ||
- | * | ||
- | * @author | ||
- | * @author | ||
- | * @author | ||
- | */ | ||
- | function _addUser($user, | ||
- | if($this-> | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $uid = $this-> | ||
- | |||
- | if ($uid) { | ||
- | foreach($grps as $group) { | ||
- | $gid = $this-> | ||
- | if ($gid === false) break; | ||
- | |||
- | } | ||
- | |||
- | if ($gid) return true; | ||
- | |||
- | else { | ||
- | /* remove the new user and all group relations if a group can't | ||
- | * be assigned. Newly created groups will remain in the database | ||
- | * and won't be removed. This might create orphaned groups but | ||
- | * is not a big issue so we ignore this problem here. | ||
- | |||
- | */ | ||
- | $this-> | ||
- | if ($this-> | ||
- | msg (" | ||
- | |||
- | |||
- | } | ||
- | } | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Deletes a given user and all his group references. | ||
- | * | ||
- | * The database connection must already be established | ||
- | * for this function to work. Otherwise it will return | ||
- | * ' | ||
- | * | ||
- | * @param | ||
- | * @return bool | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _delUser($user) { | ||
- | if($this-> | ||
- | $uid = $this-> | ||
- | if ($uid) { | ||
- | $sql = str_replace(' | ||
- | $this-> | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $this-> | ||
- | return true; | ||
- | |||
- | } | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * getUserInfo | ||
- | * | ||
- | * Gets the data for a specific user The database connection | ||
- | * must already be established for this function to work. | ||
- | * Otherwise it will return ' | ||
- | * | ||
- | * @param | ||
- | * @return bool false on error | ||
- | * @return array user info on success | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _getUserInfo($user){ | ||
- | $sql = str_replace(' | ||
- | $result = $this-> | ||
- | |||
- | if($result !== false && count($result)) { | ||
- | $info = $result[0]; | ||
- | $info[' | ||
- | |||
- | |||
- | return $info; | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Updates the user info in the database | ||
- | * | ||
- | * Update a user data structure in the database according changes | ||
- | * given in an array. The user name can only be changes if it didn't | ||
- | * exists already. If the new user name exists the update procedure | ||
- | * will be aborted. The database keeps unchanged. | ||
- | * | ||
- | * The database connection has already to be established for this | ||
- | * function to work. Otherwise it will return ' | ||
- | * | ||
- | * The password will be crypted if necessary. | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @return true on success or false on error | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _updateUserInfo($changes, | ||
- | $sql = $this-> | ||
- | $cnt = 0; | ||
- | $err = 0; | ||
- | |||
- | if($this-> | ||
- | foreach ($changes as $item => $value) { | ||
- | if ($item == ' | ||
- | if (($this-> | ||
- | $err = 1; /* new username already exists */ | ||
- | break; | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | } | ||
- | if ($cnt++ > 0) $sql .= ", "; | ||
- | $sql .= str_replace(' | ||
- | } else if ($item == ' | ||
- | if ($cnt++ > 0) $sql .= ", "; | ||
- | $sql .= str_replace(' | ||
- | } else if ($item == ' | ||
- | if (!$this-> | ||
- | $value = auth_cryptPassword($value); | ||
- | if ($cnt++ > 0) $sql .= ", "; | ||
- | $sql .= str_replace(' | ||
- | } else if ($item == ' | ||
- | if ($cnt++ > 0) $sql .= ", "; | ||
- | $sql .= str_replace(' | ||
- | } | ||
- | } | ||
- | |||
- | if ($err == 0) { | ||
- | if ($cnt > 0) { | ||
- | $sql .= " " | ||
- | if(get_class($this) == ' | ||
- | $this-> | ||
- | |||
- | } | ||
- | return true; | ||
- | |||
- | } | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Retrieves the group id of a given group name | ||
- | * | ||
- | * The database connection must already be established | ||
- | * for this function to work. Otherwise it will return | ||
- | * ' | ||
- | * | ||
- | * @param | ||
- | * @return group id | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _getGroupID($group) { | ||
- | if($this-> | ||
- | $sql = str_replace(' | ||
- | $result = $this-> | ||
- | return $result === false ? false : $result[0][' | ||
- | |||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Opens a connection to a database and saves the handle for further | ||
- | * usage in the object. The successful call to this functions is | ||
- | * essential for most functions in this object. | ||
- | * | ||
- | * @return bool | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _openDB() { | ||
- | if (!$this-> | ||
- | $con = @mysql_connect ($this-> | ||
- | if ($con) { | ||
- | if ((mysql_select_db($this-> | ||
- | if ((preg_match("/ | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | } | ||
- | $this-> | ||
- | if(!empty($this-> | ||
- | | ||
- | |||
- | } | ||
- | return true; // connection and database successfully opened | ||
- | |||
- | } else { | ||
- | mysql_close ($con); | ||
- | if ($this-> | ||
- | msg(" | ||
- | |||
- | } | ||
- | } else if ($this-> | ||
- | msg (" | ||
- | | ||
- | |||
- | return false; | ||
- | |||
- | } | ||
- | return true; // connection already open | ||
- | } | ||
- | |||
- | /** | ||
- | * Closes a database connection. | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _closeDB() { | ||
- | if ($this-> | ||
- | mysql_close ($this-> | ||
- | $this-> | ||
- | |||
- | } | ||
- | } | ||
- | |||
- | /** | ||
- | * Sends a SQL query to the database and transforms the result into | ||
- | * an associative array. | ||
- | * | ||
- | * This function is only able to handle queries that returns a | ||
- | * table such as SELECT. | ||
- | * | ||
- | * @param $query | ||
- | * @return array with the result table | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _queryDB($query) { | ||
- | if($this-> | ||
- | msg(' | ||
- | |||
- | } | ||
- | |||
- | $resultarray = array(); | ||
- | if ($this-> | ||
- | $result = @mysql_query($query, | ||
- | if ($result) { | ||
- | while (($t = mysql_fetch_assoc($result)) !== false) | ||
- | $resultarray[]=$t; | ||
- | mysql_free_result ($result); | ||
- | return $resultarray; | ||
- | |||
- | |||
- | |||
- | } | ||
- | if ($this-> | ||
- | msg(' | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Sends a SQL query to the database | ||
- | * | ||
- | * This function is only able to handle queries that returns | ||
- | * either nothing or an id value such as INPUT, DELETE, UPDATE, etc. | ||
- | * | ||
- | * @param $query | ||
- | * @return insert id or 0, false on error | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _modifyDB($query) { | ||
- | if ($this-> | ||
- | $result = @mysql_query($query, | ||
- | if ($result) { | ||
- | $rc = mysql_insert_id($this-> | ||
- | if ($rc !== false) return $rc; | ||
- | |||
- | |||
- | |||
- | } | ||
- | if ($this-> | ||
- | msg(' | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Locked a list of tables for exclusive access so that modifications | ||
- | * to the database can't be disturbed by other threads. The list | ||
- | * could be set with $conf[' | ||
- | * | ||
- | * If aliases for tables are used in SQL statements, also this aliases | ||
- | * must be locked. For eg. you use a table ' | ||
- | * some sql queries, the array must looks like this (order is important): | ||
- | | ||
- | * | ||
- | * MySQL V3 is not able to handle transactions with COMMIT/ | ||
- | * so that this functionality is simulated by this function. Nevertheless | ||
- | * it is not as powerful as transactions, | ||
- | * | ||
- | * @param $mode could be ' | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _lockTables($mode) { | ||
- | if ($this-> | ||
- | if (is_array($this-> | ||
- | if ($mode == " | ||
- | $sql = "LOCK TABLES "; | ||
- | |||
- | $cnt = 0; | ||
- | foreach ($this-> | ||
- | if ($cnt++ != 0) $sql .= ", "; | ||
- | $sql .= " | ||
- | |||
- | |||
- | |||
- | |||
- | } | ||
- | $this-> | ||
- | return true; | ||
- | } | ||
- | } | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Unlock locked tables. All existing locks of this thread will be | ||
- | * abrogated. | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _unlockTables() { | ||
- | if ($this-> | ||
- | $this-> | ||
- | |||
- | |||
- | return true; | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Transforms the filter settings in an filter string for a SQL database | ||
- | * The database connection must already be established, | ||
- | * original SQL string without filter criteria will be returned. | ||
- | * | ||
- | * @param | ||
- | * @param | ||
- | * @return SQL string with attached $filter criteria on success | ||
- | * @return the original SQL string on error. | ||
- | * | ||
- | * @author Matthias Grimm < | ||
- | */ | ||
- | function _createSQLFilter($sql, | ||
- | $SQLfilter = ""; | ||
- | $cnt = 0; | ||
- | |||
- | if ($this-> | ||
- | foreach ($filter as $item => $pattern) { | ||
- | $tmp = ' | ||
- | if ($item == ' | ||
- | if ($cnt++ > 0) $SQLfilter .= " AND "; | ||
- | $SQLfilter .= str_replace(' | ||
- | } else if ($item == ' | ||
- | if ($cnt++ > 0) $SQLfilter .= " AND "; | ||
- | $SQLfilter .= str_replace(' | ||
- | } else if ($item == ' | ||
- | if ($cnt++ > 0) $SQLfilter .= " AND "; | ||
- | $SQLfilter .= str_replace(' | ||
- | } else if ($item == ' | ||
- | if ($cnt++ > 0) $SQLfilter .= " AND "; | ||
- | $SQLfilter .= str_replace(' | ||
- | |||
- | |||
- | } | ||
- | } | ||
- | |||
- | // we have to check SQLfilter here and must not use $cnt because if | ||
- | // any of cnf[' | ||
- | // would be generated. | ||
- | |||
- | if (strlen($SQLfilter)) { | ||
- | $glue = strpos(strtolower($sql)," | ||
- | $sql = $sql.$glue.$SQLfilter; | ||
- | |||
- | } | ||
- | } | ||
- | |||
- | return $sql; | ||
- | } | ||
- | |||
- | /** | ||
- | * Escape a string for insertion into the database | ||
- | * | ||
- | * @author Andreas Gohr < | ||
- | * @param | ||
- | * @param | ||
- | */ | ||
- | function _escape($string, | ||
- | if($this-> | ||
- | $string = mysql_real_escape_string($string, | ||
- | }else{ | ||
- | $string = addslashes($string); | ||
- | |||
- | } | ||
- | if($like){ | ||
- | $string = addcslashes($string,' | ||
- | |||
- | } | ||
- | return $string; | ||
- | } | ||
- | } | ||
- | |||
- | //Setup VIM: ex: et ts=2 : | ||
- | |||
- | </ | ||
- | |||
- | ==== Set configuration variables ==== | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | |||
- | The last thing we have to do is: enable it! The file **conf/ | ||
- | <code php local.protected.php><? | ||
- | /* | ||
- | * phpBB3 | ||
- | */ | ||
- | |||
- | define(' | ||
- | $phpbb_root_path = ' | ||
- | $conf[' | ||
- | ?></ | ||
- | $phpbb_root_path has to be the relative path to phpBB from the DokuWiki directory, e.g. if phpBB is installed on the same level as DokuWiki, e.g. DokuWiki in **var/ | ||
- | |||
- | I did this, but it wouldn' | ||
- | |||
- | ===== phpBB3 Settings ===== | ||
- | |||
- | ==== Cookie Settings ==== | ||
- | |||
- | **=Angua=** **=Rincewind=** **=Adora Belle=** | ||
- | |||
- | In order for the above integration to work well, it is important that the cookie settings in the phpBB3 ACP (admin control panel) are set right. For example, with wrong cookie settings, first logging in at your phpBB3 forum, then browsing your DokuWiki pages will forcibly log you out when you next load a page of your forum. | ||
- | |||
- | If your phpBB3 forum is installed at **%%www.yourdomain.com/ | ||
- | Instead, set the " | ||
- | < | ||
- | |||
- | ==== Security Settings ==== | ||
- | |||
- | An other thing to check in the phpbb3 ACP is " | ||
- | Be care... | ||
- | |||
- | ===== Credits ===== | ||
- | |||
- | * Thanks to [[http:// | ||
- | |||
- | ===== Comments / Problems ===== | ||
- | |||
- | * I had some problems getting this integration to work, it would not authenticate. But, I found the problem: If $_SERVER[' | ||
- | |||
- | * For German phpbb3: Dont use ÄÖÜ for Usernames, it will not authenticate! It is possible to restrict those usernames in phpbb3 registration settings. Use ASCII Usernames instead. | ||
- | |||
- | * Additional info provided for Adora Belle (fixed now for me with php 5.3) Regards, djSupport |
tips/integrate_with_phpbb3.1365150828.txt.gz · Last modified: 2013-04-05 10:33 by 212.51.171.38