ajax.php 371 B

1234567891011121314
  1. <?php
  2. if(isset($_POST['type']) && $_POST['type']==="addNewIp")
  3. {
  4. $prevJson = json_decode(file_get_contents("db.json"));
  5. $newIp = new stdClass();
  6. $newIp->name = $_POST['name'];
  7. $newIp->schedule = $_POST['schedule'];
  8. $newIp->status = "off";
  9. $prevJson->{$_POST['ip']} = $newIp;
  10. file_put_contents("db.json",json_encode($prevJson));
  11. echo "did it";
  12. }
  13. ?>