vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Add / Update New Users (https://vborg.vbsupport.ru/showthread.php?t=264967)

nainil 06-09-2011 09:17 PM

Add / Update New Users
 
I am porting users from our internal cms system to VBulletin.

The internal cms system uses md5 for passwords. So I am using the attached file to add new users using the attached file.

What I want is:

1. To modify this file in such a way that if the user exists in both the system, it should check the password in our cms and update it on vbulliten with the new password. Note our cms stores password in md5. Vbulliten will need to update this user to the md5 password.

2. To mark users inactive if they are inactive in our corporate cms.

What would be the queries for these 2 activities? Any help would be appreciated.


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('includes/init.php');
    require_once(
'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'2);
    
    
$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);
}

?>


kh99 06-11-2011 03:26 PM

I don't think there's any way to convert a password from your old cms system to a vb password. Maybe you could add code to vb for an alternate way to check passwords that matches your old cms and check both when the user enters a password.

Is there such a thing as an inactive user in vb? I suppose you could create a user group for inactive users, then set the usergroup field accordingly.


All times are GMT. The time now is 03:51 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.01196 seconds
  • Memory Usage 1,728KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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