| 
									
										
										
										
											2010-09-03 18:26:59 +00:00
										 |  |  | #!/usr/bin/env php
 | 
					
						
							| 
									
										
										
										
											2008-03-22 14:13:16 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Observium | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   This file is part of Observium. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    observium | 
					
						
							|  |  |  |  * @subpackage cli | 
					
						
							|  |  |  |  * @author     Adam Armstrong <adama@memetic.org> | 
					
						
							|  |  |  |  * @copyright  (C) 2006 - 2012 Adam Armstrong | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-08 10:44:41 +00:00
										 |  |  | chdir(dirname($argv[0])); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-27 14:44:38 +00:00
										 |  |  | include("includes/defaults.inc.php"); | 
					
						
							| 
									
										
										
										
											2008-03-22 14:13:16 +00:00
										 |  |  | include("config.php"); | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  | include("includes/definitions.inc.php"); | 
					
						
							| 
									
										
										
										
											2008-03-22 14:13:16 +00:00
										 |  |  | include("includes/functions.php"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +00:00
										 |  |  | 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'); | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 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
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +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])) | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											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"); | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-23 09:54:56 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     echo("Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n"); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +00:00
										 |  |  | } | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-03-23 09:54:56 +00:00
										 |  |  |   echo("Auth module does not allow adding users!\n"); | 
					
						
							| 
									
										
										
										
											2010-03-06 01:10:05 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-22 14:13:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  | ?>
 |