Guest User

Untitled

a guest
Apr 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 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. }else if(0 == strlen($passWord)){
  20. authError('Password not set');
  21.  
  22. redirect('char.php?user='.$id
  23. }
  24.  
  25.  
  26. foreach($validUsers as $uName => $pWord){
  27. $uName = md5($uName);
  28. $pWord = md5($pWord);
  29. if($uName === $userName && $pWord === $passWord){
  30. die('success');
  31. }
  32. }
  33. authError('Invalid username/password');
  34.  
  35. //Functions:
  36.  
  37. function authError($errMsg){
  38. echo('Authorization failed'."\n<br/>".$errMsg);
  39. exit;
  40. }
  41.  
  42. function arrayGet(&$arr, $key, $defaultVal){
  43. if(array_key_exists($key, $arr)){
  44. return $arr[$key];
  45. }
  46. return $defaultVal;
  47. }
  48. ?>
Add Comment
Please, Sign In to add comment