Advertisement
Guest User

leaderboard

a guest
Jan 15th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.16 KB | None | 0 0
  1. <?php
  2.  
  3. /*Game must pass data like this: https://domain/thisscript.php?data="encodedstring".
  4. The game should generate 'mobileNo + magic sequence + encrypted password' this string and encode it.
  5. This is the 'encodedstring' on url's data parameter. The output from this php script will be echo-ed.
  6. So look up the corresponding echos. If login is succeed, then we will echo 'success' along with a bunch of data, which game must perse through regex.
  7. */
  8. require_once 'Secure.php';
  9.  
  10. $magicSeq = "__RPL__2016__LALY__MAGICNUM__";
  11. $entrySeperator = "__RPL__2016__LALY__ENTRYSEP__";
  12. $elementSeperator = "__RPL__ELEM__SEP__";
  13. $max = 3;
  14. //echo "bara";
  15. if (isset($_GET['data']))
  16. {
  17.  
  18.     $dataSet = "";
  19.     if($secure == "yes")
  20.     {
  21.         $dataSet = explode($magicSeq, Decrypt($_GET["data"]));
  22.     }
  23.     else
  24.     {
  25.         $dataSet = explode($magicSeq, $_GET["data"]);
  26.     }
  27.    
  28.  
  29.     if(count($dataSet) == 2)
  30.     {
  31.         $mobileNo = $dataSet[0];
  32.         $password = $dataSet[1];
  33.        
  34.         $DBhost = "localhost";
  35.         $DBuser = "tahmidhc_laly";
  36.         $DBpass = "^rcf;(N2W8Nm";
  37.         $DBname = "tahmidhc_lalyapp";
  38.         $DBcon = new MySQLi($DBhost,$DBuser,$DBpass,$DBname);
  39.  
  40.         if ($DBcon->connect_errno)
  41.         {
  42.             die("ERROR : -> ".$DBcon->connect_error);
  43.         }
  44.  
  45.  
  46.         $queryThisUser = $DBcon->query("SELECT mobileNumber, name, lalyName, score, password FROM userlist WHERE mobileNumber='$mobileNo'");
  47.         $rowThisUserDetails=$queryThisUser->fetch_array();
  48.  
  49.         $countResultThisUser = $queryThisUser->num_rows; // if email/password are correct returns must be 1 row
  50.  
  51.         $check_mobileNo_Blist = $DBcon->query("SELECT mobileNumber FROM blacklist WHERE mobileNumber='$mobileNo'");
  52.         $countBlist=$check_mobileNo_Blist->num_rows;
  53.  
  54.         if($countBlist == 0)
  55.         {
  56.             if ($password == $rowThisUserDetails['password'] && $countResultThisUser==1)
  57.             {
  58.                 $queryLeader = $DBcon->query("SELECT name, lalyName, score FROM userlist ORDER BY score DESC");//("SELECT name, lalyName, score FROM userlist ORDER BY score DESC");
  59.                 //$rowLD = $queryLeader->fetch_array();
  60.                 //$countLDentry = $queryLeader->num_rows;
  61.  
  62.                 $json = mysqli_fetch_all($queryLeader, MYSQLI_BOTH);
  63.                 //print_r($json[0]);
  64.                 $rt = "";
  65.                 $num2 = 0;
  66.                 //if(count($json) < )
  67.  
  68.                 for($i = 0;$i < count($json);$i++)
  69.                 {
  70.                     if($i >= $max){break;}
  71.                     $rt .= $json[$i]['name'].$elementSeperator.$json[$i]['lalyName'].$elementSeperator.$json[$i]['score'];
  72.                     if($i < count($json) - 1)
  73.                     {
  74.                         $rt .= $entrySeperator;
  75.                     }
  76.                 }
  77.                 echo "success".$entrySeperator.$rt;
  78.                 //print_r($queryLeader->num_rows);
  79.                 //echo json_encode($json );
  80.  
  81.                 //$uname = $rowLD['name'];
  82.                 //$uLalyname = $rowLD['lalyName'];
  83.                 //$score = $rowLD['score'];
  84.  
  85.                 //print_r($rowLD);
  86.                 //echo $rowLD[1];
  87.                 // echo "success##"."$mobNo"."##"."$uname"."##"."$uLalyname"."##"."$upass"."##"."$score"."##"."$lastActIdx"."##"."$lastPhaseIdx"."##"."$lastDayIdx"."##"."$lastWeekIdx"
  88.                 // ."##"."$lalyTag"."##"."$malaTag"."##"."$secureTag"."##"."$missScre";
  89.             }
  90.             else
  91.             {
  92.                 echo "error##invalidUsrDetails";
  93.             }  
  94.         }
  95.         else
  96.         {
  97.             echo "error##banned";
  98.         }
  99.         $DBcon->close();
  100.     }
  101.     else
  102.     {
  103.         echo "error##corruptData";
  104.     }
  105.    
  106. }
  107. else
  108. {
  109.     echo "error##improperFormat";
  110. }
  111.  
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement