« Zebratables in Weblication Schicker Weblication Login »

Nachtrag zu phpBB in Weblication

Viele kennen dieses Phänomen: Man kauft sich ein Kochbuch eines Starkochs und versucht ein kompliziertes Rezept nachzukochen. Meistens geht das dann komplett schief und das gewünschte Ergebnis wird nicht erzeugt.

Es soll auch einen Fall gegeben haben, bei welchem einem Starkoch ein Rezept vorlegt wurde und dieser nach 2 Stunden entnervt aufgegeben hat. Dabei handelte es sich um ein Rezept aus seinem eigenem Kochbuch…

So oder so ähnlich ging es auch mir (dabei stimmt der Vergleich mit dem Starkoch jedoch nicht ganz ;)). Der Artikel bezüglich der Einbindung des phpBB Forums hat einfach seine Lücken, die ich nun versuche hier komplett zu schließen:

Im Ordner /weblication/wBoard/phpBB/ muss eine XML-Datei angelegt werden: “wBoard_123456789.xml” - dabei einfach irgendeine beliebige Zahl wählen. Hier werden die Datenbankdaten eingegeben:

<wBoard version="4.0">
 <dbHost value="localhost" />
 <dbName value="db_name" /> 
 <port value="80" />
 <user value="user" />
 <pass value="password" />
 <usersTable value="phpbb_users" />
</wBoard>

In der Konfigurationsdaatei von weblication (weblication/wConf/wConf_1234567890.xml) muss noch der Zusatz eingefügt werden:

<EXPORT_USER_TO_PHPBB>on</EXPORT_USER_TO_PHPBB>

Alle Benutzer werden nun durch diese Konfiguration automatisch beim Login in Weblication in die Datenbank von phpBB hinzugefügt.

Die Abfrage im Forum wurde in meinem letzten Artikel über phpBB nicht ganz korrekt durchgeführt. Hier die richtige Abfrage (diese muss in die index.php des Forums):

<?php
require_once ($_SERVER["DOCUMENT_ROOT"]."/weblication/lib/WFRAMEWORK/wUserCur.php");
/***************************************************************************
 *                                index.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: index.php,v 1.99.2.7 2006/01/28 11:13:39 acydburn Exp $
 *
 *
 ***************************************************************************/
 
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
 
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
 
// START: Apache authentication hack
//   ********
//   ********
//   ********
// Please realize this totally bypasses normal phpBB authentication!
// Only use this with secure connections with high-grade encryption.
// This is mostly a copy/paste from login.php with a few tweaks. :)
 
// Make sure we have a new session.
if (!array_key_exists('sid',$HTTP_POST_VARS) && !array_key_exists('sid',$HTTP_GET_VARS)) {
   $sid = '';
 
   // Grab the login from whatever apache gives us.
   $userClass = new wUserCur();
   $username = $userClass->wGetUserName();
   if($username=='') { header("Location: URL zur FEHLERSEITE"); }
 
 
   // Get user information from the database, create the session, and log the user in.
   $sql = "SELECT user_id, username, user_password, user_active, user_level FROM phpbb_users WHERE username = '" . str_replace("\\'", "''", $username) . "'";
   // print($sql);
   if (!($result = $db->sql_query($sql))) {
      message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
   } elseif (($row = $db->sql_fetchrow($result)) && ($row['username']!="")) {
      if($row['user_level'] != ADMIN && $board_config['board_disable']) {
         redirect(append_sid("index.$phpEx", true));
      } else {
         $autologin = TRUE;
         $session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin);
         if($session_id) {
            $url = (!empty($HTTP_POST_VARS['redirect'])) ? $HTTP_POST_VARS['redirect'] : "index.$phpEx";
            redirect(append_sid($url, true));
         } else {
            message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__);
         }
      }
   } else {
      print "Error: User ".$username." does not exist!";
      header("Location: URL zur FEHLERSEITE");
      die;
   }
}
 
// STOP: Apache authentication hack

In die login.php muss dann noch folgender Code:

require_once ($_SERVER["DOCUMENT_ROOT"]."/weblication/lib/WFRAMEWORK/wUserCur.php");
/***************************************************************************
 *                                login.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: login.php,v 1.47.2.25 2006/12/16 13:11:24 acydburn Exp $
 *
 *
 ***************************************************************************/
 
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
//
// Allow people to reach login page if
// board is shut down
//
define("IN_LOGIN", true);
 
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
 
 
$userClass = new wUserCur();
$username = $userClass->wGetUserName();
$sql = "SELECT user_level	FROM " . USERS_TABLE. "Where username = $username";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
 
if ($row['user_level'] == '0') { 
	exit;
}

Dann sollte der reibungslosen Forenintegration nichts mehr im Wege stehen :)


Kommentare zu Nachtrag zu phpBB in Weblication

  1. phpBB in Weblication » Beitrag » Weblication Tipps | 24. April, 2008 | 18:23

    [...] 24.04.2008: Ein Nachtrag zu diesem Artikel ist erschienen. Dieser Eintrag wurde am on Dienstag, 22. Mai, 2007 um 07:00 Uhr veröffentlicht [...]

  2. werutzb | 8. Oktober, 2008 | 04:12

    Hi!

    I want to extend my SQL experience.
    I red that many SQL resources and want to
    get more about SQL for my position as mysql database manager.

    What can you recommend?

    Thanks,
    Werutz

  3. Ulf (Herausgeber) | 9. Oktober, 2008 | 11:35

    Dear werutz,

    sorry - but I think you’re not at the right place to extend your knownledge in mysql here. This is about Weblication. My advice: Get a project and try to learn on that one.

    Best regards
    Ulf

Schreibe einen Kommentar zu Nachtrag zu phpBB in Weblication




Impressum - Weblication Tipps