Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2.  
  3. if( !$HeaderSent )
  4. {
  5. if( !empty( $_POST ) )
  6. {
  7. $Username = strtolower( $_POST["mocuser"] );
  8. $Password = strtolower( $_POST["mocpass"] );
  9.  
  10. $SQLCon = mysql_connect( SETTING_MYSQL_HOST, SETTING_MYSQL_USER, SETTING_MYSQL_PASS );
  11. if( $SQLCon )
  12. {
  13. if( mysql_select_db( SETTING_MYSQL_DB ) )
  14. {
  15. $SQLQuery = mysql_query( "SELECT * FROM users ORDER BY id ASC;" );
  16. while( $User = mysql_fetch_array( $SQLQuery ) )
  17. {
  18. if( strtolower( $User["username"] ) == strtolower( $Username ) )
  19. {
  20. if( $User["password"] == $Password )
  21. {
  22. while( true )
  23. {
  24. $Cookie = GenerateCookie( 20 );
  25. $SQLQuery2 = mysql_query( "SELECT * FROM users WHERE cookie = '".$Cookie."';" );
  26. if( !mysql_fetch_array( $SQLQuery2 ) )
  27. {
  28. mysql_query( "UPDATE users SET cookie = '".$Cookie."' WHERE id = '".$User["id"]."';" );
  29. setcookie( "cid", $Cookie, time()+7200 );
  30. header( "Refresh: 0;URL=index.php?page=index" );
  31. break;
  32. }
  33. }
  34. }
  35. else
  36. {
  37. die( "Wrong password!" );
  38. }
  39. }
  40. else
  41. {
  42. die( "No such username!" );
  43. }
  44. }
  45. }
  46. else
  47. {
  48. die( "Could not select DB" );
  49. }
  50. }
  51. else
  52. {
  53. die( "Could not connect to MySQL service!" );
  54. }
  55. }
  56. }
  57. else
  58. {
  59. if( IsLoggedIn())
  60. {
  61. die( "You're already logged in" );
  62. }
  63. }
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement