diff --git a/.devilbox/www/htdocs/_ajax_callback.php b/.devilbox/www/htdocs/_ajax_callback.php index fc9c3304..3e17387e 100644 --- a/.devilbox/www/htdocs/_ajax_callback.php +++ b/.devilbox/www/htdocs/_ajax_callback.php @@ -3,12 +3,17 @@ require '../config.php'; if (loadClass('Helper')->isLoggedIn()) { + // + // ?database= + // if (isset($_GET['database'])) { + // &type=mysql if (isset($_GET['type']) && $_GET['type'] == 'mysql') { echo json_encode(array( 'size' => (string)loadClass('Mysql')->getDBSize($_GET['database']), 'table' => (string)loadClass('Mysql')->getTableCount($_GET['database']) )); + // &type=postgres } else if (isset($_GET['type']) && $_GET['type'] == 'postgres') { $schema = isset($_GET['schema']) ? $_GET['schema'] : ''; echo json_encode(array( @@ -16,12 +21,93 @@ if (loadClass('Helper')->isLoggedIn()) { 'table' => (string)loadClass('Pgsql')->getTableCount($_GET['database'], $schema) )); } - } else if (isset($_GET['vhost'])) { - echo loadClass('Httpd')->checkVirtualHost($_GET['vhost']); - } else { - loadClass('Helper')->redirect('/'); } -} else { + // + // ?vhost= + // + else if (isset($_GET['vhost'])) { + echo loadClass('Httpd')->checkVirtualHost($_GET['vhost']); + } + + + // + // ?software= + // + else if (isset($_GET['software'])) { + $no = 'not installed'; + $software = array(); + + if ($_GET['software'] == 'composer') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getComposerVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'drupalc') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getDrupalConsoleVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'drush') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getDrushVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'git') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getGitVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'laravel') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getLaravelVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'mds') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getMdsVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'node') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getNodeVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'npm') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getNpmVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'phalcon') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getPhalconVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'symfony') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getPhalconVersion()) !== false) ? $version : $no + )); + } + else if ($_GET['software'] == 'wpcli') { + echo json_encode(array( + $_GET['software'] => (($version = loadClass('Php')->getSymfonyVersion()) !== false) ? $version : $no + )); + } else { + echo json_encode(array($_GET['software'] => 'unknown software')); + } + } + + // + // WRONG REQUEST + // + else { + loadClass('Helper')->redirect('/'); + } +} + +// +// Not logged in +// +else { loadClass('Helper')->redirect('/'); } diff --git a/.devilbox/www/htdocs/index.php b/.devilbox/www/htdocs/index.php index 11fc9d14..87ed2836 100644 --- a/.devilbox/www/htdocs/index.php +++ b/.devilbox/www/htdocs/index.php @@ -30,6 +30,7 @@ $connection = array(); $error = null; // ---- HTTPD (required) ---- + $host = $GLOBALS['HTTPD_HOST_NAME']; $succ = loadClass('Httpd')->canConnect($error, $host); $connection['Httpd'][$host] = array( @@ -51,7 +52,6 @@ $connection['Httpd'][$host] = array( 'host' => $host, 'succ' => $succ ); - // ---- MYSQL ---- if ($avail_mysql) { $host = $GLOBALS['MYSQL_HOST_NAME']; @@ -127,6 +127,7 @@ if ($avail_redis) { ); } + // ---- MEMCACHED ---- if ($avail_memcd) { $host = $GLOBALS['MEMCD_HOST_NAME']; @@ -417,47 +418,47 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL); composer - getComposerVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + drupal-console - getDrushConsoleVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + drush - getDrushVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + git - getGitVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + - Laravell installer - getLaravelVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + Laravel installer + mysqldump-secure - getMdsVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + node - getNodeVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + npm - getNpmVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + Phalcon devtools - getPhalconVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + Symfony installer - getSymfonyVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + Wordpress cli - getWpcliVersion()) === false) {echo 'not installed';}else{echo $version;}; ?> + @@ -910,6 +911,37 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL); (function() { // your page initialization code here // the DOM will be available here + + /** + * Update installed tool versions. + * Ajax method is faster for loading the front page + * @param string app Name of the tool + */ + function updateVersions(app) { + var xhttp = new XMLHttpRequest(); + + xhttp.onreadystatechange = function() { + var elem = document.getElementById('app_'+app); + + if (this.readyState == 4 && this.status == 200) { + json = JSON.parse(this.responseText); + elem.innerHTML = json[app]; + } + }; + xhttp.open('GET', '_ajax_callback.php?software='+app, true); + xhttp.send(); + } + updateVersions('composer'); + updateVersions('drupalc'); + updateVersions('drush'); + updateVersions('git'); + updateVersions('laravel'); + updateVersions('mds'); + updateVersions('node'); + updateVersions('npm'); + updateVersions('phalcon'); + updateVersions('symfony'); + updateVersions('wpcli'); })(); diff --git a/.devilbox/www/include/lib/container/Php.php b/.devilbox/www/include/lib/container/Php.php index e79e65f8..682c118b 100644 --- a/.devilbox/www/include/lib/container/Php.php +++ b/.devilbox/www/include/lib/container/Php.php @@ -50,7 +50,7 @@ class Php extends BaseClass implements BaseInterface $output = loadClass('Helper')->exec('drush --version', $output); return loadClass('Helper')->egrep('/[0-9.]+/', $output); } - public function getDrushConsoleVersion() + public function getDrupalConsoleVersion() { $output = loadClass('Helper')->exec('drupal --version | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"', $output); return loadClass('Helper')->egrep('/[0-9.]+[-rc0-9.]*/', $output);