Advertisement
StefanBashkir

PHP_ cURL Change User Rank (ROBLOX)

Jan 29th, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. <?php
  2.  
  3. if (!isset($_GET['userId']) || !isset($_GET['roleId'])) {
  4.     exit('Error: No user and/or role specified.');
  5. }
  6. // I wonder what this could be.
  7. $groupId = 1076;
  8.  
  9. // This is used later when GETing and POSTing to authenticate who we are to roblox
  10. $roblosec = '[redacted for obvious reason]';
  11. $csrf = '';
  12.  
  13. function get($url) {
  14.     global $roblosec;
  15.  
  16.     $ch = curl_init();
  17.  
  18.     curl_setopt($ch, CURLOPT_URL, $url);
  19.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  20.     curl_setopt($ch, CURLOPT_COOKIE, '.ROBLOSECURITY=' . $roblosec);
  21.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  22.     curl_setopt($ch, CURLOPT_HEADER, 1);
  23.  
  24.     $result = curl_exec($ch);
  25.  
  26.     if (curl_errno($ch)) {
  27.         exit('cURL error: ' . curl_error($ch));
  28.     }
  29.  
  30.     curl_close($ch);
  31.  
  32.     return $result;
  33. }
  34.  
  35. function post($url, $data) {
  36.     global $roblosec, $csrf, $groupId;
  37.  
  38.     if (is_array($data)) {
  39.         $temp_data = '';
  40.  
  41.         foreach($data as $k => $v) {
  42.             $temp_data .= $k . '=' . $v . '&';
  43.         }
  44.  
  45.         $data = substr($temp_data, 0, -1);
  46.     }
  47.  
  48.     $ch = curl_init();
  49.  
  50.     curl_setopt($ch, CURLOPT_URL, $url);
  51.     curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  52.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  53.     curl_setopt($ch, CURLOPT_COOKIE, '.ROBLOSECURITY=' . $roblosec);
  54.     curl_setopt($ch, CURLOPT_HEADER, 1);
  55.     curl_setopt($ch, CURLOPT_POST, true);
  56.     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  57.     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36');
  58.     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Encoding: gzip, deflate', 'Content-Length: 0', 'Origin: http://www.roblox.com', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'X-CSRF-TOKEN: ' . $csrf, 'X-Requested-With: XMLHttpRequest'));
  59.  
  60.     $result = curl_exec($ch);
  61.  
  62.     if (curl_errno($ch)) {
  63.         exit('cURL error: ' . curl_error($ch));
  64.     }
  65.  
  66.     curl_close($ch);
  67.  
  68.     return $result;
  69. }
  70.  
  71. // Grap the csrf token
  72. preg_match('/Roblox\.XsrfToken\.setToken\(\'([^\']+)\'\);/sm', get('http://www.roblox.com/My/GroupAdmin.aspx?gid=' . $groupId), $m);
  73. $csrf = $m[1];
  74.  
  75. // And now we actually change the user's rank
  76. echo nl2br(htmlentities(post('http://www.roblox.com/groups/api/change-member-rank?groupId=' . $groupId . '&newRoleSetId=' . $_GET['roleId'] . '&targetUserId=' . $_GET['userId'], '')));
  77.  
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement