Guest User

Untitled

a guest
May 14th, 2012
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?PHP
  2. $sessionFile    =   "chat_sessions";
  3.  
  4. $loginURL       =   "https://login.minecraft.net";
  5. $version        =   12;
  6. $user           =   !empty($_POST['user']) ? $_POST['user'] : false;
  7. $pass           =   !empty($_POST['password']) ? $_POST['password'] : false;
  8. $domain         =   $_SERVER['HTTP_HOST'];
  9.  
  10. header("Access-Control-Allow-Origin: http://{$domain}");
  11. if($user && $pass){
  12.     $ch =   curl_init($loginURL);
  13.     curl_setopt($ch,CURLOPT_POST,true);
  14.     curl_setopt($ch,CURLOPT_POSTFIELDS,"user={$user}&password={$pass}&version={$version}");
  15.     curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  16.     $result =   curl_exec($ch);
  17.     if($result=='Bad login'){
  18.         ?>
  19.         [{"response":"Bad Login","result":false}]
  20.         <?PHP
  21.     }elseif($result=="User not premium"){
  22.         $username   =   $user;
  23.         $session    =   md5(uniqid());
  24.         $date       =   time();
  25.         $fh         =   fopen($sessionFile,"r");
  26.         $data       =   array();
  27.         while( ($row=fgetcsv($fh)) !==false){
  28.             $data[] =   $row;
  29.         }
  30.         fclose($fh);
  31.         for($i=0;$i<count($data);$i++){
  32.             $row    =   $data[$i];
  33.             if($row[1]==$username){
  34.                 unset($data[$i]);
  35.             }
  36.         }
  37.         $data[]     =   array($date,$username,$session);
  38.         $fh         =   fopen($sessionFile,"w+");
  39.         foreach($data as $row){
  40.             fputcsv($fh,$row);
  41.         }
  42.         fclose($fh);
  43.         ?>
  44.         [{"response":"Successful login, but user is not premium","result":true,"user":"<?=$username?>","session":"<?=$session?>"}]
  45.         <?
  46.     }elseif(preg_match('/[0-9]*:deprecated:.*:[A-z0-9]*/',$result)){
  47.         $result     =   explode(":",$result);
  48.         $username   =   $result[2];
  49.         $session    =   $result[3];
  50.         $date       =   time();
  51.         $fh         =   fopen($sessionFile,"r");
  52.         $data       =   array();
  53.         while( ($row=fgetcsv($fh)) !==false){
  54.             $data[] =   $row;
  55.         }
  56.         fclose($fh);
  57.         for($i=0;$i<count($data);$i++){
  58.             $row    =   $data[$i];
  59.             if($row[1]==$username){
  60.                 unset($data[$i]);
  61.             }
  62.         }
  63.         $data[]     =   array($date,$username,$session);
  64.         $fh         =   fopen($sessionFile,"w+");
  65.         foreach($data as $row){
  66.             fputcsv($fh,$row);
  67.         }
  68.         fclose($fh);
  69.         ?>
  70.         [{"response":"Successful login","result":true,"user":"<?=$username?>","session":"<?=$session?>"}]
  71.         <?
  72.     }else{
  73.         ?>
  74.         [{"response": "I don't know what happened, but it didn't work","result":false}]
  75.         <?
  76.     }
  77. }else{
  78.     ?>
  79.     [{"response": "Invalid login structure","result":false}]   
  80.     <?
  81. }
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment