Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 01-22-2006, 09:11 PM
OKIHost OKIHost is offline
 
Join Date: Sep 2005
Location: Bawstin
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Automatic Account Creation Issues

I use a script in Modernbill which allows me to setup a forum account when a client signs up with me automatically.

This was working fine in 3.0.X but since upgrading to 3.5.X it has some issues with creating the user such as when listing a thread you can not click on the username to send a PM, Email or look at profile. You can get a good idea of what I am talking about by looking at this thread , note the pmnowak user is the one having the issue but my account which I created myself by signing up works fine.

Another issue is when I go to PM any of these users setup by the API script through modernbill I am unable to edit the user in AdminCP or send the user a PM.

I did post in the paid request forum but no one got back to me so I figured I would try here and see if anyone has any suggestions

Here is the code from the script

HTML Code:
##############################
## NEW VBULITTEN CODE BEGIN ##
##############################

// ###################### Start makesalt #######################
// generates a totally random string of $length chars
function fetch_user_salt($length = 3)
{
        $salt = '';
        for ($i = 0; $i < $length; $i++)
        {
                $salt .= chr(rand(32, 126));
        }
        return $salt;
}

// ###################### Start htmlspecialchars_uni #######################
function htmlspecialchars_uni($text)
{
        // this is a version of htmlspecialchars that still allows unicode to function correctly
        $text = preg_replace('/&(?!#[0-9]+;)/si', '&amp;', $text); // translates all non-unicode entities

        return str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $text);
}


// ###################### Start build datastore #######################
function build_datastore($title = '', $data = '')
{
        GLOBAL $forum_table_prefix; //Config Option
        $forum_table_prefix = ($forum_table_prefix!='') ? trim($forum_table_prefix) : NULL;
    $forum_dbh = forum_connect();


        if ($title != '')
        {
                $sql ="REPLACE INTO " . $forum_table_prefix . "datastore
                                (title, data)
                        VALUES
                                ('" . addslashes(trim($title)) . "', '" . addslashes(trim($data)) . "')";
                $result = mysql_query_logger($sql,$forum_dbh);
         if (!$result) {
              return '['.ERROR.' '.mysql_errno().'] '.mysql_error();
         }
        }
}

function create_vbulletin_user($username,$password,$email)
{
         GLOBAL $forum_table_prefix; //Config Option
         define('TIMENOW', time());
         define('thedate', date("Y-m-d"));
            $forum_table_prefix = ($forum_table_prefix!='') ? trim($forum_table_prefix) : NULL;

         $forum_dbh = forum_connect();

         $salt = fetch_user_salt(3);
         $usertitle = "Hosting Client";
         $birthday = '';
                $birthday_search = '';
                $hashedpassword = md5(md5($password) . $salt);

         $sql = "INSERT INTO ".$forum_table_prefix."user
                                (username, salt, password, passworddate, email, styleid, parentemail,
                                showvbcode, usertitle, joindate, daysprune, lastvisit, lastactivity, usergroupid, timezoneoffset,
                                options, maxposts, threadedmode, startofweek, ipaddress, pmpopup, referrerid,
                                reputationlevelid, reputation, autosubscribe, birthday, birthday_search)
                        VALUES
                                ('" . addslashes(htmlspecialchars_uni($username)) . "',
                                '" . addslashes($salt) . "',
                                '" . addslashes($hashedpassword) . "',
                                '". date("Y-m-d") ."',
                                '" . addslashes(htmlspecialchars_uni($email)) . "',
                                '1',
                        '',
                                '1',
                                '" . addslashes($usertitle) . "',
                                '" . time() . "',
                                '0',
                                '" . time() . "',
                                '" . time() . "',
                                '2',
                                '0',
                                '7255',
                                '-1',
                                '0',
                                '1',
                                '127.0.0.1',
                                '1',
                                '',
                                '5',
                                '10',
                                '-1',
                                '$birthday',
                                '$birthday_search')";

         $result1 = mysql_query_logger($sql,$forum_dbh);
         if (!$result1) {
              return '['.ERROR.' '.mysql_errno().'] '.mysql_error();
         }
         $temp_user_id = mysql_insert_id();
                 mt_srand ((double) microtime() * 1000000);
         $activationid=mt_rand(0,100000000);
         $sql = "INSERT INTO ".$forum_table_prefix."useractivation (useractivationid, userid, dateline, activationid, type, usergroupid ) VALUES (NULL, '$te$         $result2 = mysql_query_logger($sql,$forum_dbh);
         if (!$result2) {
              return '['.ERROR.' '.mysql_errno().'] '.mysql_error();
         }
         $sql = "INSERT INTO ".$forum_table_prefix."userfield (userid, temp, field1, field2, field3, field4 ) VALUES ('$temp_user_id','','','','','')";
                 $result3 = mysql_query_logger($sql,$forum_dbh);
         // get total members
                 $sql = "SELECT COUNT(*) AS total, MAX(userid) AS max FROM ".$forum_table_prefix."user";
         $result4 = mysql_query_logger($sql,$forum_dbh);
         if (!$result4) {
              return '['.ERROR.' '.mysql_errno().'] '.mysql_error();
         }
         $row = mysql_fetch_array($result4);
         // get newest member
                 $sql = "SELECT * FROM " . $forum_table_prefix . "user WHERE userid = $row[max]";
                 $result5 = mysql_query_logger($sql,$forum_dbh);
                if (!$result5) {
               return '['.ERROR.' '.mysql_errno().'] '.mysql_error();
          }
         $newuser = mysql_fetch_array($result5);
                // make a little array with the data
                $values = array(
                'numbermembers' => $row['total'],
                'newusername' => $newuser['username'],
                'newuserid' => $newuser['userid']
                );
                // update the special template
                build_datastore('userstats', serialize($values));

         return ($result5) ? 1 : '['.ERROR.' '.mysql_errno().'] '.mysql_error() ;
}

##############################
## NEW VBULITTEN CODE END ##
##############################
Thanks in advance for anyone who may have any suggestions.
Reply With Quote
  #2  
Old 01-22-2006, 09:18 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would start by not trying to duplicate vB functions, but simply include the vB function file (most would already be loaded by including global.php).

PS Moved to the correct forum.
Reply With Quote
Reply

Thread Tools
Display Modes

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 06: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.09767 seconds
  • Memory Usage 2,180KB
  • 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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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_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