Advertisement
Guest User

Untitled

a guest
May 29th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.11 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.             updateRanking();
  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.         $level = 1;
  73.         $score = 0;
  74.         $playerkills = 0;
  75.         $query = sprintf("INSERT INTO mus_rankings (username, level, score, playerkills) VALUES ('%s', '%s', '%s', '%s')", mysql_real_escape_string($username), mysql_real_escape_string($level), mysql_real_escape_string($score), mysql_real_escape_string($playerkills));
  76.         mysql_query($query);
  77.     }
  78.    
  79.     // changePassword function.
  80.     // Used to change a user's password based on the username given.
  81.     function changePassword()
  82.     {
  83.         global $MyBBI;
  84.         $username = $_POST['username'];
  85.         $password = $_POST['password'];
  86.         $uid = getUserID($username);
  87.         $MyBBI->updatePasswordOfUser($uid, $password);
  88.     }
  89.    
  90.     // updateRanking function.
  91.     // Used to update the character's ranking.
  92.     function updateRanking()
  93.     {
  94.         $username = $_POST['username'];
  95.         //$level = (int) $_POST['level'];
  96.         $score = (int) $_POST['score'];
  97.         $playerkills = (int) $_POST['playerkills'];
  98.         //$query = sprintf("UPDATE mus_rankings SET level='%s' WHERE username='%s'", mysql_real_escape_string($level), mysql_real_escape_string($username));
  99.         //mysql_query($query);
  100.         $query = sprintf("UPDATE mus_rankings SET score='%s' WHERE username='%s'", mysql_real_escape_string($score), mysql_real_escape_string($username));
  101.         mysql_query($query);
  102.         $query = sprintf("UPDATE mus_rankings SET playerkills='%s' WHERE username='%s'", mysql_real_escape_string($playerkills), mysql_real_escape_string($username));
  103.         mysql_query($query);
  104.     }
  105.    
  106.  
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement