index.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. require_once "../../config.php";
  3. if(isset($_GET['schedid'])){
  4. $schedid = $_GET['schedid'];
  5. }
  6. if(isset($_GET['hostname'])){
  7. $hostname = $_GET['hostname'];
  8. }
  9. $authorisationheader = getallheaders()['Authorization'];
  10. $getauthqry = mysqli_query($link, "SELECT 1 FROM assets WHERE token = '$authorisationheader' AND name = '$hostname' LIMIT 1");
  11. while($row = mysqli_fetch_array($getauthqry)){
  12. if($row['1'] == '1'){
  13. $auth = 'ok';
  14. }
  15. }
  16. if($auth == 'ok'){
  17. $getassetqry = mysqli_query($link, "SELECT * FROM assets WHERE token = '$authorisationheader' AND name = '$hostname'");
  18. while($row = mysqli_fetch_array($getassetqry)){
  19. $assetid = $row['id'];
  20. $active = $row['active'];
  21. }
  22. if($active == 1){
  23. $status = trim($_POST["status"]);
  24. $output = trim($_POST["output"]);
  25. $date = new \DateTime();
  26. $datenow = $date->format("Y-m-d H:i:s");
  27. $sql = "UPDATE schedules SET status = ?, output = ? WHERE id = ?";
  28. if($stmt = mysqli_prepare($link, $sql)){
  29. mysqli_stmt_bind_param($stmt, "ssi", $status, $output, $schedid);
  30. if(mysqli_stmt_execute($stmt)){
  31. exit();
  32. } else{
  33. echo 0;
  34. }
  35. }
  36. }
  37. }