Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
Add new Users (automatically)
Andreas's Avatar
Andreas
Join Date: Jan 2004
Posts: 6,863

 

Germany
Show Printable Version Email this Page Subscription
Andreas Andreas is offline 06-09-2005, 10:00 PM

As this is a common request for integration purposes, I thought I should write up another HowTo

If you want to add a new user to the vBulletin database, you can use Class vB_Datamanager_User.
This Calss does make sure that everything is OK, it will also take care of the default registration options.

Example
PHP Code:
$newuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
$newuser->set('username''phpNukeUser');
$newuser->set('email''foo@bar.com');
$newuser->set('password''verysecret');
$newuser->set('usergroupid'2); 
If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
PHP Code:
$newuser->errors 
This is an array containing the errors.

If everything is OK
PHP Code:
$newuserid $newuser->save(); 
This will create a new User called phpNukeNuser (UserID returned in $newuserid).

You can also set many other info too:
  • membergroupids = comma-separated string of all additional usergroups (Default=Empty)
  • displaygroupid = ID of the usergroup this user should show up as (Default=0)
    Note that this must be set after usergroupid and membergroupids!
  • styleid = ID of the Style to be used by this user (Default=Board Default)
  • languageid = ID of the language to be used by this user (Default=Board Default)
  • threadedmode = Whether to use Flat (0), Hybrid (1) or Threaded (2) Display Mode
  • maxposts = Integer, how many posts should be shown on one Page (Default=Board Default)
  • ipaddress = String, IP-Adress of the User registering (Default=Empty)
  • refererid = String, Username or UserID of the User this user was refered by
  • parentemail = String. eMail-Address of the users Parents
  • daysprune = Integer, show threads from the last X days
  • startofweek = Integer, When does the week start (1=Sunday, 2=;onday, ...) (Default=Board Default)
  • timezoneoffset = Integer, spexifying the Timezone (-12 .. +12)
  • autosubscribe = Integer, defining default mode for Thread subscription
    -1 = no Subscription, 1 = Instant, 2 = Daily Digest, 3 = Weekly Digest
    (Default=Board Default)
  • homepage = String, URL of the users Homepage (Default=Empty)
  • icq = String, the Users ICQ # (Default=Empty)
  • aim = String, the Users AIM ID (Default=Empty)
  • yahoo = String, the Users Yahoo ID (Default=Empty)
  • MSN = String, the Users MSN ID (Default=Empty)
  • usertitle = String, the Usertitle this user should have
  • customtitle = Integer, defining behaviour of Usertitle. 0=No Custom Title, 1=Custom, Title with HTML, 2=Custom Title without HTML (Default=
  • birthday = array(month, day, year). The users birthdate.
  • avatarid = Integer, ID of the Avatar being used for this user
  • signature = String. The Users Signature
  • subfolders = Array. The Users Subscription Folders
  • pmfolders = Array. The Users Subscription Folders
  • buddylist = String. Space separated List of UserIDs defining the Users buddylist
  • ignorelist = String. Space separated List of UserIDs defining the Users ignorelist

Besides that, you can also set the options Bitfield (Receive Admin PMs, etc.)
PHP Code:
$userdata->set_bitfield('options''optionname''value'); 
The available Options are
  • showsignatures = Show Signatures
  • showavatars = Show Avatars
  • showimages = Show Images, incl. attached Images and [img] BBCode
    If this is not set they will show up as links
  • coppauser = User is COPPA User
  • adminemail = Receive Admin eMails
  • showvcard = Allow vCard Download
  • dstauto = Automatically detect DST setting
  • dstonoff = DST turned On
  • showemail = Receive eMails from other Users
  • invisible = Be invisible
  • showreputation = Show Reputation
  • receivepm = PM turned on
  • emailonpm = eMail notification for new PMs

Value must be 0 or 1 (false or true), depending if you want to set the option or not.
If the Options are not set, the Default Registration Options/Board Default Options will be used.

Important Notice
It is assumed that you are using this code from 'within' vBulletin, eg with the vBulletin backend loaded.
If this is not the case, you must include smth. like the following code in global context:
PHP Code:
define('VB_AREA''External');
define('SKIP_SESSIONCREATE'1);
define('SKIP_USERINFO'1);
define('CWD''/path/to/vbulletin');
require_once(
CWD '/includes/init.php'); 
Keep in mind that if you are using the a/m Datamanager-Code within a function or method you must global $vbulletin.

This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent.
Reply With Quote
  #102  
Old 06-14-2008, 01:15 AM
nautiboy nautiboy is offline
 
Join Date: Jun 2008
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know this question was asked earlier, but it was never answered.

Is there any way to handle the case where the password you have is an md5 hash? I don't like sending passwords in the clear, so my login pages do the md5 hash before sending up to the server, so I don't have access to the actual password.

Any ideas?

--------------- Added [DATE]1213414760[/DATE] at [TIME]1213414760[/TIME] ---------------

OK, I've managed to answer my own question. It turns out that you can use md5's also. If you pass in a plain-text, it will md5 it. But if you pass in an md5, it will use it as-is (basically it just checks to see if the password is 32 characters long - if it is, it assumes it's an md5).

So it "just works". Cool! :up:
Reply With Quote
  #103  
Old 06-26-2008, 07:23 AM
scoutz scoutz is offline
 
Join Date: Feb 2007
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know if this has been covered yet but if you would like to show the username and userid in your activation mail you just have to set $username and $userid to the appropriate values.
Reply With Quote
  #104  
Old 07-08-2008, 03:59 AM
ram94401 ram94401 is offline
 
Join Date: Dec 2007
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bradsears View Post
Hi. I'd like to be able to send the registration email after the user registers. How do I do this. Thanks in advance.

-- edit --

I answered this one myself

$activateid = build_user_activation_id($newuserid, 2, 0);
eval(fetch_email_phrases('activateaccount'));
vbmail($email, $subject, $message, true);

Thanks. But, when you do $userdm->save, won't the user is automatically activated? I assume that you used the code in https://vborg.vbsupport.ru/showpost....&postcount=31;

--------------- Added [DATE]1215493772[/DATE] at [TIME]1215493772[/TIME] ---------------

All right. This entire integration thing works partially for me. After getting frustrated, I wrote the program to get the user data from the form and update the Vbulletin tables directly.

Here is the logical flow:

1. I updated user and useractivation tables with the user information. I set the usergroupid as "3" (users waiting for email activation group) in user table and added the row for the new user in useractivation table. This row will be deleted when the user activates the account.

2. I sent the activation email to the user. This is a nice thing, because I can customize the email format. If a user registers in the main site and the forum sends the activation email, it looks kind of weird. Because some users of our CMS site don't even know what is a forum.

3. User clicks the link in the activation email. Program checks the activation id in the useractivation table. If everything is ok, the usergroupid is changed from 3 to 2 in usertable. Activation record in useractivation table is deleted, because it's no longer needed.

Ok. All works well. The user can do anything he wants just as he would normally do when he registers using forums/register.php.

But..(you know it's coming!) there is a headache for the admin. In the admin control panel, username, email, IP, and all those fields are EMPTY for this user. Options like receive admin email, PM options, etc., are all set ok. Only the username, email, IP fields are empty.

Do I need to update another table? Doesn't admin control panel use the user table to display the user profile?
Reply With Quote
  #105  
Old 07-10-2008, 06:38 PM
ArbuZz ArbuZz is offline
 
Join Date: Jun 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Personally I got very odd:"Existing data passed is not an array" while using amatulic's class and when doing:

Quote:
$userdata['username'] = $_POST['username'];
$userdata['password'] = $_POST['password'];
$userdata['email'] = $_POST['email'];
$forum->register_newuser($userdata));
What maybe the problem? Anyone?

--------------- Added [DATE]1215718968[/DATE] at [TIME]1215718968[/TIME] ---------------

Quote:
Called set_existing in ..class.forumops.php on line 296
Called login in ..class.forumops.php on line 153
I guess this has something with vBulletin's way to manage database connections

--------------- Added [DATE]1215719381[/DATE] at [TIME]1215719381[/TIME] ---------------

This doesn't help:

Quote:
$cwd = getcwd();
chdir('.../forum');
require_once('global.php');
chdir($cwd);
--------------- Added [DATE]1215760256[/DATE] at [TIME]1215760256[/TIME] ---------------

ok. for some unknown reason in the userdata_convert function exist the following line:
Quote:
$vbuser = array( 'username' => $userdata['userid'] );
but why?! I guess it has to be:

Quote:
$vbuser = array( 'username' => $userdata['username'] );
I've moved amatulic's class in the different place, stored variables in $_SESSION and called header redirect to it. So that now it has totally separated namespace. However I'm not sure if this is secure thing to do.

As I've figured out, there is some problem with login part, cause as soon as I turned it off, I was able to register user in vBulletin. At least it has showed up in the database.

--------------- Added [DATE]1215760677[/DATE] at [TIME]1215760677[/TIME] ---------------

It is "function fetch_userinfo_from_username" that does the trouble. It is not able to retrieve the information from database with its:

Quote:
...
global $vbulletin;
$useridq = $vbulletin->db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username='{$username}'");
...
Any ideas how to correct this?

--------------- Added [DATE]1215769463[/DATE] at [TIME]1215769463[/TIME] ---------------

ok. for some reason $login variable is set to true in register_newuser so that it tries to login user by default as soon as he/she is registered. However it seems that user is not inserted in database yet, when the function tries to login him/her. I don't know why, but that's what happens. So I've turned $login to false, like this:

Quote:
function register_newuser(&$userdata, $login = false)
Also I rewrote db connection, but I think It worked without it. Now everything works. Thank you amatulic. I've lost two days figuring out the faults, but thanks god it works and that's the best news Here is my working version if anyone's interested:

PHP Code:
<?php
//==============================================================
// class ForumOps - intended to be used with vBulletin 3.7.2
// by Alex Matulich, June 2008, Unicorn Research Corporation
//
// Setup:
// ------
//
// 1. First, make sure FORUMPATH is defined properly below.
//
// 2. Next, make sure the function userdata_convert correctly converts
// an array of your own user data to an array of vBulletin user data.
// Minimally, you need to convert your data to an array containing
// the keys 'username', 'password', and 'email'.  If your data array
// already contains these keys, simply have userdata_convert return
// the original array, otherwise translate your array to a vBulletin
// array having those keys.
//
// Usage:
// ------
//
// At the top of your php modules where you need to perform vBulletin
// user operations (creation, deletion, updating, login, and logout),
// put these two lines (where MY_PATH is the path to this file):
//
//     require_once(MY_PATH.'/class.forumops.php');
//     $forum = new ForumOps();
//
// Now get your user data array from $_POST or whatever.  Let's call
// this array $userdata.  Here's what you can do:
//
// CREATE AND REGISTER NEW USER:
//
//    $errmsg = $forum->register_newuser($userdata);
//
// UPDATE EXISTING USER DATA:
//
//    $errmsg = $forum->update_user($userdata);
//
// (In this case, $userdata need contain only the username and anything
// else you wish to update, such as password and/or email address.)
//
// $errmsg contains any error messages separated by <br> codes.
// If no errors occured then NULL is returned.
//
// DELETE USER:
//
//    $forum->delete_user($username); // $username = user name
//
// LOGIN USER TO THE FORUM:
//
//    $forum->login(  // requires array to be passed
//       array('username' => $username, 'password' => $pw);
//
// LOG OFF USER FROM THE FORUM:
//
//    $forum->logout();
//
// WARNING: It is common for you to have TABLE_PREFIX defined for
// your own database.  You must call it something else (for example,
// remove the underscore) or it will conflict with the vBulletin
// definition of the same name.
//===============================================================

//===============================================================
// Change this definition and the userdata_convert() function
// to suit your needs:

define('FORUMPATH'$_SERVER['DOCUMENT_ROOT'].'/forum'); // path to your forum

function userdata_convert(&$userdata// internal function
{
   
// $userdata is our array that contains user data from our own
   // user database, which we must convert to the vBulletin values.
   // Minimally, it must contain the username, email and/or password.

   // required fields
   
$vbuser = array( 'username' => $userdata['username'] );
   if (isset(
$userdata['email']))
      
$vbuser['email'] = $userdata['email'];
   if (isset(
$userdata['password']))
      
$vbuser['password'] = $userdata['password'];

   
// extra stuff, expand as desired
   
if ($userdata['birthdate'])
      
$vbuser['birthday_search'] = date('Y-m-d'$userdata['birthdate']);
   return 
$vbuser;
}
// end of configuration stuff
//===============================================================

define('REGISTERED_USERGROUP'2); // typical default for registered users
define('PERMANENT_COOKIE'false); // false=session cookies (recommended)

define('THIS_SCRIPT'__FILE__);
$cwd getcwd();
chdir(FORUMPATH);
require_once(
'./global.php');
require_once(
'./includes/init.php'); // includes class_core.php
require_once('./includes/class_dm.php'); // for class_dm_user.php
require_once('./includes/class_dm_user.php'); // for user functions
require_once('./includes/functions.php'); // vbsetcookie etc.
require_once('./includes/functions_login.php'); // process login/logout


//---------------------------------------------------------------------
// This function duplicates the functionality of fetch_userinfo(),
// using the user name instead of numeric ID as the argument.
// See comments in includes/functions.php for documentation.
//---------------------------------------------------------------------
function fetch_userinfo_from_username($username$option=0$languageid=0)
{
   global 
$vbulletin$db;
   
$result $db->query("SELECT * FROM "
      
TABLE_PREFIX "user WHERE username = '".$username."'");
    
$useridq $db->fetch_array($result);  
   if (!
$useridq) return $useridq;
   
$userid $useridq['userid'];
   return 
fetch_userinfo($userid$option$languageid);
}


//---------------------------------------------------------------------
// CLASS ForumOps
//---------------------------------------------------------------------
class ForumOps extends vB_DataManager_User {
   var 
$userdm;

   function 
ForumOps() // constructor
   
{
      global 
$vbulletin;
      
$this->userdm =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
   }


   
//======== USER REGISTRATION / UPDATE / DELETE ========

   
function register_newuser(&$userdata$login false)
   {
      global 
$vbulletin;
      
$vbuser userdata_convert($userdata);
      foreach(
$vbuser as $key => $value)
         
$this->userdm->set($key$value);
      
$this->userdm->set('usergroupid'REGISTERED_USERGROUP);

      
// Bitfields; set to desired defaults.
      // Comment out those you have set as defaults
      // in the vBuleltin admin control panel
      
$this->userdm->set_bitfield('options''adminemail'1);
      
$this->userdm->set_bitfield('options''showsignatures'1);
      
$this->userdm->set_bitfield('options''showavatars'1);
      
$this->userdm->set_bitfield('options''showimages'1);
      
$this->userdm->set_bitfield('options''showemail'0);

      if (
$login$this->login($vbuser);

      
//$this->userdm->errors contains error messages
      
if (empty($this->userdm->errors))
         
$vbulletin->userinfo['userid'] = $this->userdm->save();
      else
         return 
implode('<br>'$this->userdm->errors);
      return 
NULL;
   }


   function 
update_user(&$userdata)
   {
      global 
$vbulletin;
      
$vbuser userdata_convert($userdata);
      if (!(
$existing_user fetch_userinfo_from_username($vbuser['username'])))
         return 
'fetch_userinfo_from_username() failed.';

      
$this->userdm->set_existing($existing_user);
      foreach(
$vbuser as $key => $value)
         
$this->userdm->set($key$value);

      
// reset password cookie in case password changed
      
if (isset($vbuser['password']))
         
vbsetcookie('password',
            
md5($vbulletin->userinfo['password'].COOKIE_SALT),
            
PERMANENT_COOKIEtruetrue);

      if (
count($this->userdm->errors))
         return 
implode('<br>'$this->userdm->errors);
      
$vbulletin->userinfo['userid'] = $this->userdm->save();
      return 
NULL;
   }


   function 
delete_user(&$username)
   {
   
// The vBulletin documentation suggests using userdm->delete()
   // to delete a user, but upon examining the code, this doesn't
   // delete everything associated with the user.  The following
   // is adapted from admincp/user.php instead.
   // NOTE: THIS MAY REQUIRE MAINTENANCE WITH NEW VBULLETIN UPDATES.

      
global $vbulletin;
      
$db = &$vbulletin->db;
      
$userdata $db->query_first_slave("SELECT userid FROM "
         
TABLE_PREFIX "user WHERE username='{$username}'");
      
$userid $userdata['userid'];
      if (
$userid) {

      
// from admincp/user.php 'do prune users (step 1)'

         // delete subscribed forums
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"subscribeforum WHERE userid={$userid}");
         
// delete subscribed threads
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"subscribethread WHERE userid={$userid}");
         
// delete events
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"event WHERE userid={$userid}");
         
// delete event reminders
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"subscribeevent WHERE userid={$userid}");
         
// delete custom avatars
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"customavatar WHERE userid={$userid}");
         
$customavatars $db->query_read("SELECT userid, avatarrevision FROM "
          
TABLE_PREFIX "user WHERE userid={$userid}");
         while (
$customavatar $db->fetch_array($customavatars)) {
            @
unlink($vbulletin->options['avatarpath'] . "/avatar{$customavatar['userid']}_{$customavatar['avatarrevision']}.gif");
         }
         
// delete custom profile pics
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"customprofilepic WHERE userid={$userid}");
         
$customprofilepics $db->query_read(
            
"SELECT userid, profilepicrevision FROM "
            
TABLE_PREFIX "user WHERE userid={$userid}");
         while (
$customprofilepic $db->fetch_array($customprofilepics)) {
            @
unlink($vbulletin->options['profilepicpath'] . "/profilepic$customprofilepic[userid]_$customprofilepic[profilepicrevision].gif");
         }
         
// delete user forum access
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"access WHERE userid={$userid}");
         
// delete moderator
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"moderator WHERE userid={$userid}");
         
// delete private messages
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"pm WHERE userid={$userid}");
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"pmreceipt WHERE userid={$userid}");
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"session WHERE userid={$userid}");
         
// delete user group join requests
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"usergrouprequest WHERE userid={$userid}");
         
// delete bans
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"userban WHERE userid={$userid}");
         
// delete user notes
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"usernote WHERE userid={$userid}");

      
// from admincp/users.php 'do prune users (step 2)'

         // update deleted user's posts with userid=0
         
$db->query_write("UPDATE " TABLE_PREFIX
            
"thread SET postuserid = 0, postusername = '"
            
$db->escape_string($username)
            . 
"' WHERE postuserid = $userid");
         
$db->query_write("UPDATE " TABLE_PREFIX
            
"post SET userid = 0, username = '"
            
$db->escape_string($username)
            . 
"' WHERE userid = $userid");

         
// finally, delete the user
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"usertextfield WHERE userid={$userid}");
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"userfield WHERE userid={$userid}");
         
$db->query_write("DELETE FROM " TABLE_PREFIX
            
"user WHERE userid={$userid}");
      }
   
/*
      the following is suggested in the documentation but doesn't work:

      $existing_user = fetch_userinfo_from_username($username);
      $this->userdm->set_existing($existing_user);
      return $this->userdm->delete();
   */
   
}


   
// ======== USER LOGIN / LOGOUT ========

   
function login($vbuser)
   {
      global 
$vbulletin;
      
$vbulletin->userinfo fetch_userinfo_from_username($vbuser['username']);
      
      
// update password expire time to
      // to prevent vBulletin from expiring the password
           
      
$this->userdm->set_existing($vbulletin->userinfo);
      
$this->userdm->set('passworddate''FROM_UNIXTIME('.TIMENOW.')'false);
      
$this->userdm->save();

      
// set cookies
      
vbsetcookie('userid'$vbulletin->userinfo['userid'],
         
PERMANENT_COOKIEtruetrue);
      
vbsetcookie('password',
         
md5($vbulletin->userinfo['password'].COOKIE_SALT),
         
PERMANENT_COOKIEtruetrue);

      
// create session stuff
      
process_new_login(''1'');
   }


   function 
logout()
   {
      
process_logout(); // unsets all cookies and session data
   
}

// end class ForumOps
chdir($cwd);
?>
One additional note. I don't use update and delete functions of this class, so I didn't test them. Have that in mind when using.
Reply With Quote
  #106  
Old 07-13-2008, 12:22 AM
Jonaid Jonaid is offline
 
Join Date: Sep 2003
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there any chance that this'll work, cross site? I'd added a forum on a different server to my main site and I wanted to sync the signups so when someone signs up on my main site it signs them up on the forum.

Any advice??

Regards,

Jonaid
Reply With Quote
  #107  
Old 07-14-2008, 09:55 AM
ArbuZz ArbuZz is offline
 
Join Date: Jun 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use cURL php extension, however I do not know whether it is active by default. With cURL you can call any remote php script and pass parameters to it through the ordinary POST, just like you do it from HTML form.
Reply With Quote
  #108  
Old 07-20-2008, 05:11 PM
Peter Bowen Peter Bowen is offline
 
Join Date: Jul 2008
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

I'm using amatulic's code in an attempt to create a new user but I keep on getting this error even when using the example test code for making a new user. Any ideas?

Fatal error: Existing data passed is not an array
Called set_existing in /var/www/vhosts/carrington-club-international.co.uk/httpdocs/include/class.forumops.php on line 296
Called login in /var/www/vhosts/carrington-club-international.co.uk/httpdocs/include/class.forumops.php on line 153
Called register_newuser in /var/www/vhosts/carrington-club-international.co.uk/httpdocs/testforumreg.php on line 14
in [path]/includes/class_dm.php on line 235

Thanks

Pete
Reply With Quote
  #109  
Old 09-18-2008, 11:50 AM
Selter Selter is offline
 
Join Date: Sep 2008
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi threre,

I've got some trouble running the PHP code from the first post. To be honest - I'm not so familiar with PHP

It would be great if anybody could have a look into this ...
(I already posted this issue in the german board http://www.vbulletin-germany.com/for...ad.php?t=38534 and was advised to ask the author of the code )

Below you'll find the (entire) code which I use in a PHP file (called createuser.php).

I started the code by entering http://www.xyz.de/_forum/createuser.php in the URL-field of my browser.


Code:
 

<?php
define('VB_AREA', 'External'); 
define('SKIP_SESSIONCREATE', 1); 
define('SKIP_USERINFO', 1); 
define('CWD', '.'); 
require_once(CWD . '/includes/init.php'); 

$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY); 
$newuser->set('username', 'selter'); 
$newuser->set('email', 'selter@xyz.de'); 
$newuser->set('password', 'geheim'); 
$newuser->set('usergroupid', 2);  
$newuserid = $newuser->save();  

?>

Unfortunately I got this error message:

Quote:

Fatal error: vb_error_handler() [function.require]: Failed opening required 'DIR/includes/functions_log_error.php' (include_path='.:/usr/lib/php') in /xxxxxxx/htdocs/_forum/includes/class_core.php on line 3247

Where is the bug???

Thanks
Selter
Reply With Quote
  #110  
Old 10-13-2008, 06:52 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Selter View Post
Where is the bug???
init.php
PHP Code:
if (CWD == '.')
{
    
// getcwd() failed and so we need to be told the full forum path in config.php
    
if (!empty($vbulletin->config['Misc']['forumpath']))
    {
        
define('DIR'$vbulletin->config['Misc']['forumpath']);
    }
    else
    {
        
trigger_error('<strong>Konfigurationsfehler</strong>: Sie muessen in der Datei config.php bei <strong>forumpath</strong> einen Eintrag vornehmen.'E_USER_ERROR);
    }
}
else
{
    
define('DIR'CWD);

=> Set CWD properly, eg. full path
Reply With Quote
  #111  
Old 10-28-2008, 10:38 AM
mariusvr mariusvr is offline
 
Join Date: May 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
--------------- Added 11 Jul 2008 at 16:17 ---------------

It is "function fetch_userinfo_from_username" that does the trouble. It is not able to retrieve the information from database with its:

...
global $vbulletin;
$useridq = $vbulletin->db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username='{$username}'");
...

Any ideas how to correct this?
I am having the same error coming up when using the following code. The db object seems to empty when updating the user stats. The strange thing is that the user was created succesfully, before vbulletin crashes with this error:

Code:
Fatal error: Call to a member function query_first() on a non-object in /home/jfusiono/public_html/demo/vbulletin/includes/functions_databuild.php on line 1684
I am using the following code:

Code:
//load the vbulletin framework
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
define('CWD', $params->get('source_path'));
global $vbulletin;
require_once(CWD . '/includes/init.php');

//setup the new user
$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$newuser->set('username', $userinfo->username);
$newuser->set('email', $userinfo->email);
$newuser->set('password', $userinfo->password_clear);
$newuser->set('usergroupid', $usergroup);
$newuser->set('password', $userinfo->password_clear);
$newuserid = $newuser->save();

This is the final hurdle before releasing a Beta version of JFusion, a revolutionary Joomla universal bridge. Any help would be greatly appreciated.

Thanks, Marius
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:12 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10275 seconds
  • Memory Usage 2,465KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (7)bbcode_php
  • (11)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete