Explorar o código

Added script edit

3ndur4nce %!s(int64=3) %!d(string=hai) anos
pai
achega
fa0e625c22
Modificáronse 4 ficheiros con 68 adicións e 2 borrados
  1. 3 0
      WebPage/place/getvalues.php
  2. 15 0
      WebPage/place/postactions.php
  3. 34 2
      WebPage/place/scripts.php
  4. 16 0
      WebPage/style.css

+ 3 - 0
WebPage/place/getvalues.php

@@ -22,6 +22,9 @@ if(isset($_GET['sched'])){
 if(isset($_GET['newscriptid'])){
     $newscriptid = $_GET['newscriptid'];
 }
+if(isset($_GET['script'])){
+    $script = $_GET['script'];
+}
 if(isset($_GET['req'])){
     $req = trim($_GET['req']);
 }

+ 15 - 0
WebPage/place/postactions.php

@@ -13,4 +13,19 @@ if($place == "assets" && $sched == "save"){
             }
         }
     }
+}elseif($place == "scripts" && $do == "scriptedit"){
+    if(isset($script)){
+        $shell = trim($_POST["shell"]);
+        $data = trim($_POST["script"]);
+        $editscript = "UPDATE scripts set shell = ?, data = ? where id = $script";
+        if($stmt = mysqli_prepare($link, $editscript)){
+            mysqli_stmt_bind_param($stmt, "ss", $shell, $data);
+            if(mysqli_stmt_execute($stmt)){
+                header("location: ?a=scripts&script=$script");
+                exit;
+            }else{
+                echo "Oops! Something went wrong. Please try again later.";
+            }
+        }
+    }
 }

+ 34 - 2
WebPage/place/scripts.php

@@ -6,6 +6,38 @@
     while($row = mysqli_fetch_array($getscriptsqry)){
         echo "<a href='?a=scripts&script=".$row['id']."' class='collumnbutton'>".$row['name']."</a>";
     }
+echo "</div>";
 
-    ?>
-</div>
+    if(isset($script)){
+        $getscriptsqry = mysqli_query($link, "select * from scripts where id = $script");
+        while($row = mysqli_fetch_array($getscriptsqry)){
+            $scriptname = $row['name'];
+            $scriptdata = $row['data'];
+            $shell = $row['shell'];
+        }
+        if($shell == 'powershell'){
+            $powershell = "powershell' selected='selected";
+            $cmd = "cmd";
+            $bash = "bash";
+        }elseif($shell == 'cmd'){
+            $powershell = "powershell";
+            $cmd = "cmd' selected='selected";
+            $bash = "bash";
+        }elseif($shell == 'bash'){
+            $powershell = "powershell";
+            $cmd = "cmd";
+            $bash = "bash' selected='selected";
+        }
+        echo "<div class='editcollumn'>
+        <a>$scriptname</a><br>
+        <form action='?a=scripts&script=$script&do=scriptedit' method='POST'>
+            <select id='shell' name='shell'>
+                <option value='$cmd'>CMD</option>
+                <option value='$powershell'>PowerShell</option>
+                <option value='$bash'>BASH</option>
+            </select><br>
+            <textarea type='longtext' name='script' class='input-script' placeholder='Enter Script Here'>$scriptdata</textarea>
+            <input type='submit' class='button' value='Save'>
+            </form>
+        ";
+    }

+ 16 - 0
WebPage/style.css

@@ -279,3 +279,19 @@
     background-color:#0e1824;
     color:white;
 }
+.input-script{
+    margin-top:10px;
+    width:500px;
+    height:500px;
+    border: 3px black solid;
+    border-radius: .5rem;
+    overflow-y: auto;
+}
+.editcollumn{
+    display:block;
+    float:left;
+    width:50%;
+    border-right: 10px solid white;
+    height:90%;
+    overflow-y:auto;
+}