Advertisement
Guest User

join.php

a guest
Jul 20th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.69 KB | None | 0 0
  1. <?
  2. //die("&e=19");
  3. // Flash sends r=RoomId&id=TmpId&s=Attributes of Player String&k=Users Key
  4. // PHP returns
  5. // &l=Character in file we are on&p=playersInfo in this room seperated by newline
  6.  
  7. // Get all the variables and common functions
  8. define('PROGRAM_OPEN', true);               // This is to protect Included files, if they try to load it directly they may be able to by-pass some security checks, ensure they are going through the right channels
  9. //if ($REQUEST_METHOD != "POST") {printf('&e=4','Invalid Input');exit;} // Only accept it via post
  10. include('setup.inc.php');               // Load the Variables and Code Snippets
  11.  
  12. // Check data to make sure clean
  13. if (!IsANumber($r)) {Dienice('&e=17','Room Number Must be a Number');}
  14. if (!IsANumber($id)) {Dienice('&e=18','Player Number Must be a Number');}
  15. $Attributes = CleanInput($s);           // Make sure no slashes, but some configuration would already have them added
  16. $k = CleanForDB(CleanInput($k));
  17.  
  18. ConnectDB();
  19.  
  20. // Get this Users Information and save in $User
  21. $sql = "SELECT * FROM $Database[TablePrefix]ChatLiveUsers WHERE TmpId = '$id' AND Pass='$k'";
  22. $result = mysql_query ($sql) or Dienice('&e=19', $sql);
  23. $User = mysql_fetch_array($result);
  24. mysql_free_result($result);
  25.  
  26. // Announce their entrance to this room
  27. $filename2 = "$DataDirectory/Room$r." . date("Ymd") . ".txt";
  28. $fp2 = @fopen ($filename2, "a");    // Open the file for writting file pointer at the end, if it does not exist, create it
  29. if (!$fp2) {$fp2 = @fopen ($filename2, "a");}   // Try again
  30. if (!flock($fp2, 2)) {Dienice("&e=13","Text File could not be locked check permissions");}
  31. fwrite($fp2, "$id|$Attributes|$User[Name]\n");  // Save this new command
  32. fseek($fp2,0,SEEK_END);
  33. $Line = ftell($fp2);        // Since we just added a line, figure out what line we are on, everything after that does not matter
  34. fclose($fp2);
  35.  
  36. // Update their information
  37. $Attributes = CleanForDB($Attributes);
  38. $sql = "UPDATE $Database[TablePrefix]ChatLiveUsers SET RoomId='$r',LastCheckIn='$now',Attributes='$Attributes' WHERE TmpId = '$id' AND Pass='$k'";
  39. $result = mysql_query ($sql) or Dienice('&e=19', $sql);
  40.  
  41. include('drop.inc.php');                // Go through the database
  42.  
  43. // Drop them out of the room they are in (if they haven't entered one then it skips over this)
  44. if ($User[RoomId] != $r) {AnnounceDrop($User[RoomId],$id,'1');}
  45.  
  46.  
  47. // Send them a list of all the players in this room
  48. printf("&e=0&l=$Line&p=");
  49. $sql = "SELECT * FROM $Database[TablePrefix]ChatLiveUsers WHERE RoomId = '$r'";
  50. $result = mysql_query ($sql) or Dienice("Error in SQL statement", $sql);
  51. if (mysql_numrows($result) > 0)
  52.    {while ($Item = mysql_fetch_array($result))
  53.     {printf("$Item[TmpId]|$Item[Attributes]|$Item[Name]\n");
  54.     }
  55.    }
  56. mysql_close();
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement