1+ <?php
2+ // get the process ID parameter from the URL
3+ $ pid = $ _REQUEST ["PID " ];
4+
5+ $ command = "ps " . $ pid ;
6+
7+ // check if the PID is still running
8+ $ output = shell_exec ($ command );
9+ $ returnValue = "Alert!!! - Process ID " . $ pid . " is no longer running. Raspberry-PI-Q has exited! " ;
10+
11+ if ($ output !== "" )
12+ {
13+ $ len = strlen ($ output );
14+ if (stristr ($ output , substr ("Raspberry-PI-Q.py " , 0 , $ len )))
15+ {
16+ $ returnValue = "Process ID " . $ pid . " is still executing. " ;
17+ }
18+ }
19+
20+ echo $ returnValue ;
21+ ?>
22+ <html>
23+ <head>
24+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
25+ <script type="text/javascript">
26+ function ClearLogs()
27+ {
28+ // Erase/replace the current content of the text area with the following message
29+ $('#interactiveData').text("Log content has been erased!\n");
30+ }
31+ var lastUpdate = new Date("2017-01-01");
32+ var auto_refresh = setInterval(
33+ function ()
34+ {
35+ $('#pidUpdate').load('processID.php?PID=<?php echo $ pid ?> ').fadeIn("slow");
36+ $.getJSON("https://dweet.io/get/dweets/for/Raspberry-PI-Q-Michael_log", function(data) {
37+ var arrayLength = data.with.length;
38+ // go through list of items from DWEEP in reverse order to match chronological events
39+ for (i = arrayLength - 1; i >= 0; i--)
40+ {
41+ var item = data.with[i];
42+ var itemDate = new Date(item.created);
43+ if (itemDate > lastUpdate)
44+ {
45+ $('#interactiveData').append(itemDate.toLocaleString() + " - " + item.content.log + "\n");
46+ lastUpdate = itemDate;
47+ }
48+ }
49+ });
50+ }, 10000); // refresh every 10 seconds. Number is in milliseconds
51+ </script>
52+
53+ <title>Raspberry-PI-Q by michmike</title>
54+ </head>
55+ <body>
56+ <h1>Raspberry-PI-Q by michmike</h1>
57+ <div id="shellOutput"><textarea id="interactiveData" rows="10" cols="160"><?php echo $ shellexecOutput ?> </textarea></div>
58+ </body>
59+ </html>
0 commit comments