postactions.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. $scriptname = trim($_POST["scriptname"]);
  21. $editscript = "UPDATE scripts set name = ?, shell = ?, data = ? where id = $script";
  22. if($stmt = mysqli_prepare($link, $editscript)){
  23. mysqli_stmt_bind_param($stmt, "sss", $scriptname, $shell, $data);
  24. if(mysqli_stmt_execute($stmt)){
  25. header("location: ?a=scripts&script=$script");
  26. exit;
  27. }else{
  28. echo "Oops! Something went wrong. Please try again later.";
  29. }
  30. }
  31. }
  32. }elseif($place == "scripts" && $do == "newscript"){
  33. if(isset($script)){
  34. $shell = trim($_POST["shell"]);
  35. $data = trim($_POST["script"]);
  36. $scriptname = trim($_POST["scriptname"]);
  37. $addscript = "INSERT into scripts (name, shell, data) values (?, ?, ?)";
  38. if($stmt = mysqli_prepare($link, $addscript)){
  39. mysqli_stmt_bind_param($stmt, "sss", $scriptname, $shell, $data);
  40. if(mysqli_stmt_execute($stmt)){
  41. header("location: ?a=scripts&script=$script");
  42. exit;
  43. }else{
  44. echo "Oops! Something went wrong. Please try again later.";
  45. }
  46. }
  47. }
  48. }