Guest User

Untitled

a guest
Apr 22nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. define('PUN_ROOT', './');
  4. require PUN_ROOT.'include/common.php';
  5.  
  6.  
  7. $validUsers = array(
  8. 'kopkop' => 'kopkop',
  9. );
  10.  
  11. $userName = trim(arrayGet($_GET, 'user', ''));
  12. $passWord = trim(arrayGet($_GET, 'pass', ''));
  13. $auth = trim(arrayGet($_GET, 'user', ''));
  14.  
  15. $result = $db->query('SELECT username FROM '.$db->prefix. 'pk_players WHERE user="'.$username.'"') or error('Unable to fetch player info', __FILE__, __LINE__, $db->error());
  16.  
  17. if(0 == strlen($userName)){
  18. authError('Username not set');
  19.  
  20. redirect('char.php?user='.$id
  21. }else if(0 == strlen($passWord)){
  22. authError('Password not set');
  23.  
  24. redirect('char.php?user='.$id
  25. }
  26.  
  27.  
  28. foreach($validUsers as $uName => $pWord){
  29. $uName = md5($uName);
  30. $pWord = md5($pWord);
  31. if($uName === $userName && $pWord === $passWord){
  32. die('success');
  33. }
  34. }
  35. authError('Invalid username/password');
  36.  
  37. //Functions:
  38.  
  39. function authError($errMsg){
  40. echo('Authorization failed'."\n<br/>".$errMsg);
  41. exit;
  42. }
  43.  
  44. function arrayGet(&$arr, $key, $defaultVal){
  45. if(array_key_exists($key, $arr)){
  46. return $arr[$key];
  47. }
  48. return $defaultVal;
  49. }
  50. ?>
Add Comment
Please, Sign In to add comment