Guest User

Untitled

a guest
Nov 23rd, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | None | 0 0
  1. <?php
  2. /*
  3. CheckPlayer is a component of the OWHAutoRank plugin. It is intended to check a websites associated MySQL for a related User account.
  4. CheckPlayer, and OWHAutoRank were written by Christopher 'Raniy@omgwtfhax.info' Lohman for OMGWTFHAX.info.(c)2012
  5.  
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without modification, are
  8.  * permitted provided that the following conditions are met:
  9.  *
  10.  *    1. Redistributions of source code must retain the above copyright notice, this list of
  11.  *       conditions and the following disclaimer.
  12.  *
  13.  *    2. Redistributions in binary form must reproduce the above copyright notice, this list
  14.  *       of conditions and the following disclaimer in the documentation and/or other materials
  15.  *       provided with the distribution.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
  18.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  19.  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
  20.  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22.  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  23.  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24.  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26.  *
  27.  * The views and conclusions contained in the software and documentation are those of the
  28.  * authors and contributors and should not be interpreted as representing official policies,
  29.  * either expressed or implied, of anybody else.
  30. */
  31.  
  32. // EDIT ALL OF THESE VARIABLES TO REFLECT /YOUR/ SETUP.
  33.  
  34. // Define constants for mysql
  35. $MySQLUser = "mysqluser";
  36. $MySQLPass = "someverycleverpassword";
  37. $MySQLDBName = "forums";
  38. $MySQLString = "localhost";
  39.  
  40. // Define constants for your Websites database
  41. $MySQLTableName = "users";
  42. $MySQLFieldName = "username";
  43.  
  44.  
  45.  
  46.  
  47. // DO NOT EDIT BELOW HERE!!!!!
  48.  
  49. // Check for Querystring 'PlayerName'
  50. $PlayerName = $_POST['playername'];
  51. if($PlayerName == "")
  52. {
  53.     $PlayerName = $_GET['playername'];
  54. };
  55.  
  56. // Error controlling... If 'PlayerName' <1 or >16 return false. Not a valid 'PlayerName'
  57. if(strlen($PlayerName) <1 || strlen($PlayerName) > 16){
  58.     die("false");
  59. };
  60.  
  61. // Check MySQL for User with 'PlayerName' ignoring case.
  62. // If User exists then echo 'true'
  63.     $MyMySQL = mysql_connect($MySQLString,$MySQLUser,$MySQLPass) or die("Couldnt Connect to MySQL! ERROR!");
  64.     mysql_select_db($MySQLDBName,$MyMySQL) or die("Couldnt Select our DB! ERROR!");
  65.    
  66.     $NameQuery = "select `" . $MySQLFieldName . "` from `". $MySQLTableName . "` WHERE `" . $MySQLFieldName . "` = '" . $PlayerName . "' LIMIT 1";
  67.     $NameResult = mysql_query($NameQuery,$MyMySQL) or die("I was unable to retrieve the user list!");
  68.     $NumNames = mysql_num_rows($NameResult);
  69.     if($NumNames == 1){
  70.         die("true");
  71.     } else {
  72.         die("false");
  73.     };
  74.    
  75. ?>
Add Comment
Please, Sign In to add comment