echo " name='can_modify_passwd'> Allow the user to change his password.\n </label>\n </div>\n </div>\n <div class='col-sm-6'>\n </div>\n </div>\n <button type='submit' class='btn btn-default'>Update User</button>\n </form>"; if ($config['twofactor']) { echo "<br/><div class='well'><h3>Two-Factor Authentication</h3>"; $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?", array($vars['user_id'])); $twofactor = json_decode($twofactor['twofactor'], true); if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || time() - $twofactor['last'] < $config['twofactor_lock'])) { echo "<form class='form-horizontal' role='form' method='post' action=''>\n <input type='hidden' name='user_id' value='" . $vars['user_id'] . "'>\n <input type='hidden' name='edit' value='yes'>\n <div class='form-group'>\n <label for='twofactorunlock' class='col-sm-2 control-label'>User exceeded failures</label>\n <input type='hidden' name='twofactorunlock' value='1'>\n <button type='submit' class='btn btn-default'>Unlock</button>\n </div>\n</form>"; } if ($twofactor['key']) { echo "<form class='form-horizontal' role='form' method='post' action=''>\n <input type='hidden' name='user_id' value='" . $vars['user_id'] . "'>\n <input type='hidden' name='edit' value='yes'>\n <input type='hidden' name='twofactorremove' value='1'>\n <button type='submit' class='btn btn-danger'>Disable TwoFactor</button>\n</form>\n</div>"; } else { echo "<p>No TwoFactor key generated for this user, Nothing to do.</p>"; } } } else { echo print_error("Error getting user details"); } } else { echo print_error("Authentication method doesn't support updating users"); } } else { $user_list = get_userlist(); echo "<h3>Select a user to edit</h3>"; echo "<form method='post' action='' class='form-horizontal' role='form'>\n <input type='hidden' value='edituser' name='page'>\n <div class='form-group'>\n <label for='user_id' class='col-sm-2 control-label'>User</label>\n <div class='col-sm-4'>\n <select name='user_id' class='form-control input-sm'>"; foreach ($user_list as $user_entry) { echo "<option value='" . $user_entry['user_id'] . "'>" . $user_entry['username'] . "</option>"; } echo "</select>\n </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-offset-2 col-sm-3'>\n <button type='submit' name='Submit' class='btn btn-default'>Edit Permissions</button> / <button type='submit' name='edit' value='user' class='btn btn-default'>Edit User</button>\n </div>\n </div>\n </form>"; } } echo "</div>";
function get_user($user_id) { foreach (get_userlist() as $users) { if ($users['user_id'] === $user_id) { return $users['username']; } } return 0; }
<div class="widget-content"> <table id="syslog" class="table table-bordered table-striped data-table"> <thead> <tr> <th>User ID</th> <th>Name</th> <th>E-Mail</th> <th>Group</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php get_userlist('', ''); ?> </tbody> </table> </div> <!-- .widget-content --> </div> <!-- .widget --> <div class="actions"> <button onclick="window.location='create_user.php?group=';" class="btn btn-quaternary"><span class="icon-plus"></span>Create New User </button> </div> <!-- .actions -->
/** * Find contacts for alert * @param array $results Rule-Result * @return array */ function GetContacts($results) { global $config; if (sizeof($results) == 0) { return array(); } if ($config['alert']['default_only'] == true || $config['alerts']['email']['default_only'] == true) { return array('' . ($config['alert']['default_mail'] ? $config['alert']['default_mail'] : $config['alerts']['email']['default']) => 'NOC'); } $users = get_userlist(); $contacts = array(); $uids = array(); foreach ($results as $result) { $tmp = null; if (is_numeric($result["bill_id"])) { $tmpa = dbFetchRows("SELECT user_id FROM bill_perms WHERE bill_id = ?", array($result["bill_id"])); foreach ($tmpa as $tmp) { $uids[$tmp['user_id']] = $tmp['user_id']; } } if (is_numeric($result["port_id"])) { $tmpa = dbFetchRows("SELECT user_id FROM ports_perms WHERE access_level >= 0 AND port_id = ?", array($result["port_id"])); foreach ($tmpa as $tmp) { $uids[$tmp['user_id']] = $tmp['user_id']; } } if (is_numeric($result["device_id"])) { if ($config['alert']['syscontact'] == true) { if (dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_bool' AND device_id = ?", array($result["device_id"])) === "1") { $tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?", array($result["device_id"])); } else { $tmpa = dbFetchCell("SELECT sysContact FROM devices WHERE device_id = ?", array($result["device_id"])); } $contacts[$tmpa] = "NOC"; } $tmpa = dbFetchRows("SELECT user_id FROM devices_perms WHERE access_level >= 0 AND device_id = ?", array($result["device_id"])); foreach ($tmpa as $tmp) { $uids[$tmp['user_id']] = $tmp['user_id']; } } } foreach ($users as $user) { if (empty($user['email'])) { continue; } elseif (empty($user['realname'])) { $user['realname'] = $user['username']; } $user['level'] = get_userlevel($user['username']); if ($config["alert"]["globals"] && ($user['level'] >= 5 && $user['level'] < 10)) { $contacts[$user['email']] = $user['realname']; } elseif ($config["alert"]["admins"] && $user['level'] == 10) { $contacts[$user['email']] = $user['realname']; } elseif (in_array($user['user_id'], $uids)) { $contacts[$user['email']] = $user['realname']; } } $tmp_contacts = array(); foreach ($contacts as $email => $name) { if (strstr($email, ',')) { $split_contacts = preg_split("/[,\\s]+/", $email); foreach ($split_contacts as $split_email) { if (!empty($split_email)) { $tmp_contacts[$split_email] = $name; } } } else { $tmp_contacts[$email] = $name; } } return $tmp_contacts; }
<div class="widget-content"> <table id="syslog" class="table table-bordered table-striped data-table"> <thead> <tr> <th>User ID</th> <th>Name</th> <th>E-Mail</th> <th>Group</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php get_userlist('', '2'); ?> </tbody> </table> </div> <!-- .widget-content --> </div> <!-- .widget --> <div class="actions"> <button onclick="window.location='create_user.php?group=2';" class="btn btn-quaternary"><span class="icon-plus"></span>Create New Advertiser </button> </div> <!-- .actions -->