Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2015, 02:44 AM
WeBBy WeBBy is offline
 
Join Date: Jun 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 01-22-2015, 03:12 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 01-23-2015, 02:10 PM
WeBBy WeBBy is offline
 
Join Date: Jun 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanx m8 - gives me something to figure out this weekend
Reply With Quote
  #4  
Old 02-12-2015, 02:53 AM
WeBBy WeBBy is offline
 
Join Date: Jun 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 02-13-2015, 03:19 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 02-13-2015, 04:15 PM
WeBBy WeBBy is offline
 
Join Date: Jun 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!!!
Reply With Quote
  #7  
Old 02-15-2015, 10:54 PM
WeBBy WeBBy is offline
 
Join Date: Jun 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 03-14-2015, 07:10 PM
WeBBy WeBBy is offline
 
Join Date: Jun 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


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 04:10 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.04047 seconds
  • Memory Usage 2,300KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete