Advertisement
Guest User

Untitled

a guest
Feb 15th, 2009
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.08 KB | None | 0 0
  1. <?php
  2. /*
  3. AccountCheckEngine.php coded by Apoc@MMOwned.com & Apoc@ApocDev.com
  4. */
  5.  
  6. define(US_LOGIN_URL, 'https://www.blizzard.com/login/login.xml?referer=https%3A%2F%2Fwww.worldofwarcraft.com%2Faccount%2F&loginType=wow');
  7. define(EU_LOGIN_URL, 'https://eu.blizzard.com/login/login.xml?loginType=wow&referer=https%3A%2F%2Fwww.wow-europe.com%2Faccount%2F');
  8.  
  9. /* Checks to make sure the web host even supports cURL. */
  10. function checkBasicCURLFunctions()
  11. {
  12.     if(!function_exists("curl_init") || !function_exists("curl_setopt") || !function_exists("curl_exec") || !function_exists("curl_close"))
  13.     {
  14.         return false;
  15.     }
  16.   else
  17.   {
  18.     return true;
  19.   }
  20. }
  21.  
  22. /* Checks the specified password to see if it's valid or not */
  23. function CheckValidPassword($password)
  24. {
  25.     if (strlen($password) >= 8 && strlen($password) <=16)
  26.     {
  27.         // Return if there were no matches.
  28.         return preg_match('/^(?=.*\d)(?=.*[a-zA-Z])(?!.*[^\w!"#$,%]).{8,16}$/', $password) == 0;
  29.     }
  30.     return false;
  31. }
  32.  
  33. /* Checks the specified username to see if it's valid or not */
  34. function CheckValidUsername($username)
  35. {
  36.     if (strlen($username) >= 3 && strlen($username) <=16)
  37.     {
  38.         // Return if there were no matches.
  39.         return preg_match('/^\w{3,16}$/', $username) == 0;
  40.     }
  41.     return false;
  42. }
  43.  
  44. /* Checks the specified username and password to see if they're valid or not */
  45. function CheckValidAccount($username, $password)
  46. {
  47.     // Checks all the WoW specific account verifications prior to web based login.
  48.     if ($username != $password)
  49.     {
  50.         return CheckValidUsername($username) && CheckValidPassword($password);
  51.     }
  52.     return false;
  53. }
  54.  
  55. /* Runs the actual login process */
  56. function _Login($username, $password, $url)
  57. {
  58.     if (!CheckValidAccount($username, $password))
  59.     {
  60.         // Not a valid account. Don't bother going any further!
  61.         return "FAIL: Username/password is not allowed!";
  62.     }
  63.     if (!checkBasicCURLFunctions)
  64.     {
  65.         return "FAIL: cURL not available!";
  66.     }
  67.     $postvars = "accountName=$username&password=$password";
  68.     $ch = curl_init($url);
  69.     curl_setopt($ch, CURLOPT_POST, 1); // Sending a POST request
  70.     curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); // Setup the POST variables
  71.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Just go along with any redirects
  72.     curl_setopt($ch, CURLOPT_HEADER, 0); // We don't want to return any HTTP headers
  73.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // And we want the return contents, instead of a bool value.
  74.     $returnedPage = curl_exec($ch); // Get our stuff!
  75.     curl_close($ch);
  76.    
  77.     if (strstr($returnedPage, "Invalid account name or password"))
  78.     {
  79.         return "FAIL: Invalid account name or password";
  80.     }
  81.     else
  82.     {
  83.         return "SUCCESS";
  84.     }
  85. }
  86.  
  87. /* Attempts to login to the US account management website
  88.  
  89. Returns: SUCCESS on login, a fail message otherwise.
  90.  
  91. */
  92. function CheckUsLogin($username, $password)
  93. {
  94.     return _Login($username, $password, US_LOGIN_URL);
  95. }
  96.  
  97. /* Attempts to login to the EU account management website
  98.  
  99. Returns: SUCCESS on login, a fail message otherwise.
  100.  
  101. */
  102. function CheckEuLogin($username, $password)
  103. {
  104.     return _Login($username, $password, EU_LOGIN_URL);
  105. }
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement