<script type="text/javascript"> function complie() { document.getElementById("form1").action="fileInput.php?method=compile"; document.getElementById("form1").submit(); } function run() { document.getElementById("form1").action="fileInput.php?method=run"; document.getElementById("form1").submit(); } </script> <form name="form1" id="form1" method="post" action=""> <label for="inputText"></label> <div align="center"> <p> <textarea name="inputText" id="inputText" cols="100" rows="20" ><?php if(isset($_POST['inputText'])){print $_POST['inputText'];} ?></textarea> </p> <p> <label for="filename">input filename*</label> <input name="filename" type="text" id="filename" value="" size="20" maxlength="20"> <br> (Note: if you use the file name as "XXX.java", you should create your main class as "XXX" as well)</p> <p> <input type="button" name="button" id="button" value="Compile" onClick="complie()"> <input type="button" name="Run" id="Run" value="Run" onClick="run()"> </p> </div> </form> <table width="100%" border="0"> <tr> <td bgcolor="#00FFFF"> <div align="center"> <?php if(isset($_POST['inputText']) && $_POST['filename'] !=""){ $javaFileName = $_POST['filename']; $javaFilePath = "."; if(isset($_GET['method']) && $_GET['method'] == "compile"){ if(file_put_contents($javaFileName,$_POST['inputText'])) { exec('cd '.$javaFilePath.' && javac -verbose '.$javaFileName.' 2>&1',$text); if($text != NULL){ foreach($text as $subText) { print $subText."<br>"; } } } } else if(isset($_GET['method']) && $_GET['method'] == "run"){ if(file_put_contents($javaFileName,$_POST['inputText'])) { exec('cd '.$javaFilePath.' && javac '.$javaFileName.' 2>&1',$text); if($text != NULL){ foreach($text as $subText) { print $subText."<br>"; } } } $classFile = str_replace(".java","",$javaFileName); exec('cd '.$javaFilePath.' && java '.$classFile.' 2>&1',$text); if($text != NULL){ foreach($text as $subText) { print $subText."<br>"; } } } }else if(isset($_POST['inputText'])){ print '<span style="font-style: italic">Something is incorrect, please check file name that should not be blank.</span>'; } ?></div></td> </tr> </table>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง