FILTER_VALIDATE_INT, "rawpasswd" => FILTER_UNSAFE_RAW, "rawpasswd2" => FILTER_UNSAFE_RAW, "svnpasswd" => FILTER_SANITIZE_STRIPPED, "cvsaccess" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], "enable" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], "spamprotect" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], "greylist" => ["filter" => FILTER_CALLBACK, "options" => function($v) { if ($v == "on") { return true; } return false; }], "verified" => FILTER_VALIDATE_INT, "use_sa" => FILTER_VALIDATE_INT, "email" => FILTER_SANITIZE_EMAIL, "name" => FILTER_SANITIZE_SPECIAL_CHARS, "sshkey" => FILTER_SANITIZE_SPECIAL_CHARS, "purpose" => FILTER_SANITIZE_SPECIAL_CHARS, "profile_markdown" => FILTER_UNSAFE_RAW, ]; $rawin = filter_input_array(INPUT_POST) ?: []; $in = isset($rawin["in"]) ? filter_var_array($rawin["in"], $indesc, false) : []; $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT) ?: 0; $username = filter_input(INPUT_GET, "username", FILTER_SANITIZE_STRIPPED) ?: 0; head("user administration"); db_connect(); # ?username=whatever will look up 'whatever' by email or username if ($username) { $query = "SELECT userid FROM users" . " WHERE username=? OR email=?"; $res = db_query_safe($query, [$username, $username]); if (!($id = @mysql_result($res, 0))) { warn("wasn't able to find user matching '$username'"); } } if ($id) { $query = "SELECT * FROM users WHERE users.userid=?"; $res = db_query_safe($query, [$id]); $userdata = mysql_fetch_array($res); if (!$userdata) { warn("Can't find user#$id"); } } $action = filter_input(INPUT_POST, "action", FILTER_CALLBACK, ["options" => "validateAction"]); if ($id && $action) { csrf_validate($_SESSION, $action); if (!is_admin($_SESSION["username"])) { warn("you're not allowed to take actions on users."); exit; } switch ($action) { case 'approve': user_approve((int)$id); break; case 'remove': user_remove((int)$id); break; default: warn("that action ('$action') is not understood."); } } if ($in) { csrf_validate($_SESSION, "useredit"); if (!can_modify($_SESSION["username"],$id)) { warn("you're not allowed to modify this user."); } else { if ($error = invalid_input($in)) { warn($error); } else { if (!empty($in['rawpasswd'])) { $userinfo = fetch_user($id); $in['svnpasswd'] = gen_svn_pass($userinfo["username"], $in['rawpasswd']); } $cvsaccess = empty($in['cvsaccess']) ? 0 : 1; $enable = empty($in['enable']) ? 0 : 1; $spamprotect = empty($in['spamprotect']) ? 0 : 1; $use_sa = empty($in['use_sa']) ? 0 : (int)$in['use_sa']; $greylist = empty($in['greylist']) ? 0 : 1; if ($id) { # update main table data if (!empty($in['email']) && !empty($in['name'])) { $query = new Query("UPDATE users SET name=?,email=?", [$in['name'], $in['email']]); if (!empty($in['svnpasswd'])) { $query->add(',svnpasswd=?', [$in['svnpasswd']]); } if (!empty($in['sshkey'])) { $query->add(',ssh_keys=?', [html_entity_decode($in['sshkey'],ENT_QUOTES)]); } if (is_admin($_SESSION["username"]) && !empty($in['username'])) { $query->add(',username=?', [$in['username']]); } if (is_admin($_SESSION["username"])) { $query->add(',cvsaccess=?', [$cvsaccess]); } $query->add( ',spamprotect=?, enable=?, use_sa=?, greylist=?', [$spamprotect, $enable, $use_sa, $greylist]); if (!empty($in['rawpasswd'])) { $query->add(',pchanged=?', [$ts]); } $query->add(' WHERE userid=?', [$id]); if (!empty($in['passwd'])) { // Kill the session data after updates :) $_SERVER["credentials"] = []; } db_query($query); if(!empty($in['purpose'])) { $purpose = hsc($in['purpose']); $query = "INSERT INTO users_note (userid, note, entered) VALUES (?, ?, NOW())"; db_query_safe($query, [$id, $purpose]); } if(!empty($in['profile_markdown'])) { $profile_markdown = $in['profile_markdown']; $profile_html = Markdown($profile_markdown); $query = "INSERT INTO users_profile (userid, markdown, html) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE markdown=?, html=?"; db_query_safe($query, [$id, $profile_markdown, $profile_html, $profile_markdown, $profile_html]); } } warn("record $id updated"); $id = false; } } } } if ($id) { ?>
"> " />
Name:
Email:
/> Enable email for my account.
VCS username:
Leave password fields blank to leave password unchanged.
Password:
Password (again):
VCS access? />
Has VCS access?
Use Challenge/Response spam protection? />
Show people on my quarantine list
SpamAssassin threshold Block mail scoring or higher in SpamAssassin tests. Set to 0 to disable.
Greylist Delay reception of your incoming mail by a minimum of one hour using a 451 response.
Legitimate senders will continue to try to deliver the mail, whereas spammers will typically give up and move on to spamming someone else.
See this whitepaper for more information on greylisting.
/> Enable greylisting on my account
Verified? /> Note: Do not worry about this value. It's sometimes used to check if old-timers are still around.
SSH Key

Adding/editing the SSH key takes a few minutes to propagate to the server.
Multiple keys are allowed, separated using a newline.

People Profile
('s page)

Use Markdown. Type as much as you like.

Add Note:
" />
" />

Notes:

", date("r",$userdata['ts']), "
".$userdata['note'].""; } foot(); exit; } ?> add(" LEFT JOIN users_note ON users_note.userid = users.userid "); if ($search) { $query->add("WHERE (MATCH(name,email,username) AGAINST (?) OR username = ?) ", [$search, $search]); } else { $query->add(' WHERE 1=1 '); } if ($unapproved) { $query->add(' AND NOT cvsaccess '); } $query->add(" GROUP BY users.userid "); if ($order) { if (!in_array($order, ["username", "name", "email", "note"], true)) { die("Invalid order!"); } if ($forward) { $ext = "ASC"; } else { $ext = "DESC"; } // Safe because we checked that $order is part of a fixed set. $query->add(" ORDER BY $order $ext"); } $query->add(" LIMIT ?int, ?int ", [$begin, $max]); $res = db_query($query); $res2 = db_query_safe("SELECT FOUND_ROWS()"); $total = (int)mysql_result($res2,0); $extra = [ "search" => $search, "order" => $order, "forward" => $forward, "begin" => $begin, "max" => $max, "unapproved" => $unapproved, ]; ?>

Browse users

">
!$unapproved]);?>">; "username"]);?>">username "name"]);?>">name "email"]);?>">email "email"]);?>">email "note"]);?>">note
">edit