auth:punbb
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
auth:punbb [2012-04-05 12:40] – [Configuration] 213.160.21.174 | auth:punbb [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PunBB or FluxBB Authentication backend ====== | ||
- | This backend provides authentication against a [[http:// | ||
- | |||
- | ===== Requirements ===== | ||
- | |||
- | * A recent PunBB 1.2.x forum installation (1.3.x support is in beta) / Works also with PunBB' | ||
- | * The forum needs to be on the same domain as the wiki | ||
- | * magic_quotes_gpc needs to be **off** ((Either disable in your '' | ||
- | |||
- | ===== Configuration ===== | ||
- | |||
- | The backend reuses your PunBB configuration. You just need to enable it and set is the '' | ||
- | |||
- | <code php local.protected.php> | ||
- | <?php | ||
- | $conf[' | ||
- | $conf[' | ||
- | define(' | ||
- | </ | ||
- | |||
- | This path must be an absolute path, like ''/ | ||
- | |||
- | To have your admin users recognized you need to set your [[config: | ||
- | |||
- | ===== Source and Installation with PunBB 1.2.x or FluxBB 1.2.x ===== | ||
- | |||
- | Up to DokuWiki 2008-05-05 this backend was included in the DokuWiki install. Newer versions no longer come with this backend. | ||
- | |||
- | To install the backend, create a '' | ||
- | |||
- | <code php punbb.class.php> | ||
- | <?php | ||
- | /** | ||
- | * PunBB auth backend | ||
- | * | ||
- | * Uses external Trust mechanism to check against PunBB' | ||
- | * user cookie. PunBB' | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | |||
- | if(!defined(' | ||
- | if(get_magic_quotes_gpc()){ | ||
- | nice_die(' | ||
- | <a href=" | ||
- | to be disabled for proper operation. Either setup your PHP install accordingly or | ||
- | choose a different auth backend.' | ||
- | } | ||
- | |||
- | require_once PUN_ROOT.' | ||
- | require_once DOKU_INC.' | ||
- | |||
- | # | ||
- | # | ||
- | |||
- | class auth_punbb extends auth_mysql { | ||
- | |||
- | /** | ||
- | * Constructor. | ||
- | * | ||
- | * Sets additional capabilities and config strings | ||
- | */ | ||
- | function auth_punbb(){ | ||
- | global $conf; | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | // make sure we use a crypt understood by punbb | ||
- | if(function_exists(' | ||
- | $conf[' | ||
- | }else{ | ||
- | $conf[' | ||
- | } | ||
- | |||
- | // get global vars from PunBB config | ||
- | global $db_host; | ||
- | global $db_name; | ||
- | global $db_username; | ||
- | global $db_password; | ||
- | global $db_prefix; | ||
- | |||
- | // now set up the mysql config strings | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id | ||
- | AND u.username = ' | ||
- | AND g.g_title | ||
- | $conf[' | ||
- | id, g_title as `group` | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id | ||
- | AND u.username = ' | ||
- | $conf[' | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id | ||
- | AND u.username = ' | ||
- | $conf[' | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id"; | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | (username, password, email, realname) | ||
- | | ||
- | $conf[' | ||
- | $conf[' | ||
- | SET group_id=%{gid} | ||
- | WHERE id=' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | " | ||
- | |||
- | $conf[' | ||
- | // call mysql constructor | ||
- | $this-> | ||
- | } | ||
- | |||
- | /** | ||
- | * Just checks against the $pun_user variable | ||
- | */ | ||
- | function trustExternal($user, | ||
- | global $USERINFO; | ||
- | global $conf; | ||
- | global $lang; | ||
- | global $pun_user; | ||
- | global $pun_config; | ||
- | $sticky ? $sticky = true : $sticky = false; //sanity check | ||
- | |||
- | // someone used the login form | ||
- | if(!empty($user)){ | ||
- | if($this-> | ||
- | $expire = ($sticky) ? time() + 31536000 : 0; | ||
- | $uinfo | ||
- | pun_setcookie($uinfo[' | ||
- | $pun_user = array(); | ||
- | $pun_user[' | ||
- | $pun_user[' | ||
- | $pun_user[' | ||
- | $pun_user[' | ||
- | $pun_user[' | ||
- | }else{ | ||
- | //invalid credentials - log off | ||
- | msg($lang[' | ||
- | auth_logoff(); | ||
- | return false; | ||
- | } | ||
- | } | ||
- | |||
- | if(isset($pun_user) && !$pun_user[' | ||
- | // okay we're logged in - set the globals | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | |||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | return true; | ||
- | } | ||
- | |||
- | // to be sure | ||
- | auth_logoff(); | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * remove punbb cookie on logout | ||
- | */ | ||
- | function logOff(){ | ||
- | global $pun_user; | ||
- | $pun_user = array(); | ||
- | $pun_user[' | ||
- | pun_setcookie(1, | ||
- | } | ||
- | } | ||
- | //Setup VIM: ex: et ts=2 enc=utf-8 : | ||
- | </ | ||
- | |||
- | ===== Source and Installation - punbb 1.3.x ===== | ||
- | |||
- | Up to DokuWiki 2008-05-05 this backend was included in the DokuWiki install. Newer versions no longer come with this backend. | ||
- | |||
- | To install the backend, create a '' | ||
- | |||
- | <code php punbb.class.php> | ||
- | <?php | ||
- | /** | ||
- | * PunBB 1.3.x auth backend | ||
- | * | ||
- | * Uses external Trust mechanism to check against PunBB' | ||
- | * user cookie. PunBB' | ||
- | * | ||
- | * @author | ||
- | */ | ||
- | |||
- | // needed if you use URL rewrite in you Wiki and Punbb | ||
- | // i.e.: example.com/ | ||
- | define(' | ||
- | |||
- | // do not confirm the action in punbb, usefull for ajax in dokuwiki | ||
- | define(' | ||
- | |||
- | if(!defined(' | ||
- | if(get_magic_quotes_gpc()){ | ||
- | nice_die(' | ||
- | <a href=" | ||
- | to be disabled for proper operation. Either setup your PHP install accordingly or | ||
- | choose a different auth backend.' | ||
- | } | ||
- | |||
- | require_once FORUM_ROOT.' | ||
- | require_once DOKU_INC.' | ||
- | |||
- | # | ||
- | # | ||
- | |||
- | class auth_punbb extends auth_mysql { | ||
- | |||
- | /** | ||
- | * Constructor. | ||
- | * | ||
- | * Sets additional capabilities and config strings | ||
- | */ | ||
- | function auth_punbb(){ | ||
- | global $conf; | ||
- | $this-> | ||
- | $this-> | ||
- | |||
- | // make sure we use a crypt understood by punbb | ||
- | if(function_exists(' | ||
- | $conf[' | ||
- | }else{ | ||
- | $conf[' | ||
- | } | ||
- | |||
- | // get global vars from PunBB config | ||
- | global $db_host; | ||
- | global $db_name; | ||
- | global $db_username; | ||
- | global $db_password; | ||
- | global $db_prefix; | ||
- | |||
- | // now set up the mysql config strings | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id | ||
- | AND u.username = ' | ||
- | AND g.g_title | ||
- | $conf[' | ||
- | id, g_title as `group` | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id | ||
- | AND u.username = ' | ||
- | $conf[' | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id | ||
- | AND u.username = ' | ||
- | $conf[' | ||
- | FROM ${db_prefix}users AS u, ${db_prefix}groups AS g | ||
- | WHERE u.group_id = g.g_id"; | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | (username, password, email, realname) | ||
- | | ||
- | $conf[' | ||
- | $conf[' | ||
- | SET group_id=%{gid} | ||
- | WHERE id=' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | $conf[' | ||
- | |||
- | $conf[' | ||
- | " | ||
- | |||
- | $conf[' | ||
- | // call mysql constructor | ||
- | $this-> | ||
- | } | ||
- | |||
- | /** | ||
- | * Just checks against the $forum_user variable | ||
- | */ | ||
- | function trustExternal($user, | ||
- | global $USERINFO; | ||
- | global $conf; | ||
- | global $lang; | ||
- | global $forum_user; | ||
- | global $pun_config; | ||
- | $sticky ? $sticky = true : $sticky = false; //sanity check | ||
- | |||
- | // someone used the login form | ||
- | if(!empty($user)){ | ||
- | if($this-> | ||
- | $expire = ($sticky) ? time() + 31536000 : 0; | ||
- | $uinfo | ||
- | forum_setcookie($uinfo[' | ||
- | $forum_user = array(); | ||
- | $forum_user[' | ||
- | $forum_user[' | ||
- | $forum_user[' | ||
- | $forum_user[' | ||
- | $forum_user[' | ||
- | }else{ | ||
- | //invalid credentials - log off | ||
- | msg($lang[' | ||
- | auth_logoff(); | ||
- | return false; | ||
- | } | ||
- | } | ||
- | |||
- | if(isset($forum_user) && !$forum_user[' | ||
- | // okay we're logged in - set the globals | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | |||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | return true; | ||
- | } | ||
- | |||
- | // to be sure | ||
- | auth_logoff(); | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * remove punbb cookie on logout | ||
- | */ | ||
- | function logOff(){ | ||
- | global $forum_user; | ||
- | $forum_user = array(); | ||
- | $forum_user[' | ||
- | forum_setcookie(1, | ||
- | } | ||
- | } | ||
- | //Setup VIM: ex: et ts=2 enc=utf-8 : | ||
- | </ | ||
- | |||
- | ===== Source and Installation - FluxBB 1.4 ===== | ||
- | |||
- | Same instructions as with FluxBB 1.2.x, but there are some functions in the file **inc/ | ||
- | * utf8_strlen | ||
- | * utf8_substr | ||
- | * utf8_ltrim | ||
- | * utf8_rtrim | ||
- | * utf8_trim | ||
- | * utf8_strtolower | ||
- | * utf8_strtoupper | ||
- | * utf8_ucfirst | ||
- | * utf8_strpos | ||
- | * utf8_bad_replace | ||
- | |||
- | Error message: < | ||
- | |||
- | So we need to edit inc/ | ||
- | === Example: utf8_strlen === | ||
- | replace: | ||
- | <code php> | ||
- | return strlen(utf8_decode($string)); | ||
- | }</ | ||
- | with: | ||
- | <code php> | ||
- | function utf8_strlen($string){ | ||
- | return strlen(utf8_decode($string)); | ||
- | } | ||
- | }</ | ||
- | |||
- | You'll have to apply these modifications 10 times in inc/ | ||
- | [[oli_v_ier@yahoo.fr|olivier]] | ||
- | [[id.2ndr@laposte.net|id2ndr]] | ||
- | |||
- | ==== dokuwiki 2010-11-07 " | ||
- | |||
- | With these version a small modification should be done to avoid the error bellow : | ||
- | < | ||
- | Fatal error: Call to a member function query() on a non-object in / | ||
- | </ | ||
- | * Add the line bellow in '' | ||
- | * Remove the line in '' | ||
- | |||
- | === PunBB CSRF & Ajax problem === | ||
- | |||
- | If you want to make ajax-quicksearch work, You should define the constant FORUM_SKIP_CSRF_CONFIRM before including any PunBB code | ||
- | so, the code above should be like below : < | ||
- | include PUN_ROOT.' | ||
- | ===== Discussion ===== | ||
- | |||
- | * Some username are not understand by DokuWiki (Pérot became P�rot or Pérot) | ||
- | DokuWiki uses UTF-8 and PunBB ISO8859-1, so this is just a character encoding problem. In order to get the right usernames, open / | ||
- | <code php> | ||
- | // okay we're logged in - set the globals | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | |||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | return true; | ||
- | }</ | ||
- | And replace by : | ||
- | <code php> | ||
- | // okay we're logged in - set the globals | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | |||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | return true; | ||
- | }</ | ||
- | // | ||
- | |||
- | * As punbb 1.3 will support utf8, a better patch is :<code php> | ||
- | // okay we're logged in - set the globals | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | </ | ||
- | * I think there is a problem when you use DokuWiki' | ||
- | * yann: edit the file conf/ | ||
- | * Better yet, use the group Members as is defined in the table groups in the PunBB MySQL database. |
auth/punbb.1333622457.txt.gz · Last modified: 2012-04-05 12:40 by 213.160.21.174