2010-09-03 18:26:59 +00:00
|
|
|
#!/usr/bin/env php
|
2008-03-22 14:13:16 +00:00
|
|
|
<?php
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
/*
|
2013-10-28 12:01:36 -07:00
|
|
|
* Observium
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2013-10-28 12:01:36 -07:00
|
|
|
* This file is part of Observium.
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2013-10-28 12:01:36 -07:00
|
|
|
* @package observium
|
2012-05-09 10:01:42 +00:00
|
|
|
* @subpackage cli
|
2013-10-28 12:01:36 -07:00
|
|
|
* @author Adam Armstrong <adama@memetic.org>
|
|
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-04-08 10:44:41 +00:00
|
|
|
chdir(dirname($argv[0]));
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
require 'includes/defaults.inc.php';
|
|
|
|
require 'config.php';
|
|
|
|
require 'includes/definitions.inc.php';
|
|
|
|
require 'includes/functions.php';
|
2008-03-22 14:13:16 +00:00
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
if (file_exists('html/includes/authentication/'.$config['auth_mechanism'].'.inc.php')) {
|
|
|
|
include 'html/includes/authentication/'.$config['auth_mechanism'].'.inc.php';
|
2010-03-06 01:10:05 +00:00
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
else {
|
|
|
|
echo "ERROR: no valid auth_mechanism defined.\n";
|
|
|
|
exit();
|
2011-03-17 11:12:32 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
if (auth_usermanagement()) {
|
|
|
|
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
|
|
|
|
if (!user_exists($argv[1])) {
|
|
|
|
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
|
|
|
|
echo 'User '.$argv[1]." added successfully\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo 'User '.$argv[1]." already exists!\n";
|
|
|
|
}
|
2011-03-18 16:56:02 +00:00
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
else {
|
|
|
|
echo "Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n";
|
2010-03-06 01:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
else {
|
|
|
|
echo "Auth module does not allow adding users!\n";
|
|
|
|
}//end if
|