if ($this_user) { if (!isset($confirmed)) { echo "<center>"; echo "Are you sure you want to report a problem with:<br>\n <b>{$referrer}</b><br><br>"; echo "<form action='pagenotworking.php' method=get>"; echo "<b>Please tell us briefly what is wrong ...</b>\n"; echo "<br>\n"; echo "<textarea name=description rows=10 cols=80></textarea><br>\n"; echo "<b><input type=hidden name=confirmed value=1></b>"; echo "<b><input type=hidden name=referrer value='{$referrer}'></b>"; echo "<b><input type=submit name=tag value='Submit'></b>"; echo "</form>"; echo "</center>\n"; } else { $uid_name = $this_user->name(); $uid_email = $this_user->email(); $uid_uid = $this_user->uid(); if (!isset($description)) { $description = ""; } TBMAIL($TBMAIL_OPS, "Page Not Working Properly", "{$uid_name} ({$uid_uid}) is reporting that page:\n\n" . " {$referrer}\n\n" . "is not working properly:\n\n" . "{$description}\n", "From: {$uid_name} <{$uid_email}>\n" . "Errors-To: {$TBMAIL_WWW}"); echo "<br>\n Thanks! A message has been sent to {$TBMAILADDR} to let us know\n something is wrong with <b>{$referrer}</b>"; } } echo "<br><br><br>\n"; echo "Back to <a href='{$referrer}'>previous page</a>\n"; echo "<br>\n"; # # Standard Testbed Footer # PAGEFOOTER();
$owner = $uid_idx; $vals = array($owner, $uid_idx, $uid_idx, '"' . mysql_escape_string(NewUUID()) . '"', "now()", "now()"); foreach ($dbfields as $f) { if (isset($formfields[$f])) { $dbname = $f; $value = $formfields[$f]; array_push($cols, '`' . $dbname . '`'); array_push($vals, '"' . mysql_escape_string($value) . '"'); } } DBQueryFatal("insert into emulab_pubs (" . implode(",", $cols) . ") values (" . implode(",", $vals) . ")"); $idx = mysql_insert_id(); echo "<p>The following was Submitted: </p>"; ConfirmationCommon(); if (!$isadmin) { TBMAIL("{$TBMAILADDR_OPS}", "New Publication Submitted", $formdump, "From: " . $this_user->name() . "<" . $this_user->email() . ">"); } PAGEFOOTER(); } else { $update_list = array("last_edit = now()", "`last_edit_by` = {$uid_idx}"); $update_start = count($update_list); if (!isset($formfields['deleted'])) { $formfields['deleted'] = false; } # determine what changed foreach ($dbfields as $f) { if (isset($formfields[$f]) && $defaults[$f] != $formfields[$f]) { $dbname = $f; $value = @$formfields[$f]; array_push($update_list, "`" . $dbname . "` = \"" . mysql_escape_string($value) . '"'); }
function NewUser($uid, $flags, $args) { global $TBBASE, $TBMAIL_APPROVAL, $TBMAIL_AUDIT, $TBMAIL_WWW; global $MIN_UNIX_UID; $isleader = $flags & TBDB_NEWACCOUNT_PROJLEADER ? 1 : 0; $wikionly = $flags & TBDB_NEWACCOUNT_WIKIONLY ? 1 : 0; $webonly = $flags & TBDB_NEWACCOUNT_WEBONLY ? 1 : 0; # # If no uid, we need to generate a unique one for the user. # if (!$uid) { # # Take the first 5 letters of the email to form a root. That gives # us 3 digits to make it unique, since unix uids are limited to 8 # chars, sheesh! # $email = $args["usr_email"]; if (!preg_match('/^([-\\w\\+\\.]+)\\@([-\\w\\.]+)$/', $email, $matches)) { return null; } $token = $matches[1]; # Squeeze out any dots or dashes. $token = preg_replace('/\\./', '', $token); $token = preg_replace('/\\-/', '', $token); # Trim off any trailing numbers or +foo tokens. if (!preg_match('/^([a-zA-Z]+)/', $token, $matches)) { return null; } $token = $matches[1]; # First 5 chars, at most. $token = substr($token, 0, 5); # Grab all root matches from the DB. $query_result = DBQueryFatal("select uid from users " . "where uid like '{$token}%'"); if (!$query_result) { return null; } # Easy; no matches at all! if (!mysql_num_rows($query_result)) { $uid = "{$token}" . "001"; } else { $max = 0; # # Find unused slot. Must be a better way to do this! # while ($row = mysql_fetch_array($query_result)) { $foo = $row[0]; # Split name from number if (!preg_match('/^([a-zA-Z]+)(\\d*)$/', $foo, $matches)) { return null; } $name = $matches[1]; $number = $matches[2]; # Must be exact root if ($name != $token) { continue; } # Backwards compatability; might not have appended number. if (isset($number) && intval($number) > $max) { $max = intval($number); } } $max++; $uid = $token . sprintf("%03d", $max); } } # # The array of inserts is assumed to be safe already. Generate # a list of actual insert clauses to be joined below. # $insert_data = array(); foreach ($args as $name => $value) { $insert_data[] = "{$name}='{$value}'"; } # Every user gets a new unique index. $uid_idx = TBGetUniqueIndex('next_uid'); # Get me an unused unix id. Nice query, eh? Basically, find # unused numbers by looking at existing numbers plus one, and check # to see if that number is taken. $query_result = DBQueryFatal("select u.unix_uid + 1 as start from users as u " . "left outer join users as r on " . " u.unix_uid + 1 = r.unix_uid " . "where u.unix_uid>={$MIN_UNIX_UID} and " . " u.unix_uid<60000 and " . " r.unix_uid is null limit 1"); if (!$query_result || !mysql_num_rows($query_result)) { TBERROR("Could not find an unused unix_uid!", 1); } $row = mysql_fetch_row($query_result); $unix_uid = $row[0]; # Initial mailman_password. $mailman_password = substr(GENHASH(), 0, 10); # And a verification key. $verify_key = md5(uniqid(rand(), 1)); # Now tack on other stuff we need. if ($wikionly) { $insert_data[] = "wikionly='1'"; } if ($webonly) { $insert_data[] = "webonly='1'"; } $insert_data[] = "usr_created=now()"; $insert_data[] = "usr_modified=now()"; $insert_data[] = "pswd_expires=date_add(now(), interval 1 year)"; $insert_data[] = "unix_uid={$unix_uid}"; $insert_data[] = "status='newuser'"; $insert_data[] = "mailman_password='******'"; $insert_data[] = "verify_key='{$verify_key}'"; $insert_data[] = "uid_idx='{$uid_idx}'"; $insert_data[] = "uid='{$uid}'"; # Insert into DB. Should probably lock the table ... if (!DBQueryWarn("insert into users set " . implode(",", $insert_data))) { return null; } if (!DBQueryWarn("insert into user_stats (uid, uid_idx) " . "VALUES ('{$uid}', {$uid_idx})")) { DBQueryFatal("delete from users where uid_idx='{$uid_idx}'"); return null; } $newuser = User::Lookup($uid_idx); if (!$newuser) { return null; } # # See if we are in an initial Emulab setup. # $FirstInitState = TBGetFirstInitState() == "createproject"; if ($FirstInitState) { return $newuser; } # stuff for email message. $key = $newuser->verify_key(); $usr_name = $newuser->name(); $usr_email = $newuser->email(); # Email to user. TBMAIL("{$usr_name} '{$uid}' <{$usr_email}>", "Your New User Key", "\n" . "Dear {$usr_name} ({$uid}):\n\n" . "This is your account verification key: {$key}\n\n" . "Please use this link to verify your user account:\n" . "\n" . " {$TBBASE}/login.php3?vuid={$uid}&key={$key}\n" . "\n" . ($wikionly ? "Once you have verified your account, you will be able to access\n" . "the Wiki. You MUST verify your account first!" : ($webonly ? "Once you have verified your account, Testbed Operations will be\n" . "able to approve you. You MUST verify your account first!" : ($isleader ? "You will then be verified as a user. When you have been both\n" . "verified and approved by Testbed Operations, you will be marked\n" . "as an active user and granted full access to your account.\n" . "You MUST verify your account before your project can be approved!\n" : "Once you have verified your account, the project leader will be\n" . "able to approve you.\n\n" . "You MUST verify your account before the project leader can " . "approve you\n" . "After project approval, you will be marked as an active user, and\n" . "will be granted full access to your user account."))) . "\n\n" . "Thanks,\n" . "Testbed Operations\n", "From: {$TBMAIL_APPROVAL}\n" . "Bcc: {$TBMAIL_AUDIT}\n" . "Errors-To: {$TBMAIL_WWW}"); return $newuser; }
$hostname = isset($hostname) ? addslashes($hostname) : ""; DBQueryFatal("insert into new_nodes set node_id='{$hostname}', type='{$type}', " . "IP='{$IP}', temporary_IP='{$tmpIP}', dmesg='{$messages}', created=now(), " . "identifier={$identifier}, role='{$role}'"); $query_result = DBQueryFatal("select last_insert_id()"); $row = mysql_fetch_array($query_result); $new_node_id = $row[0]; echo "Node ID is {$new_node_id}\n"; foreach ($interfaces as $interface) { $card = $interface["card"]; $mac = $interface["mac"]; $type = $interface["type"]; DBQueryFatal("insert into new_interfaces set " . "new_node_id={$new_node_id}, card={$card}, mac='{$mac}', " . "interface_type='{$type}'"); } # # Send mail to testbed-ops about the new node # TBMAIL($TBMAIL_OPS, "New Node", "A new node, {$hostname}, has checked in"); function check_node_exists($node_id) { $node_id = addslashes($node_id); # # Just check to see if this node already exists in one of the # two tables - return 1 if it does, 0 if not # $query_result = DBQueryFatal("select node_id from nodes " . "where node_id='{$node_id}'"); if (mysql_num_rows($query_result)) { return 1; } $query_result = DBQueryFatal("select node_id from new_nodes " . "where node_id='{$node_id}'"); if (mysql_num_rows($query_result)) { return 1; }
function NewMemberNotify($user) { global $TBWWW, $TBMAIL_APPROVAL, $TBMAIL_AUDIT, $TBMAIL_WWW, $TBMAIL_NOREPLY; if (!$this->project) { $this->LoadProject(); } $project = $this->project; $pid = $project->pid(); $gid = $this->gid(); $leader = $project->GetLeader(); $leader_name = $leader->name(); $leader_email = $leader->email(); $leader_uid = $leader->uid(); $allleaders = $this->LeaderMailList(); $joining_uid = $user->uid(); $usr_title = $user->title(); $usr_name = $user->name(); $usr_affil = $user->affil(); $usr_email = $user->email(); $usr_addr = $user->addr(); $usr_addr2 = $user->addr2(); $usr_city = $user->city(); $usr_state = $user->state(); $usr_zip = $user->zip(); $usr_country = $user->country(); $usr_phone = $user->phone(); $usr_URL = $user->URL(); TBMAIL("{$leader_name} '{$leader_uid}' <{$leader_email}>", "{$joining_uid} {$pid} Project Join Request", "{$usr_name} is trying to join your group {$gid} in project {$pid}.\n" . "\n" . "Contact Info:\n" . "Name: {$usr_name}\n" . "Emulab ID: {$joining_uid}\n" . "Email: {$usr_email}\n" . "User URL: {$usr_URL}\n" . "Job Title: {$usr_title}\n" . "Affiliation: {$usr_affil}\n" . "Address 1: {$usr_addr}\n" . "Address 2: {$usr_addr2}\n" . "City: {$usr_city}\n" . "State: {$usr_state}\n" . "ZIP/Postal Code: {$usr_zip}\n" . "Country: {$usr_country}\n" . "Phone: {$usr_phone}\n" . "\n" . "Please return to {$TBWWW},\n" . "log in, and select the 'New User Approval' page to enter your\n" . "decision regarding {$usr_name}'s membership in your project.\n\n" . "Thanks,\n" . "Testbed Operations\n", "From: {$usr_name} '{$joining_uid}' <{$usr_email}>\n" . "Cc: {$allleaders}\n" . "Bcc: {$TBMAIL_AUDIT}\n" . "Errors-To: {$TBMAIL_WWW}"); return 0; }
if (!$GENIRACK) { USERERROR("This toggle is disabled on non-geni racks!", 1); } # must be admin if (!$isadmin) { USERERROR("You do not have permission to toggle {$type}!", 1); } if (!($target_user = User::Lookup($user))) { PAGEARGERROR("Target user '{$user}' is not a valid user!"); } $zapurl = CreateURL("showuser", $target_user); $target_user->SetAdminFlag($value); $target_uid = $target_user->uid(); $this_uid = $this_user->uid(); if ($value) { TBMAIL($TBMAIL_OPS, "Admin Flag enabled for '{$target_uid}'", "{$this_uid} has enabled the admin flag for '{$target_uid}'!\n\n", "From: {$TBMAIL_OPS}\n" . "Bcc: {$TBMAIL_AUDIT}\n" . "Errors-To: {$TBMAIL_WWW}"); } SUEXEC($uid, $TBADMINGROUP, "webtbacct mod {$target_uid}", SUEXEC_ACTION_DIE); SUEXEC($uid, $TBADMINGROUP, "webmodgroups {$target_uid}", SUEXEC_ACTION_DIE); } elseif ($type == "cvsweb") { # must be admin if (!$isadmin) { USERERROR("You do not have permission to toggle {$type}!", 1); } if (!($target_user = User::Lookup($user))) { PAGEARGERROR("Target user '{$user}' is not a valid user!"); } $zapurl = CreateURL("showuser", $target_user); $target_user->SetWebFreeze($value); } elseif ($type == "stud") { # must be admin