Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. // Connects to the db
  4. $dbconn = new mysqli("localhost", "i01qbpdb_locusja", "ninfa2812", "i01qbpdb_locus");
  5.  
  6. if($dbconn->connect_error){
  7. die("Connessione fallita " . $dbconn->connect_error);
  8. }
  9.  
  10. // Gets the data relevant to the "act"
  11. $act = $_REQUEST['act'];
  12. $rows = array();
  13.  
  14. $sqlNUOVO = "";
  15. $select = 'no';
  16. switch($act){
  17. case 'CHKUSER':
  18. $pwd = $_REQUEST['password'];
  19.  
  20. $sqlNUOVO = "select cognome from public.user where username = '" . $_REQUEST['user']. "' and password = '$pwd'";
  21. $consulta=pg_exec($dbconn, $sqlNUOVO);
  22. $numregs=pg_numrows($consulta);
  23. if( $numregs == 0 ){
  24. $rows['result'] = '0';
  25. }else{
  26. $rows['result'] = pg_result($consulta,0,'cognome');
  27. }
  28. /*
  29. scrive il LOG
  30. */
  31. $sqlNUOVO = "insert into logaccessi values ('" . $_REQUEST['user']. "',now(),'LOGON')";
  32. $consulta=pg_exec($dbconn, $sqlNUOVO);
  33. break;
  34.  
  35. // If we need to find the beacon ...
  36. case 'GET_BEACON':
  37. $sqlNUOVO = "SELECT `description`,`text`,`soundUrl` FROM `beacon` WHERE beaconId = '" . $_REQUEST['beaconId'] ."'";
  38. $select = 'exec';
  39. break;
  40. default:
  41. ;
  42. }
  43.  
  44. if($select == 'exec'){
  45. // Asks for the result of the query
  46. $result = $dbconn->query($sqlNUOVO);
  47. if($result->num_rows > 0){
  48. $rows = array();
  49. while($r = $result->fetch_assoc()){
  50. $rows[] = $r;
  51. }
  52. }
  53. }
  54.  
  55. $json = json_encode($rows);
  56. print $json;
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement