Forum einbinden

Gesperrt
schnoupf
Beiträge: 9
Registriert: Mi 20. Mai 2009, 18:52
Kontaktdaten:

Forum einbinden

Beitrag von schnoupf »

Hallo,

ich möchte meinen Contenido Frontend Login gleichzeitig für den Forenlogin mitbenutzen. Die User und Passwörter werden jeweils getrennt gespeichert sind aber immer identisch.
Als Forensoftware benutze ich das Woltlab Burning Board Lite v2.0.1

Mit deisem Code kann ich auf einer leeren Seite problemlos den Login setzen, also die Sessions und Cookies für das Forum.
Wenn ich allerdings versuche diesen Code in einem Modul (im Contenido Backend) oder direkt in der front_content.php zu includen dann kommt entweder ein Fehler oder die Seite bleibt ganz weiss...

Hier Der Code der den Forenlogin übernehmen sollte und der auf einer "leeren" Seite außerhalb Contenido problemlos funktioniert:

Code: Alles auswählen

$packageDirs = array();
if (!defined('WBB_DIR')) define('WBB_DIR', '../contenido/plugins/wbblite201/');
if (!defined('WCF_DIR')) define('WCF_DIR', '../contenido/plugins/wbblite201/wbb/');
if (!defined('RELATIVE_WBB_DIR')) define('RELATIVE_WBB_DIR', '');
if (!defined('WBB_N')) define('WBB_N', '1_1');
$packageDirs[] = WBB_DIR;

if (!defined('RELATIVE_WCF_DIR'))   define('RELATIVE_WCF_DIR', RELATIVE_WBB_DIR.'wbb/');
if (!defined('PACKAGE_ID')) define('PACKAGE_ID', 24);
if (!defined('PACKAGE_NAME')) define('PACKAGE_NAME', 'WoltLab Burning Board Lite');
if (!defined('PACKAGE_VERSION')) define('PACKAGE_VERSION', '2.0.1');

require_once(WCF_DIR.'lib/system/WCF.class.php'); 
require_once(WCF_DIR.'lib/system/auth/UserAuth.class.php');
require_once(WBB_DIR.'lib/system/WBBCore.class.php');
new WBBCore();
    
$foUser = UserAuth::getInstance()->loginManually("xxx", "xxx");
WCF::getSession()->changeUser($foUser);
    
$cookieTime = time() + (365*24*60*60);
HeaderUtil::setCookie("userID", $foUser->userID, $cookieTime);
HeaderUtil::setCookie("password", StringUtil::getSaltedHash("tiger", $foUser->salt), $cookieTime);
Das Problem liegt bei den require_once, danach bleibt die Seite leer...

Hat jmd eine Idee oder sowas auch schon mal erfolgreich umgesetzt?

Hier noch die Klassen die inkludiert werden (WBBCore.class.php):

Code: Alles auswählen

<?php
// wcf imports
require_once(WCF_DIR.'lib/page/util/menu/HeaderMenuContainer.class.php');
require_once(WCF_DIR.'lib/page/util/menu/UserCPMenuContainer.class.php');
require_once(WCF_DIR.'lib/page/util/menu/UserProfileMenuContainer.class.php');
require_once(WCF_DIR.'lib/system/style/Style.class.php');

/**
 * This class extends the main WCF class by forum specific functions.
 *
 * @package	com.woltlab.wbb.system
 * @author	Marcel Werk
 * @copyright	2001-2007 WoltLab GmbH
 * @license	WoltLab Burning Board License <http://www.woltlab.com/products/burning_board/license.php>
 */
class WBBCore extends WCF implements HeaderMenuContainer, UserCPMenuContainer, UserProfileMenuContainer {
	protected static $headerMenuObj = null;
	protected static $userCPMenuObj = null;
	protected static $userProfileMenuObj = null;

	/**
	 * @see WCF::initTPL()
	 */
	protected function initTPL() {
		// init style to get template pack id
		$this->initStyle();
		
		global $packageDirs;
 		require_once(WCF_DIR.'lib/system/template/StructuredTemplate.class.php');
		self::$tplObj = new StructuredTemplate(self::getStyle()->templatePackID, self::getLanguage()->getLanguageID(), ArrayUtil::appendSuffix($packageDirs, 'templates/'));
		$this->assignDefaultTemplateVariables();
		
		// init cronjobs
		$this->initCronjobs();
		
		// user ban
		if (self::getUser()->banned && (!isset($_REQUEST['page']) || $_REQUEST['page'] != 'LegalNotice')) {
			require_once(WCF_DIR.'lib/system/exception/PermissionDeniedException.class.php');
			throw new PermissionDeniedException();
		}
	}
	
	/**
	 * Initialises the cronjobs.
	 */
	protected function initCronjobs() {
		self::getTPL()->assign('executeCronjobs', WCF::getCache()->get('cronjobs-'.PACKAGE_ID, 'nextExec') < TIME_NOW);
	}
	
	/**
	 * @see WCF::loadDefaultCacheResources()
	 */
	protected function loadDefaultCacheResources() {
		parent::loadDefaultCacheResources();
		$this->loadDefaultWBBCacheResources();
	}
	
	/**
	 * Loads default cache resources of burning board.
	 * Can be called statically from other applications or plugins.
	 */
	public static function loadDefaultWBBCacheResources() {
		WCF::getCache()->addResource('board', WBB_DIR.'cache/cache.board.php', WBB_DIR.'lib/system/cache/CacheBuilderBoard.class.php');
		WCF::getCache()->addResource('boardData', WBB_DIR.'cache/cache.boardData.php', WBB_DIR.'lib/system/cache/CacheBuilderBoardData.class.php', 0, 300);
		WCF::getCache()->addResource('stat', WBB_DIR.'cache/cache.stat.php', WBB_DIR.'lib/system/cache/CacheBuilderStat.class.php', 0, 300);
		WCF::getCache()->addResource('bbcodes', WCF_DIR.'cache/cache.bbcodes.php', WCF_DIR.'lib/system/cache/CacheBuilderBBCodes.class.php');
		WCF::getCache()->addResource('smilies', WCF_DIR.'cache/cache.smilies.php', WCF_DIR.'lib/system/cache/CacheBuilderSmilies.class.php');
		WCF::getCache()->addResource('cronjobs-'.PACKAGE_ID, WCF_DIR.'cache/cache.cronjobs-'.PACKAGE_ID.'.php', WCF_DIR.'lib/system/cache/CacheBuilderCronjobs.class.php');
		WCF::getCache()->addResource('help-'.PACKAGE_ID, WCF_DIR.'cache/cache.help-'.PACKAGE_ID.'.php', WCF_DIR.'lib/system/cache/CacheBuilderHelp.class.php');
	}
	
	/**
	 * Initialises the page header menu.
	 */
	protected static function initHeaderMenu() {
		require_once(WCF_DIR.'lib/page/util/menu/HeaderMenu.class.php');
		self::$headerMenuObj = new HeaderMenu();
		if (HeaderMenu::getActiveMenuItem() == '') HeaderMenu::setActiveMenuItem('wbb.header.menu.board');
	}
	
	/**
	 * Initialises the user cp menu.
	 */
	protected static function initUserCPMenu() {
		require_once(WCF_DIR.'lib/page/util/menu/UserCPMenu.class.php');
		self::$userCPMenuObj = UserCPMenu::getInstance();
	}
	
	/**
	 * Initialises the user profile menu.
	 */
	protected static function initUserProfileMenu() {
		require_once(WCF_DIR.'lib/page/util/menu/UserProfileMenu.class.php');
		self::$userProfileMenuObj = UserProfileMenu::getInstance();
	}
	
	/**
	 * @see WCF::getOptionsFilename()
	 */
	protected function getOptionsFilename() {
		return WBB_DIR.'options.inc.php';
	}
	
	/**
	 * Initialises the style system.
	 */
	protected function initStyle() {
		Style::changeStyle(self::getSession()->getStyleID());
	}
	
	/**
	 * Changes the active style.
	 * 
	 * @param	integer		$styleID
	 * @deprecated
	 */
	public static final function changeStyle($styleID) {
		return Style::changeStyle($styleID);
	}
	
	/**
	 * @see HeaderMenuContainer::getHeaderMenu()
	 */
	public static final function getHeaderMenu() {
		if (self::$headerMenuObj === null) {
			self::initHeaderMenu();
		}
		
		return self::$headerMenuObj;
	}
	
	/**
	 * @see UserCPMenuContainer::getUserCPMenu()
	 */
	public static final function getUserCPMenu() {
		if (self::$userCPMenuObj === null) {
			self::initUserCPMenu();
		}
		
		return self::$userCPMenuObj;
	}
	
	/**
	 * @see UserProfileMenuContainer::getUserProfileMenu()
	 */
	public static final function getUserProfileMenu() {
		if (self::$userProfileMenuObj === null) {
			self::initUserProfileMenu();
		}
		
		return self::$userProfileMenuObj;
	}
	
	/**
	 * Returns the active style object.
	 * 
	 * @return	Style
	 */
	public static final function getStyle() {
		return Style::getStyle();
	}
	
	/**
	 * @see WCF::initSession()
	 */
	protected function initSession() {
		// start session
		require_once(WBB_DIR.'lib/system/session/WBBSessionFactory.class.php');
		$factory = new WBBSessionFactory();
		self::$sessionObj = $factory->get();
		self::$userObj = self::getSession()->getUser();
	}
	
	/**
	 * @see	WCF::assignDefaultTemplateVariables()
	 */
	protected function assignDefaultTemplateVariables() {
		parent::assignDefaultTemplateVariables();
		self::getTPL()->assign('timezone', DateUtil::getTimezone());
	}
}
?>
WCF.class.php:

Code: Alles auswählen

<?php
// define current wcf version
define('WCF_VERSION', '1.0.10 (Horizon)');

// define current unix timestamp
define('TIME_NOW', time());

// define constants
define('IS_APACHE_MODULE', function_exists('apache_get_version'));

// imports
if (!defined('NO_IMPORTS')) {
	require_once(WCF_DIR.'lib/system/cache/CacheHandler.class.php');
	require_once(WCF_DIR.'lib/system/exception/PrintableException.class.php');
	require_once(WCF_DIR.'lib/system/language/Language.class.php');
	require_once(WCF_DIR.'lib/system/template/Template.class.php');
	require_once(WCF_DIR.'lib/system/benchmark/Benchmark.class.php');
	require_once(WCF_DIR.'lib/core.functions.php');
}

/**
 * WCF is the central class for the community framework.
 * It holds the database connection, access to template and language engine.
 * 
 * @package	com.woltlab.wcf.system
 * @author	Marcel Werk
 * @copyright	2001-2007 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 */
class WCF {
	
	/**
	 * database object
	 * 
	 * @var Database
	 */
	protected static $dbObj;
	
	/**
	 * cache handler object
	 *
	 * @var CacheHandler
	 */
	protected static $cacheObj;
	
	/**
	 * session object..
	 *
	 * @var Session
	 */
	protected static $sessionObj;
	
	/**
	 * current user object
	 *
	 * @var UserSession
	 */
	protected static $userObj;
	
	/**
	 * language object
	 *
	 * @var Language
	 */
	protected static $languageObj;
	
	/**
	 * template object
	 *
	 * @var Template
	 */
	protected static $tplObj;
	
	/**
	 * benchmark object
	 *
	 * @var Benchmark
	 */
	protected static $benchmarkObj;
	
	/**
	 * Calls all init functions of the WCF class. 
	 */
	public function __construct() {
		if (!defined('TMP_DIR')) define('TMP_DIR', BasicFileUtil::getTempFolder());
		$this->initBenchmark();
		$this->initMagicQuotes();
		$this->initDB();
		$this->initOptions();
		$this->initCache();
		$this->initSession();
		$this->initLanguage();
		$this->initTPL();
	}
	
	/**
	 * Replacement of the "__destruct()" method. 
	 * Seems that under specific conditions (windows) the destructor is not called automatically.
	 * So we use the php register_shutdown_function to register an own destructor method. 
	 * Flushs the output, updates the session and executes the shutdown queries.
	 */
	public static function destruct() {
		if (ob_get_level() && ini_get('output_handler')) ob_flush();
		else flush();
		if (is_object(self::getSession())) self::getSession()->update();
		if (is_object(self::getDB())) self::getDB()->sendShutdownUpdates();
	}
	
	/**
	 * Initialises the benchmark system.
	 */
	protected function initBenchmark() {
		self::$benchmarkObj = new Benchmark();
	}
	
	/**
	 * Returns the benchmark object.
	 * 
	 * @return	Benchmark
	 */
	public static final function getBenchmark() {
		return self::$benchmarkObj;
	}
	
	/**
	 * Removes slashes in superglobal gpc data arrays if 'magic quotes gpc' is enabled.
	 */
	protected function initMagicQuotes() {
		if (function_exists('get_magic_quotes_gpc')) {
			if (@get_magic_quotes_gpc()) {
				if (count($_REQUEST)) {
					$_REQUEST = ArrayUtil::stripslashes($_REQUEST);
				}
				if (count($_POST)) {
					$_POST = ArrayUtil::stripslashes($_POST);
				}
				if (count($_GET)) {
					$_GET = ArrayUtil::stripslashes($_GET);
				}
				if (count($_COOKIE)) {
					$_COOKIE = ArrayUtil::stripslashes($_COOKIE);
				}
				if (count($_FILES)) {
					foreach ($_FILES as $name => $attributes) {
						foreach ($attributes as $key => $value) {
							if ($key != 'tmp_name') {
								$_FILES[$name][$key] = ArrayUtil::stripslashes($value);
							}
						}
					}
				}
			}
		}
	
		if (function_exists('set_magic_quotes_runtime')) {
			@set_magic_quotes_runtime(0);
		}
	}
	
	/**
	 * Returns the database object.
	 * 
	 * @return	Database
	 */
	public static final function getDB() {
		return self::$dbObj;		
	}
	
	/**
	 * Returns the cache handler object.
	 * 
	 * @return	CacheHandler
	 */
	public static final function getCache() {
		return self::$cacheObj;		
	}
	
	/**
	 * Returns the session object.
	 * 
	 * @return	Session
	 */
	public static final function getSession() {
		return self::$sessionObj;
	}
	
	/**
	 * Returns the user object.
	 * 
	 * @return	UserSession
	 */
	public static final function getUser() {
		return self::$userObj;
	}
	
	/**
	 * Returns the language object.
	 * 
	 * @return 	Language
	 */
	public static final function getLanguage() {
		return self::$languageObj;
	}
	
	/**
	 * Returns the template object.
	 * 
	 * @return	Template
	 */
	public static final function getTPL() {
		return self::$tplObj;
	}
	
	/**
	 * Returns the active request object.
	 *
	 * @return	RequestHandler
	 */
	public static final function getRequest() {
		return RequestHandler::getActiveRequest();
	}
	
	/**
	 * Calls the show method on the given exception.
	 * 
	 * @param	Exception	$e	
	 */
	public static final function handleException(Exception $e) {
		if ($e instanceof PrintableException) {
			$e->show();
			exit;
		}
		
		print $e;
	}
	
	/**
	 * Catches php errors and throws instead a system exception.
	 * 
	 * @param	integer		$errorNo
	 * @param	string		$message
	 * @param	string		$filename
	 * @param	integer		$lineNo
	 */
	public static final function handleError($errorNo, $message, $filename, $lineNo) { 
		if (error_reporting() != 0) {
			$type = 'error';
			switch ($errorNo) {
				case 2: $type = 'warning';
					break;
				case 8: $type = 'notice';
					break;
			}
			
			throw new SystemException('PHP '.$type.' in file '.$filename.' ('.$lineNo.'): '.$message, 0);
		}
	}
	
	/**
	 * Loads the database configuration and creates a new connection to the database.
	 */
	protected function initDB() {
		// get configuration
		$dbHost = $dbUser = $dbPassword = $dbName = $dbCharset = '';
		$dbClass = 'MySQLDatabase';
		require_once(WCF_DIR.'config.inc.php');
		
		// create database connection
		require_once(WCF_DIR.'lib/system/database/'.$dbClass.'.class.php');
		self::$dbObj = new $dbClass($dbHost, $dbUser, $dbPassword, $dbName, $dbCharset);
	}
	
	/**
	 * Initialises the cache handler and loads the default cache resources.
	 */
	protected function initCache() {
		self::$cacheObj = new CacheHandler();
		$this->loadDefaultCacheResources();
	}
	
	/**
	 * Loads the default cache resources.
	 */
	protected function loadDefaultCacheResources() {
		self::getCache()->addResource('languages', WCF_DIR.'cache/cache.languages.php', WCF_DIR.'lib/system/cache/CacheBuilderLanguages.class.php');
		self::getCache()->addResource('spiders', WCF_DIR.'cache/cache.spiders.php', WCF_DIR.'lib/system/cache/CacheBuilderSpiders.class.php');
	}
	
	/**
	 * Includes the options file.
	 * If the option file doesn't exist, the rebuild of it is started.
	 */
	protected function initOptions() {
		// get options file name
		$optionsFile = $this->getOptionsFilename();
		
		// create options file if doesn't exist
		if (!file_exists($optionsFile) || filemtime($optionsFile) <= 1) {
			require_once(WCF_DIR.'lib/acp/option/Options.class.php');
			Options::rebuildFile($optionsFile);
		}
		require_once($optionsFile);
	}
	
	/**
	 * Returns the name of the options file.
	 * 
	 * @return	string		name of the options file
	 */
	protected function getOptionsFilename() {
		return WCF_DIR.'options.inc.php';
	}
	
	/**
	 * Starts the session system.
	 */
	protected function initSession() {
		if (!defined('NO_IMPORTS')) require_once(WCF_DIR.'lib/system/session/CookieSessionFactory.class.php');
		$factory = new CookieSessionFactory();
		self::$sessionObj = $factory->get();
		self::$userObj = self::getSession()->getUser();
	}
	
	/**
	 * Initialises the language engine.
	 */
	protected function initLanguage() {
		if (isset($_GET['l']) && !self::getUser()->userID) {
			self::getSession()->setLanguageID(intval($_GET['l']));
		}
		
		self::$languageObj = new Language(self::getSession()->getLanguageID());
	}
	
	/**
	 * Initialises the template engine.
	 */
	protected function initTPL() {
		self::$tplObj = new Template(self::getLanguage()->getLanguageID());
		$this->assignDefaultTemplateVariables();
	}
	
	/**
	 * Assigns some default variables to the template engine.
	 */
	protected function assignDefaultTemplateVariables() {
		self::getTPL()->registerPrefilter('lang');
		self::getTPL()->assign('this', $this);
	}
	
	/**
	 * Wrapper for the getter methods of this class.
	 * 
	 * @param	string		$name
	 * @return	mixed		value
	 */
	public function __get($name) {
		$method = 'get'.ucfirst($name);
		if (method_exists($this, $method)) {
			return $this->$method();
		}
		
		throw new SystemException("method '".$method."' does not exist in class WCF");
	}
	
	/**
	 * Changes the active language.
	 * 
	 * @param	integer		$languageID
	 */
	public static final function setLanguage($languageID) {
		self::$languageObj = new Language($languageID);
	}
}
?>

UserAuth.class.php:

Code: Alles auswählen

<?php
// imports
if (!defined('NO_IMPORTS')) {
	require_once(WCF_DIR.'lib/system/auth/UserAuthDefault.class.php');
	require_once(WCF_DIR.'lib/system/event/EventHandler.class.php');
	require_once(WCF_DIR.'lib/data/user/User.class.php');
}

/**
 * All user authentication types should implement the abstract functions of this class.
 * 
 * @package	com.woltlab.wcf.system.auth
 * @author	Marcel Werk
 * @copyright	2001-2007 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 */
abstract class UserAuth {
	protected static $instance = null;
	
	/**
	 * Returns an instance of the enabled user auth class.
	 * 
	 * @return	UserAuth
	 */
	public static function getInstance() {
		if (self::$instance === null) {
			// call loadInstance event
			if (!defined('NO_IMPORTS')) EventHandler::fireAction('UserAuth', 'loadInstance');
		
			if (self::$instance === null) self::$instance = new UserAuthDefault();
		}
		return self::$instance;
	}
	
	/**
	 * Returns true, if this auth type supports persistent logins.
	 * 
	 * @return	boolean
	 */
	public abstract function supportsPersistentLogins();
	
	/**
	 * Stores the user access data for a persistent login.
	 * 
	 * @param	User		$user
	 * @param 	string		$username
	 * @param	string		$password
	 */
	public abstract function storeAccessData(User $user, $username, $password);
	
	/**
	 * Does an manual user login.
	 * 
	 * @param 	string		$username
	 * @param	string		$password
	 * @param	string		$userClassname		class name of user class
	 * @return	User
	 */
	public abstract function loginManually($username, $password, $userClassname = 'UserSession');
	
	/**
	 * Does an automatic user login.
	 * 
	 * @param	boolean		$persistent		true = persistent login
	 * @param	string		$userClassname		class name of user class
	 * @return	User
	 */
	public abstract function loginAutomatically($persistent = false, $userClassname = 'UserSession');
}
?>
Vielen Dank für eure Hilfe...
schnoupf
Beiträge: 9
Registriert: Mi 20. Mai 2009, 18:52
Kontaktdaten:

Re: Forum einbinden

Beitrag von schnoupf »

also scheinbar liegt es daran, dass das Forum Klassen mit dem beispielsweise dem Namen Template oder User benutzt. Genau solche Klassen gibt es ja auch in Contenido.
Gibt es da php-technisch keine Möglichkeit beide Klassen zu benutzen.
In anderen Programmiersprachen gibt es ja namespaces oder ich importiere eine Libaray, da ist dann auch unrelavant ob Namen der Klasse gleich lauten.

Ich habe im Moment eine Lösung die mir nicht so ganz zusagt, habe einen unsichtbaren Iframe der dann den Code mit dem Forenlogin übernimmt... Ist aber meiner Meinung nach supotimal.

Jemand noch andere Ideen?

Gruß
Ben
Gesperrt