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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2008, 12:45 PM
jstep jstep is offline
 
Join Date: Jan 2006
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 1 problem using alternative Registration

I have a site and a forum, I would like to allow users to register at the site, and be automatically registered for the forum

As a matter of simplicity I would like to keep the databases seperate (they are both fairly large)

Right now here is my sql statement to register a new user

PHP Code:
// date for entry
                    
$date=date('y m d');
                    
// IP ADRESS
                    #
                    
$userIP $_SERVER['HTTP_X_FORWARDED_FOR'];
                    if(
$userIP == "")
                    {
                        
$userIP $_SERVER['REMOTE_ADDR'];
                    }
                    
// Get a salt
                    
$salt substr(md5(rand().rand()), 03);
                    
// work with password 2 here
                    
$password2md5(md5($password2).$salt);
                    
                    
$addvbmysql_query("INSERT INTO `civclash_user` (`usergroupid`,`username`,`passworddate`,`password`, `email`, `ipaddress`, `salt`, `showvbcode`) VALUES ('2','$username', '$date', '$password2', '$email', '$userIP', '$salt', '1')");
                    if (
$addvb){
                        echo 
"<br /> You were also added to the forum, see www.civclash.com/forums/index.php";
                    }  else {
                        echo 
"You could not be added to the forum. Contact the administration.";
                    } 
So essentially I am just making my registration form work for two different databases

Unfortunately (for some strange reason) when I add the new user, all their posts are listed as guest(it says their name, but lists them as guest, on the member list I can visit their profile and it shows them as a member). I can only think that it is because I forgot to add something to that query?

Sorry, I am decent at php, but by no means an expert

Any Help is greatly appreciated.

Thanks
Jstep
Reply With Quote
  #2  
Old 06-29-2008, 12:53 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is more to just adding a row in the user table in registering a user in vBulletin. Use the datamanager, it will handle everything for you (once you feed it data).
Reply With Quote
  #3  
Old 06-29-2008, 01:09 PM
jstep jstep is offline
 
Join Date: Jan 2006
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there anywhere I can find a description of the datamanager?

and where is it in the code?

thanks for your help

edit: I reckon this should do it? https://vborg.vbsupport.ru/showthrea...ht=datamanager
Reply With Quote
  #4  
Old 06-29-2008, 01:51 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://www.vbulletin.com/docs/html/data_managers" target="_blank">Data Managers</a>
Reply With Quote
  #5  
Old 06-29-2008, 03:54 PM
jstep jstep is offline
 
Join Date: Jan 2006
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<style type="text/css" media="all">
@import "style.css";
</style>
</head>

<body>

<?php include("header.php"); ?>

<div id="Header"><a href="./index.php" title="CivClash">CivClash</a></div>

<div id="Content">
<center><?
if ($gMode=="1"){
    echo "<center>";
    //checks if there trying to veriy there account
    if(isset($_GET['verify'])) {
        //gets the code and makes it safe
        $code = addslashes($_GET['code']);
        //gets the code from the database
        $getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
        //counts the number of rows
        $getcode = mysql_num_rows($getcode);
        //if the ammount of rows is 0 the code does not exist
        if($getcode == 0) {
            echo "Invalid verification code!";
        }
        //or if the code does exist we will activiate there account
        else{
            //get the data from the database
            $getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
            //fetchs the data from the db
            $dat = mysql_fetch_array($getcode);
            //sets the users user level to 2 which means they can now use there account
            $update = mysql_query("UPDATE `members` SET `userlevel` = '2' WHERE `username` = '".$dat['username']."'") or die(mysql_error());
            //deletes the code as there is no use of it now
            $delete = mysql_query("DELETE FROM `verification` WHERE code = '$code'");
            //says thanks and your account is ready for use
            echo "Thank you, Your account has been verified.";
        }
    }else
    //if we have posted the register for we will register this user
    if(isset($_GET['register'])) {
        //check to see if any fields were left blank
        if((!$_POST[username]) || (!$_POST[password]) || (!$_POST[cpassword]) || (!$_POST[email])) {
            echo "A field was left blank please go back and try again.";
        }else{
            //posts all the data from the register form
            $username = $_POST[username];
            $password = $_POST[password];
            $cpassword = $_POST[cpassword];
            $email = $_POST[email];
            //check see if the 2 passwords are the same
            if($password == $cpassword)
            {
                // Save as alternative to be used with vbulletin
                $password2= $password;
                //encrypts the password 8 times
                $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($password))))))));
                $cname = mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username'");
                $cname= mysql_num_rows($cname);
                //checks to see if the username or email already exist
                if($cname>=1) {
                    echo "The username is already in use";
                }else{

                    // Add the user to Vbulletin
                    define('THIS_SCRIPT', '../forumadd.php');
                    chdir('forums/');
                    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);

                    $userdm->set('username', $username);
                    $userdm->set('email', $email);
                    $userdm->set('password', $password);
                    $userdm->set('usergroupid',$usergroupid);
                    $userdm->set('ipaddress', $ipaddress);
                    $userdm->set('timezoneoffset', $timezoneoffset);
                    $userdm->set_bitfield('options', 'adminemail', '1');
                    $userdm->set_bitfield('options', 'showemail', '1');

                    #If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
                    if (count($userdm->errors)) {
                        for($i=0; $i<count($userdm->errors); $i++) {
                            print "ERROR{$i}:{$userdm->errors[$i]}\n";
                        }
                    }
                    else{
                        # If everything is OK
                        $newuserid = $userdm->save();
                    }
                    chdir('..');
getting headers already sent error? any idea what I need to change?

Unable to add cookies, header already sent.
File: /usr/home/civclash/public_html/register.php
Line: 10

Line 10=<style type="text/css" media="all">
Reply With Quote
  #6  
Old 06-29-2008, 05:42 PM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't output anything before including vBulletin.
Reply With Quote
  #7  
Old 06-29-2008, 08:49 PM
jstep jstep is offline
 
Join Date: Jan 2006
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i fixed this by having a

PHP Code:
echo "You will now be registered for the forum.";
                        echo 
"<meta http-equiv='Refresh' content='2; URL=./forums/forumadd.php?username=$username&password=$password2&email=$email'/>"
and then the forumadd handles everything else

Now if I can just make it so you can't just add in anything in those $_GET variables to create a new account
Reply With Quote
  #8  
Old 06-30-2008, 12:38 PM
eclectus eclectus is offline
 
Join Date: May 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you could echo out a form with hidden fields, and then do form.submit() at the end, it will forward the form with POST so nothing is exposed
Reply With Quote
  #9  
Old 07-01-2008, 07:04 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Using form.submit() will not work if Javascript is disabled.
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 03:15 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.07171 seconds
  • Memory Usage 2,274KB
  • 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
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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