Skip to content

Commit 7a9df36

Browse files
committed
PR - tariqbuilds#11: changed response type to be application/json per tariqbuilds#10
2 parents 629ff29 + 3931119 commit 7a9df36

13 files changed

+32
-11
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ <h3> Processes </h3>
323323
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.min.js"></script>
324324
<script src="js/odometer.js"></script>
325325
<script src="js/magic_happens_here.js"></script>
326+
<script src="js/base.js"></script>
326327

327328
</body>
328329
</html>

sh/df.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
exec('df -h|awk \'{print $1","$2","$3","$4","$5","$6}\'',$result);
4-
4+
header('Content-Type: application/json; charset=UTF-8');
5+
56
echo "[";
67
$x = 0;
78
$max = count($result)-1;

sh/hostname.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<?php echo shell_exec('hostname');
1+
<?php
2+
3+
header('Content-Type: application/json; charset=UTF-8');
4+
echo shell_exec('hostname');

sh/ip.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
exec('curl http://ipecho.net/plain; echo',$result2);
77

8+
header('Content-Type: application/json; charset=UTF-8');
9+
810
echo '[[','"external ip","',$result2[0],'"]';
911
$x = 0;
1012
$max = count($result)-1;
@@ -16,4 +18,3 @@
1618
$x++;
1719
}
1820
echo ']';
19-
//echo json_encode($r);

sh/issue.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<?php echo shell_exec('lsb_release -ds;uname -r') ;
1+
<?php
2+
header('Content-Type: application/json; charset=UTF-8');
3+
echo shell_exec('lsb_release -ds;uname -r') ;

sh/mem.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
//exec('cat /proc/meminfo|awk \'{print $1","$2}\'',$result);
44
//exec('free -m|awk \'{print $1","$2","$3","$4}\'',$result);
5+
56
exec('free -tmo|awk \'{print $1","$2","$3-$6-$7","$4+$6+$7}\'',$result);
6-
echo json_encode( explode(',',$result[1]) );
7+
header('Content-Type: application/json; charset=UTF-8');
8+
echo json_encode( explode(',',$result[1]) );
9+

sh/online.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
{
99
$result[] = explode(",", $user);
1010
}
11+
header('Content-Type: application/json; charset=UTF-8');
1112
echo json_encode($result);

sh/ps.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// each row (including header) is in csv format
44
exec('ps -aux|awk '."'{print ".'$1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11'."}'", $result);
55

6+
header('Content-Type: application/json; charset=UTF-8');
7+
68
echo "[";
79
$x = 0;
810
$max = count($result)-1;

sh/test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
$milli = shell_exec('awk \'{print $1*1000}\' /proc/uptime');
44

5+
header('Content-Type: application/json; charset=UTF-8');
6+
57
echo (int)($milli)/(1000*60*60);

sh/top.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
1818
*/
1919

20+
header('Content-Type: application/json; charset=UTF-8');
21+
2022
$final = '[';
2123

2224
// Extract the first row of results
@@ -56,6 +58,4 @@
5658

5759
$final .= ']';
5860

59-
echo($final);
60-
61-
61+
echo($final);

sh/uptime.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<?php echo (int) (shell_exec('cat /proc/uptime')/(60*60));
1+
<?php
2+
3+
header('Content-Type: application/json; charset=UTF-8');
4+
echo (int) (shell_exec('cat /proc/uptime')/(60*60));

sh/users.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
exec('awk -F: \'{ if ($3<=499) print "system,"$1","$6; else print "user,"$1","$6; }\' < /etc/passwd',$result);
44

5+
header('Content-Type: application/json; charset=UTF-8');
56
echo "[";
67
$x = 0;
78
$max = count($result)-1;
@@ -13,4 +14,4 @@
1314
echo json_encode( $line );
1415
echo ($x-1==$max)?'':',';
1516
}
16-
echo ']';
17+
echo ']';

sh/whereis.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
exec('whereis php node mysql vim python ruby java apache2 nginx openssl vsftpd make'.
44
'|awk \'{ split($1, a, ":");if (length($2)==0) print a[1]",Not Installed"; else print a[1]","$2;}\'',$result);
55

6-
6+
header('Content-Type: application/json; charset=UTF-8');
7+
78
echo "[";
89
$x = 0;
910
$max = count($result)-1;

0 commit comments

Comments
 (0)