Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2011, 12:28 PM
dog199200's Avatar
dog199200 dog199200 is offline
 
Join Date: Sep 2010
Location: Missouri
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default External Registration

Article URL: https://vborg.vbsupport.ru/showthrea...reate+New+User
Forum URL: http://www.forum.divineshadowsonline.com/
Forum Version: 4.1.8

I found this article a few days ago as I was looking for a way to use vB's internal registration system from an external page, but I keep getting a fatal error:

Code:
Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 205
Here's a slightly modified version of the code I found on the last page of the article:

Main Code
Code:
<?php 
mysql_connect($DBhost, $DBuser, $DBpass) or die(mysql_error()); 
mysql_select_db($DBname) or die(mysql_error()); 

$RegAllowArray = mysql_query("SELECT * FROM setting WHERE varname = 'allowregistration'") or die(mysql_error()); 
$RegAllow = mysql_fetch_array($RegAllowArray);

$CountUserArray = mysql_query("SELECT COUNT(*) FROM user") or die(mysql_error()); 
$CountUser = mysql_num_rows($CountUserArray); 

if($CountUser < 50)
{
	if($RegAllow['value'] != 0)
	{
		function register_in_vb($username, $password, $email, $day, $month, $year)
		{
			define('VB_AREA', 'External');
			define('SKIP_SESSIONCREATE', 0);
			define('SKIP_USERINFO', 1);
			require_once('/home/shininga/public_html/divineshadowsonline/forum/includes/init.php');
			require_once('/home/shininga/public_html/divineshadowsonline/forum/includes/functions_misc.php');

			$registry = $vbulletin; 
			unset($vbulletin); 
			$vbDb = $registry->db; 
			//declare as global vbulletin's registry and db objects 
			global $vbulletin,$db; 
			$vbulletin = $registry; 
			//backup the original $db object (new!!) 
			$backupdb = $db; 
			$db = $vbDb; 

			$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
			$newuser->set('username', $username);
			$newuser->set('email', $email);
			$newuser->set('password', $password);
			$newuser->set('usergroupid', 2);
			$newuser->set('displaygroupid', 2);
			$newuser->set('birthday', array($month, $day, $year));
			
			$newuser->pre_save();
			
			if(empty($newuser->errors)){
				$db = $backupdb;
				echo 1;	
				return $newuser->save();
				
			}else{
				$db = $backupdb;
				echo 0;
				print_r( $newuser->errors);
				include("/home/shininga/public_html/divineshadowsonline/includes/register-form.php");
			}
		}
			
		if(!$logged_in) {
			if(isset($_POST['username'])) 
			{
				$key = $_POST['key'];
				$username = $_POST['username'];
				$password = $_POST['password'];
				$confirmpass = $_POST['confirmpass'];
				$day = $_POST['day'];
				$month = $_POST['month'];
				$year = $_POST['year'];
				$email = $_POST['email'];
				$tos = $_POST['tos'];
				include("/home/shininga/public_html/divineshadowsonline/includes/register-functions.php");
				$newuserid = register_in_vb($username, $password, $email, $day, $month, $year);
				
			} else if(!isset($_POST['username'])) {
				include("/home/shininga/public_html/divineshadowsonline/includes/register-form.php");
			}
		} else {
			echo "<h4><center><b>You are already logged in!</b></center></h4>";
		}
	} else {
		echo "<center>Registration Are Currently Disabled</center>";
	}
} else {
	echo "<center>Registration Are Currently Disabled</center>";
}
mysql_close();
?>
I could really use some help figuring out why i'm getting the error please. :P

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

Can anyone help me please? I really would rather use the internal systems to add users to the database so that everything runs through the error handle and stuff. It would be a royal pain in the but to rebuild every single one of the error handles in order to check if the information is valid.
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 05:32 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.03303 seconds
  • Memory Usage 2,204KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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