Browse Source

first release

Sunit Kumar Nandi 11 years ago
commit
c7f99ac8ad
5 changed files with 119 additions and 0 deletions
  1. 7 0
      header.html
  2. 18 0
      index.html
  3. 20 0
      input.html
  4. 40 0
      output.php
  5. 34 0
      textinput.php

+ 7 - 0
header.html

@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+
+<h1 align="center">GCC web interface</h1>
+<p align="center">By Sunit Kumar Nandi (CSE/12/365) and Kirtiman Mishra (CSE/12/367)</p>
+
+</html>

+ 18 - 0
index.html

@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>	
+
+<head>
+<title>Web interface for GCC compiler</title>
+</head>
+
+
+<frameset rows="20%,80%">
+ <frame name="header" src="header.html">
+   <frameset cols="60%,40%">
+      <frame name="input" src="input.html">
+      <frame name="output" src="output.php">
+   </frameset>
+</frameset>
+
+
+</html>

+ 20 - 0
input.html

@@ -0,0 +1,20 @@
+<html>
+
+<body>
+<form name="form1" method="post" target="output" action="output.php?saving=1">
+Write your program here:
+<br>
+<textarea name="data" cols="80" rows="10">
+</textarea>
+<br><br><br>
+Standard input: <input type="text" name="stdin">
+<br><br>
+Command line arguments: <input type="text" name="args">
+<br><br>
+<input type="submit" value="Run">
+</form>
+<br>
+<a href="textinput.php" target="output">Click here to submit text file input</a>
+</body>
+
+</html>

+ 40 - 0
output.php

@@ -0,0 +1,40 @@
+<html>
+
+<body>
+<?php
+$saving = $_REQUEST['saving'];
+if ($saving == 1){ 
+$data = $_POST['data'];
+$args = $_POST['args'];
+$stdin= $_POST['stdin'];
+$unique = rand(1, 10000);
+$file = "prog".$unique.".c";
+$srcpath = "./".$file;
+$executable = "./"."prog".$unique;
+$fp = fopen($file, "w") or die("<p>Couldn't open $file for writing!</p>");
+fwrite($fp, $data) or die("<p>Couldn't write values to file!</p>"); 
+
+fclose($fp); 
+echo "<p>Saved to $file successfully!</p>";
+
+echo"<p>
+Compiling the program $file<br>
+Error list:<br>";
+$output1 = shell_exec("g++ $srcpath -o $executable 2>&1");
+echo "$output1";
+echo "</p>";
+echo "<p>Running the program:<br>";
+$output2 = shell_exec("echo $stdin | $executable $args");
+echo "$output2";
+echo "<br>
+</p>";
+
+shell_exec("rm -rf $srcpath $executable");
+}
+else {
+echo "<p>Enter your code in the left frame and hit run to display the output.</p>";
+}
+?>
+</body>
+
+</html>

+ 34 - 0
textinput.php

@@ -0,0 +1,34 @@
+<html>
+<body>
+<?php
+$saving = $_REQUEST['saving'];
+if ($saving == 1){ 
+$data = $_POST['data'];
+$unique = rand(1, 10000);
+$file = "text".$unique.".txt";
+
+$fp = fopen($file, "w") or die("<p>Couldn't open $file for writing!</p>");
+fwrite($fp, $data) or die("<p>Couldn't write values to file!</p>"); 
+
+fclose($fp); 
+echo "<p>Saved to $file successfully! You may now use $file as a text input for your program.</p>";
+}
+?>
+
+<p>
+<form name="form1" method="post" action="?saving=1">
+Write your text here:
+<br>
+<textarea name="data" cols="50" rows="10">
+This is the file you can use to provide input to your program and later on open it inside your program to process the input.
+</textarea>
+<br>
+<input type="submit" value="Save">
+<br>
+<br>
+<a href="output.php">Click here to close text input</a>
+</form>
+</p>
+
+</body>
+</html>