function listUser() { global $DB; global $MySelf; global $IGB; global $TIMEMARK; global $IGB_VISUAL; // Are we allowed to peek into peoples files? if (!$MySelf->canSeeUsers()) { makeNotice("You are not allowed to do this!", "error", "forbidden"); } // Is the supplied ID truly numeric? if (!is_numeric($_GET[id])) { makeNotice("Why would you do such a thing? Are you evil at heart? Lets assume its a \"mistake\" for now..", "warning", "*cough*", "index.php?action=editusers", "I'm sorry..."); } else { $id = (int) $_GET[id]; } // Query the database. $users = $DB->query("select * from users where id='{$id}' AND deleted='0' limit 1"); // Build the tables. while ($row = $users->fetchRow()) { $table = new table(2, true); $table->addHeader(">> Managing user " . ucfirst($row[username])); $username = ucfirst($row[username]); $table->addRow(); $table->addCol("ID:"); $table->addCol(str_pad("{$row['id']}", 5, "0", STR_RIGHT_PAD)); $table->addRow(); $table->addCol("Username:"******"<input type=\"text\" name=\"username\" value=\"" . $uname_temp . "\">"; $confi_temp = "<input type=\"checkbox\" name=\"username_check\" value=\"true\">"; $table->addCol($field_temp . " (changing username tick here also: " . $confi_temp . ")"); } else { $table->addCol(ucfirst($row[username])); } $table->addRow(); $table->addCol("eMail:"); $table->addCol("<input type=\"text\" size=\"40\" name=\"email\" value=\"" . ($row[email] == "" ? 'no email supplied' : $row[email]) . "\">"); $table->addRow(); $table->addCol("Password:"******"<input type=\"password\" size=\"40\" name=\"password\">"); // Ranks System $RanksDS = $DB->query("SELECT * FROM ranks ORDER BY rankOrder ASC"); $rankCount = $RanksDS->numRows(); if ($rankCount >= 1) { // We have at least 1 rank. while ($rank = $RanksDS->fetchRow()) { if ($rank[rankid] == $row[rank]) { // The current rank is selected. $rank_pdm .= "<option SELECTED value=\"{$rank['rankid']}\">{$rank['name']}</option>"; } else { // The others of course, are not. $rank_pdm .= "<option value=\"{$rank['rankid']}\">{$rank['name']}</option>"; } } $rankColumn = "<select name=\"rank\">" . $rank_pdm . "</select>"; } else { // No rank has been set yet. $rankColumn = "There are no ranks. Go create some!"; } $table->addRow(); $table->addCol("Rank:"); $table->addCol($rankColumn); $table->addRow(); $table->addCol("Last login:"******"{$row['lastlogin']}" < 10) { $table->addCol("never"); } else { $table->addCol(date("d.m.y H:i:s", $row[lastlogin])); } $table->addRow(); $table->addCol("Credits:"); $table->addCol(number_format(getCredits($row[id]), 2) . " ISK"); // Is the account confirmed? if ("{$row['confirmed']}" == "0") { $table->addRow(); $table->addCol("Account confirmed:"); $table->addCol("This account has <b>not</b> been confirmed yet."); $table->addRow(); $table->addCol("Confirm account:"); $table->addCol("<input type=\"checkbox\" name=\"confirm\" value=\"true\"> Tick box to confirm account. <br><br>This is a one-way action only. Once an account" . " has been confirmed you can not unconfirm it. Tho you can block or delete it." . " Be careful not to confirm an account by accident - you could allow a non-authorized third party to access your MiningBuddy!"); $table->addRow(); $table->addCol("Account confirmed:"); // Give a red light if user has not even verified himself. if ("{$row['emailvalid']}" == "0") { $table->addCol("<b>WARNING!</b><br> The User has not yet verified this email yet! If you choose to enable" . " this account at this time, be very sure that you know the person requesting the account!", array("bgcolor" => "#662222")); } else { $table->addCol("<br><br><b>The user validated the email address.</b><br>"); } } else { $table->addRow(); $table->addCol("This account has been confirmed."); if ("{$row['emailvalid']}" == "0") { $table->addCol("<font color=\"#ff0000\">WARNING!</b></font><br> The User has not verified this email but the account has been confirmed!"); // Add a "confirm email" checkbox. $table->addRow(); $table->addCol("Mark users email as valid:"); $table->addCol("<input type=\"checkbox\" name=\"SetEmailValid\" value=\"true\">"); } else { $table->addCol("The user validated the supplied email address."); } } /* * API Goodness */ $api = new api($row[id], true); $apit = new table(2, true); $apit->addHeader(">> Api information for " . ucfirst($row[username])); $apit->addRow(); $apit->addCol("API Key in database:"); if ($api->getApiID() && $api->getApiKey()) { $apit->addCol(yesno(1, true)); $apit->addRow(); $apit->addCol("API valid:"); $apit->addCol(yesno($api->valid(), true)); if ($api->valid()) { $apit->addRow(); $apit->addCol("Character ID:"); $apit->addCol($api->getCharacterID()); $apit->addRow(); $apit->addCol("Validated on:"); $apit->addCol(date("d.m.Y H:i:s", $api->validatedOn())); } $apit->addRow(); $apit->addCol("Remove API key from database:"); $apit->addCol("[<a href=\"index.php?action=delapi&id={$id}\">delete api key</a>]"); } else { $apit->addCol(yesno(0)); } // Permissions matrix $perms = array("canLogin" => "log in", "canJoinRun" => "join mining Ops", "canCreateRun" => "create new mining Ops", "canCloseRun" => "close mining Ops", "canDeleteRun" => "delete mining Ops", "canAddHaul" => "haul from/to mining Ops", "canSeeEvents" => "view scheduled events", "canDeleteEvents" => "can delete events", "canEditEvents" => "add and delete scheduled events", "canChangePwd" => "change his own password", "canChangeEmail" => "change his own email", "canChangeOre" => "manage ore prices and enable/disable them.", "canAddUser" => "add new accounts", "canSeeUsers" => "see other accounts", "canDeleteUser" => "delete other accounts.", "canEditRank" => "edit other peoples ranks.", "canManageUser" => "grant and take permissions.", "isOfficial" => "create official mining runs (with payout).", "isAdmin" => "edit site settings.", "isLottoOfficial" => "administrate the lottery", "canPlayLotto" => "play Lotto!", "isAccountant" => "edit other users credits.", "optIn" => "User has opt-in to eMails."); // Create a seperate permissions table. $perm_table = new table(2, true); $perm_table->addHeader(">> " . ucfirst($row[username]) . " has permission to... "); $perm_keys = array_keys($perms); $LoR = 1; foreach ($perm_keys as $key) { if ($LoR) { $perm_table->addRow(); } if ($row[$key]) { $perm_table->addCol("<input type=\"checkbox\" name=\"{$key}\" checked> " . $perms[$key]); } else { $perm_table->addCol("<input type=\"checkbox\" name=\"{$key}\"> " . $perms[$key]); } $LoR = 1 - $LoR; } if (!$LoR) { $perm_table->addCol(); } // Delete User $perm_table->addRow(); $perm_table->addCol("<hr>", array("colspan" => 2)); $perm_table->addRow(); $perm_table->addCol("Delete user:"******"<input type=\"checkbox\" name=\"delete\" value=\"true\"> Tick box to delete the user permanently."); $perm_table->addRow(); $perm_table->addCol("<hr>", array("colspan" => 2)); // Commit changes button. $perm_table->addHeaderCentered("<input type=\"submit\" name=\"send\" value=\"Commit changes\">", array("colspan" => 2, "align" => "center")); } $form .= "<form action=\"index.php\" method=\"POST\">"; $form .= "<input type=\"hidden\" name=\"id\" value=\"" . $_GET[id] . "\">"; $form .= "<input type=\"hidden\" name=\"check\" value=\"true\">"; $form .= "<input type=\"hidden\" name=\"action\" value=\"edituser\">"; // Show all logins. $logins = getLogins($id); // Show failed logins. $failed_logins = showFailedLogins("15", idToUsername($id)); /* * Transactions. */ if ($MySelf->isAccountant()) { $acc = new table(2, true); $acc->addHeader(">> Create transaction to user " . ucfirst(idToUsername($id))); $acc->addRow(); $acc->addCol("Credit to:"); $acc->addCol($username); $acc->addRow(); $acc->addCol("Authorization by:"); $acc->addCol(ucfirst($MySelf->getUsername())); $acc->addRow(); $acc->addCol("Time of Transaction:"); $acc->addCol(date("r", $TIMEMARK)); $acc->addRow(); $acc->addCol("Withdrawal or deposit:"); $pdm = "<select name=\"wod\">"; $pdm .= "<option value=\"0\">Deposit (give money)</option>"; $pdm .= "<option SELECTED value=\"1\">Withdrawal (take money)</option>"; $pdm .= "</select>"; $acc->addCol($pdm); $acc->addRow(); $acc->addCol("Amount:"); $acc->addCol("<input size=\"8\" type=\"text\" name=\"amount\"> ISK"); $acc->addRow(); $acc->addCol("Reason:"); $pdm = "<select name=\"reason1\">"; $pdm .= "<option>requested payout</option>"; $pdm .= "<option SELECTED>normal payout</option>"; $pdm .= "<option>payout of loan</option>"; $pdm .= "<option>manual deposit</option>"; $pdm .= "<option>cash recived</option>"; $pdm .= "</select>"; $acc->addCol($pdm . " -or- <input type=\"text\" name=\"reason2\">"); $acc->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Authorize transaction\">"); $transBox = "<form action=\"index.php\" method=\"POST\">"; $transBox .= $acc->flush(); $transBox .= "<input type=\"hidden\" name=\"id\" value=\"" . $_GET[id] . "\">"; $transBox .= "<input type=\"hidden\" name=\"check\" value=\"true\">"; $transBox .= "<input type=\"hidden\" name=\"action\" value=\"transaction\">"; $transBox .= "</form>"; } $page = "<h2>Managing user details</h2>" . $form . $table->flush() . "<br>" . $apit->flush() . "<br>" . $perm_table->flush() . "</form>" . $transBox; $transactions = getTransactions($id); if ($transactions) { $page .= $transactions; } // Add login table if we have more than 0 logins. if ($logins) { if ($transactions) { $page .= "<br>"; } $page .= $logins; } $page .= $failed_logins; // Return the page. return $page; }
function makeWelcome() { // Load the globals. global $VERSION; global $SITENAME; global $IGB; global $IGB_VISUAL; global $MySelf; global $DB; global $ValidUntil; /* HTML stuff */ $page = "<h2>Welcome to {$VERSION}!</h2>"; /* The welcome table */ $table = new table(2, true); $table->addHeader(">> Welcome to {$VERSION}"); $table->addRow(); $table->addCol("Logged in as:", array("bold" => true, "align" => "right")); $table->addCol(ucfirst($MySelf->getUsername())); $table->addRow(); $table->addCol("Registered Rank:", array("bold" => true, "align" => "right")); $table->addCol($MySelf->getRankName()); $table->addRow(); $table->addCol("Latest login:"******"bold" => true, "align" => "right")); if ($MySelf->getLastlogin() < 1) { $table->addCol("This is your very first login! Welcome!"); } else { $table->addCol(date("r", $MySelf->getLastlogin())); } $table->addRow(); $table->addCol("Your account:", array("bold" => true, "align" => "right")); $table->addCol(number_format(getCredits($MySelf->getID()), 2) . " ISK"); $table->addRow(); $table->addCol("Your profile:", array("bold" => true, "align" => "right")); $table->addCol(makeProfileLink($MySelf->getID())); global $BLESSED; if ($BLESSED) { $table->addRow("#330000"); $table->addCol("Installation Blessed!", array("bold" => true, "align" => "right")); $table->addCol("It is not affected by expiration. It runs with the highest priority on the server and all limitations have been lifted."); } // Set the filename to the announce textfile. $announceFile = "/path/to/your/announce/txt.file"; // Check its existance... if (file_exists($announceFile)) { // Then load it. $globalAnnounce = file_get_contents($announceFile); } // Only display contents if more than X characters long. if (strlen($globalAnnounce) > 10) { // Create announcement table... $announceTable = new table(1, true); $announceTable->addHeader(">>> Important hosting information"); $announceTable->addRow(); $announceTable->addCol("{$globalAnnounce}"); // ... and add it to the page. $page .= $announceTable->flush(); } $page .= $table->flush(); /* Show failed Logins to admins. */ if ($MySelf->isAdmin()) { $page .= showFailedLogins("15"); } else { $page .= showFailedLogins("10", $MySelf->getUsername()); } /* permissions table */ $permsTable = new table(1, true); $permsTable->addHeader(">> Your permissions"); // Permissions matrix $perms = array("canLogin" => "log in.", "canJoinRun" => "join mining operations.", "canCreateRun" => "create new mining operations.", "canCloseRun" => "close mining operations.", "canDeleteRun" => "delete mining operations.", "canAddHaul" => "haul to mining operations.", "canSeeEvents" => "view scheduled events.", "canEditEvents" => "add and delete scheduled events.", "canChangePwd" => "change your own password.", "canChangeEmail" => "change your own email.", "canChangeOre" => "manage ore prices and enable/disable them.", "canAddUser" => "add new accounts.", "canSeeUsers" => "see other accounts.", "canDeleteUser" => "delete other accounts.", "canEditRank" => "edit other peoples ranks.", "canManageUser" => "grant and take permissions.", "isAccountant" => "manage the corporation wallet and authorize payments.", "isOfficial" => "create official mining runs (with payout)."); $permDS = $DB->getAssoc("SELECT * FROM users WHERE id='" . $MySelf->getID() . "' AND deleted='0'"); $keys = array_keys($perms); foreach ($keys as $key) { if ($permDS[$MySelf->getID()][$key] == 1) { $permsTable->addRow(); $permsTable->addCol("You are allowed to " . $perms[$key]); } } $permsTable->addHeader("If you believe your permissions are faulty, consult your CEO immediatly."); // Show the balance $balance = getTransactions($MySelf->getID()); $logins = getLogins($MySelf->getID()); $page .= "<br>" . $balance . "<br>" . $permsTable->flush() . "<br>" . $logins; // .. then return it. return $page; }