PDA

View Full Version : Salt Create error !


Chaya_
01-18-2015, 08:10 PM
<?php

class Vbulletin extends Plugin
{
/**
* Runtime values
*/
private $username;
private $password;
private $email;
private $db;

/**
* Receive the user information
* @param String $username
* @param String $password
* @param String email
*/
public function register($username, $password, $email)
{
$this->username = $username;
$this->password = $password;
$this->email = $email;

$this->db = $this->CI->load->database($this->CI->config->item('bridge'), TRUE);

$this->process();
}

/**
* Add the account
*/
private function process()
{
$salt = $this->fetch_user_salt(30);

$password = $this->encryptPassword($salt);
$this->db->query("INSERT INTO ".$this->CI->config->item('forum_table_prefix')."user(`usergroupid`, `username`, `password`, `email`, `joindate`, `salt`) VALUES ('2', ?, ?, ?, ?, ?)", array($this->username, $password, $this->email, time(), $salt));
}

/**
* Encrypt the password with a specific algorithm
* @return String
*/
private function encryptPassword($salt)
{
return md5(md5($salt) .md5( $this->password ));
}

private function fetch_user_salt($length = 30)
{
$salt = '';
for ($i = 0; $i < $length; $i++)
{
$salt .= chr(rand(33, 126));
}
return $salt;
}
}

What is wrong in this script ?

ozzy47
01-18-2015, 08:12 PM
Where is that from, and what is it supposed to be doing?
What is it not doing?

You need to provide more information as to the problems.

Chaya_
01-18-2015, 08:14 PM
it creates an account wth fusion cms !

This is a plugin module ...

the problem is the salt... i create the account from users, that all works fine, but the salt is wrong or login works not

ozzy47
01-18-2015, 08:16 PM
You would need to ask the developer of the plugin what the issues may be.

Chaya_
01-18-2015, 08:18 PM
i am the dev LoL !

I ask the community what is wrong with my script, why salt is wrong ?!

This script input userdatas in the users table ... like this ...

`usergroupid`, `username`, `password`, `email`, `joindate`, `salt`)

But Salt is wrong !

ozzy47
01-18-2015, 08:20 PM
Ahh, ok, did not know you were the developer. :)

Did you happen to look into how vBulletin generates the salt?

Chaya_
01-18-2015, 08:22 PM
Pls Check your PM, i am german boy, i cant write good in english !

ozzy47
01-18-2015, 08:24 PM
Sorry, I don't offer unsolicited support requets via PM. :)

Chaya_
01-18-2015, 08:26 PM
WTF ...

I only need show you my problem... OMG !

ozzy47
01-18-2015, 08:28 PM
I did not ask you to PM me. Support is handled out here in the forums, unless someone asks you to PM them something. :)

Chaya_
01-18-2015, 08:30 PM
you understandf me or ? i cannot write all in english ?! Understand that ?

ozzy47
01-18-2015, 08:33 PM
Irregardless, my original point still stands. " Sorry, I don't offer unsolicited support requets via PM. :) "

Perhaps someone will come along in this thread and ask you to pm them a link to your desktop, and have a look. :)

ozzy47
01-18-2015, 08:36 PM
Or since your native language is German, perhaps ask here, http://www.vbulletin-germany.org/forum.php

There is some real good coders over there.

kh99
01-18-2015, 09:11 PM
Try this:
private function encryptPassword($salt)
{
return md5(md5( $this->password ). $salt);
}