vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Automatically register user (https://vborg.vbsupport.ru/showthread.php?t=316834)

WeBBy 01-22-2015 02:44 AM

Automatically register user
 
Can someone tell me where the adding new user script is located in vbb 5.x?

I had an automatic vbb registration in 3.8.x that I created long ago. Now that I am using vbb 5.x would like to integrate same. This is my original script (simple and sweet):
PHP Code:

define('VB_AREA''External'); 
define('SKIP_SESSIONCREATE'1); 
define('SKIP_USERINFO'1); 
define('CWD''/home/curecd/www/discussions'); 
require_once(
CWD '/core/includes/init.php');
$newuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY); 
$newuser->set('username'$userid); 
$newuser->set('email'$email); 
$newuser->set('password'$password); 
$newuser->set('usergroupid'2); 
$newuser->set('usertitle''<b>CDI Member</b>');
$newuser->set('ipaddress'$ip);
$newuser->set_bitfield('options''adminemail''1');
$newuser->set_bitfield('options''showemail''1');
$newuser->errors;  
$newuserid $newuser->save(); 

Unfortunately, it does not work with vbb 5 (returns
Fatal error: Class 'vB_Request_Web' not found in /home/curecd/public_html/discussions/core/includes/init.php on line 38
Fatal error: Class 'vB_Shutdown' not found in /home/curecd/public_html/discussions/core/vb/vb.php on line 454)

Does anyone have any advise on how to get this script modified for vbb 5.x and/or the location of the register commands in vbb 5.x so I can start from scratch :(

Any thoughts/advise would be greatly appreciated

Thanx

Dead Eddie 01-22-2015 03:12 AM

The registration action is in includes/vb5/frontend/controller/registration.php

It's the actionRegistration() method.

You'll want to use the API. core/vb/api/user.php

It's the save() method.

WeBBy 01-23-2015 02:10 PM

Thanx m8 - gives me something to figure out this weekend ;)

WeBBy 02-12-2015 02:53 AM

Hey Dead Eddie,

I have played with this a bit, but honestly I really do not have the time.
You seem far more familiar with the inner workings of Vb5 and could probably do this a whole lot easier and faster.
If interested in helping out here, send me a pm. I am not opposed to paying for your time and effort.

Dead Eddie 02-13-2015 03:19 PM

I might be able to come up with a working example, but I'm not 100% sure when I'll have time to work on it. And, the PHPdoc documentation for this method is just north of completely useless.

WeBBy 02-13-2015 04:15 PM

Vbb can be really difficult to work with since templates and stuff is not php parsed. I haven't even been able to locate the actual php script that is running the registeration,

I even tried to auto submit the form with hidden fields but IE gives you a json download request and FireFox/Chrome both display the json response both of which terminate the script.

Although I have not given up entirely, I am atm at a loss.
Again, willing to pay someone - it is less aggravating!!!

WeBBy 02-15-2015 10:54 PM

hey Dead Eddie, I was never able to directly input into the vb database in vb 3.x but seems to work just fine in vb 5.x. Could something really be easier in vb 5.x?????

I am on to getting an auto login now.

I can accomplish that, but can't seem to stop the redirect after login.

Any ideas on this would be helpful

WeBBy 03-14-2015 07:10 PM

By request:

The system we have is a full featured dynamic website in which vbb is only a small part. Membership in the main site is fee-based and it would be impractical to have 2 separate logins. So, on registration in the main site, all information gets logged into a database (temporary):

PHP Code:

$joindate $_SERVER['REQUEST_TIME'];
$ip $_SERVER['REMOTE_ADDR'];
$randomid time(); 
//add to database
$db mysql_connect("localhost""username""pass") or die ("Cannot connect to MySQL");
mysql_select_db("database",$db) or die ('Cannot Connect to Database');
$query "insert into temporary (fname, lname, address, address2, city, state, zip, country, email, phone, iam, other, userid, password, joindate, ip, randomid, active)
    values('
$_POST[fname]','$_POST[lname]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[country]','$_POST[email]','$_POST[phone]','$_POST[iam]','$_POST[other]','$_POST[nick]','$_POST[password]','$joindate','$ip', '$randomid','0')";
 
$result mysql_query($query,$db) or die("<b>A fatal MySQL error occured in the Member Database</b>.\n<br>Error: (" mysql_errno() . ") " mysql_error()); 

User is then redirected to Paypal with random id:

PHP Code:

<input type="hidden" name="return" value="http://www.xxx.com/xxx.php?randomid=<? echo $_POST[randomid]; ?>">
<input type="hidden" name="cancel_return" value="http://www.xxx.com/xxx.php??randomid=<? echo $_POST[randomid]; ?>">

From Paypal (assuming completed payment and randomid returned )...
We transfer data into permanent database:

PHP Code:

//Get data from temporary database
$db mysql_connect("localhost""user""pass") or die ("Cannot connect to MySQL");
mysql_select_db("dbname",$db);
$result mysql_query("SELECT * FROM temporary WHERE randomid = '$_GET[randomid]'",$db);
while (
$row mysql_fetch_array($result)) {
extract($row); 
    }

//tranfer from Temp to Member database
mysql_select_db("database",$db) or die ('Cannot Connect to Member Database');
$query "insert into members (fname, lname, address, address2, city, state, zip, country, email, phone, type, other, userid, password, joindate, ip, active)
    values('
$fname','$lname','$address1','$address2','$city','$state','$zip','$country','$email','$phone','$iam', '$other','$userid','$password','$joindate','$ip','1')";
$result mysql_query($query,$db) or die("<b>A fatal MySQL error occured in the Member Database</b>.\n<br>Error: (" mysql_errno() . ") " mysql_error()); 

and 
temporary database deleted:

$db mysql_connect("localhost""user""pass") or die ("Cannot connect to MySQL");
mysql_select_db("dbname",$db) or die ('Cannot Connect to vbb Database');
$result mysql_query("DELETE FROM temporary WHERE userid='$username'",$db) or die ("<b>A fatal MySQL error occured deleting data from the temporary database</b>.\nError: (" mysql_errno() . ") " mysql_error()); 

Based on the original password entered above, we generate a vb compatible password (that we will also use for main site):

PHP Code:

    //cleam some data and create some variables
    
$pass $password
    unset (
$password);
    
$username$userid;
    unset (
$userid);
    
$passworddate date(Y-m-d);

    
// Generate salt
    
function createSalt() {
    
$salt '';
    for (
$i 0$i 30$i++) {
    
$salt .= chr(rand(33126));
        }
    return 
$salt;
        }

    
//Generate password hash
    
function createPassword($password$salt) {
    return 
md5(md5($password) . $salt);
        }
    
//clean salt 
    
$salt=mysql_escape_string($salt);
    
$salt createSalt();
    
$password createPassword($pass$salt); 


We can then add the user to the vb user database:

PHP Code:

//Add to vbb database
$db mysql_connect("localhost""user""pass") or die ("Cannot connect to MySQL");
mysql_select_db("vbb",$db) or die ('Cannot Connect to vbb Database');
$query "insert into user (usergroupid, displaygroupid, username, password, passworddate, email, styleid, showvbcode, showbirthday, usertitle, customtitle, joindate, daysprune, reputation, reputationlevelid, pmpopup, avatarid, avatarrevision, profilepicrevision, sigpicrevision, options, notification_options, birthday_search, maxposts, ipaddress, referrerid, languageid, autosubscribe, pmtotal, pmunread, salt)
 values('12','0','
$username', '$password', '$passworddate', '$email', '0', '1', '2', 'CDI Member', '0', '$joindate', '0', '10', '5', '1', '0', '0', '0', '0', '45095252', '268435450', '0000-00-00', '-1', '$ip', '0', '1', '1', '0', '0', '$salt')"
$result mysql_query($query,$db) or die("<b>A fatal MySQL error occured in the VBB database</b>.\nError: (" mysql_errno() . ") " mysql_error()); 

And add some custom field data:

PHP Code:

    //Get vbb userid
    
mysql_select_db("vbb",$db);
    
$result mysql_query("SELECT * FROM user WHERE username = '$username'",$db);
    while (
$row mysql_fetch_array($result)) {
    
extract($row); 
            }
    
//Add Misc data to userfield
    
mysql_select_db("vbb",$db) or die ('Cannot Connect to vbb Database');
    
$query "insert into userfield (userid, field2, field4)
     values('
$userid', '$city$state', '$iam')"
    
$result mysql_query($query,$db) or die("<b>A fatal MySQL error occured in the VBB database</b>.\nError: (" mysql_errno() . ") " mysql_error());    

And 
any other information you may wish to add (like I add automatic subscriptionsect). 


I know that entereing data directly into the vbb database is strongly discouraged and that the code(s) above may not be the best or optimum, but auto-registration has long been sought in vbb and nobody has ever put one forth although I know they exist.

So, rather than critisize, maybe post the "proper" way to auto register AND autologin.


All times are GMT. The time now is 07:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01190 seconds
  • Memory Usage 1,799KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete