Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Kills the script if the security key is incorrect.
- $securitykey = $_POST['securitykey'];
- if ($securitykey !== 'Samantha')
- {
- die('Authorization failure.');
- }
- // Initializes the MyBB integration.
- define('IN_MYBB', NULL);
- require_once '../global.php';
- require_once 'class.MyBBIntegrator.php';
- $MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);
- // Connects to the MyBB MySQL database.
- $dbhost = 'localhost';
- $dbuser = 'azgarhos_mysql06';
- $dbpass = 'db060591';
- $dbname = 'azgarhos_mysql06';
- $dbconnect = mysql_connect($dbhost, $dbuser, $dbpass);
- mysql_select_db($dbname);
- // Determines what task is to be completed.
- $taskid = $_POST['taskid'];
- switch ($taskid)
- {
- case '1':
- newCharacter();
- break;
- case '2':
- changePassword();
- break;
- case '3':
- updateScore();
- break;
- }
- // getUserID function.
- function getUserID ($username)
- {
- $query = sprintf("SELECT uid FROM mybb_users WHERE username = '%s'", mysql_real_escape_string($username));
- $result = mysql_query($query);
- while ($row = mysql_fetch_assoc($result))
- {
- $uid = $row['uid'];
- }
- return($uid);
- }
- // newCharacter function.
- // Used to create a new account on the MyBB database.
- function newCharacter()
- {
- global $MyBBI;
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $info = array(
- 'username' => $username,
- 'password' => $password,
- 'password2' => $password,
- 'email' => $email,
- 'email2' => $email,
- 'hideemail' => 1,
- 'invisible' => 0,
- 'receivepms' => 1,
- 'pmnotice' => 1,
- 'emailpmnotify' => 0
- );
- $MyBBI->register($info);
- $score = 0;
- $query = sprintf("INSERT INTO mus_highscores (username, score) VALUES ('%s', '%s')", mysql_real_escape_string($username), mysql_real_escape_string($score));
- mysql_query($query);
- }
- // changePassword function.
- // Used to change a user's password based on the username given.
- function changePassword()
- {
- global $MyBBI;
- $username = $_POST['username'];
- $password = $_POST['password'];
- $uid = getUserID($username);
- $MyBBI->updatePasswordOfUser($uid, $password);
- }
- // updateScore function.
- // Used to update the character's score.
- function updateScore()
- {
- $username = $_POST['username'];
- $score = (int) $_POST['score'];
- $query = sprintf("UPDATE mus_highscores SET score='%s' WHERE username='%s'", mysql_real_escape_string($score), mysql_real_escape_string($username));
- mysql_query($query);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement