1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/sources/sh/where.php

26 lines
793 B
PHP
Raw Normal View History

2014-06-02 13:38:03 +02:00
<?php
// Read list of programs to check from a list
if (file_exists("monitor"))
{
$data = file_get_contents("monitor");
$binaries = preg_split('~ ~', $data, NULL, PREG_SPLIT_NO_EMPTY);
}
// If file doesn't exist then use hard coded list
else
{
$binaries = explode(" ", "php node mysql vim python ruby java apache2 nginx openssl vsftpd make");
}
$path = 'PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:' . getenv('PATH');
$data = array();
foreach ($binaries as $b) {
$which = array();
exec($path . ' command -v ' . escapeshellarg($b), $which, $return_var);
$data[] = array($b, $return_var ? "Not Installed" : $which[0]);
}
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($data);