Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
nodejs
00list_files.php
00list_files.php
<?php //get file uri if(!empty($_GET)) extract($_GET); else $skript='01def_simple.js'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?=$skript?> evaluate</title> <script src="<?=$skript?>"></script> <link rel="stylesheet" href="/assets/"> <!-- bootstrap --> <meta name="viewport" content="width=device-width, maximum-scale=1.0"> <link rel="stylesheet" type="text/css" href="/assets/bootstrap/3.2.0/dist/css/bootstrap.min.css"> <style> body { padding-top: 10px; } .konzola { background-color:#180512; color:white; min-height:200px; font:14px Courier; padding:10px; } .konzola>pre { background-color:#180512; border:0px solid red; color:white; } .konzola .komand { font-size:larger; color:#F0BAF3; } </style> </head> <body> <div class="container-fluid"> <div class="col-sm-4"> <div class="well"> <!-- List all files --> <h3>Test JS script file</h3> Selected file: <b style="color:#C10089"><?=$skript?></b> <br>Compare console.log() outputs in browser and NodeJS. <br>Notice: Open browser's console in FireBUG! <br><br> <!-- List all files in directory --> <ol style="font:12px Verdana"> <?php $file_arr=scandir('./'); foreach($file_arr as $file): if($file!='.' && $file!='..' && $file!='00list_files.php'): ?> <li><a href="./00list_files.php?skript=<?=$file?>"><?= $file ?></a></li> <?php endif; endforeach; ?> </ol> </div> </div> <div class="col-sm-8"> <div class="col-sm-12"> <!-- Previe JS source code --> <?php $source_code=file_get_contents($skript); ?> <h4>..:: Source code - <?= $skript ?> ::..</h4> <div class="konzola"> <pre><?= $source_code ?></pre> </div> </div> <div class=""> </div> <div class="col-sm-12"> <!-- NodeJS console output --> <?php //ececute node $command='node '.$skript; $output=shell_exec($command); $ps_list=shell_exec('ps -aux | grep node'); ?> <h4>..:: NodeJS Console - <?= $skript ?> ::..</h4> <div class="konzola"> <b class="komand">$ <?=$command?></b> <br> <pre><?= $output ?></pre> </div> <!-- list all node processes --> <pre> <b class="komand">$ps -aux | grep node</b> (list all node processes) <?=$ps_list?> </pre> </div> </div> </div> </body> </html>
Reload page
Preview
W3C validation
Edit Code
JS Console