tips:integrate_with_smf
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:integrate_with_smf [2022-08-12 03:58] – [The original author's method] / translation mistake corrected 91.35.106.95 | tips:integrate_with_smf [2023-09-20 21:11] (current) – use plugin:authmysql:smf instead Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SMF Integration ====== | ||
- | This is a little bridge between DokuWiki and the [[http:// | ||
- | The bridge part is **experimental**, | ||
- | ===== Steps ===== | ||
- | * Configure dokuWiki to use the SMF users and groups | ||
- | * Create a Board in SMF to hold the discussions | ||
- | * Configure the bridge | ||
- | * Adapt the template | ||
- | |||
- | ===== Requirements ===== | ||
- | |||
- | * A working installation of SMF | ||
- | * A working installation of dokuWiki | ||
- | |||
- | |||
- | ===== Using the Auth System ===== | ||
- | |||
- | **A fully functional way to integrate the authorization system of DokuWiki with SMF database described here:** | ||
- | |||
- | * [[auth: | ||
- | |||
- | ==== The original author' | ||
- | |||
- | :!: This method won't work with non-ASCII usernames | ||
- | |||
- | This code assumes that the SMF tables in the database have the prefix " | ||
- | <code php> | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | FROM smf_members | ||
- | WHERE memberName = ' | ||
- | AND passwd = SHA1( CONCAT( LOWER(memberName), | ||
- | |||
- | //SMF stores realnames, but for login purposes the username is the way to go. | ||
- | $conf[' | ||
- | FROM smf_members | ||
- | WHERE memberName=' | ||
- | // | ||
- | $conf[' | ||
- | USING latin1 ) | ||
- | COLLATE latin1_general_ci AS `group` | ||
- | UNION | ||
- | SELECT REPLACE( g.groupName, | ||
- | FROM smf_membergroups g, smf_members u | ||
- | WHERE ( | ||
- | g.ID_GROUP = u.ID_GROUP | ||
- | OR ( | ||
- | FIND_IN_SET(g.ID_GROUP , u.additionalGroups) | ||
- | ) | ||
- | ) | ||
- | AND u.memberName=' | ||
- | |||
- | </ | ||
- | |||
- | This uses the SMF groups for the ACL system. However, whitespaces in the group names will be replaced with underscores. | ||
- | |||
- | ==== Alternatives ==== | ||
- | |||
- | :!: This method also willn' | ||
- | |||
- | There is a community-developed SMF auth module for less experienced users. see [[http:// | ||
- | |||
- | ===== Setting up the Bridge ===== | ||
- | This is about setting up the discuss add-on. The add-on is hooked into the template, hence it is somewhat limited. | ||
- | |||
- | First, it needs a new table in the SMF database to link Wiki to discussions (not vice-versa). | ||
- | < | ||
- | CREATE TABLE `wiki_discussions` ( | ||
- | `ID_MSG` MEDIUMINT( 10 ) NOT NULL , | ||
- | `ID_TOPIC` MEDIUMINT( 8 ) NOT NULL , | ||
- | `page` VARCHAR( 50 ) NOT NULL , | ||
- | PRIMARY KEY ( `page` ) , | ||
- | UNIQUE ( | ||
- | `ID_MSG` , | ||
- | `ID_TOPIC` | ||
- | ) | ||
- | ) | ||
- | </ | ||
- | |||
- | Then, create a new subdirectory ' | ||
- | |||
- | In that new dir, copy this into a file " | ||
- | <code php> | ||
- | <?php | ||
- | |||
- | /* | ||
- | A small script to allow the creation of Discussion | ||
- | By hsudhof | ||
- | |||
- | |||
- | To install, first create a table: | ||
- | CREATE TABLE `wiki_discussions` ( | ||
- | `ID_MSG` MEDIUMINT( 10 ) NOT NULL , | ||
- | `ID_TOPIC` MEDIUMINT( 8 ) NOT NULL , | ||
- | `page` VARCHAR( 50 ) NOT NULL , | ||
- | PRIMARY KEY ( `page` ) , | ||
- | UNIQUE ( | ||
- | `ID_MSG` , | ||
- | `ID_TOPIC` | ||
- | ) | ||
- | |||
- | Then, configure the MySQL conncetion. | ||
- | |||
- | Now you can adopt youtr template to include the discuss link. | ||
- | |||
- | Finally, configure the add-on in smf_config.php | ||
- | */ | ||
- | | ||
- | |||
- | require_once(DOKU_INC.' | ||
- | require_once(DOKU_INC.' | ||
- | |||
- | require_once DOKU_INC.' | ||
- | $db = new auth_mysql(); | ||
- | |||
- | $conf[' | ||
- | include_once(" | ||
- | |||
- | if (isset($_GET[' | ||
- | global $ID, $INFO, $info; | ||
- | require_once(DOKU_INC.' | ||
- | require_once(DOKU_INC.' | ||
- | |||
- | $page = $_GET[' | ||
- | |||
- | $ID = $page; | ||
- | $INFO = pageinfo(); | ||
- | // | ||
- | |||
- | if (!discussion_exists($page)) | ||
- | { | ||
- | create_discussion($page); | ||
- | } | ||
- | $topic_id =get_discussion_id($page); | ||
- | //echo ' | ||
- | |||
- | header(' | ||
- | exit; | ||
- | |||
- | } | ||
- | |||
- | |||
- | /** | ||
- | * Create Link | ||
- | * | ||
- | * Returns a String to create a link leading to the discussion topic. Does not print the string on its own. | ||
- | * | ||
- | * @author | ||
- | * @param | ||
- | * @returns | ||
- | */ | ||
- | function get_discussion_link($name1){ | ||
- | global | ||
- | |||
- | $ret = '<a href="' | ||
- | | ||
- | return $ret.$name1.'</ | ||
- | |||
- | } | ||
- | |||
- | /** | ||
- | * Create Button | ||
- | * | ||
- | * Returns a String to create a button leading to the discussion topic. Does not print the string on its own. | ||
- | * | ||
- | * @author | ||
- | * @param | ||
- | * @returns | ||
- | */ | ||
- | function get_discussion_button($name){ | ||
- | global | ||
- | require_once(DOKU_INC.' | ||
- | $ret = '< | ||
- | $ret .= '< | ||
- | $ret.= '< | ||
- | |||
- | | ||
- | |||
- | return $ret; | ||
- | } | ||
- | |||
- | |||
- | /** | ||
- | * Check for existence | ||
- | * | ||
- | * Checks if there is an entry in the database for the given page. | ||
- | * | ||
- | * @author | ||
- | * @param | ||
- | * @returns | ||
- | */ | ||
- | function discussion_exists($page){ | ||
- | global | ||
- | |||
- | $page = addslashes($page); | ||
- | $db-> | ||
- | $sql = " | ||
- | |||
- | $result = $db -> | ||
- | |||
- | $db-> | ||
- | |||
- | return $result != null; | ||
- | } | ||
- | |||
- | |||
- | |||
- | /** | ||
- | * Creates Discussion | ||
- | * | ||
- | * Inserts a new topic in the SMF database. Does not update board stats, nor manual search tables. | ||
- | * | ||
- | * @author | ||
- | * @param | ||
- | * @returns | ||
- | */ | ||
- | function create_discussion($page){ | ||
- | global $db, $INFO, $conf, $ID; | ||
- | $page= addslashes($page); | ||
- | if($INFO[' | ||
- | { | ||
- | $db-> | ||
- | $board_id = $conf[' | ||
- | $topic_id = 0; | ||
- | $member_id = $conf[' | ||
- | $subject = $conf[' | ||
- | $link = ' | ||
- | $body = $conf[' | ||
- | $poster_name | ||
- | $poster_email | ||
- | $poster_time | ||
- | $poster_ip | ||
- | |||
- | $modified_name =''; | ||
- | |||
- | // First insert the post | ||
- | $post_sql | ||
- | (ID_BOARD, | ||
- | VALUES ($board_id , | ||
- | |||
- | |||
- | $post_id = $db-> | ||
- | |||
- | //then the topic | ||
- | $topic_sql = " | ||
- | (ID_BOARD, | ||
- | VALUES ($board_id, $member_id, $member_id, $post_id, $post_id )"; | ||
- | |||
- | |||
- | $topic_id = $db-> | ||
- | |||
- | //update the post | ||
- | $post_sql2 | ||
- | SET ID_TOPIC = $topic_id | ||
- | WHERE ID_MSG = $post_id | ||
- | LIMIT 1 "; | ||
- | |||
- | //and finally leave a note about what was done | ||
- | $db-> | ||
- | $wikisql= " | ||
- | (ID_MSG, | ||
- | VALUES | ||
- | ($post_id, | ||
- | |||
- | |||
- | $db-> | ||
- | $db-> | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | |||
- | |||
- | /** | ||
- | * Returns the topic id of the discussion | ||
- | * | ||
- | * If the page has an entry in the discussion table, this function will return the associated topic ID. | ||
- | * The check for the existence has to be done before calling this function. If the topic is not found, the function will remove the entry from the database and redirect to the Wiki. | ||
- | * | ||
- | * @author | ||
- | * @param | ||
- | * @returns | ||
- | */ | ||
- | function get_discussion_id($page){ | ||
- | global $db, $INFO, $conf; | ||
- | |||
- | $page = addslashes($page); | ||
- | $db-> | ||
- | $sql = " | ||
- | $result = $db -> | ||
- | if (!$result){ //oopsie: somebody deleted our topic. Let's clean up the database. | ||
- | $wikisql= " | ||
- | $result = $db -> | ||
- | $db-> | ||
- | $db-> | ||
- | header(" | ||
- | exit; | ||
- | } | ||
- | |||
- | return $result[0][' | ||
- | |||
- | $db-> | ||
- | return $result != false; | ||
- | } | ||
- | |||
- | |||
- | ?> | ||
- | </ | ||
- | And your configuration like this in " | ||
- | <code php> | ||
- | <?php | ||
- | /** | ||
- | The Config and Language Keys for the SMF bridge. | ||
- | |||
- | */ | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | ?> | ||
- | </ | ||
- | |||
- | Finally, it is time to adapt your template: | ||
- | <code php> | ||
- | //This inserts a button | ||
- | <?php include_once(' | ||
- | |||
- | //and this a link. | ||
- | <?php include_once(' | ||
- | </ | ||
- | |||
- | ===== Update about non-ASCII usernames ===== | ||
- | |||
- | Unfortunatelly, | ||
- | |||
- | To fix this problem you can use auth module from here: | ||
- | |||
- | * [[auth: | ||
- | |||
- | Or you need to change checkPass request to this one: | ||
- | |||
- | <code php> | ||
- | $conf[' | ||
- | FROM smf_members | ||
- | WHERE memberName = ' | ||
- | AND passwd = ' | ||
- | </ | ||
- | |||
- | And modify DokuWiki auth file '' | ||
- | |||
- | <code php> | ||
- | function checkPass($user, | ||
- | $rc = false; | ||
- | |||
- | $encpass = sha1(strtolower($this-> | ||
- | |||
- | if($this-> | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $sql = str_replace(' | ||
- | $result = $this-> | ||
- | | ||
- | ... | ||
- | </ | ||
- | ===== Comments ===== | ||
- | |||
- | I have gotten this to work successfully with SMF 1.1.11 and Dokuwiki (2009-12-25c).\\ | ||
- | - Antoris, Leader of Legacy of Hdoe Clan Consortium [[http:// |
tips/integrate_with_smf.1660269513.txt.gz · Last modified: 2022-08-12 03:58 by 91.35.106.95