tips:integrate_with_phpbb3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next 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 [2014-08-08 23:45] – Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== phpBB 3 (authentication) integration ====== | ====== phpBB 3 (authentication) integration ====== | ||
+ | |||
+ | :!: **Please NOTE: | ||
+ | * **These instruction are deprecated** since release 2013-05-10 Weatherwax | ||
+ | * **Instead use the [[plugin: | ||
+ | |||
+ | |||
+ | |||
+ | ======Instructions for old wikis (before 2013-05-10) ====== | ||
===== Features ===== | ===== Features ===== | ||
Line 18: | Line 26: | ||
===== Installation instructions ===== | ===== 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=** | + | //Since release 2013-05-10 Weatherwax//\\ You skip these instructions, |
- | //To get this to work with the most recent stable | + | //Release “Adora Bell 10-09-2012”// |
+ | To get this to work with the most Release Candidate | ||
- | //To get this to work with the outdated | + | //Release “Angua 25-01-2012”// |
+ | To get this to work with the most recent stable | ||
- | To install this mod, you can: | + | //Release |
- | * use this [[http://www.crocko.com/F8D5FF634CE744DB9413C13F7FF7B3D4/AnguaRC1_phpbb3login.rar|download package for DokuWiki 2011-11-10 RC1 Angua]] FIXME or | + | To get this to work with the outdated version of DokuWiki “Rincewind” and PHPBB3 only do the following steps marked with **=Rincewind=** |
- | * follow these steps: | + | |
+ | |||
+ | To install this mod, you follow these steps: | ||
- create '' | - create '' | ||
- edit '' | - edit '' | ||
Line 35: | Line 47: | ||
- edit '' | - edit '' | ||
- edit '' | - edit '' | ||
- | - edit '' | ||
- [[#set configuration variables]] | - [[#set configuration variables]] | ||
- | |||
==== Create inc/ | ==== Create inc/ | ||
Line 242: | Line 252: | ||
By this : | By this : | ||
<code php> // call mysql constructor | <code php> // call mysql constructor | ||
- | $parent:: | + | parent:: |
This is because the **auth_mysql** class is now in PHP5 and uses the new constructor. | This is because the **auth_mysql** class is now in PHP5 and uses the new constructor. | ||
Line 387: | Line 397: | ||
</ | </ | ||
- | ==== 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 ==== | ==== Set configuration variables ==== | ||
Line 1542: | Line 443: | ||
* 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. | * 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 | + | * Additional info provided for Adora Belle (fixed now for me with php 5.3) Regards, djSupport |
+ | |||
+ | * Is this guide for the latest version " | ||
+ | > No, these instructions are old. Please use the [[plugin: |