2013-08-01, 06:02 PM
I've been on the forums here as a guest for a bit now and have pieced together a third party registration page (that also registers for WordPress).
The problem I'm having is with the loginkey. The script successfully inserts the uid, username, salted password, salt, and email. However the loginkey keeps showing up as 0.
The created user is able to login however there is an error message:
Warning [2] array_merge() [function.array-merge]: Argument #1 is not an array - Line: 277 - File: inc/class_session.php PHP 5.3.27 (Linux)
[PHP] errorHandler->error
/inc/class_session.php 277 array_merge
/inc/class_session.php 54 session->load_user
/global.php 55 session->init
/index.php 18 require_once
and they are unable to view the board.
I am assuming this is because of the login key (seeing as they all have to do with sessions) but really am learning as I go with this one so feel free to correct me.
The resulting mybb_users entry looks like this:
4|TestAccount|13a37d4ed6726555abf0c01b2fd6675c|inqgjzjr|0|[email protected]|0|0|0|0|0|1375379616|0|0|all|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|<lastip>|0|<longlastip>|0|1|0|0|0|0|0|0|0|0|0|0|0|1|0
I have notice that after I login (and get the error message) the loginkey is generated but I still get that error message when I try to login again so maybe it is unrelated?
This is also my first php script ever so I'm sure there are some ugly lines for those of you who are better at it then me.
The sign up page is here: http://revolutionarywire.com/test/signup.php
The forums are hosted here: http://revolutionarywire.com/forums
the processor script is the one quoted above.
The problem I'm having is with the loginkey. The script successfully inserts the uid, username, salted password, salt, and email. However the loginkey keeps showing up as 0.
The created user is able to login however there is an error message:
Warning [2] array_merge() [function.array-merge]: Argument #1 is not an array - Line: 277 - File: inc/class_session.php PHP 5.3.27 (Linux)
[PHP] errorHandler->error
/inc/class_session.php 277 array_merge
/inc/class_session.php 54 session->load_user
/global.php 55 session->init
/index.php 18 require_once
and they are unable to view the board.
I am assuming this is because of the login key (seeing as they all have to do with sessions) but really am learning as I go with this one so feel free to correct me.
<?php
//Define incoming script
$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
//Include Wordpress library
include("../wp-blog-header.php");
//Variables
$pwgenerated = false;
//Functions
function random_str($length){
$rangeMin = pow(36, $length-1); //smallest number to give length digits in base 36
$rangeMax = pow(36, $length)-1; //largest number to give length digits in base 36
$base10Rand = mt_rand($rangeMin, $rangeMax); //get the random number
$newRand = base_convert($base10Rand, 10, 36); //convert it
return $newRand; //spit it out
}
//Name variables from form
$username = $_POST['field_1'];
$password = $_POST['field_2'];
$cpassword = $_POST['field_3'];
$fname = $_POST['field_4'];
$lname = $_POST['field_5'];
$email = $_POST['field_6'];
$web = $_POST['field_7'];
$zip = $_POST['field_8'];
$user_id = username_exists( $username ) ;
//Check username for symbols
if (ctype_alnum($username)) {
} else {
Header("Location: signup.php?usernamealpha");
}
//If username exsists go back to signup.php
if( $user_id ){
Header("Location: signup.php?username");
} else {
}
//If email exists go back to signup.php
if( email_exists($email) ){
Header("Location: signup.php?email");
} else {
}
//Make sure either password or e-mail is provided
if (empty($password) and empty($email)) {
Header("Location: signup.php?passmail");
}
//If confirm password is filled out make sure it matches password
if (empty($cpassword)) {
} else {
if ($password != $cpassword) {
Header("Location: signup.php?password");
}
}
if (empty($password)) {
$password = wp_generate_password( $length=12 ) ;
$pwgenerated = true;
}
//Generate Wordpress & MyBB Data
$wp_user_id = username_exists( $username );
$bb_salt = random_str(8);
$bb_password = md5(md5($bb_salt).md5($password));
$bb_loginkey = random_str(50);
if (empty($email)) {
$email = '[email protected]' ;
}
$user_data = array(
'ID' => '',
'user_pass' => $password,
'user_login' => $username,
'user_url' => $web,
'user_email' => $email,
'first_name' => $fname,
'last_name' => $lname,
'role' => get_option('default_role')
);
//Connect to MyBB Database
$bb_connect = mysql_connect("localhost", "", "") or die(mysql_error());
mysql_select_db("", $bb_connect) or die(mysql_error());
$bb_query = mysql_query("SELECT * FROM mybb_users") or die(mysql_error());
$bb_uid = mysql_num_rows($bb_query) + 1;
mysql_query("INSERT INTO mybb_users
(uid, username, password, salt, loginkey, email) VALUES('$bb_uid', '$username', '$bb_password', '$bb_salt', '$bb_loginkey', '$email' ) ")
or die(mysql_error());
// Insert data into databses
//$user_id = wp_insert_user( $user_data );
//wp_set_password($password, $user_id);
?>
The resulting mybb_users entry looks like this:
4|TestAccount|13a37d4ed6726555abf0c01b2fd6675c|inqgjzjr|0|[email protected]|0|0|0|0|0|1375379616|0|0|all|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|<lastip>|0|<longlastip>|0|1|0|0|0|0|0|0|0|0|0|0|0|1|0
I have notice that after I login (and get the error message) the loginkey is generated but I still get that error message when I try to login again so maybe it is unrelated?
This is also my first php script ever so I'm sure there are some ugly lines for those of you who are better at it then me.
The sign up page is here: http://revolutionarywire.com/test/signup.php
The forums are hosted here: http://revolutionarywire.com/forums
the processor script is the one quoted above.