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 ?
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 ?