2008-12-17, 01:35 AM
Seeker,
It is a commercial project. But since I have the 'power', I am more than happy to share with you guys. So here it goes!
Due to the fact that this is a commercial project, please link to the following site if you decide to use it.
www.clinkpc.com
Hope that helps!!
Can you tell me why I am not being able to put this code inside a function? It is working well when I am just executing it, but it is not running when I put it inside a function. Thanks.
It is a commercial project. But since I have the 'power', I am more than happy to share with you guys. So here it goes!
function forum_registeruser($username_in, $password_in, $email_in, $usergroup_in){
$connect = mysql_connect("host","username","password") or die ("Could not even connect to the database");//change host, username and password according to your personal specifications
mysql_select_db("mybb");//Change 'mybb' to the name of the database that you are using for your forum
$query="SELECT username FROM users WHERE username='".$username_in."'";
$checkexistence = mysql_query($query) or die("Could not read from table");
$exists=false;
while ($rows=mysql_fetch_array($checkexistence)){
extract($rows);
if($username==NULL){
$exists=false;
}else{
$exists=true;
}
}
if($exists==false){
$salt=random_str('8');
$password_hash=salt_password($password_in, $salt);
$login_key=generate_loginkey();
$insert_query = "INSERT INTO users (username, password, salt, loginkey, email, usergroup) VALUES ('".$username_in."', '".$password_hash."', '".$salt."', '".$login_key."', '".$email_in."', '".$usergroup_in."')";
$insertuser = mysql_query($insert_query) or die("Could not insert data into table");
echo('User successfully registered.');
}else{
echo('User already exists.');
}
}
function random_str($length="8")
{
$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str = '';
for($i = 1; $i <= $length; ++$i)
{
$ch = mt_rand(0, count($set)-1);
$str .= $set[$ch];
}
return $str;
}
function salt_password($password, $salt)
{
return md5(md5($salt).md5($password));
}
function generate_loginkey()
{
return random_str(50);
}
Due to the fact that this is a commercial project, please link to the following site if you decide to use it.
www.clinkpc.com
Hope that helps!!
(2008-12-16, 06:02 PM)Ryan Gordon Wrote: [ -> ]<?php define("IN_MYBB", 1); define("NO_ONLINE", 1); require_once('./yourmybbpath/inc/init.php'); $cache->update_stats(); echo('Updated Finished!'); ?>
Can you tell me why I am not being able to put this code inside a function? It is working well when I am just executing it, but it is not running when I put it inside a function. Thanks.