Advertisement
jared314

Untitled

Aug 6th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2.  
  3. $dbConn = mysql_connect('localhost', '****', '****')
  4. or die(print_r(mysql_error()));
  5.  
  6. mysql_select_db('base_logger') or die(print_r(mysql_error()));
  7.  
  8. $token = $_POST['token'];
  9. $ign = $_POST['ign'];
  10. $event = $_POST['event'];
  11. $discription = $_POST['discription'];
  12. $id = $_POST['id'];
  13.  
  14. $user_id = validateToken($token, $id);
  15.  
  16. if ($user_id) {
  17. enterRecord($ign, $event, $discription, $user_id, $token);
  18. } else {
  19. echo 'error';
  20. }
  21.  
  22. function enterRecord($ign, $event, $discription, $user_id, $token) {
  23. $query = "INSERT INTO logs (user_id, ign, event, discription, timestamp, token) VALUES ('".$user_id."', '".dbEsc($ign)."', ".$event.", '".dbEsc($discription)."', NOW(), '".dbEsc($token)."')";
  24. $result = mysql_query($query);
  25. if ($result) {
  26. echo 'sucess';
  27. } else {
  28. echo 'error';
  29. }
  30. }
  31.  
  32. function validateToken($token, $id) {
  33. $query = "select user_id from tokens where token = '".dbEsc($token). "' AND computer_id = ".dbEsc($id). ";";
  34. $result = mysql_query($query);
  35. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  36. return $row['user_id'];
  37. }
  38.  
  39. function dbEsc($theString) {
  40. $theString = mysql_real_escape_string($theString);
  41. return $theString;
  42. }
  43.  
  44. function dbError(&$xmlDoc, &$xmlNode, $theMessage) {
  45. $errorNode = $xmlDoc->createElement('mysqlError', $theMessage);
  46. $xmlNode->appendChild($errorNode);
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement