vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Add new Users (automatically) (https://vborg.vbsupport.ru/showthread.php?t=82836)

adbox 01-25-2011 02:59 PM

Looking for an updated version of this script for 4.1.1

Am getting this error:

Code:

Fatal error: Call to undefined function fetch_phrase() in /home2/hatnohat/public_html/forum/includes/functions.php on line 3456
--------------- Added [DATE]1295975525[/DATE] at [TIME]1295975525[/TIME] ---------------

This works for me.

add_user.php (custom API)

PHP Code:

<?php

function register_in_vb($username$password$email)
{
    
define('VB_AREA''External');
    
define('SKIP_SESSIONCREATE'0);
    
define('SKIP_USERINFO'1);
    
define('CWD''./../../forum/' );
    require_once(
CWD '/includes/init.php');
    require_once(
CWD '/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'$vbulletinERRTYPE_ARRAY);
    
$newuser->set('username'$username);
    
$newuser->set('email'$email);
    
$newuser->set('password'$password);
    
$newuser->set('usergroupid'9);
    
    
$newuser->pre_save();
    
    if(empty(
$newuser->errors)){
        
$db $backupdb;
        echo 
1;
        return 
$newuser->save();
        
    }else{
        
$db $backupdb;
        echo 
0;
        
print_r$newuser->errors);
    }
        
}

$key $_GET['key'];
$username $_GET['username'];
$password $_GET['password'];
$email $_GET['email'];

if (
$key=='mysecretkey')
{
    
// Add the users to vBulletin
    
$newuserid register_in_vb($username$password$email);
}

?>


Andreas 01-26-2011 05:21 PM

Quote:

Originally Posted by adbox (Post 2154368)
Looking for an updated version of this script for 4.1.1

Am getting this error:

Code:

Fatal error: Call to undefined function fetch_phrase() in /home2/hatnohat/public_html/forum/includes/functions.php on line 3456

This is caused by a Bug that should be fixed in one of the next releases.

In the meantime you can simply add
PHP Code:

define('VB_API'false); 

to your code.

nack 08-05-2011 01:19 PM

I used this code and everything was working fine. Users got added, but when they tried to login, they got this message:
Code:

You have been banned for the following reason:
 No reason was specified.

Date the ban will be lifted: Never

I looked in the banned list. They are not in there. What could have been wrong?

ingwa 09-07-2011 06:04 PM

Nack, make sure the user group that your user is being created under is being defined. If you aren't in the right group then they show as being banned. Hope this helps.

dog199200 12-03-2011 11:03 AM

I keep getting a fatal error:Fatal error:

Code:

Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 205
I slightly modified the code above:

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 please. :P

adbox 12-06-2011 02:50 PM

Maybe this resource is related?

https://vborg.vbsupport.ru/showthread.php?t=267099

dog199200 12-06-2011 05:19 PM

Quote:

Originally Posted by adbox (Post 2275189)

They seem to be, but it doesn't exactly answer the question. I noticed i only get the error because of my header which i need:

Code:

ob_start();
$curdir = getcwd ();
chdir('/home/shininga/public_html/divineshadowsonline/forum/');
require_once('./global.php'); 

$phrasegroups = array();
$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);


chdir ($curdir);

I have that added to the top of every single page because i've build my own api system for my main website around it.

adbox 12-06-2011 05:28 PM

What if you change your header to this:

Code:


require_once('/home/shininga/public_html/divineshadowsonline/forum/'); 

$phrasegroups = array();
$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);

I'm not certain the change directory commands are necessary.

dog199200 12-06-2011 05:34 PM

Doesn't work. I had to change the directory before because I had to call a lot of the internal features within vB. I'm pulling user information and login checks of all types all over the site. If i just include the global instead of redefining the directory I get this error:

Code:

Warning: require_once(./includes/class_bootstrap.php) [function.require-once]: failed to open stream: No such file or directory in /home/shininga/public_html/divineshadowsonline/forum/global.php on line 15

Fatal error: require_once() [function.require]: Failed opening required './includes/class_bootstrap.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/shininga/public_html/divineshadowsonline/forum/global.php on line 15

Edit: Basically without the header being as how i had it, my whole site would break.

dilios 08-25-2014 06:47 PM

Vbulletin 4.x user registration version:
Code:

define('THIS_SCRIPT', 'reguser.php');
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');
 
$userdm = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);
$pass1 = $_REQUEST["pw1"];
$pass2 = $_REQUEST["pw2"];
if ($pass1 == $pass2)
        $passwd = $pass1;
else
        exit;
$userdm->set('username', $_REQUEST["user"]);
$userdm->set('email', $_REQUEST["email"]);
$userdm->set('password', $passwd);
$userdm->set('usergroupid',2);
 
#If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
if (count($userdm->errors))
{
        echo "<pre>";
        var_dump($userdm->errors);
        echo "</pre>";
} else {
        # If everything is OK
        $newuserid = $userdm->save();
        echo $newuserid."<br>Done.";
}



All times are GMT. The time now is 06:53 AM.

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.02508 seconds
  • Memory Usage 1,785KB
  • 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
  • (9)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete