this is a snipped used to create a user in a mybb-forum(v1.4 - 1.8 for other versions i don't know) when he registers in the game
insert in includes\pages\login\ShowVertifyPage.class.php after line 116 (PlayerUtil::sendMessage($userID, 1, $senderName, 1, $subject, $message, TIMESTAMP);)
Display All
replace the filds where you find a comment that looks like this: //<--
the original script can be found here community.mybb.com/archive/
it was written in 2008 so i had to replace dbconnection with pdo.
but still it's running flawlessly.
insert in includes\pages\login\ShowVertifyPage.class.php after line 116 (PlayerUtil::sendMessage($userID, 1, $senderName, 1, $subject, $message, TIMESTAMP);)
PHP Source Code: includes\pages\login\ShowVertifyPage.class.php
- //--------------user im forum registrieren----------------------------------------
- function forum_registeruser($username_in, $password_in, $email_in, $usergroup_in){
- $servernameo = "server ip or localhost"; //<--
- $usernameo = "username"; //<--
- $passwordo = "password"; //<--
- try {
- $connect = new PDO("mysql:host=$servernameo;dbname=dbname", $usernameo, $passwordo);//<--(dbname)
- // set the PDO error mode to exception
- $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- //test if user exists
- $queryo="SELECT username FROM mybb_users WHERE username='".$username_in."'";//<--use the prefix of your mybb installation
- $checkexistence = $connect->query($queryo);
- $exists=false;
- $counter=0;
- while($rowso = $checkexistence->fetch(PDO::FETCH_BOTH)){
- extract($rowso);
- if($username==NULL){
- $exists=false;
- }else{
- $exists=true;
- }
- }
- //create user
- if($exists==false){
- $salto=random_str('8');
- $password_hasho=salt_password($password_in, $salto);
- $login_keyo=generate_loginkey();
- $statementmant = $connect->prepare("INSERT INTO mybb_users (username, password, salt, loginkey, email, usergroup)
- VALUES (:username_in, :password_hasho, :salto, :login_keyo, :email_in, :usergroup_in)");//<--use the prefix of your mybb installation
- $insertuser = $statementmant->execute(array(
- ":username_in" => $username_in,
- ":password_hasho" => $password_hasho,
- ":salto" => $salto,
- ":login_keyo" => $login_keyo,
- ":email_in" => $email_in,
- ":usergroup_in" => $usergroup_in
- ));
- //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($passwordo, $salto)
- {
- return md5(md5($salto).md5($passwordo));
- }
- function generate_loginkey()
- {
- return random_str(50);
- }
- forum_registeruser($userData['userName'], $userData['password'] , $userData['email'], '2');
- //------------------------------------------------------
the original script can be found here community.mybb.com/archive/
it was written in 2008 so i had to replace dbconnection with pdo.
but still it's running flawlessly.