Dit is een archief van het phpBBservice.nl forum. Nieuwe berichten plaatsen is niet meer mogelijk.
Z
#1
Hey!

Ik ben bezig met een website waarbij ik het registreren wil integreren in de algemene website. Hiervoor heb ik een brok code van het internet gehaald ie goed zou moeten werken.

Het gaat om de volgende code:

Code: Selecteer alles

<?php

// CMS config
$cmsConfig = new config;

define('IN_PHPBB',true);
   global $db, $cache, $config;
$phpbb_root_path = $cmsConfig->pad . 'forum/';
$phpEx = 'php';
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'includes/functions_display.php');
include_once($phpbb_root_path . 'includes/functions_user.php');

//Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('ucp');
 
if($user->data['is_registered'])
{
        meta_refresh(3, append_sid("index.$phpEx"));
        trigger_error("You are already registered!");
}
 
$submit = request_var('submit', '');
if($submit)
{
        // Retrieve default group ID
        $sql = 'SELECT group_id
                FROM ' . GROUPS_TABLE . "
                WHERE group_name = '" . $db->sql_escape('REGISTERED') . "'
                        AND group_type = " . GROUP_SPECIAL;
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
 
        if (!$row)
        {
                trigger_error('NO_GROUP');
        }
        $group_id = $row['group_id'];
        
 
        $data = array(
                'username'                      => utf8_normalize_nfc(request_var('username', '', true)),
                'user_password'         => phpbb_hash(request_var('password', '', true)),
                'user_email'            => strtolower(request_var('email', '')),
                'group_id'                      => (int) $group_id,
                'user_type'                     => USER_NORMAL,
                'user_ip'                       => $user->ip,
        );
        
        $validate_username = validate_username($data['username']);
        if ($validate_username !== false)
        {
                trigger_error($validate_username, E_USER_ERROR);
        }
        
        $validate_password = validate_password($data['user_password']);
        if ($validate_password !== false)
        {
          trigger_error($validate_password, E_USER_ERROR);
        }
        
        $validate_email = validate_email($data['user_email']);
        if ($validate_email !== false)
        {
         trigger_error($validate_email, E_USER_ERROR);
        }
        
        $user_id = user_add($data);
 
        if ($user_id === false)
        {
                trigger_error('NO_USER', E_USER_ERROR);
        }
 
        //Set up welcome message
        if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable'])
        {
                $message = $user->lang['ACCOUNT_INACTIVE'];
        }
        else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable'])
        {
                $message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
        }
        else
        {
                $message = $user->lang['ACCOUNT_ADDED'];
        }
        
        //Display message
        $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
        trigger_error($message);
}
else
{
        echo '<form action="./register.php" method="post">
              Username: <input type="text" name="username" /><br />
              E-mail address: <input type="text" name="email" size="25" maxlength="100" /><br />
              Password: <input type="password" name="password" size="25" /><br />
              <input type="submit" name="submit" value="Submit" />
              </form>';
}
?>
Geeft error:

Code: Selecteer alles

[phpBB Debug] PHP Notice: in file /forum/includes/session.php on line 273: session_begin(includes/auth/auth_db.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /forum/includes/session.php on line 273: session_begin(): Failed opening 'includes/auth/auth_db.php' for inclusion (include_path='.:/usr/share/pear')
Language file en/common. couldn't be opened.
Ik ben er al achter gekomen dat het komt omdat mijn $phpbb_root_path en $phpEx niet overgedragen worden naar de andere bestanden. En om nou in elk bestand global $phpbb_root_path, $phpEx; te zette lijkt me nogal omslachtig.

Hebben jullie misschien een idee? :)
R
#2

Code: Selecteer alles

 echo '<form action="./register.php" method="post">
              Username: <input type="text" name="username" /><br />
              E-mail address: <input type="text" name="email" size="25" maxlength="100" /><br />
              Password: <input type="password" name="password" size="25" /><br />
              <input type="submit" name="submit" value="Submit" />
              </form>';
Gebruik aub hiervoor de variable , en een beetje code guidelines van het phpBB.com MOD team volgen hoor ;)

Hmm:

Code: Selecteer alles

// CMS config
$cmsConfig = new config;

define('IN_PHPBB',true);
   global $db, $cache, $config;
$phpbb_root_path = $cmsConfig->pad . 'forum/';
$phpEx = 'php';
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'includes/functions_display.php');
include_once($phpbb_root_path . 'includes/functions_user.php');   
vervangen met:

Code: Selecteer alles

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
  
global is er onnodig, kan je eens vertellen hoe de class eruit ziet van ; $cmsConfig ?