Pagina 1 van 1

[PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 06 jun 2009, 07:07
door Grimlock
  • Adres van je forum: http://theevolution.nl/forums/
    Event. modificaties op je forum: Aleen de stijl is drastisch aangepast
    Wanneer ontstond het probleem? n.v.t
    phpBB versie: 3.0.4

    Hoi, hoi.

    Graag zou ik voorkomen dat de gebruikers op mijn website zich op twee plaatsen moeten registreren (mijn cms & op de forums) en hetzelfde geld voor het inloggen.

    Nu heb ik er over zitten denken om de code en database structuur van phpbb aan te passen zodat er gebruik wordt gemaakt van maar één gebruikerstabel. Maar ik denk dit in de praktijk geen doen is. Zoiezo kom ik dan in de problemen wanneer er een nieuwe versie uitkomt van phpbb.

    De oplossing die ik hiervoor heb bedacht is het volgende: Wanneer een gebruiker zich registreert of inlogt zullen die POST gegevens verzonden moeten worden van mijn cms registratie/login formulier naar dat van phpbb. Dit brengt helaas wel wat redundantie met zich mee (zoals twee gebruikers tabellen) maar dat moet dan maar.

    Mijn vraag is, heeft iemand hier ervaring mee? Hoe kan ik dit het beste aanpakken? Welke POST variabelen worden waar verwacht voor de gebruikers registratie van phpbb? En die voor het inloggen?

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 06 jun 2009, 08:33
door Derky
Je zou hiervoor de code van de auth hook kunnen gebruiken:
./includes/auth/auth_db.php

Wellicht kan je daar ook iets inbouwen zodat je met je forum login ook op je CMS wordt ingelogd. ;)

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 15 jun 2009, 15:22
door Grimlock
Oké ik heb het zo goed als werkend nu, het enige probleem is dat ik de ucp.php moet includen in mijn RegistrationHandler classe van mijn CMS. Dit heeft als gevolg dat PHPBB begin te janken over het include pad.
Fatal error: Call to a member function sql_query() on a non-object in /home/sites/webhosting/codestars/theevolution/www/forums/includes/cache.php on line 51

Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/sites/webhosting/codestars/theevolution:/tmp:/usr/bin) in /home/sites/webhosting/codestars/theevolution/www/forums/includes/functions.php on line 884

Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/sites/webhosting/codestars/theevolution:/tmp:/usr/bin) in /home/sites/webhosting/codestars/theevolution/www/forums/includes/functions.php on line 884
Dit is de functie die ik geschreven heb die phpbb gerust stelt om op deze manier te registreren + de registratiegevens.

Code: Selecteer alles

//...
	/*
	 * We need to tell phpbb that it's okay to register this way.
	 */
	private function __construct(){}
	
	public function init($userName, $userEmail, $userPassword)
	{
		if(empty($userName) || empty($userEmail) || empty($userPassword))
		{
			// Missing one or more values...
			return false;
		}
		
		define('PHPBB_ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/forums/');
		$_POST["agreed"] = true;
		$_POST["submit"] = "Bevestig";	
		
		$_REQUEST = array
		(
			"username" => $userName,
			"email" => $userEmail,
			"email_confirm" => $userEmail,
		    "new_password" => $userPassword,
		    "password_confirm" => $userPassword,
			"creation_time" => time(),
			"lang" => "nl",
			"confirm_code" => "cmslogin"
		);
		
		$_REQUEST['mode'] = 'register'; 
		$_REQUEST['submit'] = true;
		$_REQUEST['coppa'] = true;
		$_REQUEST['cms_login'] = true;

		require_once(SITE_PATH . 'forums/ucp.php');
		
		// Done!
		return true;
	}
// ...etc
Hoe los ik dit probleem op?

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 16 jun 2009, 14:26
door Grimlock
Iemand? :?

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 19 jun 2009, 10:20
door Derky
Ik denk dat het beter is als je gewoon het relatieve pad gebruikt in plaats van dit:

Code: Selecteer alles

define('PHPBB_ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/forums/'); 
dus './../forums/'

Ik heb ook mijn twijfels of het gaat lukken met het includen van ucp.php. Ik denk dat je beter de register code daaruit kan halen en alleen de standaard dingen include (die standaard included worden, ucp.php is een vooral een pagina voor de output).

Code: Selecteer alles

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('ucp'); 

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 21 jun 2009, 12:37
door Grimlock
Hoi Derky,

Bedankt tot zo ver. Helaas werkt het nog niet... ik zit nog steeds naar de zelfde foutmelding te staren. :geek:

Deze code heb ik nu:

Code: Selecteer alles

		if(empty($userName) || empty($userEmail) || empty($userPassword))
		{
			// Missing one or more values...
			return false;
		}
		
		//define('PHPBB_ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/forums/');
		//$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
		//define('IN_PHPBB', true);
		//set_include_path('www/forums/');
    	//$phpbb_root_path = 'forums/';
	    define('IN_PHPBB', true);
		$phpbb_root_path = './forums/';
		
		$_POST["agreed"] = true;
		$_POST["submit"] = "Bevestig";	
		
		$_REQUEST = array
		(
			"username" => $userName,
			"email" => $userEmail,
			"email_confirm" => $userEmail,
		    "new_password" => $userPassword,
		    "password_confirm" => $userPassword,
			"creation_time" => time(),
			"lang" => "nl",
			"confirm_code" => "cmslogin"
		);
		
		$_REQUEST['mode'] = 'register'; 
		$_REQUEST['submit'] = true;
		$_REQUEST['coppa'] = true;
		$_REQUEST['cms_login'] = true;

	    $phpEx = substr(strrchr(__FILE__, '.'), 1);
	    require($phpbb_root_path . 'common.' . $phpEx);
	    require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
	    require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
	
	    // Start session management
	    $user->session_begin();
	    $auth->acl($user->data);
	    $user->setup('ucp'); 
Zoals je ziet heb ik al vanalles uitgeprobeerd, maar hij blijft deze foutmelding geven:

Code: Selecteer alles


Fatal error: Call to a member function sql_query() on a non-object in /home/sites/webhosting/codestars/theevolution/www/forums/includes/cache.php on line 51

Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/sites/webhosting/codestars/theevolution:/tmp:/usr/bin) in /home/sites/webhosting/codestars/theevolution/www/forums/includes/functions.php on line 884

Warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/sites/webhosting/codestars/theevolution:/tmp:/usr/bin) in /home/sites/webhosting/codestars/theevolution/www/forums/includes/functions.php on line 884
[phpBB Debug] PHP Notice: in file /home/sites/webhosting/codestars/theevolution/www/bll/class.SessionHandler.php on line 132: Cannot modify header information - headers already sent
Toen ik in /includes/registerForums.php ucp.php include werkte het wel, maar sinds ik het geintergreerd heb in mijn RegisterHandler klasse van mijn cms wijgert hij de bestanden van het forum te includen.

Zo ziet de bestand structuur eruit, register.php roept eerst de klasse RegistrationHandler aan en wanneer de input velden geldig zijn verklaart door de validatie klasse zal de ForumsRegistration klasse aangeroepen worden.
/register.php -> /bll/class.RegisterHandler.php -> /bll/class.ForumsRegistration.php. Dus het kan zijn dat hij include vanuit / of juist vanuit /bll/
Include paden zijn niet bepaald mijn sterkste kant :lol:

Hier: http://www.phpbb.com/kb/article/phpbb2- ... tegration/ vond ik nog wat extra informatie over het intergreren van een phpbb sessie op een eigen geschreven pagina. Maar met hun code had ik helaas de zelfde foutmelding.

Hopelijk kan iemand me helpen! Als dit is opgelost is het eindelijk mogelijk om, wanneer men zich registreert voor het cms, dat er automatisch ook een forums account wordt aangemaakt!

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 21 jun 2009, 13:06
door Grimlock
Trouwens, als ik

$phpbb_root_path = './forums/';
echo realpath($phpbb_root_path);

Krijg ik deze output:
/home/sites/webhosting/codestars/theevolution/www/forums

Dat zou goed moeten zijn... snap nog steeds niet waarom phpbb dan toch moeilijk doet.

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 21 jun 2009, 13:35
door Derky
Graag niet dubbelposten binnen 24 uur. ;)

Fatal error: Call to a member function sql_query() on a non-object in /home/sites/webhosting/codestars/theevolution/www/forums/includes/cache.php on line 51

Bij mij op regel 51 staat $result = $db->sql_query($sql);, zou het kunnen zijn dat jouw CMS iets hiervan overschrijft? Waardoor het geen object meer is? :|
Wijziging:
Include je trouwens nog steeds ucp.php? Probeer eens om alleen common en functions_user te includen en gebruik dan de functie user_add() ipv je huidige manier.

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 23 jun 2009, 17:43
door Grimlock
Nee, ik include geen ucp.php meer (zie code van mijn vorige bericht).
Nope, gebruik geen $db object in die klasse dus kan onmogelijk het probleem zijn.

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 20 sep 2010, 12:07
door traxion
heeft iemand hiervoor al een oplossing?

Op het moment dat ik onderstaande code draai in index.php werkt die goed

Code: Selecteer alles

        define('IN_PHPBB', true);
        $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'phpBB3/';
        $phpEx = substr(strrchr(__FILE__, '.'), 1);
        include($phpbb_root_path . 'common.' . $phpEx);
        require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
        require($phpbb_root_path . 'includes/functions_module.' . $phpEx);

        // Start session management
        $user->session_begin();
        $auth->acl($user->data);
        $user->setup();

        include($phpbb_root_path . 'config.' . $phpEx); 
Op het moment dat ik deze in een class zet ( als constructer)

Code: Selecteer alles

class phpBB3 {
/**
 *
 * @var phpbb3_user a phpbb3 var with user-information
 */
public $user;
    /**
     * Construct function
     * init phpbb3 acces
     */
    public function __construct(&$user){
    
        define('IN_PHPBB', true);
        $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'phpBB3/';
        $phpEx = substr(strrchr(__FILE__, '.'), 1);
        include($phpbb_root_path . 'common.' . $phpEx);
        require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
        require($phpbb_root_path . 'includes/functions_module.' . $phpEx);

        // Start session management
        $user->session_begin();
        $auth->acl($user->data);
        $user->setup();

        include($phpbb_root_path . 'config.' . $phpEx);

    }
} 
krijg ik dezelfde error als bovenstaande topic
Fatal error: Call to a member function sql_query() on a non-object in C:\wamp\www\users\phpBB3\includes\cache.php on line 51

Re: [PHP] CMS en PHPBB login & registratie samenvoegen

Geplaatst: 01 jun 2013, 00:15
door pbrouwers
Voor het geval ooit iemand dit topic leest en geen oplossing vindt:

Zo gauw je met objects gaat werken, kan je de phpbb objects niet op dezelfde manier gebruiken ($user, ...). Daarom dat je ook die foutmelding krijgt. (Call to a member function sql_query() on a non-object.) De $cache is gewoon een variable nu, geen object meer.
Dit probleem kun je makkelijk verhelpen door de phpbb objects in je class op te roepen met global.

Voorbeeld:
global $user, $auth, $cache, $db, $phpEx, $phpbb_root_path, $config, $template;