postactions.php 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. if($place == "assets" && $sched == "save"){
  3. if(isset($newscriptid)){
  4. $schedtime = trim($_POST["datetime"]);
  5. $addsched = "INSERT INTO schedules (assetid, scriptid, runtime, userid) values (?, ?, ?, ?)";
  6. if($stmt = mysqli_prepare($link, $addsched)){
  7. mysqli_stmt_bind_param($stmt, "iisi", $asset, $newscriptid, $schedtime, $userid);
  8. if(mysqli_stmt_execute($stmt)){
  9. header("location: ?a=assets&asset=$asset&do=scripts");
  10. exit;
  11. }else{
  12. echo "Oops! Something went wrong. Please try again later.";
  13. }
  14. }
  15. }
  16. }elseif($place == "scripts" && $do == "scriptedit"){
  17. if(isset($script)){
  18. $shell = trim($_POST["shell"]);
  19. $data = trim($_POST["script"]);
  20. $editscript = "UPDATE scripts set shell = ?, data = ? where id = $script";
  21. if($stmt = mysqli_prepare($link, $editscript)){
  22. mysqli_stmt_bind_param($stmt, "ss", $shell, $data);
  23. if(mysqli_stmt_execute($stmt)){
  24. header("location: ?a=scripts&script=$script");
  25. exit;
  26. }else{
  27. echo "Oops! Something went wrong. Please try again later.";
  28. }
  29. }
  30. }
  31. }