librenms/config_to_json.php

31 lines
562 B
PHP
Raw Normal View History

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