2012-06-11 2 views

답변

0

이렇게하면 기본 사용자를 설정할 수 있습니다.

define('IN_PHPBB', true); 
global $db; 
global $config; 
global $user; 
global $auth; 
global $cache; 
global $template; 

global $phpbb_root_path; 
global $phpEx; 

include('forums/common.php'); // THIS NEEDS TO BE CHANGED TO MATCH YOUR PHPBB3 INSTALL LOCATION; 
           // Currently, I am assuming you have this page at the root of your domain 
           // and PHPBB3 is install in the 'forums' subdirectory 

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

require($phpbb_root_path .'includes/functions_user.php'); 

$username = $_POST['user']; 
$password = $_POST['password'];  // Do not encrypt this password, it is handled later by an MD5 function and PHPBB3's own code 
$email = $_POST['email']; 

// You should add in a check to verify that the username is unique to your PHPBB3 install, otherwise you'll get errors 
// I left this as an exercise for you so that you can handle it how you want (reload the page, fail completely, offer suggestions, etc) 

$user_row = array(
    'username' => $username, 
    'user_password' => md5($password), 'user_email' => $email, 
    'group_id' => 2,     // This is the 'Registered Users' group. Change this as you feel is appropriate 
    'user_timezone' => '0.00',   // GMT 
    'user_dst' => 0,     // No Day Light Saving 
    'user_lang' => 'en', 
    'user_type' => '0',     // This means 'Normal User' 
    'user_actkey' => '', 
    'user_dateformat' => 'd M Y H:i', 
    'user_style' => 1, 
    'user_regdate' => time(), 
); 

$id = user_add($user_row);    // Returns the ID of the new user 

가정 :

  • 이 파일은 도메인의 루트에 있으며 포럼은 forums 하위 디렉토리에 있습니다. 그렇지 않은 경우 변경해야 할 내용을 표시하는 설명을 추가했습니다.
  • 중복 된 사용자 이름에 대해 오류 검사가 수행되지 않았습니다. 이것을 처리 할 방법이 있거나이 스크립트를 적절히 수정할 수 있다고 가정합니다.
+0

PHPBB3은 사용자 생성시'salt'를 사용합니다. 이것은 동일한 암호를 가진 사용자가 다른 해시 값을 가짐을 의미합니다. 위 코드에서 새 사용자와 '123456789'를 사용하여 포럼에 로그인 할 수 있습니까? – Andy