getButtons.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. include_once('includes/db_connect.php');
  3. include_once('includes/global_functions.php');
  4. $radioid = $_GET['radioid'];
  5. $radiomac = $_GET['radiomac'];
  6. if($radioid == "" && $radiomac == ""){
  7. print(json_encode([error => "Not a valid radioid"]));
  8. die();
  9. }else{
  10. if($radiomac != ""){
  11. $radiomac = str_replace(':', '', $radiomac);
  12. $radioid = substr($radiomac, 6 , 11);
  13. }
  14. $array = array();
  15. if($stmt = $mysqli -> prepare("SELECT id, buttonid, name, streamurl, streamport, streamip FROM PresetRadioStream LEFT JOIN users ON users.uid = PresetRadioStream.uid WHERE radiotoken=? LIMIT 5")){
  16. $stmt -> bind_param("s", $radioid);
  17. $stmt -> execute();
  18. $stmt -> bind_result($id, $bid, $name, $streamurl, $streamport, $streamip);
  19. while($result = $stmt -> fetch()){
  20. array_push($array, array( id=> $id,
  21. bid => $bid,
  22. name => $name,
  23. ip => $streamip,
  24. port => $streamport,
  25. url => $streamurl,
  26. )
  27. );
  28. };
  29. $stmt -> close();
  30. }
  31. print(json_encode($array, JSON_UNESCAPED_SLASHES));
  32. }