daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Assuming config.php is already included
  3. $server = DB_HOST;
  4. $port = DB_PORT;
  5. $db_user = DB_USER;
  6. $pass = DB_PASSWORD;
  7. $db = DB_NAME;
  8.  
  9. $connection = mysqli_connect($server, $db_user, $pass, $db);
  10. if (!$connection) {
  11.     die("Connection failed: " . mysqli_connect_error());
  12. }
  13.  
  14. function checkUsername($username, $uuid) {
  15.     $return = '';
  16.     $username = mysqli_real_escape_string($connection, htmlspecialchars($username));
  17.     $checkExistingUsers = mysqli_query($connection, "SELECT username,uuid FROM cad_users WHERE username='$username'") or die(mysqli_error($connection));
  18.     $checkUUID = mysqli_fetch_object($checkExistingUsers);
  19.  
  20.     if ($username == '') {
  21.         $return = 'emptyString';
  22.     } else if ($username == null) {
  23.         $return = 'nullString';
  24.     } else if (mysqli_num_rows($checkExistingUsers) >= 1 && $checkUUID->uuid != $uuid) {
  25.         $return = 'userExists';
  26.     } else if (containsSpecials($username)) {
  27.         $return = 'containsSpecials';
  28.     } else {
  29.         $return = 'valid';
  30.     }
  31.     return $return;
  32. }
  33.  
  34. function checkCallsign($callsign, $uuid) {
  35.     $return = '';
  36.     $username = mysqli_real_escape_string($connection, htmlspecialchars($username));
  37.     $checkExistingUsers = mysqli_query($connection, "SELECT callsign,uuid FROM cad_units WHERE callsign='$callsign'") or die(mysqli_error($connection));
  38.     $checkUUID = mysqli_fetch_object($checkExistingUsers);
  39.  
  40.     if ($username == '') {
  41.         $return = 'emptyString';
  42.     } else if ($username == null) {
  43.         $return = 'nullString';
  44.     } else if (mysqli_num_rows($checkExistingUnits) >= 1 && $checkUUID->uuid != $uuid) {
  45.         $return = 'exists';
  46.     } else if (containsSpecials($username)) {
  47.         $return = 'containsSpecials';
  48.     } else {
  49.         $return = 'valid';
  50.     }
  51.     return $return;
  52. }
  53.  
  54. function containsSpecials($string) {
  55.     $illegal = "`~!@#$%^&*()=+{}[]\|;:',<>/?\\\"";
  56.     if (false === strpbrk($string, $illegal)) {
  57.         return false;
  58.     } else {
  59.         return true;
  60.     }
  61. }
  62.  
  63. function stripString($string) {
  64.     return mysqli_real_escape_string($connection, htmlspecialchars($string));
  65. }
  66. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top