Example #1
0
         if (!$user_auth && !$ldap_error) {
             /* if auth has not occured process for builtin - AKA Ldap fall through */
             log_save(_("LOGIN: Builtin Authenication enabled"), SEV_DEBUG, FACIL_AUTH);
             $user = api_user_info(array("username" => $username, "password" => md5($_POST["login_password"]), "realm" => 0));
         }
 }
 /* end of switch */
 /* Create user from template if requested */
 if (!sizeof($user) && $copy_user && read_config_option("user_template") != "0" && strlen($username) > 0) {
     log_save(sprintf(_("LOGIN: User '%s' does not exist, copying template user"), $username), SEV_WARNING, FACIL_AUTH);
     /* check that template user exists */
     if (api_user_info(array("username" => read_config_option("user_template"), "realm" => 0))) {
         #if (db_fetch_row("select * from user_auth where username='******' and realm = 0")) {
         log_save(sprintf(_("LOGIN: Coping Template user '%s' to user '%s'"), read_config_option("user_template"), $username), SEV_DEBUG, FACIL_AUTH);
         /* template user found */
         api_user_copy(read_config_option("user_template"), $username, $realm);
         /* requery newly created user */
         $user = api_user_info(array("username" => $username, "realm" => $realm));
         #$user = db_fetch_row("select * from user_auth where username='******' and realm = " . $realm);
     } else {
         /* error */
         auth_display_custom_error_message(sprintf(_("Template user '%s' does not exist."), read_config_option("user_template")));
         log_save(sprintf(_("LOGIN: Unable to locate template user '%s'"), read_config_option("user_template")), SEV_ERROR, FACIL_AUTH);
         exit;
     }
 }
 /* Guest account checking - Not for builtin */
 $guest_user = false;
 if (sizeof($user) < 1 && $user_auth && read_config_option("guest_user") != "0") {
     log_save(_("LOGIN: Authenicated user, but no cacti user record, loading guest account"), SEV_DEBUG, FACIL_AUTH);
     /* Locate guest user record */
Example #2
0
function user_actions() {
	global $colors, $user_actions, $fields_user_edit, $user_password_expire_intervals;

	/* if we are to save this form, instead of display it */
	if (isset($_POST["selected_items"])) {
		$selected_items = unserialize(stripslashes($_POST["selected_items"]));

		if ($_POST["drp_action"] == "3") {
			/* Enable Selected Users */
			for ($i=0;($i<count($selected_items));$i++) {
				api_user_enable($selected_items[$i]);
			}
		}elseif ($_POST["drp_action"] == "4") {
			/* Disable Selected Users */
			for ($i=0;($i<count($selected_items));$i++) {
				api_user_disable($selected_items[$i]);
			}
		}elseif ($_POST["drp_action"] == "1") {
			/* Delete User */
			for ($i=0; $i<count($selected_items); $i++) {
				api_user_remove($selected_items[$i]);
			}

		}elseif ($_POST["drp_action"] == "2") {
			/* Copy User */
			/* Check for new user name */
			if ((!empty($_POST["user_new"])) && (!empty($_POST["user_name"]))) {
				if (api_user_copy($_POST["user_name"],$_POST["user_new"]) == 1) {
					raise_message(12);
				}
			}
		}elseif ($_POST["drp_action"] == "5") {
			/* Password Expiration */
			for ($i=0; $i<count($selected_items); $i++) {
				api_user_expire_length_set($selected_items[$i], $_POST["expire_interval"]);
			}

		}

		header("Location: user_admin.php");
		exit;
	}

	/* setup some variables */
	$user_list = ""; $i = 0; $username = "";

	/* loop through each of the users selected on the previous page and get more info about them */
	while (list($var,$val) = each($_POST)) {
		if (ereg("^chk_([0-9]+)$", $var, $matches)) {
			$user = api_user_info( array( "id" => $matches[1]) );
			$user_list .= "<li>" . $user["username"] . "<br>";
			$username_list[$user["username"]] = $user["username"];
			$user_array[$i] = $matches[1];
		}
		$i++;
	}

	require_once(CACTI_BASE_PATH . "/include/top_header.php");

	html_start_box("<strong>" . $user_actions{$_POST["drp_action"]} . "</strong>", "60%", $colors["header_panel_background"], "3", "center", "");

	print "<form action='user_admin.php' method='post'>\n";

	if ($_POST["drp_action"] == "3") { /* Enable Users */
		print "	<tr>
				<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>
					<p>" . _("To enable the following users, press the \"yes\" button below.") . "</p>
					<p>$user_list</p>
				</td>
				</tr>";
	}elseif ($_POST["drp_action"] == "4") { /* Disable Users */
		print "	<tr>
				<td colspan='4' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>
					<p>". _("To disable the following users, press the \"yes\" button below.") . "</p>
					<p>$user_list</p>
				</td>
				</tr>";

	}elseif ($_POST["drp_action"] == "2") { /* copy user */
		print "	<tr>
				<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>
					<p>" . _("Would you like to copy a user to a new user?") . "</p>
				</td>
				</tr>";

		if (isset($user_array)) {

			$form_array = array(
			"user_name" => array(
				"method" => "drop_array",
				"friendly_name" => _("User Name"),
				"description" => _("Select the user name you would like to copy from."),
				"value" => "",
				"array" => $username_list
				),
			"user_new" => array(
				"method" => "textbox",
				"friendly_name" => _("New User Name"),
				"description" => _("Type the user name of the new user."),
				"value" => "",
				"max_length" => "100"
				)
			);
			draw_edit_form(
				array(
					"config" => array("no_form_tag" => true),
					"fields" => $form_array
					)
				);
		}

	}elseif ($_POST["drp_action"] == "1") { /* delete */
		print "	<tr>
				<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>
					<p>" . _("Are you sure you want to delete the following users?") . "</p>
					<p>$user_list</p>
					</td></tr>
				</td>
			</tr>\n
			";

	}elseif ($_POST["drp_action"] == "5") { /* Password Expiration */
		print "	<tr>
				<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>
					<p>" . _("Would you like to set Password Expiration?") . "</p>
					<p>$user_list</p>
				</td>
				</tr>";


		$form_array = array(
		"expire_interval" => array(
			"method" => "drop_array",
			"friendly_name" => _("Password Expiration Interval"),
			"description" => _("Select the interval that you would like to apply to the selected users."),
			"value" => "",
			"array" => $user_password_expire_intervals
			)
		);
		draw_edit_form(
			array(
				"config" => array("no_form_tag" => true),
				"fields" => $form_array
				)
			);
	}

	if (!isset($user_array)) {
		print "<tr><td colspan='2' bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>" . _("You must select at least one user.") . "</span></td></tr>\n";
		$save_html = "";
	}else{
		$save_html = "<input type='image' src='" . html_get_theme_images_path("button_yes.gif") . "' alt='" . _("Save") . "' align='absmiddle'>";
	}

	print "	<tr>
			<td colspan='2' align='right' bgcolor='#" . $colors["buttonbar_background"] . "'>
				<input type='hidden' name='action' value='actions'>
				<input type='hidden' name='selected_items' value='" . (isset($user_array) ? serialize($user_array) : '') . "'>
				<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>
				<a href='user_admin.php'><img src='" . html_get_theme_images_path("button_no.gif") . "' alt='" . _("Cancel") . "' align='absmiddle' border='0'></a>
				$save_html
			</td>
		</tr>
		";

	html_end_box();

	require_once(CACTI_BASE_PATH . "/include/bottom_footer.php");
}