librenms/config_to_json.php

34 lines
575 B
PHP
Raw Normal View History

2013-11-03 23:03:57 +00:00
<?php
/*
2013-11-25 20:35:55 +00:00
Configuration to JSON converter
Written by Job Snijders <job.snijders@atrato.com>
2013-11-03 23:03:57 +00:00
*/
2013-11-25 20:33:33 +00:00
$defaults_file = 'includes/defaults.inc.php';
2013-11-03 23:03:57 +00:00
$config_file = 'config.php';
2013-11-25 20:35:55 +00:00
// move to install dir
2013-11-03 23:03:57 +00:00
chdir(dirname($argv[0]));
function iscli() {
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
return true;
} else {
return false;
}
2013-11-03 23:03:57 +00:00
}
// check if we are running throw the CLI, otherwise abort
if ( iscli() ) {
2013-11-25 20:33:33 +00:00
require_once($defaults_file);
require_once($config_file);
print(json_encode($config));
2013-11-03 23:03:57 +00:00
}
?>