Files
librenms-librenms/adduser.php
T

60 lines
1.1 KiB
PHP
Raw Normal View History

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