commit version 23.9.13005

This commit is contained in:
2023-11-29 23:53:32 -05:00
parent b7f6a79c2c
commit fa8a702a67
4133 changed files with 2121180 additions and 965181 deletions

View File

@ -5,52 +5,52 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage cli
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
*
*/
chdir(dirname($argv[0]));
$options = getopt("d");
if (isset($options['d'])) { array_shift($argv); } // for compatibility
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility
include("includes/sql-config.inc.php");
include("includes/observium.inc.php");
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WAdd User%n\n", 'color');
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd User%n\n", 'color');
if (OBS_DEBUG) { print_versions(); }
$auth_file = $config['html_dir'].'/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file))
{
include($auth_file);
// Include base auth functions calls
include($config['html_dir'].'/includes/authenticate-functions.inc.php');
} else {
print_error("ERROR: no valid auth_mechanism defined.");
exit();
if (OBS_DEBUG) {
print_versions();
}
if (auth_usermanagement())
{
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]))
{
if (!auth_user_exists($argv[1]))
{
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4]))
{
print_success("User ".$argv[1]." added successfully.");
} else {
print_error("User ".$argv[1]." creation failed!");
}
$auth_file = $config['html_dir'] . '/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file)) {
// Include base auth functions calls
include_once($config['html_dir'] . '/includes/sessions.inc.php');
include_once($config['html_dir'] . '/includes/authenticate-functions.inc.php');
include_once($auth_file);
} else {
print_error("ERROR: no valid auth_mechanism defined.");
exit();
}
if (auth_usermanagement()) {
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
if (!auth_user_exists($argv[1])) {
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
print_success("User " . $argv[1] . " added successfully.");
} else {
print_error("User " . $argv[1] . " creation failed!");
}
} else {
print_warning("User " . $argv[1] . " already exists!");
}
} else {
print_warning("User ".$argv[1]." already exists!");
}
} else {
$msg = "%n
$msg = "%n
USAGE:
$scriptname <username> <password> <level 1-10> [email]
@ -59,16 +59,15 @@ EXAMPLE:
USER LEVELS:" . PHP_EOL;
foreach($GLOBALS['config']['user_level'] as $level => $entry)
{
$msg .= ' '.$level.' - %W'.$entry['name'].'%n ('.$entry['subtext'].')'. PHP_EOL;
}
$msg .= PHP_EOL . "%rInvalid arguments!%n";
foreach ($GLOBALS['config']['user_level'] as $level => $entry) {
$msg .= ' ' . $level . ' - %W' . $entry['name'] . '%n (' . $entry['subtext'] . ')' . PHP_EOL;
}
$msg .= PHP_EOL . "%rInvalid arguments!%n";
print_message($msg, 'color', FALSE);
}
print_message($msg, 'color', FALSE);
}
} else {
print_error("Auth module does not allow adding users!");
print_error("Auth module does not allow adding users!");
}
// EOF