Advertisement
Guest User

Untitled

a guest
May 29th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2.  
  3.     // Kills the script if the security key is incorrect.
  4.     $securitykey = $_POST['securitykey'];
  5.     if ($securitykey !== 'Samantha')
  6.     {
  7.         die('Authorization failure.');
  8.     }
  9.    
  10.     // Initializes the MyBB integration.
  11.     define('IN_MYBB', NULL);
  12.     require_once '../global.php';
  13.     require_once 'class.MyBBIntegrator.php';
  14.     $MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);
  15.    
  16.     // Connects to the MyBB MySQL database.
  17.     $dbhost = 'localhost';
  18.     $dbuser = 'azgarhos_mysql06';
  19.     $dbpass = 'db060591';
  20.     $dbname = 'azgarhos_mysql06';
  21.     $dbconnect = mysql_connect($dbhost, $dbuser, $dbpass);
  22.     mysql_select_db($dbname);
  23.  
  24.     // Determines what task is to be completed.
  25.     $taskid = $_POST['taskid'];
  26.     switch ($taskid)
  27.     {
  28.         case '1':
  29.             newCharacter();
  30.             break;
  31.         case '2':
  32.             changePassword();
  33.             break;
  34.         case '3':
  35.             updateScore();
  36.             break;
  37.     }
  38.    
  39.     // getUserID function.
  40.     function getUserID ($username)
  41.     {
  42.         $query = sprintf("SELECT uid FROM mybb_users WHERE username = '%s'", mysql_real_escape_string($username));
  43.         $result = mysql_query($query);
  44.         while ($row = mysql_fetch_assoc($result))
  45.         {
  46.             $uid = $row['uid'];
  47.         }
  48.         return($uid);
  49.     }
  50.    
  51.     // newCharacter function.
  52.     // Used to create a new account on the MyBB database.
  53.     function newCharacter()
  54.     {
  55.         global $MyBBI;
  56.         $username = $_POST['username'];
  57.         $password = $_POST['password'];
  58.         $email = $_POST['email'];
  59.         $info = array(
  60.             'username' => $username,
  61.             'password' => $password,
  62.             'password2' => $password,
  63.             'email' => $email,
  64.             'email2' => $email,
  65.             'hideemail' => 1,
  66.             'invisible' => 0,
  67.             'receivepms' => 1,
  68.             'pmnotice' => 1,
  69.             'emailpmnotify' => 0
  70.         );
  71.         $MyBBI->register($info);
  72.         $score = 0;
  73.         $query = sprintf("INSERT INTO mus_highscores (username, score) VALUES ('%s', '%s')", mysql_real_escape_string($username), mysql_real_escape_string($score));
  74.         mysql_query($query);
  75.     }
  76.    
  77.     // changePassword function.
  78.     // Used to change a user's password based on the username given.
  79.     function changePassword()
  80.     {
  81.         global $MyBBI;
  82.         $username = $_POST['username'];
  83.         $password = $_POST['password'];
  84.         $uid = getUserID($username);
  85.         $MyBBI->updatePasswordOfUser($uid, $password);
  86.     }
  87.    
  88.     // updateScore function.
  89.     // Used to update the character's score.
  90.     function updateScore()
  91.     {
  92.         $username = $_POST['username'];
  93.         $score = (int) $_POST['score'];
  94.         $query = sprintf("UPDATE mus_highscores SET score='%s' WHERE username='%s'", mysql_real_escape_string($score), mysql_real_escape_string($username));
  95.         mysql_query($query);
  96.     }
  97.    
  98.  
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement