Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.38 KB | None | 0 0
  1. <?php
  2.  
  3. function sendCurl($url, $is_post = false, $postdata = null){
  4.     $request = curl_init($url);
  5.     curl_setopt($request, CURLOPT_POST, $is_post);
  6.     curl_setopt($request, CURLOPT_POSTFIELDS, $postdata);
  7.     curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
  8.     $response = json_decode(curl_exec($request),false);
  9.     if(is_array($response)){
  10.         return $response[0];
  11.     }else{
  12.         return $response;
  13.     }
  14. }
  15.  
  16. function getSalt(){
  17.     return rand(1,10000);
  18. }
  19.  
  20. class mcUser{
  21.     public $id;
  22.     public $fid;
  23.     public $name;
  24.     public $gps;
  25.     public $jpid;
  26.     public $spinsLeft;
  27.     private $key;
  28.    
  29.     public function __construct($fbid, $fbname){
  30.         $this->key = "4ATreS384Epepa2aHAFr";
  31.         $this->fid = $fbid;
  32.         $this->name = $fbname;
  33.        
  34.         $jpids = explode(" ", file_get_contents("jpcoords.txt"));
  35.         $jpindex = rand(0,count($jpids));
  36.         $jp_r = explode(",", $jpids[$jpindex]);
  37.         $this->jpid = str_replace("%0A", "", urlencode($jp_r[0]));
  38.         $this->gps = $jp_r[1] . " " . $jp_r[2];
  39.        
  40.         $salt = getSalt();
  41.         $postdata = array(
  42.             'customer_fid' => $this->fid,
  43.             'customer_name' => $this->name,
  44.             'salt' => $salt,
  45.             'token' => hash('sha512', $this->key . $salt . $this->fid)
  46.         );
  47.         $response = sendCurl("http://mcdonalds.kiloo.com/index.php/customer_v4/login/", true, $postdata);
  48.         $this->id = $response->customer_id;
  49.         $this->spinsLeft = $this->checkJackpot();
  50.     }
  51.    
  52.     public function collectCoin($coin){
  53.         $salt = getSalt();
  54.         $postdata = array(
  55.             'customer_id' => $this->id,
  56.             'customer_fid' => $this->fid,
  57.             'collection_type' => $coin,
  58.             'gps' => $this->gps,
  59.             'salt' => $salt,
  60.             'token' => hash('sha512', $this->key . $salt . $this->id . $coin . $this->gps . $this->fid)
  61.         );
  62.         $response = sendCurl("http://mcdonalds.kiloo.com/index.php/customer_v4/collect_coin/", TRUE, $postdata);
  63.         return $response;
  64.     }
  65.    
  66.     public function getCoins(){
  67.         $salt = getSalt();
  68.         $postdata = array(
  69.             'customer_id' => $this->id,
  70.             'customer_fid' => $this->fid,
  71.             'salt' => $salt,
  72.             'token' => hash('sha512', (string) $this->key . $salt . $this->id . $this->fid)
  73.         );
  74.         $response = sendCurl("http://mcdonalds.kiloo.com/index.php/customer_v4/get/collected_coins/", TRUE, $postdata);
  75.         return $response->collected_coins;
  76.     }
  77.    
  78.     public function checkJackpot(){
  79.         $salt = getSalt();
  80.         $getdata = array(
  81.             'customer_id' => urlencode($this->id),
  82.             'jackpot_id' => urlencode($this->jpid),
  83.             'salt' => urlencode($salt),
  84.             'token' => urlencode(hash('sha512', $this->key . $salt . $this->id))
  85.         );
  86.         $getString = "http://mcdonalds.kiloo.com/index.php/customer_v4/jackpot_status/?";
  87.         foreach($getdata as $key => $value){
  88.             $getString .= $key . '=' . $value . '&';
  89.         }
  90.         $URI = str_replace("%0A", "", rtrim($getString, '&'));
  91.         $response = sendCurl($URI);
  92.         return $response->available_spins;
  93.     }
  94.    
  95.     public function spinJackpot(){
  96.         for($i = 1; $i <= $this->spinsLeft; $i++){
  97.             $salt = getSalt();
  98.             echo "<b>Spin " . $i . ": </b>";
  99.             $postdata = array(
  100.                 'customer_id' => $this->id,
  101.                 'jackpot_id' => $this->jpid,
  102.                 'location' => $this->gps,
  103.                 'salt' => $salt,
  104.                 'token' => hash('sha512', $this->key . $salt . $this->id . $this->jpid . $this->gps)
  105.             );
  106.             $response = sendCurl("http://mcdonalds.kiloo.com/index.php/customer_v4/jackpot/", TRUE, $postdata);
  107.             if($response->game_result){
  108.                 echo "Won " . $response->prize . "<br />";
  109.                 break;
  110.             }
  111.             echo "No prize<br />";
  112.         }
  113.            
  114.     }
  115.    
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement