コード例 #1
0
function lotto_editLottery()
{
    // We need some globals
    global $MySelf;
    global $DB;
    $formDisable = "";
    if (lotto_getOpenDrawing()) {
        $formDisable = "disabled";
    }
    // is Lotto enabled at all?
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Deny access to non-lotto-officials.
    if (!$MySelf->isLottoOfficial()) {
        makeNotice("You are not allowed to do this!", "error", "Permission denied");
    }
    $table = new table(2, true);
    $table->addHeader(">> Open new drawing");
    $table->addRow();
    $table->addCol("Number of tickets in draw:");
    $table->addCol("<input type=\"text\" name=\"count\" " . $formDisable . " value=\"30\">");
    //	$newLotto = new table (2);
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" " . $formDisable . " value=\"open new drawing\">", array("bold" => true, "colspan" => 2));
    $html = "<h2>Lotto Administration</h2>";
    $html .= "<form action=\"index.php\" method=\"POST\">";
    $html .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $html .= "<input type=\"hidden\" name=\"action\" value=\"createDrawing\">";
    $html .= $table->flush();
    $html .= "</form>";
    if (lotto_getOpenDrawing()) {
        $html .= "[<a href=\"index.php?action=drawLotto\">Draw Winner</a>]";
    }
    return $html;
}
コード例 #2
0
ファイル: showHierarchy.php プロジェクト: nuxi/MiningBuddy
function showHierarchy()
{
    // Globals!
    global $DB;
    // Get all sorted ranks.
    $Ranks = $DB->query("SELECT DISTINCT name, rankid, rankOrder FROM ranks ORDER by rankOrder ASC");
    while ($rank = $Ranks->fetchRow()) {
        // Get all the users in the current rank.
        $peopleInRank = $DB->query("SELECT DISTINCT username, rank FROM users WHERE rank='{$rank['rankid']}' AND deleted='0' AND canLogin='******' ORDER BY username");
        // Are there people in this rank?
        if ($peopleInRank->numRows() > 0) {
            // Create a temp. table.
            $table = new table(1, true);
            $table->addHeader(">> " . $rank[name]);
            while ($peep = $peopleInRank->fetchRow()) {
                $table->addRow();
                $table->addCol("<a href=\"index.php?action=profile&id=" . usernameToID($peep[username]) . "\">" . ucfirst($peep[username]) . "</a>");
            }
            $html .= $table->flush() . "<br>";
            unset($table);
        }
    }
    $header = "<h2>" . getConfig("sitename") . " - Hierarchy</h2>";
    return $header . $html;
}
コード例 #3
0
ファイル: makeAddUserForm.php プロジェクト: nuxi/MiningBuddy
function makeAddUserForm()
{
    // Are we allowed to?
    global $MySelf;
    if (!$MySelf->canAddUser()) {
        makeNotice("You are not authorized to do that!", "error", "Forbidden");
    }
    // Suggest a user password.
    $suggestedPassword = crypt(base64_encode(rand(11111, 99999)), "8ewf7tg2k,leduj");
    $table = new table(2, true);
    $table->addHeader(">> Add a new user");
    $table->addRow("#060622");
    $table->addCol("You can manually add a new user with this form. But use this only " . "as a last resort, for example, if your server can not send eMails. " . "Always let the user request an account. This form was supposed to be " . "removed, but complains from the users kept it alive.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Username:"******"<input type=\"text\" name=\"username\" maxlength=\"20\">");
    $table->addRow();
    $table->addCol("eMail:");
    $table->addCol("<input type=\"text\" name=\"email\">");
    $table->addRow();
    $table->addCol("Password:"******"<input type=\"password\" name=\"pass1\" value=\"{$suggestedPassword}\"> (Suggested: {$suggestedPassword})");
    $table->addRow();
    $table->addCol("Verify Password:"******"<input type=\"password\" name=\"pass2\" value=\"{$suggestedPassword}\">");
    $table->addHeaderCentered("<input type=\"submit\" name=\"create\" value=\"Add user to database\">");
    $page = "<h2>Add a new User</h2>";
    $page .= "<form action=\"index.php\" method=\"post\">";
    $page .= $table->flush();
    $page .= "<input type=\"hidden\" name=\"action\" value=\"newuser\">";
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $page .= "</form>";
    return $page;
}
コード例 #4
0
function makeRequestAccountPage($failedFastLogin = false)
{
    // We need global Variables.
    global $VERSION;
    global $SITENAME;
    global $IGB;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $table = new table(2, true);
    } else {
        $table = new table(2, true, "width=\"500\"", "align=\"center\"");
    }
    if ($_GET[admin] == true) {
        $table->addHeader(">> Create initial Superadmin account");
    } else {
        $table->addHeader(">> Request an account");
    }
    // Trust, INC.
    if ($failedFastLogin) {
        // This happens when someone allowed fast logins(!) and the user does not exist.
        global $EVE_Charname;
        $table->addRow("#660000");
        $table->addCol("Fast login failed; Username \"" . ucfirst($EVE_Charname) . "\" does not exist.", array("colspan" => 2, "align" => "center"));
    }
    $table->addRow("#060622");
    if ($_GET[admin] == true) {
        $table->addCol("Fill out the form below to create the initial superadmin account. " . "This account will have all priviledges - so keep the login credentials safe! " . "Your password will be randomly generated and revealed to you just once, " . "so write it down or copy it elsewhere. You will have the option to " . "change your password on your first login.", array("colspan" => 2));
    } else {
        $table->addCol("Fill out the form below to apply for a new account. After you requested " . "an account you will receive an email with an activation link. Finally, your " . "CEO has to approve of your account, after which you will receive your initial password.", array("colspan" => 2));
    }
    $table->addRow();
    $table->addCol("Character Name:");
    // Trust, INC.
    global $EVE_Charname;
    if ($EVE_Charname) {
        $table->addCol("<input type=\"text\" name=\"username\" value=\"{$EVE_Charname}\" maxlength=\"30\">");
    } else {
        $table->addCol("<input type=\"text\" name=\"username\" maxlength=\"30\">");
    }
    $table->addRow();
    $table->addCol("Your valid eMail:");
    $table->addCol("<input type=\"text\" name=\"email\" maxlength=\"70\">");
    if ($_GET[admin] == false) {
        $table->addHeaderCentered("<input type=\"submit\" name=\"login\" value=\"request account\">");
        $table->addRow("#060622");
        $table->addCol("[<a href=\"index.php\">Cancel request</a>]", array("colspan" => 2));
    } else {
        $table->addHeaderCentered("<input type=\"submit\" name=\"login\" value=\"Create Superadmin\">");
    }
    $page = "<br><br>";
    $page .= "<form action=\"index.php\" method=\"post\">";
    $page .= "<input type=\"hidden\" name=\"action\" value=\"requestaccount\">";
    $page .= $table->flush();
    $page .= "</form><br><br>";
    // Print it, and die (special case: login does not get beautified.)
    $html = new html();
    $html->addBody($page);
    die($html->flush());
}
コード例 #5
0
ファイル: editTemplate.php プロジェクト: nuxi/MiningBuddy
function editTemplate()
{
    global $DB;
    global $MySelf;
    // Are we allowed to?
    if (!$MySelf->isAdmin()) {
        makeNotice("Only an Administator can edit the sites templates.", "warning", "Access denied");
    }
    // No Identifier, no service
    if ($_POST[check]) {
        // We got the returning form, edit it.
        numericCheck($_POST[id], 0);
        $ID = $_POST[id];
        // Fetch the current template, see that its there.
        $test = $DB->query("SELECT identifier FROM templates WHERE id='{$ID}' LIMIT 1");
        if ($test->numRows() == 1) {
            // We got the template
            $template = sanitize($_POST[template]);
            $DB->query("UPDATE templates SET template='" . $template . "' WHERE id='{$ID}' LIMIT 1");
            // Check for success
            if ($DB->affectedRows() == 1) {
                // Success!
                header("Location: index.php?action=edittemplate&id={$ID}");
            } else {
                // Fail!
                makeNotice("There was a problem updating the template in the database!", "error", "Internal Error", "index.php?action=edittemplate&id={$ID}", "Cancel");
            }
        } else {
            // There is no such template
            makeNotice("There is no such template in the database!", "error", "Invalid Template!", "index.php?action=edittemplate&id={$ID}", "Cancel");
        }
    } elseif (empty($_GET[id])) {
        // No returning form, no identifier.
        header("Location: index.php?action=configuration");
    } else {
        $ID = $_GET[id];
    }
    // numericheck!
    numericCheck($ID, 0);
    $temp = $DB->getCol("SELECT template FROM templates WHERE id='{$ID}' LIMIT 1");
    $table = new table(1, true);
    $table->addHeader(">> Edit template");
    $table->addRow();
    $table->addCol("<center><textarea name=\"template\" rows=\"30\" cols=\"60\">" . $temp[0] . "</textarea></center>");
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Edit Template\">");
    $form1 = "<form action=\"index.php\" method=\"POST\">";
    $form2 = "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $form2 .= "<input type=\"hidden\" name=\"action\" value=\"editTemplate\">";
    $form2 .= "<input type=\"hidden\" name=\"id\" value=\"" . $ID . "\">";
    $form2 .= "</form>";
    $backlink = "<br><a href=\"index.php?action=configuration\">Back to configuration</a>";
    return "<h2>Edit the template</h2>" . $form1 . $table->flush() . $form2 . $backlink;
}
コード例 #6
0
ファイル: confirm.php プロジェクト: nuxi/MiningBuddy
function confirm($question = "Are you sure?")
{
    // switch post or get.
    if (isset($_POST[check])) {
        // The user confirmed the box. Dont loop. Accept it already ;)
        if ($_POST[confirmed] == true) {
            return true;
        }
        $MODE = "POST";
        $FORM = $_POST;
        $keys = array_keys($_POST);
    } else {
        // The user confirmed the box. Dont loop. Accept it already ;)
        if ($_GET[confirmed] == true) {
            return true;
        }
        $MODE = "GET";
        $FORM = $_GET;
        $keys = array_keys($_GET);
    }
    // Assemble hidden values for the confirm form.
    foreach ($keys as $key) {
        $html .= "<input type=\"hidden\" name=\"" . $key . "\" value=\"" . $FORM[$key] . "\">";
    }
    // Cancel button
    $cancel = "<form action=\"index.php\" method=\"POST\">";
    $cancel .= "<input type=\"submit\" name=\"confirmed\" value=\"CANCEL\">";
    $cancel .= "</form>";
    // OK button
    $ok = "<form action=\"index.php\" method=\"{$MODE}\">";
    $ok .= $html;
    $ok .= "<input type=\"submit\" name=\"confirmed\" value=\"OK\">";
    $ok .= "</form>";
    $table = new table("2", true, "width=\"50%\"", "align=\"center\"");
    $table->addHeader("<img src=\"./images/warning.png\">");
    $table->addRow("#060622");
    $table->addCol(">> Confirmation needed", array("colspan" => "2"));
    $table->addRow();
    $table->addCol("<br>" . $question . "<br><br>", array("colspan" => "2"));
    $table->addRow();
    $table->addCol($cancel, array("align" => "left"));
    $table->addCol($ok, array("align" => "right"));
    $htmlobj = new html();
    $htmlobj->addBody("<br><br><br><br>" . $table->flush() . "<br><br><br><br>");
    die($htmlobj->flush());
}
コード例 #7
0
ファイル: makeLostPassForm.php プロジェクト: nuxi/MiningBuddy
function makeLostPassForm()
{
    // We need some global vars again.
    global $IGB;
    global $SITENAME;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $table = new table(2, true);
    } else {
        $table = new table(2, true, "width=\"500\"", "align=\"center\"");
    }
    $table->addHeader(">> Request a new password");
    $table->addRow("#060622");
    $table->addCol("Fill out the form below to have a new password generated and sent to you registered eMail address.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Character Name:");
    // Trust, INC.
    global $EVE_Charname;
    if ($EVE_Charname) {
        $table->addCol("<input type=\"text\" name=\"username\" value=\"{$EVE_Charname}\" maxlength=\"30\">");
    } else {
        $table->addCol("<input type=\"text\" name=\"username\" maxlength=\"30\">");
    }
    $table->addRow();
    $table->addCol("Your valid eMail:");
    $table->addCol("<input type=\"text\" name=\"email\" maxlength=\"70\">");
    $table->addHeaderCentered("<input type=\"submit\" name=\"change\" value=\"Get Password\">");
    $table->addRow("#060622");
    $table->addCol("[<a href=\"index.php\">Cancel request</a>]", array("colspan" => 2));
    //	$page = "<h2>Lost password</h2>";
    $page = "<br><br>";
    $page .= "<form action=\"index.php\" method=\"post\">";
    $page .= "<input type=\"hidden\" name=\"action\" value=\"lostpass\">";
    $page .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $page .= $table->flush();
    $page .= "</form><br><br>";
    // Print it, and die (special case: login does not get beautified.)
    $html = new html();
    $html->addBody($page);
    die($html->flush());
}
コード例 #8
0
ファイル: getTransactions.php プロジェクト: nuxi/MiningBuddy
function getTransactions($user)
{
    // Database 4tw!
    global $DB;
    // Sanity!
    numericCheck($user, 0);
    // Grande Heading!
    $table = new table(6, true);
    $table->addHeader(">> Transaction log for <a href=\"index.php?action=edituser&id={$user}\">" . ucfirst(idToUsername($user)) . "</a> " . number_format(getCredits($user), 2) . " ISK");
    // Table columns descriptors.
    $table->addRow("#060622");
    $table->addCol("Date");
    $table->addCol("Transaction ID");
    $table->addCol("Banker");
    $table->addCol("Type");
    $table->addCol("Amount");
    $table->addCol("Reason");
    // ask the oracle.
    $transactions = $DB->getCol("SELECT COUNT(id) as count FROM transactions WHERE owner='" . $user . "' ORDER BY time DESC, id DESC");
    $transactions_count = $transactions[0];
    $transactions_pages = ceil($transactions_count / 20);
    // No transactions yet.
    if ($transactions_count < 1) {
        return false;
    }
    $currentPage = isset($_GET['walletPage']) ? $_GET['walletPage'] : 0;
    // Get the right amount of datasets from the dbase.
    if ($currentPage > 0 && is_numeric($currentPage)) {
        $min = 20 * $currentPage - 20;
    } else {
        $min = 0;
    }
    // Query the database accordingly
    $transactions = $DB->query("SELECT * FROM transactions WHERE owner='" . $user . "' ORDER BY time DESC, id DESC LIMIT {$min},20");
    while ($transaction = $transactions->fetchRow()) {
        $table->addRow();
        $table->addCol(date("d.m.y H:i:s", $transaction['time']));
        $table->addCol(str_pad($transaction['id'], "6", "0", STR_PAD_LEFT));
        $table->addCol(ucfirst(idToUsername($transaction['banker'])));
        switch ($transaction['type']) {
            case "0":
                $table->addCol("deposit");
                break;
            case "1":
                $table->addCol("withdrawal");
                break;
        }
        if ($transaction['amount'] > 0) {
            $table->addCol("<font color=\"#00ff00\">" . number_format($transaction['amount'], 2) . " ISK</font>");
        } else {
            $table->addCol("<font color=\"#ff0000\">" . number_format($transaction['amount'], 2) . " ISK</font>");
        }
        $table->addCol(strtolower($transaction['reason']));
    }
    // Get the right next and previous pages.
    $currentPage = isset($_GET['walletPage']) ? $_GET['walletPage'] : 0;
    // if we have more than 1 page, show the navbar.
    if ($transactions_pages > 1) {
        // Handle first page: Static numbering.
        if ($currentPage < 1) {
            $next = 2;
        } else {
            // handle pages greater 2. Check if we have yet another page.
            if ($transactions_pages > $currentPage) {
                $next = $currentPage + 1;
            }
            // All pages above 2 have a previous page.
            $prev = $currentPage - 1;
        }
        $table->addRow("#060622");
        // Show backlink, unless we are at page 1.
        if ($prev) {
            // We have a previous page (at page > 1)
            $table->addCol("<a href=\"index.php?action={$_GET['action']}&id={$_GET['id']}&walletPage={$prev}\">prev</a>", array("colspan" => 2));
        } else {
            // No previos page (at page 1);
            $table->addCol(" ", array("colspan" => 2));
        }
        // Show direct page links.
        if ($transactions_pages > 1) {
            for ($i = 1; $i <= $transactions_pages; $i++) {
                if ($currentPage == $i) {
                    $text .= "[{$i}]";
                } else {
                    $text .= "[<a href=\"index.php?action={$_GET['action']}&id={$_GET['id']}&walletPage={$i}\">{$i}</a>]";
                }
            }
        }
        $table->addCol($text, array("colspan" => 2, "align" => "center"));
        // Next link
        if ($currentPage < $transactions_pages) {
            // We have a next page. (at page < n)
            $table->addCol("<a href=\"index.php?action={$_GET['action']}&id={$_GET['id']}&walletPage={$next}\">next</a>", array("colspan" => 2, "align" => right));
        } else {
            // This was the last page. (at page n)
            $table->addCol(" ", array("colspan" => 2));
        }
    }
    $table->addHeader("If there are any problems with your transactions, contact your ceo immediatly.");
    return $table->flush();
}
コード例 #9
0
ファイル: showRanks.php プロジェクト: nuxi/MiningBuddy
function showRanks()
{
    // We needeth the databaseth!
    global $DB;
    global $MySelf;
    // Is sire alloweth to logineth?
    if (!$MySelf->canEditRank()) {
        makeNotice("You do not have sufficient rights to access this page.", "warning", "Access denied");
    }
    // Get all current ranks.
    $ranks_ds = $DB->query("SELECT * FROM ranks ORDER BY rankOrder ASC");
    $currentRanks = $ranks_ds->numRows();
    // Are there any ranks defined yet?
    if ($currentRanks > 0) {
        // Yuh. Create table.
        $headerConfig = array("bold" => true, "align" => "center");
        $table = new table(4, true);
        $table->addHeader(">> Edit current ranks");
        $table->addRow();
        $table->addCol("Rank Order", $headerConfig);
        $table->addCol("Rank Name", $headerConfig);
        $table->addCol("Nr. of times Issued", $headerConfig);
        $table->addCol("Delete Rank", $headerConfig);
        // Create a nice, fancy row for every rank.
        while ($rank = $ranks_ds->fetchRow()) {
            $table->addRow();
            for ($i = 1; $i <= $currentRanks; $i++) {
                $ro = str_pad($i, 3, "0", STR_PAD_LEFT);
                if ($rank[rankOrder] == $i) {
                    $pdm .= "<option SELECTED value=\"{$ro}\">{$i}</option>";
                } else {
                    $pdm .= "<option value=\"{$ro}\">{$i}</option>";
                }
            }
            $ddm = "<select name=\"order_" . $rank[rankid] . "\">" . $pdm . "</select>";
            $table->addCol($ddm, $headerConfig);
            $table->addCol("<input type=\"text\" name=\"title_" . $rank[rankid] . "_name\" value=\"" . $rank[name] . "\">", $headerConfig);
            // how many times has the rank been issue?
            $count = $DB->getCol("SELECT COUNT(id) FROM users WHERE rank='{$rank['rankid']}' AND deleted='0'");
            $count = $count[0];
            if ($count < 1) {
                $table->addCol("<i>Rank not used</i>");
            } else {
                $table->addCol($count);
            }
            $table->addCol("<a href=\"index.php?action=deleterank&id={$rank['rankid']}\">delete</a>", $headerConfig);
            unset($pdm);
            unset($ddm);
        }
        // Submit button & stuff.
        $hidden = "<input type=\"hidden\" name=\"check\"  value=\"true\">" . "<input type=\"hidden\" name=\"action\"  value=\"editranks\">";
        $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update Ranks\">");
        $rankTable = "<form action=\"index.php\" method=\"POST\">" . $table->flush() . $hidden . "</form>";
        unset($table);
        unset($currentRanks);
    }
    // Create the new-rank-form-jiggamajig.
    $table = new table(2, true);
    $table->addHeader(">> Add a new rank");
    $table->addRow();
    $table->addCol("Rank name:");
    $table->addCol("<input type=\"text\" name=\"rankname\">");
    $hidden = "<input type=\"hidden\" name=\"check\"  value=\"true\">" . "<input type=\"hidden\" name=\"action\"  value=\"addnewrank\">";
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Add Rank\">");
    $addRankTable = "<form action=\"index.php\" method=\"POST\">" . $table->flush() . $hidden . "</form>";
    // Flush the page!
    return "<h2>Edit the ranks</h2>" . $rankTable . $addRankTable;
}
コード例 #10
0
ファイル: makeMenu.php プロジェクト: nuxi/MiningBuddy
function makeMenu($page = false)
{
    // We need some globals.
    global $SITENAME;
    global $IGB;
    global $MySelf;
    global $TIMEMARK;
    global $UPDATE;
    global $IGB_VISUAL;
    $mining_AddHaul = "";
    $mining_canTimer = "";
    $mining_addOp = "";
    $admin_addUser = "";
    $admin_Ore = "";
    $admin_Ships = "";
    $admin_viewUser = "";
    $events_add = "";
    $events_view = "";
    $operationsModule = "";
    $eventsModule = "";
    $lottoModule = "";
    $adminModule = "";
    $pref_emailValid = "";
    /*
     * Mining related Menues.
     */
    // Create Run
    if ($MySelf->canCreateRun()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $mining_addOp = "[<a href=\"index.php?action=newrun\">Add Op</a>]";
        } else {
            // Using a real browser.
            $mining_addOp = "<a class='menu' href=\"index.php?action=newrun\">&gt; Add Op</a>";
        }
    }
    // Add Haul
    if ($MySelf->canAddHaul() && userInRun($MySelf->getID())) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $mining_AddHaul = "[<a href=\"index.php?action=addhaul\">Add Haul</a>]";
        } else {
            // Using a real browser.
            $mining_AddHaul = "<a class='menu' href=\"index.php?action=addhaul\">&gt; Add Haul</a>";
        }
    }
    // See all ops link.
    if ($IGB && $IGB_VISUAL) {
        $mining_AllOps = "[<a href=\"index.php?action=list\">List Ops</a>]";
    } else {
        $mining_AllOps = "<a class='menu' href=\"index.php?action=list\">&gt; List Ops</a>";
    }
    // Ore Quotes
    if ($IGB && $IGB_VISUAL) {
        $mining_oreQuotes = "[<a href=\"index.php?action=showorevalue\">Quotes</a>]";
    } else {
        $mining_oreQuotes = "<a class='menu' href=\"index.php?action=showorevalue\">&gt; Quotes</a>";
    }
    // Can timer link
    if (getConfig("cargocontainer")) {
        if ($IGB && $IGB_VISUAL) {
            $mining_canTimer = "[<a href=\"index.php?action=cans\">Can Timer</a>]";
        } else {
            $mining_canTimer = "<a class='menu' href=\"index.php?action=cans\">&gt; Can Timer</a>";
        }
    }
    // Statistics
    if ($IGB && $IGB_VISUAL) {
        $mining_stats = "[<a href=\"index.php?action=globstats\">Statistics</a>]";
    } else {
        $mining_stats = "<a class='menu' href=\"index.php?action=globstats\">&gt; Statistics</a>";
    }
    // Hierarchy
    if ($IGB && $IGB_VISUAL) {
        $mining_hier = "[<a href=\"index.php?action=hierarchy\">Hierarchy</a>]";
    } else {
        $mining_hier = "<a class='menu' href=\"index.php?action=hierarchy\">&gt; Hierarchy</a>";
    }
    // Ship Values
    if ($IGB && $IGB_VISUAL) {
        $mining_shipValues = "[<a href=\"index.php?action=showshipvalue\">Ship Values</a>]";
    } else {
        $mining_shipValues = "<a class='menu' href=\"index.php?action=showshipvalue\">&gt; Ship Values</a>";
    }
    // Assemble the mining Module link.
    if ($IGB && $IGB_VISUAL) {
        $miningModule = $mining_AllOps . " " . $mining_AddHaul . " " . $mining_canTimer . " " . $mining_oreQuotes . " " . $mining_ShipValues . " " . $mining_addOp . " " . $mining_stats . "";
    } else {
        $miningModule = "<div>";
        $miningModule .= "<img src=\"./images/m-mining.png\">";
        $miningModule .= $mining_AllOps;
        $miningModule .= $mining_AddHaul;
        $miningModule .= $mining_canTimer;
        $miningModule .= $mining_oreQuotes;
        $miningModule .= $mining_shipValues;
        $miningModule .= $mining_addOp;
        $miningModule .= $mining_stats;
        $miningModule .= $mining_hier;
        $miningModule .= "</div><div class='clear'></div>";
    }
    /*
     * Preferences Stuff
     */
    // Is our Email validated?
    if (!$MySelf->getEmailvalid()) {
        // No, its not!
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $pref_emailValid = "[<a href=\"index.php?action=revalidate\">confirm email</a>]";
        } else {
            // Using a real browser.
            $pref_emailValid = "<a class='menu' href=\"index.php?action=revalidate\">&gt; Validate Email</a>";
        }
    }
    if ($IGB && $IGB_VISUAL) {
        $pref_Pref = "[<a href=\"index.php?action=preferences\">Preferences</a>]";
    } else {
        $pref_Pref = "<a class='menu' href=\"index.php?action=preferences\">&gt; Preferences</a>";
    }
    if ($IGB && $IGB_VISUAL) {
        $pref_Prof = "[<a href=\"index.php?action=profile&id=" . $MySelf->getID() . "\">Profile</a>]";
    } else {
        $pref_Prof = "<a class='menu' href=\"index.php?action=profile&id=" . $MySelf->getID() . "\">&gt; Profile</a>";
    }
    if ($IGB && $IGB_VISUAL) {
        $pref_Style = "[<a href=\"index.php?action=profile&id=" . $MySelf->getID() . "\">Style</a>]";
    } else {
        $pref_Style = "<a class='menu' href=\"index.php?action=style&id=" . $MySelf->getID() . "\">&gt; Style</a>";
    }
    // Assemble the Preferences module
    if ($IGB && $IGB_VISUAL) {
        $prefModule = $pref_Pref . " " . $pref_Prof . " " . $pref_emailValid . "";
    } else {
        $prefModule = "<div>";
        $prefModule .= "<img border=\"0\" src=\"images/m-preferences.png\">";
        $prefModule .= $pref_Pref;
        $prefModule .= $pref_Prof;
        $prefModule .= $pref_emailValid;
        $prefModule .= $pref_Style;
        $prefModule .= "</div><div class='clear'></div>";
    }
    /*
     * Logout Stuff
     */
    if ($IGB && $IGB_VISUAL) {
        // Are we IGB && Passwordless login?
        if (getConfig("trustSetting") == 2 && $IGB) {
            $logoutModule = "<i>Can not logout due to fast login.</i>";
        } else {
            $logoutModule = "[<a href=\"index.php?auth=logout\">Logout</a>]";
        }
    } else {
        if (getConfig("trustSetting") == 2 && $IGB) {
            $logoutModule = "";
        } else {
            $logoutModule = "<div>";
            $logoutModule .= "<img src=\"images/m-logout.png\">";
            $logoutModule .= "<a class='menu' href=\"index.php?action=switch\">&gt; Switch Character</a>";
            $logoutModule .= "<a class='menu' href=\"index.php?auth=logout\">&gt; Logout</a>";
            $logoutModule .= "</div><div class='clear'></div>";
        }
    }
    /*
     * Administrative Stuff
     */
    // Are we allowed to change the ore value, edit it?
    if ($MySelf->canChangeOre()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_Ore = "[<a href=\"index.php?action=changeow\">Edit Items</a>]";
        } else {
            // Using a real browser.
            $admin_Ore = "<a class='menu' href=\"index.php?action=changeow\">&gt; Edit Items</a>";
        }
    }
    // Are we allowed to change the ship value, edit it?
    if ($MySelf->canChangeOre()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_Ships = "[<a href=\"index.php?action=changesv\">Edit Ships</a>]";
        } else {
            // Using a real browser.
            $admin_Ships = "<a class='menu' href=\"index.php?action=changesv\">&gt; Edit Ships</a>";
        }
    }
    // Site configuration
    if ($MySelf->isAdmin()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_site = "[<a href=\"index.php?action=configuration\">Site Settings</a>]";
        } else {
            // Using a real browser.
            $admin_site = "<a class='menu' href=\"index.php?action=configuration\">&gt; Site Settings</a>";
        }
    }
    // Site Maintenance
    if ($MySelf->isAdmin()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_maint = "[<a href=\"index.php?action=maintenance\">Maintenance</a>]";
        } else {
            // Using a real browser.
            $admin_maint = "<a class='menu' href=\"index.php?action=maintenance\">&gt; Maintenance</a>";
        }
    }
    // Manage Ranks
    if ($MySelf->canEditRank()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_ranks = "[<a href=\"index.php?action=showranks\">Edit Ranks</a>]";
        } else {
            // Using a real browser.
            $admin_ranks = "<a class='menu' href=\"index.php?action=showranks\">&gt; Edit Ranks</a>";
        }
    }
    // Are we allowed to view Users?
    if ($MySelf->canSeeUsers()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_viewUser = "******"index.php?action=editusers\">List Users</a>]";
        } else {
            // Using a real browser.
            $admin_viewUser = "******"index.php?action=editusers\">&gt; List Users</a>";
        }
    }
    // Are we allowed to
    if ($MySelf->canAddUser()) {
        // Yeah we are allowed to do this.
        if ($IGB && $IGB_VISUAL) {
            // Browswing in the iGB.
            $admin_addUser = "******"index.php?action=newuser\">Add User</a>]";
        } else {
            // Using a real browser.
            $admin_addUser = "******"index.php?action=newuser\">&gt; Add User</a>";
        }
    }
    // Assemble the module.
    if ($admin_addUser || $admin_Ore || $admin_Ships || $admin_viewUser) {
        if ($IGB && $IGB_VISUAL) {
            $adminModule = $admin_site . " " . $admin_ranks . " " . $admin_viewUser . " " . $admin_addUser . " " . $admin_Ore . " " . $admin_Ships . "";
        } else {
            $adminModule = "<div>";
            $adminModule .= "<img src=\"images/m-administration.png\">";
            $adminModule .= $admin_site;
            $adminModule .= $admin_maint;
            $adminModule .= $admin_viewUser;
            $adminModule .= $admin_addUser;
            $adminModule .= $admin_ranks;
            $adminModule .= $admin_Ore;
            $adminModule .= $admin_Ships;
            $adminModule .= "</div><div class='clear'></div>";
        }
    }
    /*
     * Events Stuff
     */
    if (getConfig("events")) {
        // Are we allowed to see events?
        if ($MySelf->canSeeEvents()) {
            // Yeah we are allowed to do this.
            if ($IGB && $IGB_VISUAL) {
                // Browswing in the iGB.
                $events_view = "[<a href=\"index.php?action=showevents\">Schedule</a>]";
            } else {
                // Using a real browser.
                $events_view = "<a class='menu' href=\"index.php?action=showevents\">&gt; Schedule</a>";
            }
        }
        // Are we allowed to add events?
        if ($MySelf->canEditEvents()) {
            // Yeah we are allowed to do this.
            if ($IGB && $IGB_VISUAL) {
                // Browswing in the iGB.
                $events_add = "[<a href=\"index.php?action=addevent\">Add Event</a>]";
            } else {
                // Using a real browser.
                $events_add = "<a class='menu' href=\"index.php?action=addevent\">&gt; Add Event</a>";
            }
        }
    }
    // El grande Online Thingy
    if ($IGB && $IGB_VISUAL) {
        $events_OnlineTimer = "[<a href=\"index.php?action=onlinetime\">Online Time</a>]";
    } else {
        $events_OnlineTimer = "<a class='menu' href=\"index.php?action=onlinetime\">&gt; Online Time</a>";
    }
    // Assemblte Events module
    if ($events_add || $events_view) {
        if ($IGB && $IGB_VISUAL) {
            $eventsModule = $events_view . " " . $events_add . " " . $events_OnlineTimer . "";
        } else {
            $eventsModule = "<div>";
            $eventsModule .= "<img src=\"./images/m-events.png\">";
            $eventsModule .= $events_view;
            $eventsModule .= $events_add;
            $eventsModule .= $events_OnlineTimer;
            $eventsModule .= "</div><div class='clear'></div>";
        }
    }
    /*
     * Wallet stuff
     */
    if ($IGB && $IGB_VISUAL) {
        $walletModule = "[<a href=\"index.php?action=manageWallet\">Manage Wallet</a>]";
        if ($MySelf->isAccountant()) {
            $walletModule .= " [<a href=\"index.php?action=payout\">Manage Payouts</a>]";
        }
    } else {
        $walletModule = "<div><img src=\"./images/wallet.png\">";
        $walletModule .= "<a class='menu' href=\"index.php?action=manageWallet\">&gt; Manage Wallet</a>";
        if ($MySelf->isAccountant()) {
            $walletModule .= "<a class='menu' href=\"index.php?action=payout\">&gt; Manage Payouts</a>";
        }
        $walletModule .= "</div><div class='clear'></div>";
    }
    /*
     * Lotto related things.
     */
    $LOTTO = getConfig("Lotto");
    if ($LOTTO) {
        // Are we allowed to play Lotto?
        if ($MySelf->canPlayLotto()) {
            // Yeah we are allowed to do this.
            if ($IGB && $IGB_VISUAL) {
                // Browswing in the iGB.
                $lotto_Play = "[<a href=\"index.php?action=lotto\">Lotto</a>]";
            } else {
                // Using a real browser.
                $lotto_Play = "<a class='menu' href=\"index.php?action=lotto\">&gt; Lotto</a>";
            }
        }
        if ($MySelf->isLottoOfficial()) {
            // Yeah we are allowed to do this.
            if ($IGB && $IGB_VISUAL) {
                // Browswing in the iGB.
                $lotto_Admin = "[<a href=\"index.php?action=editLotto\">Admin Lotto</a>]";
            } else {
                // Using a real browser.
                $lotto_Admin = "<a class='menu' href=\"index.php?action=editLotto\">&gt; Admin Lotto</a>";
            }
        }
        if ($lotto_Admin || $lotto_Play) {
            // Assemble the Lotto module.
            if ($IGB && $IGB_VISUAL) {
                $lottoModule = $lotto_Play . " " . $lotto_Admin . "";
            } else {
                $lottoModule = "<div>";
                $lottoModule .= "<img src=\"./images/m-lotto.png\">";
                $lottoModule .= $lotto_Play;
                $lottoModule .= $lotto_Admin;
                $lottoModule .= "</div><div class='clear'></div>";
            }
        }
    }
    /*
     * Open operations Module
     */
    if ($IGB && $IGB_VISUAL) {
        // tough luck.
    } else {
        $runs = sidebarOpenRuns();
        if ($runs) {
            $operationsModule = "<div>";
            $operationsModule .= "<img src=\"./images/m-runs-in-progress.png\">";
            $operationsModule .= sidebarOpenRuns() . "";
            $operationsModule .= "</div><div class='clear'></div>";
        }
    }
    /*
     * Show the time.
     */
    $clockScript = "<script>\n\tvar eveTime = new Date({$TIMEMARK}*1000);\n\teveTime.setHours(eveTime.getHours()-3);\n\tvar eveTimeRefreshRate = 20;// seconds\n\tvar eveTimeZone = '';\n\tfunction updateTime(){\n\t\teveTime = new Date(eveTime.getTime()+(eveTimeRefreshRate * 1000));\n\t\tminutes = eveTime.getMinutes();\n\t\tif(minutes.length < 2){\n\t\t\tminutes = '0' + minutes;\n\t\t}\n\t\thours = eveTime.getHours();\n\t\tif(hours.length < 2){\n\t\t\thours = '0' + hours;\n\t\t}\n\t\t\$('#eveTime').html(hours + ':' + minutes + ' EvE');\n\t\tsetTimeout('updateTime()', eveTimeRefreshRate * 1000);\n\t}\n\tsetTimeout('updateTime()', eveTimeRefreshRate * 1000);\n\t\n\t\$('#menu img').click(function() {\n\t  \$(this).siblings().toggle('slow');\n\t});\n\t\n\t\n\t</script>";
    $clock = "<b><hr><center id='eveTime'>" . date("H:i", $TIMEMARK) . " EvE</center><hr>{$clockScript}</b>";
    /*
     * Assemble the module-block.
     */
    if ($IGB && $IGB_VISUAL) {
        global $VERSION;
        $menu = new table(2, true, "width=\"99%\"");
        // Add the beta warning for the IGB
        global $IS_BETA;
        if ($IS_BETA) {
            $BETAWARNING = "<font color=\"#ff0000\"> - <b>This is a BETA release! Watch out for bugs!</b></font>";
        }
        // Add the Version bar.
        $menu->addHeader($VERSION . $BETAWARNING);
        // Create the mining Menu.
        $menu->addRow();
        $menu->addCol("Mining  >>", array("align" => "right", "bold" => "true"));
        $menu->addCol($miningModule);
        if ($events_add || $events_view) {
            $menu->addRow();
            $menu->addCol("Events  >>", array("align" => "right", "bold" => "true"));
            $menu->addCol($eventsModule);
        }
        // Wallet Menu.
        $menu->addRow();
        $menu->addCol("Wallet  >>", array("align" => "right", "bold" => "true"));
        $menu->addCol($walletModule);
        // Preferences.
        $menu->addRow();
        $menu->addCol("Preferences  >>", array("align" => "right", "bold" => "true"));
        $menu->addCol($prefModule);
        // Ore managagement.
        if ($admin_Ore || $admin_viewUser || $admin_addUser) {
            $menu->addRow();
            $menu->addCol("Admin  >>", array("align" => "right", "bold" => "true"));
            $menu->addCol($adminModule);
        }
        // Logout.
        $menu->addRow();
        $menu->addCol("Exit  >>", array("align" => "right", "bold" => "true"));
        $menu->addcol($logoutModule);
        $menu->addHeader("Logged in as <font color=\"00aa00\">%%USERNAME%%</font>, Rank: <font color=\"00aa00\">%%RANK%%</font>, {$DIV_MENU} Credits: <font color=\"00aa00\">%%CREDITS%%</font>.");
        $modules = $menu->flush();
    } else {
        $modules = $UPDATE . $miningModule . $operationsModule . $walletModule . $eventsModule . $lottoModule . $prefModule . $adminModule . $logoutModule . $clock;
    }
    // And return it all.
    if ($page) {
        return str_replace("%%MENU%%", $modules, $page);
    } else {
        return $modules;
    }
}
コード例 #11
0
ファイル: lotto_playLotto.php プロジェクト: nuxi/MiningBuddy
function lotto_playLotto()
{
    // Globals, as usual.
    global $DB;
    global $MySelf;
    $LOTTO_MAX_PERCENT = getConfig("lottoPercent");
    $ID = $MySelf->getID();
    // is Lotto enabled at all?
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Only people with parents consent may play!
    if (!$MySelf->canPlayLotto()) {
        makeNotice("Im sorry, but you are not allowed to play Lotto. " . "Ask your CEO or a friendly Director to enable this for you.", "warning", "Unable to play :(");
    }
    // Get my credits
    $MyStuff = $DB->getRow("SELECT lottoCredit, lottoCreditsSpent FROM users WHERE id='" . $MySelf->getID() . "'");
    $Credits = $MyStuff[lottoCredit];
    $CreditsSpent = $MyStuff[lottoCreditsSpent];
    // Handle empty accounts.
    if ($Credits < 1) {
        $Credits = "None";
    }
    if ($CreditsSpent < 1) {
        $CreditsSpent = "None";
    }
    // My Info Table.
    $MyInfo = new table(2, true);
    $MyInfo->addHeader(">> My lotto assets");
    $MyInfo->addRow();
    $MyInfo->addCol("My balance (tickets):");
    $MyInfo->addCol($Credits);
    $MyInfo->addRow();
    $MyInfo->addCol("Total spent (tickets):");
    $MyInfo->addCol($CreditsSpent);
    $MyInfo->addHeader("Need more credits? <a href=\"index.php?action=buycredits\">Buy them here!</a>");
    // Print resent pots.
    $MyWins = new table(4, true);
    $MyWins->addHeader(">> Recent jackpots");
    $MyWins->addRow("#060622");
    $MyWins->addCol("Drawing");
    $MyWins->addCol("Winner");
    $MyWins->addCol("Winning Ticket");
    $MyWins->addCol("Jackpot");
    $Jackpots = $DB->query("SELECT * FROM lotto WHERE isOpen='0'");
    if ($Jackpots->numRows() >= 1) {
        while ($jp = $Jackpots->fetchRow()) {
            //			$TotalTickets_DS = $DB->Query("SELECT ticket FROM lotteryTickets WHERE drawing='" . $woot[drawing] . "' AND owner >= '0'");
            //			$TotalTickets = $TotalTickets_DS->numRows();
            $MyWins->addRow();
            $MyWins->addCol("<a href=\"index.php?action=lotto&showdrawing=" . $jp[drawing] . "\">#" . str_pad($jp[drawing], 3, "0", STR_PAD_LEFT) . "</a>");
            if ($jp[winner] == "-1") {
                $MyWins->addCol("<i>No one</i>");
            } else {
                $MyWins->addCol(ucfirst(idToUsername($jp[winner])));
            }
            $MyWins->addCol("#" . str_pad($jp[winningTicket], 3, "0", STR_PAD_LEFT));
            $MyWins->addCol(number_format($jp[potSize]) . " ISK");
            $GotWinners = true;
        }
    }
    $drawingID = lotto_getOpenDrawing();
    $drawingID = $drawingID[0];
    // Load the current drawing.
    if (!$_GET[showdrawing]) {
        $drawingID = lotto_getOpenDrawing();
        //$drawingID = $drawingID[0];
    } else {
        numericCheck($_GET[showdrawing], 0);
        $drawingID = $_GET[showdrawing];
    }
    // jackpot! WOOT!
    $Jackpot = $DB->getCol("SELECT value FROM config WHERE name='jackpot' LIMIT 1");
    if ($drawingID != is_null()) {
        $currentBuyin = $DB->getCol("SELECT COUNT(*) FROM lotteryTickets WHERE drawing=" . $drawingID . " AND owner >=0");
        $totalJackpot = $Jackpot[0] + $currentBuyin[0] * 1000000;
    }
    $MyWins->addHeader("The current jackpot is at " . number_format($totalJackpot, 2) . " ISK.");
    //	$MyWins->addHeader("Please contact your lotto officer to claim your prize.");
    // Only do this if we have an open  drawing, doh!
    if ($drawingID != is_null()) {
        $TICKETS = $DB->query("SELECT *  FROM lotteryTickets WHERE drawing = '{$drawingID}' ORDER BY ticket");
        $allowedTickets = lotto_checkRatio($drawingID);
        // Table header
        $drawing = new table(2, true);
        $drawing->addHeader(">> Drawing #{$drawingID}");
        // 1=left side, 0=right side.
        $side = 1;
        while ($ticket = $TICKETS->fetchRow()) {
            $ticketCount++;
            // If we are on the left side, open up a new table row.
            if ($side == 1) {
                $drawing->addRow();
            }
            // Ticket owned already?
            if ($ticket[owner] == -1) {
                if ($Credits >= 1 && $allowedTickets > 0) {
                    $drawing->addCol("<a href=\"index.php?action=claimTicket&drawing={$max}&ticket=" . $ticket[ticket] . "\">#" . str_pad($ticket[ticket], 4, "0", STR_PAD_LEFT) . "</a> (unclaimed)");
                } else {
                    $drawing->addCol("#" . str_pad($ticket[ticket], 4, "0", STR_PAD_LEFT) . " (unclaimed)");
                }
            } elseif ($ticket[owner] >= 0) {
                // Increase the chances counter.
                if ($ticket[owner] == $ID) {
                    $chances++;
                }
                if ($ticket[isWinner]) {
                    $drawing->addCol("#" . str_pad($ticket[ticket], 4, "0", STR_PAD_LEFT) . " (" . idToUsername($ticket[owner]) . ") <font color=\"#00ff00\"><b>WINNER!</b></font>");
                } else {
                    $drawing->addCol("#" . str_pad($ticket[ticket], 4, "0", STR_PAD_LEFT) . " (" . idToUsername($ticket[owner]) . ")");
                }
            } else {
                if ($ticket[isWinner]) {
                    $drawing->addCol("#" . str_pad($ticket[ticket], 4, "0", STR_PAD_LEFT) . " (locked) <font color=\"#00ff00\"><b>WINNER!</b></font>");
                } else {
                    $drawing->addCol("#" . str_pad($ticket[ticket], 4, "0", STR_PAD_LEFT) . " (locked)");
                }
            }
            // Toggle sides.
            $side = 1 - $side;
            $AreTickets = true;
        }
        // My Chances
        $winningChance = number_format(100 / ($ticketCount / $chances), 3) . "%";
        // Even the odds ;)
        if ($side == 0) {
            $drawing->addCol("---");
        }
        if ($allowedTickets > 0) {
            $drawing->addHeader("Click on a ticket to buy  it, up to {$allowedTickets} more ({$LOTTO_MAX_PERCENT}%). Your chances of winning are: {$winningChance}");
        } else {
            $drawing->addHeader("You exceeded the maximum allowed tickets ({$LOTTO_MAX_PERCENT}%). Your chances of winning are: {$winningChance}");
        }
    }
    // HTML goodness.
    $html = "<h2>Play Lotto</h2>";
    $html .= $MyInfo->flush() . "<br>";
    if ($GotWinners) {
        $html .= $MyWins->flush() . "<br>";
    }
    // only include ticket table if we have tickets.
    if ($AreTickets) {
        $html .= $drawing->flush();
    }
    // return the page.
    return $html;
}
コード例 #12
0
ファイル: showOreValue.php プロジェクト: nuxi/MiningBuddy
function showOreValue()
{
    // Get the globals.
    global $ORENAMES;
    global $DBORE;
    global $DB;
    global $STATIC_DB;
    // load the values.
    $latestDS = $DB->query("select item, Worth, time, modifier, t.volume from orevalues a, {$STATIC_DB}.invTypes t where a.item = replace(replace(t.typeName,'-',''),' ','') and time = (select max(time) from orevalues b where a.item = b.item) group by item ORDER BY time DESC");
    if (!isset($_GET['id'])) {
        // No ID requested, get latest
        $orevaluesDS = $latestDS;
        $isLatest = true;
    } else {
        if (!is_numeric($_GET['id']) || $_GET['ID'] < 0) {
            // ID Set, but invalid
            makeNotice("Invalid ID given for ore values! Please go back, and try again!", "warning", "Invalid ID");
        } else {
            // VALID id
            //$orevaluesDS = $DB->query("select distinct item, from orevalues WHERE time='" . sanitize($_GET[id]) . "' limit 1");
            $orevaluesDS = $DB->query("select item, Worth, time, modifier, t.volume from orevalues a, {$STATIC_DB}.invTypes t where a.item = t.typeName and time = (select max(time) from orevalues b where a.item = b.item and time <= '" . sanitize($_GET['id']) . "') group by item ORDER BY time DESC");
        }
    }
    // Check for a winner.
    if ($orevaluesDS->numRows() <= 0) {
        makeNotice("Invalid ID given for ore values! Please go back, and try again!", "warning", "Invalid ID");
    }
    // Check for latest orevalue
    if (!$isLatest) {
        $isLatest = true;
        while ($row = $latestDS->fetchRow()) {
            $latest[$row['item']] = $row;
            if ($row['time'] < sanitize($_GET['id'])) {
                $isLatest = false;
            }
        }
    }
    $archiveTime = strtotime("2999-12-31");
    while ($row = $orevaluesDS->fetchRow()) {
        $orevalues[$row['item']] = $row;
        $archiveTime = $archiveTime > $row['time'] ? $row['time'] : $archiveTime;
    }
    // Create the table.
    if (!$isLatest) {
        $table = new table(8, true);
        $add = "Archived";
        $colspan = 7;
    } else {
        $table = new table(6, true);
        $add = "Current";
        $colspan = 5;
    }
    //$table->addHeader(">> $add Ore Quotes (dated: " . date("m.d.y H:i:s", $orevalues[0][time]) . ", modified by " . ucfirst(idToUsername($orevalues[0][modifier])) . ")", array (
    $table->addHeader(">> {$add} Ore Quotes (dated: " . date("m.d.Y H:i:s", $archiveTime) . ")", array("bold" => true));
    $table->addRow();
    $table->addCol("Ore Name", array("colspan" => 2, "bold" => true));
    $table->addCol("Value", array("bold" => true));
    if (!$isLatest) {
        $table->addCol("Diff", array("bold" => true));
    }
    $table->addCol("Ore Name", array("colspan" => 2, "bold" => true));
    $table->addCol("Value", array("bold" => true));
    if (!$isLatest) {
        $table->addCol("Diff", array("bold" => true));
    }
    // How many ores are there in total? Ie, how long has the table to be?
    $tableLength = ceil(count($ORENAMES) / 2) - 1;
    for ($i = 0; $i <= $tableLength; $i++) {
        $table->addRow();
        for ($side = 0; $side <= 1; $side++) {
            $ORE = $ORENAMES[$i + ($tableLength + 1) * $side];
            // Fetch the right image for the ore.
            $ri_words = str_word_count($ORE, 1);
            $ri_max = count($ri_words);
            $ri = strtolower($ri_words[$ri_max - 1]);
            if ($ORE != "") {
                $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ores/" . $ORE . ".png\">");
                if (!$isLatest && $orevalues[$DBORE[$ORE]]['time'] != $archiveTime) {
                    $DATE = $orevalues[$DBORE[$ORE]]['time'] > $archiveTime ? date("m.d.y H:i:s", $orevalues[$DBORE[$ORE]]['time']) : "";
                    $color = $orevalues[$DBORE[$ORE]]['time'] > $archiveTime ? "#00ff00" : "#ff0000";
                    $ORE = "{$ORE} <font color=\"{$color}\">{$DATE}</font>";
                }
                $table->addCol($ORE);
                $iskperhour = $orevalues[$DBORE[$ORE]]['Worth'] / $orevalues[$DBORE[$ORE]]['volume'];
                $value = "<div class='value'><div class='isk'>" . number_format($orevalues[$DBORE[$ORE]]['Worth'], 2) . " ISK" . "</div><div class='iph'>" . number_format($iskperhour, 2) . " ISK/m3</div></div>";
                $table->addCol($value);
                if (!$isLatest) {
                    $diff = $orevalues[$DBORE[$ORE]]['Worth'] - $latest[$DBORE[$ORE]]['Worth'];
                    if ($diff > 0) {
                        $color = "#00ff00";
                    } elseif ($diff == 0) {
                        $color = "";
                    } elseif ($diff <= 0) {
                        $color = "#ff0000";
                    }
                    $table->addCol("<font color=\"{$color}\">{$diff}</font>");
                }
            } else {
                $table->addCol("");
                $table->addCol("");
                $table->addCol("");
                if (!$isLatest) {
                    $table->addCol("");
                }
            }
        }
    }
    if (!$isLatest) {
        $table->addRow("#882020");
        $table->addCol("These values are not the current payout values. Click <a href=\"index.php?action=showorevalue\">here</a> to see up-to-date quotes.", array("colspan" => 8));
    }
    /*
     * Create a list of all previous changes.
     */
    /* Disabled on feb 24 during database changes to oreValue table.
    	$AllChanges = $DB->query("SELECT time,id FROM orevalues ORDER BY time ASC");
    	
    	while ($ds = $AllChanges->fetchRow()) {
    		if ($ds[time] > 0) {
    			if ($ds[time] == $orevalues[0][time]) {
    				$otherValues .= "[" . date("d.m.y", $ds[time]) . "] ";
    			} else {
    				$otherValues .= "[<a href=\"index.php?action=showorevalue&id=$ds[id]\">" . date("d.m.y", $ds[time]) . "</a>] ";
    			}
    		}
    	}
    	
    	$table->addRow("#060622");
    	$table->addCol("Other quotes:");
    	$table->addCol($otherValues, array (
    		"colspan" => $colspan
    	));
    	*/
    $script = "<script>\$('.valueHeader').click(function(){\$('.isk').toggle();\$('.iph').toggle();})</script>";
    // return the page
    return "<h2>Ore <span class='valueHeader'>Quotes</span></h2>" . $script . $table->flush();
}
コード例 #13
0
ファイル: listRuns.php プロジェクト: nuxi/MiningBuddy
function listRuns()
{
    /* bgcolor and i are used to alternate the tablerow
     * background color.
     */
    $bgc = array("#222222", "#333333");
    $bgi = 0;
    // Our database.
    global $DB;
    global $MySelf;
    global $READONLY;
    global $PREFS;
    $sirstate = $PREFS->getPref("sirstate");
    /*
     * LIST OPEN RUNS
     */
    // Query it.
    $results = $DB->query("select * from runs where endtime IS NULL order by id");
    $mode = array("bold" => true);
    $table = new table(9, true);
    $table->addHeader(">> Currently active Operations");
    $table->addRow("#060622");
    $table->addCol("Run ID");
    $table->addCol("Supervisor");
    $table->addCol("Op Type");
    $table->addCol("Starttime");
    $table->addCol("Endtime");
    $table->addCol("Location");
    $table->addCol("Security");
    $table->addCol("Official run");
    $table->addCol("Locked");
    $runsExist = false;
    // Now we loop through each returned result.
    while ($row = $results->fetchRow()) {
        // Skip inofficial runs if user does not want to see them.
        if (!$sirstate && !$row['isOfficial'] && !($MySelf->getID() == $row['supervisor'])) {
            continue;
        }
        $table->addRow();
        $table->addCol("<a href=\"index.php?action=show&id={$row['id']}\">" . str_pad($row['id'], 5, "0", STR_PAD_LEFT) . "</a>");
        $table->addCol(makeProfileLink($row['supervisor']));
        $table->addCol($row['optype'] == "" ? "Standard" : $row['optype']);
        $table->addCol(date("d.m.y H:i", $row['starttime']));
        /* This handles the endtime. Prints endtime if it has already
         * ended, or "active" along with an "end run"-link if still open.
         */
        unset($tmp);
        if ($row['endtime'] == "") {
            $tmp = "<b>active</b>";
            // If access level is above or equal 3 give option to close run.
            if ($MySelf->canCloseRun()) {
                $tmp .= " (<a href=\"index.php?action=endrun&id={$row['id']}\">close run</a>)";
            }
        } else {
            $tmp = date("d.m.y H:i", $row['endtime']);
        }
        // Add the end-time to the table.
        $table->addCol($tmp);
        // Show the security status
        $System = new solarSystem($row['location']);
        if ($System->valid()) {
            $table->addCol($System->makeFancyLink());
            $table->addCol($System->getSecurity());
        } else {
            $table->addCol(ucfirst($row['location']));
            $table->addCol("?");
        }
        $table->addCol(yesno($row['isOfficial'], true));
        $table->addCol(yesno($row['isLocked'], true, true));
        $runsExist = true;
        // We wont print out table if there are no open runs.
    }
    /*
     *  LIST CLOSED RUNS
     */
    // Query it.
    if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) {
        $page = "LIMIT " . $_GET['page'] * 20 . ", 20";
    } elseif (isset($_GET['page']) && $_GET['page'] == "all") {
        $page = "";
    } else {
        $page = "LIMIT 20";
    }
    $results = $DB->query("SELECT * FROM runs WHERE endtime IS NOT NULL ORDER BY endtime DESC {$page}");
    // This is the table header.
    $table_closed = new table(11, true);
    $table_closed->addHeader(">> Archived Operations");
    $table_closed->addRow("#060622");
    $table_closed->addCol("Run ID");
    $table_closed->addCol("Supervisor");
    $table_closed->addCol("Op Type");
    $table_closed->addCol("Starttime");
    $table_closed->addCol("Endtime");
    $table_closed->addCol("Location");
    $table_closed->addCol("Security");
    $table_closed->addCol("Yield");
    $table_closed->addCol("TMEC(tm)");
    $table_closed->addCol("Was official");
    // Offer delete button.
    if ($MySelf->canDeleteRun() && !$READONLY) {
        $table_closed->addCol("Delete", $mode);
    } else {
        $table_closed->addCol("");
    }
    // Now we loop through each returned result.
    while ($row = $results->fetchRow()) {
        // Skip inofficial runs if user does not want to see them.
        if (!$sirstate && !$row['isOfficial'] && !($MySelf->getID() == $row['supervisor'])) {
            continue;
        }
        $table_closed->addRow();
        $table_closed->addCol("<a href=\"index.php?action=show&id={$row['id']}\">" . str_pad($row['id'], 5, "0", STR_PAD_LEFT) . "</a>");
        $table_closed->addCol(makeProfileLink($row['supervisor']));
        $table_closed->addCol($row['optype'] == "" ? "Standard" : $row['optype']);
        $table_closed->addCol(date("d.m.y H:i", $row['starttime']));
        /* This handles the endtime. Prints endtime if it has already
         * ended, or "active" along with an "end run"-link if still open.
         */
        unset($tmp);
        if ("{$row['endtime']}" == "") {
            $tmp = "<b>active</b>";
            // If access level is above or equal 3 give option to close run.
            if ($MySelf->canCloseRun()) {
                $tmp .= " (<a href=\"index.php?action=endrun&id={$row['id']}\">close run</a>)";
            }
        } else {
            $tmp = date("d.m.y H:i", $row['endtime']);
        }
        // Add the end-time to the table.
        $table_closed->addCol($tmp);
        // Show the security status
        $System = new solarSystem($row['location']);
        if ($System->valid()) {
            $table_closed->addCol($System->makeFancyLink());
            $table_closed->addCol($System->getSecurity());
        } else {
            $table_closed->addCol(ucfirst($row['location']));
            $table_closed->addCol("?");
        }
        // get the total ores gained.
        $totalIsk = getTotalWorth($row['id']);
        $table_closed->addCol(number_format($totalIsk, 2) . " ISK", array("style" => "text-align:right;"));
        // Add the TMEC
        if ($row['tmec'] == 0) {
            $TMEC = calcTMEC($row['id']);
        } else {
            $TMEC = $row['tmec'];
        }
        $table_closed->addCol($TMEC, array("style" => "text-align:right;"));
        // Add "run is official" bit.
        $table_closed->addCol(yesno($row['isOfficial'], true), array("style" => "text-align:right;"));
        $closedRunsExist = true;
        // We wont print out table if there are no open runs.
        // Add possible delete run button.
        if ($MySelf->canDeleteRun() && !$READONLY) {
            $table_closed->addCol("<a href=\"index.php?action=deleterun&id={$row['id']}\">delete</a>");
        } else {
            $table_closed->addCol("");
        }
    }
    // The "show this many ops"-part.
    $count = $DB->getCol("SELECT COUNT(id) FROM runs WHERE endtime > 0");
    $countSteps = floor($count[0] / 20);
    $showMore = "Switch to page >> ";
    for ($i = 1; $i <= $countSteps; $i++) {
        $thisStep = str_pad($i, 2, "0", STR_PAD_LEFT);
        $showMore .= "[<a href=\"index.php?action=list&page=" . $thisStep . "\">" . $thisStep . "</a>] ";
    }
    $showMore .= "[<a href=\"index.php?action=list&page=all\">All</a>] ";
    $table_closed->addHeader($showMore);
    // Fancy it up!
    $page = "<h2>Mining Operations</h2>";
    // Print the open runs table, IF there are open runs.
    if ($runsExist) {
        $page .= $table->flush() . "<br>";
    }
    // Print the closed runs table, IF there are closed runs.
    if ($closedRunsExist) {
        $page .= $table_closed->flush();
    } else {
        $page .= "<i>There are no (closed) mining operations in the database. Is this a fresh installation?</i>";
    }
    return $page;
}
コード例 #14
0
function makeNewOreRunPage()
{
    // Load the globals.
    global $VERSION;
    global $SITENAME;
    global $TIMEMARK;
    global $ORENAMES;
    global $DBORE;
    global $DB;
    global $MySelf;
    $locationPDM = "";
    // We need a list of all the previous run locations.
    $locations = $DB->query("SELECT DISTINCT location FROM runs ORDER BY location");
    if ($locations->numRows() > 0) {
        while ($location = $locations->fetchRow()) {
            $locationPDM .= "<option value=\"" . $location['location'] . "\">" . $location['location'] . "</option>";
        }
        $locationPDM = "<select name=\"locations\">" . $locationPDM . "</select>";
    }
    // Table
    $table = new table(2, true);
    $table->addHeader(">> Create a new operation");
    $table->addRow();
    // Field: Location.
    $table->addCol("Location of Operation:");
    if ($locationPDM) {
        // We have at least one possible System we hauled before.
        $table->addCol($locationPDM . " -or- <input type=\"text\" name=\"location\">");
    } else {
        // There are not target systems in the database.
        if (getConfig("trustSetting") > 0) {
            $table->addCol("<input type=\"text\" value=\"" . $_SERVER['HTTP_EVE_SOLARSYSTEMNAME'] . "\" name=\"location\">");
        } else {
            $table->addCol("<input type=\"text\" name=\"location\">");
        }
    }
    $pdm = "";
    // Field: Officer in Charge
    if ($MySelf->isOfficial()) {
        $SeniorUsers = $DB->getCol("SELECT DISTINCT username FROM users WHERE canCreateRun = 1 AND deleted='0' ORDER BY username");
        foreach ($SeniorUsers as $senior) {
            if ($MySelf->getUsername() == "{$senior}") {
                $pdm .= "<option value=\"{$senior}\" selected>" . ucwords($senior) . "</option>";
            } else {
                $pdm .= "<option value=\"{$senior}\">" . ucwords($senior) . "</option>";
            }
            $seniorUsersPDM = "<select name=\"supervisor\">" . $pdm . "</select>";
        }
    } else {
        // In case the user is not a senior member he can not change the officer in charge.
        $seniorUsersPDM = ucfirst($MySelf->getUsername());
        $seniorUsersPDM .= "<input type=\"hidden\" name=\"supervisor\" value=\"" . $MySelf->getUsername() . "\">";
    }
    // We have no senior member (aka: people who may start runs)
    if (!$seniorUsersPDM) {
        makeNotice("No one from your current users may create or lead a mining operation. Please give out appropiate permissions.", "warning", "Insufficient Rights");
    } else {
        $table->addRow();
        $table->addCol("Executing Officer:");
        $table->addCol($seniorUsersPDM);
    }
    $table->addRow();
    $table->addCol("Op Type:");
    $OPTYPE = isset($_REQUEST['optype']) ? $_REQUEST['optype'] : "";
    $ops = $DB->getAll("select opName from opTypes;");
    if ($DB->isError($ops)) {
        die($ops->getMessage());
    }
    $opSelect = "<select name='optype' onChange='window.location = \"?action=newrun&optype=\"+this.value'>\n";
    $opSelect .= "<option value=''>Standard</option>\n";
    foreach ($ops as $op) {
        $default = $op['opName'] == $OPTYPE ? "selected" : "";
        $opSelect .= "<option {$default} value='" . $op['opName'] . "'>" . $op['opName'] . "</option>\n";
    }
    $opSelect .= "</select>";
    $table->addCol($opSelect);
    // Field: Corporation keeps.
    $table->addRow();
    $table->addCol("Corporation keeps:");
    // Get the average amount.
    if ($MySelf->isOfficial()) {
        if (!getConfig("defaultTax")) {
            // No default tax has been defined in the config file, generate our own.
            $tax = $DB->getCol("SELECT AVG(corpKeeps) AS tax FROM runs;");
            $tax = round($tax[0]);
            // in case there are no taxes yet AND no default has been set.
            if (!$tax) {
                $tax = "15";
            }
        } else {
            if ($OPTYPE == "Shopping") {
                $tax = "0";
            } else {
                // Set the default tax, according to config.
                $tax = getConfig("defaultTax");
            }
        }
        $table->addCol("<input readonly=\"readonly\" type=\"text\" maxlength=\"3\" value=\"{$tax}\" size=\"4\" name=\"corpkeeps\">% of gross value.");
    } else {
        $table->addCol("As this is not an official Op, no tax is deducted.");
    }
    // Give option to make this run official.
    if ($MySelf->isOfficial()) {
        $table->addRow();
        $table->addCol("Official Run:");
        $table->addCol("<input type=\"checkbox\" name=\"isOfficial\" checked=\"checked\" >Tick box if this is an official mining run.");
    }
    // Field: Starttime.
    $table->addRow();
    $table->addCol("Starttime:");
    // Get a time-array and do the human friendly part.
    // Funnies: We always want to use "00" as the minute, and always at the start of the
    // NEXT hour.
    $times = humanTime("toHuman", $TIMEMARK + 3600);
    $timefield = "<input type=\"text\" name=\"ST_day\"    size=\"4\" maxlength=\"2\" value=\"" . $times['day'] . "\">." . "<input type=\"text\" name=\"ST_month\"  size=\"4\" maxlength=\"2\" value=\"" . $times['month'] . "\">." . "<input type=\"text\" name=\"ST_year\"   size=\"6\" maxlength=\"4\" value=\"" . $times['year'] . "\">" . "&nbsp;&nbsp;" . "<input type=\"text\" name=\"ST_hour\"   size=\"4\" maxlength=\"2\" value=\"" . $times['hour'] . "\">:" . "<input type=\"text\" name=\"ST_minute\" size=\"4\" maxlength=\"2\" value=\"00\">";
    $orNow = "<input type=\"checkbox\" name=\"startnow\" value=\"true\" checked=\"checked\" > start now";
    $or = " - or - ";
    $table->addCol($orNow . $or . $timefield);
    $table->addRow();
    $table->addCol("format: day.month.year hour:minute", array("align" => "right", "colspan" => "2"));
    // Now we need the sum of all ores.
    //$totalOres = count($ORENAMES);
    /*
    // And the sum of all ENABLED ores.
    $totalEnabledOres = $DB->getCol("select count(name) as active from config where name LIKE '%".$OPTYPE."Enabled' AND value='1'");
    $totalEnabledOres = $totalEnabledOres[0];
    */
    /*
     * This is evil. We have to create an array that we fill up sorted.
     * It aint cheap. First, we loop through all the ore values.
     */
    /*
    for ($p = 0; $p < $totalOres; $p++) {
    	// Then we check each ore if it is enabled.
    	$ORE = $DBORE[$ORENAMES[$p]];
    	if (getOreSettings($ORE,$OPTYPE)) {
    		// If the ore is enabled, add it to the array.
    		$left[] = $ORE;
    	} else {
    		// add to disabled-array.
    		$disabledOres[] = $ORE;
    	}
    }
    
    $totalEnabledOres = count($left);
    
    // No ores enabled?
    if ($totalEnabledOres == 0) {
    	makeNotice("Your CEO has disabled *all* the Oretypes. Please ask your CEO to reactivate at leat one Oretype.", "error", "No valid Oretypes!");
    }
    
    // The table is, rounded up, exactly half the size of all enabled ores.
    $tableLength = ceil($totalEnabledOres / 2);
    // Now, copy the lower second half into a new array.
    $right = array_slice($left, $tableLength);
    */
    /*
     * So now we have an array of all the enabled ores. All we
     * need to do now, is create a nice, handsome table of it.
     * Loop through this array.
     */
    /*
    for ($i = 0; $i < $tableLength; $i++) {
    
    	// Fetch the right image for the ore.
    	$ri_words = str_word_count(array_search($left[$i], $DBORE), 1);
    	$ri_max = count($ri_words);
    	$ri = strtolower($ri_words[$ri_max -1]);
    
    	// Add a row.
    	$table->addRow();
    
    	// left side.
    	$table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($left[$i], $DBORE) . ".png\"> <input type=\"text\" name=\"$left[$i]\" size=\"10\" value=\"0\"> " . array_search($left[$i], $DBORE) . " wanted. ");
    
    	// We need an ore type (just in case of odd ore numbers)
    	if ($right[$i] != "") {
    		// right side.
    
    		// Fetch the right image for the ore.
    		$ri_words = str_word_count(array_search($right[$i], $DBORE), 1);
    		$ri_max = count($ri_words);
    		$ri = strtolower($ri_words[$ri_max -1]);
    
    		// Add the column.
    		$table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($right[$i], $DBORE) . ".png\"> <input type=\"text\" name=\"$right[$i]\" size=\"10\" value=\"0\"> " . array_search($right[$i], $DBORE) . " wanted. ");
    
    	} else {
    		// We have an odd number of ores: add empty cell.
    		$table->addCol("");
    	}
    
    }
    
    // Display the ore-disables-disclaimer. (Only if there are disabled oretypes.)
    if (!empty ($disabled)) {
    	$disabledText = "The following Oretypes has been disabled by the CEO: $disabled";
    }
    */
    $submitbutton = "<input type=\"hidden\" name=\"check\" value=\"true\">" . "<input type=\"hidden\" value=\"addrun\" name=\"action\">" . "<input type=\"submit\" value=\"Create new Operation\" name=\"submit\">";
    // El grande submit button!
    $table->addHeaderCentered($submitbutton);
    /*
    	// Show, if any, disabled ore-types.
    	if ($disabledText) {
    		$table->addRow();
    		$table->addCol("<br><br>" . $disabledText . ".", array (
    			"colspan" => "2"
    		));
    	}*/
    // Render the table, and return it.
    return "<h2>Create a new Operation</h2><form action=\"index.php\" method=\"POST\">" . $table->flush() . "</form>";
}
コード例 #15
0
ファイル: joinRun.php プロジェクト: nuxi/MiningBuddy
function joinRun()
{
    // Access the globals.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    $runid = (int) $_GET[id];
    $userid = $MySelf->GetID();
    // Are we allowed to join runs?
    if (!$MySelf->canJoinRun()) {
        makeNotice("You are not allowed to join mining operations. Please ask your CEO to unblock your account.", "error", "Forbidden");
    }
    // Is $runid truly an integer?
    numericCheck($runid);
    // Is the run still open?
    if (!miningRunOpen($runid)) {
        makeNotice("This mining operation has been closed!", "warning", "Can not join", "index.php?action=show&id={$runid}");
    }
    // Are we banned from the run?
    $State = $DB->getCol("SELECT status FROM joinups WHERE run='{$runid}' and userid='" . $MySelf->getID() . "'ORDER BY id DESC LIMIT 1");
    $State = $State[0];
    switch ($State) {
        case "2":
            // We have been kicked.
            $kicked = true;
            break;
        case "3":
            // We have been banned!
            if (runSupervisor($runid) == $MySelf->getUsername() || $MySelf->isOfficial()) {
                $banned = "You have been banned from this operation but your rank overrides this block.";
            } else {
                makeNotice("You have been banned from this operation. You can not rejoin it.", "warning", "You are banned.", "index.php?action=list", "[cancel]");
            }
            break;
    }
    // Is the run locked?
    if (runIsLocked($runid)) {
        makeNotice("You can not join this run as this run has been locked by " . runSupervisor($runid) . ".", "notice", "Mining operation locked", "index.php?action=show&id={$runid}", "[Cancel]");
    }
    // Join with shiptype.
    if (!$_GET['confirmed-ship']) {
        $table = new table(1, true);
        $table->addHeader(">> Join an Operation");
        // If we have been kicked, inform the user.
        if ($kicked) {
            $table->addRow("#880000");
            $table->addCol("Warning: You have been recently kicked. Please check if you are allowed to rejoin to avoid a ban.");
        }
        // If we are banned by an official, inform the user.
        if ($banned) {
            $table->addRow("#880000");
            $table->addCol($banned);
        }
        $table->addRow();
        $table->addCol($form . "Join the Operation in " . ucfirst(getLocationOfRun($runid)) . ".");
        $table->addRow();
        $table->addCol("You have requested to join mining operation #{$runid}. Please choose the shipclass " . "you are going to join up with.");
        $table->addRow();
        $table->addCol("Shiptype: " . $hiddenstuff . joinAs(), array("align" => "center"));
        $table->addRow("#444455");
        $table->addCol("<input type=\"submit\" name=\"submit\" value=\"Join mining operation\">" . $form_end, array("align" => "center"));
        $page = "<h2>Join an Operation.</h2>";
        $page .= "<form action=\"index.php\" method=\"GET\">";
        $page .= "<input type=\"hidden\" name=\"id\" value=\"{$runid}\">";
        $page .= "<input type=\"hidden\" name=\"confirmed-ship\" value=\"true\">";
        $page .= "<input type=\"hidden\" name=\"confirmed\" value=\"true\">";
        $page .= "<input type=\"hidden\" name=\"multiple\" value=\"true\">";
        $page .= "<input type=\"hidden\" name=\"action\" value=\"joinrun\">";
        $page .= $table->flush();
        $page .= "</form>";
        return $page;
    }
    // Sanitize the Shiptype.
    global $SHIPTYPES;
    $ShiptypesCount = count($SHIPTYPES);
    if (!numericCheck($_GET[shiptype], 0, $ShiptypesCount)) {
        makeNotice("The shiptype you tried to join up with is invalid, please go back, and try again.", "warning", "Shiptype invalid!", "index.php?action=show&id={$_GET['id']}");
    } else {
        $shiptype = $_GET[shiptype];
    }
    // Warn the user if he is already in another run.
    $joinedothers = $DB->query("select run from joinups where userid='{$userid}' and parted IS NULL order by run");
    // And check for that just now.
    if ($joinedothers->numRows() > 0) {
        confirm("You joined another mining operation already!<br>Are you sure you want to join multiple runs at the same time?");
    }
    // Get the correct time to join (in case event hasnt started yet)
    $startOfRun = $DB->getCol("SELECT starttime FROM runs WHERE id='{$runid}' LIMIT 1");
    if ($startOfRun[0] > $TIMEMARK) {
        $time = $startOfRun[0];
    } else {
        $time = $TIMEMARK;
    }
    // Dont allow him to join the same mining run twice.
    if (userInRun($MySelf->getID(), "{$runid}") == "none") {
        // Mark user as joined.
        $DB->query("insert into joinups (userid, run, joined, shiptype) values (?,?,?,?)", array("{$userid}", "{$runid}", "{$time}", "{$shiptype}"));
        // Forward user to his joined run.
        makeNotice("You have joined the Mining Operation.", "notice", "Joining confirmed", "index.php?action=show&id={$id}");
    } else {
        // Hes already in that run.
        makeNotice("You are already in that mining run!", "notice", "Joinup not confirmed", "index.php?action=show&id={$id}");
    }
}
コード例 #16
0
ファイル: listUser.php プロジェクト: nuxi/MiningBuddy
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;
}
コード例 #17
0
ファイル: manageWallet.php プロジェクト: nuxi/MiningBuddy
function manageWallet()
{
    // Globals
    global $MySelf;
    global $DB;
    $MyCredits = getCredits($MySelf->getID());
    // Get (recent?) transactions
    $html = getTransactions($MySelf->getID());
    if ($MyCredits > 0) {
        // Create the dropdown menu with all pilots.
        $NamesDS = $DB->query("SELECT DISTINCT username, id FROM users WHERE deleted='0' ORDER BY username");
        $ddm = "<select name=\"to\">";
        while ($name = $NamesDS->fetchRow()) {
            // Lets not allow transfers to self.
            if ($name[id] != $MySelf->getID()) {
                $ddm .= "<option value=\"" . $name[id] . "\">" . ucfirst($name[username]) . "</option>";
            }
        }
        $ddm .= "</select>";
        $tt = new table(2, true);
        $tt->addHeader(">> Transfer ISK");
        $tt->addRow("#060622");
        $tt->addCol("You can transfer ISK into another Pilots wallet by using this form.", array("colspan" => 2));
        $tt->addRow();
        $tt->addCol("Transfer from:");
        $tt->addCol(ucfirst($MySelf->getUsername()));
        $tt->addRow();
        $tt->addCol("Transfer to:");
        $tt->addCol($ddm);
        $tt->addRow();
        $tt->addCol("Amount:");
        $tt->addCol("<input type=\"text\" name=\"amount\">");
        $tt->addRow();
        $tt->addCol("Reason:");
        $tt->addCol("<input type=\"text\" name=\"reason\">");
        $tt->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Transfer money\">");
        // Create form stuff, and embed the table within.
        $transfer = "<form action=\"index.php\" method=\"POST\">";
        $transfer .= $tt->flush();
        $transfer .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $transfer .= "<input type=\"hidden\" name=\"action\" value=\"transferMoney\">";
        $transfer .= "</form>";
        // Create the payout form.
        $payout = new table(2, true);
        $payout->addHeader(">> Request payout");
        $payout->addRow("#060622");
        $payout->addCol("Fill out this form to request payout of ISK. An accountant will honor your request soon.", array("colspan" => 2));
        $payout->addRow();
        $payout->addCol("Payout amount:");
        $payout->addCol("<input type=\"text\" name=\"amount\" value=\"" . $MyCredits . "\"> ISK");
        $payout->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"request payout\">");
        // Create form stuff, and embed the table within.
        $requestPayout = "<form action=\"index.php\" method=\"POST\">";
        $requestPayout .= $payout->flush();
        $requestPayout .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $requestPayout .= "<input type=\"hidden\" name=\"action\" value=\"requestPayout\">";
        $requestPayout .= "</form>";
    }
    /*
     * Show current requests
     */
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NULL AND applicant='" . $MySelf->getID() . "' ORDER BY time");
    $table = new table(4, true);
    $table->addHeader(">> Pending payout requests");
    $table->addRow("#060622");
    $table->addCol("request");
    $table->addCol("time");
    $table->addCol("amount");
    $table->addCol("Cancel");
    while ($request = $requests->fetchRow()) {
        $table->addRow();
        $table->addCol("#" . str_pad($request[request], "5", "0", STR_PAD_LEFT));
        $table->addCol(date("d.m.y H:i:s", $request[time]));
        $table->addCol(number_format($request[amount], 2) . " ISK");
        $table->addCol("<input type=\"checkbox\" name=\"" . $request[request] . "\" value=\"true\">");
        $haveRequest = true;
    }
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"cancel marked requests\">");
    $takeBack = "<form action=\"index.php\" method=\"POST\">";
    $takeBack .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $takeBack .= "<input type=\"hidden\" name=\"action\" value=\"deleteRequest\">";
    $takeBack .= $table->flush();
    $rakeBack .= "</form>";
    /*
     * Show fulfilled requests
     */
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NOT NULL AND applicant='" . $MySelf->getID() . "' ORDER BY time");
    $table_done = new table(5, true);
    $table_done->addHeader(">> Fulfilled payout requests");
    $table_done->addRow("#060622");
    $table_done->addCol("request");
    $table_done->addCol("time");
    $table_done->addCol("amount");
    $table_done->addCol("Payout time");
    $table_done->addCol("Paid by");
    while ($request = $requests->fetchRow()) {
        $table_done->addRow();
        $table_done->addCol("#" . str_pad($request[request], "5", "0", STR_PAD_LEFT));
        $table_done->addCol(date("d.m.y H:i:s", $request[time]));
        $table_done->addCol(number_format($request[amount], 2) . " ISK");
        $table_done->addCol(date("d.m.y H:i:s", $request[payoutTime]));
        $table_done->addCol(ucfirst(idToUsername($request[banker])));
        $haveOldRequests = true;
    }
    if ($html) {
        $html = "<h2>Your Wallet</h2>" . $html . "<br>" . $requestPayout . $transfer;
        if ($haveRequest) {
            $html .= $takeBack . "<br>";
        }
        if ($haveOldRequests) {
            $html .= $table_done->flush();
        }
    } else {
        $html = "<h2>Your Wallet</h2>Once your wallet has any transactions you can view the details here. And once you obtained a positive balance you can transfer money and request payouts.<br>";
    }
    return $html;
}
コード例 #18
0
ファイル: makeCanPage.php プロジェクト: nuxi/MiningBuddy
function makeCanPage()
{
    // Defining some globals.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    global $PREFS;
    $USERNAME = $MySelf->getUsername();
    $USERID = $MySelf->getID();
    $TTL = getConfig("canLifeTime") * 60;
    // is the cargo module active?
    if (!getConfig("cargocontainer")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Get all current locations.
    $locations = $DB->getCol("SELECT DISTINCT location FROM runs ORDER BY location");
    // Get all current cans.
    $cans = $DB->getAssoc("SELECT * from cans");
    // Get last can-nr.
    $canNaming = $PREFS->getPref("CanNaming");
    // Query the database accordingly.
    if ($canNaming == 1) {
        $maxCan = $DB->getCol("SELECT MAX(name) as max FROM cans WHERE pilot = '{$USERID}'");
    } else {
        $maxCan = $DB->getCol("SELECT MAX(name) as max FROM cans");
    }
    // For can-naming: Increment the number.
    if ($maxCan[0] == "") {
        // No can jettisoned yet.
        $canname = "001";
    } else {
        if (is_numeric($maxCan[0])) {
            // Can ejected, and it is numeric, we can increase that number.
            $canname = str_pad($maxCan[0] + 1, "3", "0", STR_PAD_LEFT);
        } else {
            // User entered some non-numerical stuff, can not increase.
            unset($canname);
        }
    }
    // Get the system the users mining operation takes place in, if any.
    $myRun = userInRun($USERNAME);
    if ($myRun != false) {
        $myLocation = $DB->getCol("SELECT location FROM runs WHERE id='{$myRun}'");
        $myLocation = $myLocation[0];
    }
    // Assemble the locations dropdown menu.
    if (!empty($locations)) {
        // Loop through all the locations.
        foreach ($locations as $location) {
            // And preselect the location the users miningrun takes place, if any.
            if ("{$location}" == "{$myLocation}") {
                $ddm .= "<option selected value=\"{$location}\">{$location}</option>";
            } else {
                $ddm .= "<option value=\"{$location}\">{$location}</option>";
            }
        }
    }
    // Select all current cans owned by the pilot.
    $CansDS = $DB->query("SELECT location, droptime, name, id, isFull, miningrun FROM cans WHERE pilot = '{$USERID}' ORDER BY droptime ASC");
    if ($CansDS->numRows() > 0) {
        // We have at least one can out there, lets do this.
        $myCans = new table(7, true);
        $myCans->addHeader(">> My cargo containers in space");
        $mode = array("bold" => true);
        $myCans->addRow("#060622");
        $myCans->addCol("Name", $mode);
        $myCans->addCol("Location", $mode);
        $myCans->addCol("Self or Run", $mode);
        $myCans->addCol("Droptime", $mode);
        $myCans->addCol("est. Poptime", $mode);
        $myCans->addCol("Time Left", $mode);
        $myCans->addCol("Can is full", $mode);
        while ($can = $CansDS->fetchRow()) {
            $candroptime = $can[droptime];
            // Time of can drop.
            $poptime = $candroptime + $TTL;
            // Extimated pop time (droptime + 1h)
            $timeleft = $candroptime + $TTL - $TIMEMARK;
            // Time left (poptime - current time)
            $minsleft = str_pad(number_format(($timeleft - 60) / 60, 0), "2", "0", STR_PAD_LEFT);
            $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
            if ($secsleft < 1) {
                // We want all negative amounts to read "00".
                $secsleft = "00";
            }
            // Colorize the remaining time
            if ($minsleft >= 30) {
                // More or equal 30 mins: Green. We are cool.
                $color = "#88ff88";
            } elseif ($minsleft <= 29 && $minsleft >= 15) {
                // Less or equal 29 mins: Yellow, keep an eye out.
                $color = "#FFFF00";
            } elseif ($minsleft < 15) {
                // Less than 15 minutes: Ayee! RED! Refresh!s
                $color = "#FF0000";
            }
            $myCans->addRow();
            $myCans->addCol("<a href=\"index.php?action=popcan&id={$can['id']}\"><b>{$can['name']}</b></a>");
            $system = new solarSystem($can[location]);
            $myCans->addCol($system->makeFancyLink());
            // Can for self or mining run?
            if ($can[miningrun] >= 0) {
                $myCans->addCol("<a href=\"index.php?action=show&id={$can['miningrun']}\">" . str_pad($can[miningrun], "5", "0", STR_PAD_LEFT) . "</a>");
            } else {
                $myCans->addCol("(for self)");
            }
            $myCans->addCol(date("H:i:s", $can[droptime]));
            $myCans->addCol(date("H:i:s", $poptime));
            // Can popped already?
            if ($minsleft > 0) {
                $myCans->addCol("<font color=\"{$color}\">" . numberToString($timeleft) . "</font>");
            } else {
                $myCans->addCol("<font color=\"{$color}\">POPPED</font>");
            }
            // Can full?
            if ($can[isFull]) {
                $myCans->addCol("<a href=\"index.php?action=togglecan&canid={$can['id']}\"><font color=\"#00ff00\">YES</font></a>");
            } else {
                $myCans->addCol("<a href=\"index.php?action=togglecan&canid={$can['id']}\">No</a>");
            }
        }
        // The delete all button.
        $myCans->addHeaderCentered("[<a href=\"index.php?action=popcan&id=all\">pop all cans</a>]");
        $MyCansExist = true;
    }
    // Select all current cans, belonging to the mining run.
    $MiningRun = userInRun($MySelf->getUsername());
    if ($MiningRun) {
        $CansDS = $DB->query("SELECT location, droptime, name, pilot, isFull, miningrun FROM cans WHERE miningrun='{$MiningRun}' ORDER BY droptime ASC");
        if ($CansDS->numRows() > 0) {
            // We got one or more can floating around that belong to our mining run.
            $runCans = new table(7, true);
            $runCans->addHeader(">> My operations's cargo containers in space");
            $runCans->addRow("#060622");
            $runCans->addCol("Name", $mode);
            $runCans->addCol("Owner", $mode);
            $runCans->addCol("Location", $mode);
            $runCans->addCol("Droptime", $mode);
            $runCans->addCol("est. Poptime", $mode);
            $runCans->addCol("time remaining", $mode);
            $runCans->addCol("is full", $mode);
            while ($can = $CansDS->fetchRow()) {
                // Same as above.
                $candroptime = $can[droptime];
                $timeleft = $candroptime + $TTL - $TIMEMARK;
                $minsleft = str_pad(number_format(($timeleft - 60) / 60, 0), "2", "0", STR_PAD_LEFT);
                $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
                $poptime = $candroptime + $TTL;
                // No negative minutes..
                if ($secsleft < 1) {
                    $secsleft = "00";
                }
                // Colorize..
                if ($minsleft >= 30) {
                    $color = "#88ff88";
                } elseif ($minsleft < 29 && $minsleft >= 15) {
                    $color = "#FFFF00";
                } elseif ($minsleft < 15) {
                    $color = "#FF0000";
                }
                // Build table..
                $runCans->addRow();
                $runCans->addCol($can[name]);
                $runCans->addCol(idToUsername($can[pilot]));
                $system = new solarSystem($can[location]);
                $runCans->addCol($system->makeFancyLink());
                $runCans->addCol(date("H:i:s", $can[droptime]));
                $runCans->addCol(date("H:i:s", $poptime));
                // Can popped already?
                if ($minsleft > 0) {
                    $runCans->addCol("<font color=\"{$color}\">" . numberToString($timeleft) . "</font>");
                } else {
                    $runCans->addCol("<font color=\"{$color}\">POPPED</font>");
                }
                // Can full?
                if ($can[isFull]) {
                    $runCans->addCol("<font color=\"#00ff00\">YES</font>");
                } else {
                    $runCans->addCol("No");
                }
            }
            $runCansExists = true;
        }
    }
    // Select all current cans, regardless
    $CansDS = $DB->query("SELECT location, droptime, name, pilot, isFull FROM cans WHERE pilot <> '{$USERID}' ORDER BY droptime ASC");
    if ($CansDS->numRows() > 0) {
        // There is at least.. yeah..
        $allCans = new table(7, true);
        $allCans->addHeader(">> All containers floating in space");
        $allCans->addRow("#060622");
        $allCans->addCol("Name", $mode);
        $allCans->addCol("Owner", $mode);
        $allCans->addCol("Location", $mode);
        $allCans->addCol("Droptime", $mode);
        $allCans->addCol("est. Poptime", $mode);
        $allCans->addCol("time remaining", $mode);
        $allCans->addCol("is full", $mode);
        while ($can = $CansDS->fetchRow()) {
            // Time-stuff, yet again.
            $candroptime = $can[droptime];
            $timeleft = $candroptime + $TTL - $TIMEMARK;
            $minsleft = str_pad(number_format(($timeleft - 60) / 60, 0), "2", "0", STR_PAD_LEFT);
            $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
            $poptime = $candroptime + $TTL;
            // no neg mins..
            if ($secsleft < 1) {
                $secsleft = "00";
            }
            // color..
            if ($minsleft >= 30) {
                $color = "#88ff88";
            } elseif ($minsleft < 29 && $minsleft >= 15) {
                $color = "#FFFF00";
            } elseif ($minsleft < 15) {
                $color = "#FF0000";
            }
            $allCans->addRow();
            $allCans->addCol($can[name]);
            $allCans->addCol(idToUsername($can[pilot]));
            $system = new solarSystem($can[location]);
            $allCans->addCol($system->makeFancyLink());
            $allCans->addCol(date("H:i:s", $can[droptime]));
            $allCans->addCol(date("H:i:s", $poptime));
            // Can popped already?
            if ($minsleft > 0) {
                $allCans->addCol("<font color=\"{$color}\">" . numberToString($timeleft) . "</font>");
            } else {
                $allCans->addCol("<font color=\"{$color}\">POPPED</font>");
            }
            // Can full?
            if ($can[isFull]) {
                $allCans->addCol("<font color=\"#00ff00\">YES</font>");
            } else {
                $CANS_other .= "<td align=\"center\">No</td>";
                $allCans->addCol("No");
            }
        }
        $allCansExists = true;
    }
    // Lets get down to html buisiness.
    // Show only what the man wants. Eh, Tony?
    global $PREFS;
    if ($PREFS->getPref("CanAddCans")) {
        // Create a new add-can table.
        $addFormTable = new table(2, true);
        $addFormTable->addHeader(">> Register a new cargo container");
        // Row: Name
        $addFormTable->addRow();
        $addFormTable->addCol("Container name:", $mode);
        $addFormTable->addCol("<input type=\"text\" name=\"cantag\" value=\"" . $canname . "\" maxlength=\"100\" size=\"20\">");
        // Row: Naming preferences
        $addFormTable->addRow();
        $addFormTable->addCol("Naming&nbsp;preferences:", $mode);
        // Pre-select the current preferences.
        switch ($canNaming) {
            case "0":
                $c1 = "selected";
                break;
            case "1":
                $c2 = "selected";
                break;
            case "2":
                $c3 = "selected";
                break;
        }
        $canNamingPDM = "<select name=\"canprefs\">" . "<option " . $c1 . " value=\"0\">Do not suggest names</option>" . "<option " . $c2 . " value=\"1\">Numbers - select your highest can-number</option>" . "<option " . $c3 . " value=\"2\">Numbers - select overall highest can-number</option>" . "</select>";
        $addFormTable->addCol($canNamingPDM);
        // Row: Location
        $addFormTable->addRow();
        $addFormTable->addCol("Location:", $mode);
        $addFormTable->addCol("<select name=\"location\">" . $ddm . "</select>");
        // Row: System
        $addFormTable->addRow();
        $addFormTable->addCol("<b>-or-</b> System name:", $mode);
        $addFormTable->addCol("<input type=\"text\" name=\"location2\">");
        // Row: Time of Launch
        $addFormTable->addRow();
        $addFormTable->addCol("Time of launch:", $mode);
        // Get a time-array and do the human friendly part.
        // Funnies: We always want to use "00" as the minute, and always at the start of the
        // NEXT hour.
        $times = humanTime("toHuman", $TIMEMARK);
        $timefield = "<input type=\"text\" name=\"ST_day\"    size=\"2\" maxlength=\"4\" value=\"" . $times[day] . "\">." . "<input type=\"text\" name=\"ST_month\"  size=\"2\" maxlength=\"4\" value=\"" . $times[month] . "\">." . "<input type=\"text\" name=\"ST_year\"   size=\"4\" maxlength=\"6\" value=\"" . $times[year] . "\">" . "&nbsp;&nbsp;" . "<input type=\"text\" name=\"ST_hour\"   size=\"2\" maxlength=\"4\" value=\"" . $times[hour] . "\">:" . "<input type=\"text\" name=\"ST_minute\" size=\"2\" maxlength=\"4\" value=\"" . $times[minute] . "\">";
        $addFormTable->addCol($timefield . " <i>(d:m:y, h:m)</i>");
        // Row: Belongs to run
        $addFormTable->addRow();
        $addFormTable->addCol("For mining op:", $mode);
        if ($PREFS->getPref("CanForRun")) {
            $addFormTable->addCol("<input type=\"checkbox\" CHECKED name=\"forRun\" value=\"true\"> Tick this if the can(s) you are dropping are part of your mining run, if any.");
        } else {
            $addFormTable->addCol("<input type=\"checkbox\" CHECKED name=\"forRun\" value=\"true\"> Tick this if the can(s) you are dropping are part of your mining run, if any.");
        }
        // Row: Submit button.
        $addFormTable->addHeaderCentered("<input type=\"submit\" name=\"create\" value=\"Register can in Database\">" . "<input type=\"hidden\" name=\"action\" value=\"addcan\">" . "<input type=\"hidden\" name=\"check\" value=\"true\">");
    }
    $html = "<h2>Cargo container chronograph</h2>";
    if ($PREFS->getPref("CanAddCans")) {
        $html .= "<form action=\"index.php\" method=\"post\">" . $addFormTable->flush();
    }
    if ($PREFS->getPref("CanMyCans") && $MyCansExist) {
        $html .= "<br>" . $myCans->flush();
    }
    if ($PREFS->getPref("CanRunCans") && $runCansExists) {
        $html .= "<br>" . $runCans->flush();
    }
    if ($PREFS->getPref("CanAllCans") && $allCansExists) {
        $html .= "<br>" . $allCans->flush();
    }
    return $html . "</form>";
}
コード例 #19
0
ファイル: makeWelcome.php プロジェクト: nuxi/MiningBuddy
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;
}
コード例 #20
0
ファイル: showEvent.php プロジェクト: nuxi/MiningBuddy
function showEvent()
{
    // Lets import some globals, shall we?
    global $MySelf;
    global $DB;
    global $TIMEMARK;
    $ID = $MySelf->getID();
    // is the events module active?
    if (!getConfig("events")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Are we allowed to be here?
    if (!$MySelf->canSeeEvents()) {
        makeNotice("You are not allowed to do this!", "error", "Forbidden");
    }
    // Is the ID safe?
    if (!is_numeric($_GET[id]) || $_GET[id] < 0) {
        makeNotice("Invalid ID given!", "error", "Invalid Data");
    }
    // Load the event.
    $EVENTS = $DB->getRow("SELECT * FROM events WHERE id='{$_GET['id']}'");
    $mission = new table(2, true);
    $mission->addHeader(">> Mission information");
    $mission->addRow();
    $mission->addCol("Mission ID:");
    $mission->addCol(str_pad("{$EVENTS['id']}", 5, "0", STR_RIGHT_PAD));
    $mission->addRow();
    $mission->addCol("Mission Type:");
    $mission->addCol($EVENTS[type]);
    $mission->addRow();
    $mission->addCol("Executing Officer:");
    // In case of a numeric value we have to translate that into plain english.
    if (is_numeric($EVENTS[officer])) {
        $officer = idToUsername($EVENTS[officer]);
    } else {
        $officer = $EVENTS[officer];
    }
    $mission->addCol(ucfirst($officer));
    $mission->addRow();
    $mission->addCol("System:");
    $mission->addCol(ucfirst($EVENTS[system]));
    $mission->addRow();
    $mission->addCol("Security:");
    $mission->addCol($EVENTS[security]);
    // Has the event started yet?
    $delta = $TIMEMARK - $EVENTS[starttime];
    if ($delta > 0) {
        // Yep!
        $mission->addRow();
        $mission->addCol("Mission underway for:");
        $mission->addCol(numberToString($delta));
    } else {
        // Nope!
        $delta = $delta * -1;
        $mission->addRow();
        $mission->addCol("Mission will start in:");
        $mission->addCol(numberToString($delta));
    }
    $mission->addRow();
    $mission->addCol("Est. Duration:");
    $mission->addCol($EVENTS[duration]);
    // How difficult is it?
    $mission->addRow();
    $mission->addCol("Difficulty:");
    switch ($EVENTS[difficulty]) {
        case 0:
            $mission->addCol("No risk involved");
            break;
        case 1:
            $mission->addCol("Inferior forces");
            break;
        case 2:
            $mission->addCol("Adequate forces");
            break;
        case 3:
            $mission->addCol("Major forces expected");
            break;
        case 4:
            $mission->addCol("Superior forces expected");
            break;
        case 5:
            $mission->addCol("Suicide Mission");
            break;
    }
    $mission->addRow();
    $mission->addCol("Payment:");
    $mission->addCol($EVENTS[payment]);
    $mission->addRow();
    $mission->addCol("Collateral:");
    $mission->addCol(number_format($EVENTS[collateral]));
    $mission->addRow();
    $mission->addCol("Notes:");
    $mission->addCol(nl2br($EVENTS[notes]));
    $shipsTable = new table(3, true);
    $shipsTable->addHeader(">> Shiptypes and Joinups");
    // Compute the wanted Ships.
    $ships = unserialize($EVENTS[ships]);
    $SHIPTYPES = array("shuttles", "frigates", "destroyers", "cruisers", "bcruiser", "scruiser", "bship", "dread", "carrier", "titan", "barges", "indies", "freighter", "jfreighter", "exhumer");
    $TRANSLATE = array("shuttles" => "Shuttle", "frigates" => "Frigate", "destroyers" => "Destroyer", "cruisers" => "Cruiser", "bcruiser" => "Battlecruiser", "scruiser" => "Strategic Cruiser", "bship" => "Battleship", "dread" => "Dreadnought", "carrier" => "Carrier", "titan" => "Titan", "barges" => "Mining Barge", "indies" => "Industrial Ship", "freighter" => "Freighter", "jfreighter" => "Jump Freighter", "exhumer" => "Exhumer");
    $shipsTable->addRow("#060622");
    $shipsTable->addCol("Ship class");
    $shipsTable->addCol("Signed up");
    $shipsTable->addCol("Join up");
    // Ugh. ugly hack. Easier way?
    $JOINUPS_DS = $DB->getCol("SELECT signups FROM events WHERE id = '{$_GET['id']}'");
    $JOINUPS = unserialize($JOINUPS_DS[0]);
    unset($JOINUPS_DS);
    $JOINUPS_SHIPS = array_count_values($JOINUPS);
    // Translate the ships.
    foreach ($SHIPTYPES as $type) {
        if (in_array($type, $ships)) {
            $shipsTable->addRow();
            $shipsTable->addCol($TRANSLATE[$type] . "s");
            // Print how many ships are coming.
            if ($JOINUPS_SHIPS[$type] != "") {
                $shipsTable->addCol("{$JOINUPS_SHIPS[$type]}");
            } else {
                $shipsTable->addCol("none");
            }
            // Okay this is fun. First lets see if the user is already in this event.
            if ($JOINUPS[$ID] != "") {
                // User in Event. Lets see if the current shiptype is the shiptype hes joined up with.
                if ($JOINUPS[$ID] != $type) {
                    // Its not. Offer to switch.
                    $shipsTable->addCol("<a href=\"index.php?action=joinevent&id={$EVENTS['id']}&type={$type}\">Switch to " . $TRANSLATE[$type] . " class</a>");
                } else {
                    // It is. Renember him.
                    $shipsTable->addCol("You are signed up as " . $TRANSLATE[$type]);
                }
            } else {
                // User is not in event, offer to joinup.
                $shipsTable->addCol("<a href=\"index.php?action=joinevent&id={$EVENTS['id']}&type={$type}\">Join as " . $TRANSLATE[$type] . "</a>");
            }
        }
    }
    // Offer to quit Event.
    if ($JOINUPS[$ID] != "") {
        $shipsTable->addHeaderCentered("<a href=\"index.php?action=joinevent&id={$EVENTS['id']}&type=quit\">Cancel my signup for this event.</a>");
    }
    // Pilot overview.
    $pilotTable = new table(1, true);
    $pilotTable->addHeader(">> Current event roster");
    $keys = array_keys($JOINUPS);
    foreach ($keys as $key) {
        $pilotTable->addRow();
        $pilotTable->addCol(ucfirst(idToUsername($key)) . " has joined as a " . $TRANSLATE[$JOINUPS[$key]]);
    }
    // Return what we got.
    $html = "<h2>Detailed Mission Information</h2>" . $mission->flush();
    $html .= "<br>[<a href=\"index.php?action=showevents\">Back to overview</a>]<br>";
    $html .= "<br>" . $shipsTable->flush();
    $html .= "<br>" . $pilotTable->flush();
    return $html;
}
コード例 #21
0
ファイル: profile.php プロジェクト: nuxi/MiningBuddy
function profile()
{
    // The usual suspects.
    global $MySelf;
    global $DB;
    // Set the ID.
    $ID = sanitize($_GET[id]);
    numericCheck($_GET[id], 0);
    // Load the profile.
    $profile = new profile($ID);
    $username = ucfirst(idToUsername($ID));
    // Cache our permissions.
    $canSeeUsers = $MySelf->canSeeUsers();
    // Need the api.
    $api = new api($ID);
    // Create table header.
    $table = new table(2, true);
    $table->addHeader(">> About " . $username);
    $table->addRow();
    $table->addCol("Current rank:");
    $table->addCol(getRank($ID));
    $table->addRow();
    $table->addCol("Last login:"******"SELECT lastlogin FROM users WHERE id='" . $ID . "' AND deleted='0' LIMIT 1");
    $table->addCol(date("d.m.y. H:i:s", $lastLog[0]));
    $table->addRow();
    $table->addCol("Total logins:");
    $lastLog = $DB->getCol("SELECT COUNT(authkey) FROM auth WHERE user='******' LIMIT 1");
    $table->addCol(number_format($lastLog[0], 0));
    $table->addRow();
    $table->addCol("Valid api-key on file:");
    $table->addCol(yesno($api->valid(), true));
    $table->addRow();
    $table->addCol("Is available for mining:");
    if ($profile->isOwn()) {
        if ($profile->MinerFlag()) {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&mining=false\">set not available</a>]";
        } else {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&mining=true\">set available</a>]";
        }
    }
    $table->addCol(yesno($profile->MinerFlag(), true) . $temp);
    $table->addRow();
    $table->addCol("Is available for hauling:");
    if ($profile->isOwn()) {
        if ($profile->HaulerFlag()) {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&hauling=false\">set not available</a>]";
        } else {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&hauling=true\">set available</a>]";
        }
    }
    $table->addCol(yesno($profile->HaulerFlag(), true) . $temp);
    $table->addRow();
    $table->addCol("Is available for fighting:");
    if ($profile->isOwn()) {
        if ($profile->FighterFlag()) {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&fighting=false\">set not available</a>]";
        } else {
            $temp = " [<a href=\"index.php?action=modprofile&id=" . $ID . "&fighting=true\">set available</a>]";
        }
    }
    $table->addCol(yesno($profile->FighterFlag(), true) . $temp);
    if ($profile->emailVisible() || $profile->isOwn()) {
        if ($profile->isOwn()) {
            if ($profile->emailVisible()) {
                $temp = " (public) [<a href=\"index.php?action=modprofile&id=" . $ID . "&email=hide\">hide from public</a>]";
            } else {
                $temp = " (hidden) [<a href=\"index.php?action=modprofile&id=" . $ID . "&email=show\">make public</a>]";
            }
        }
        $table->addRow();
        $table->addCol("Email address:");
        $email = $DB->getCol("SELECT email FROM users WHERE id='" . $ID . "' LIMIT 1");
        $table->addCol($email[0] . $temp);
    }
    // Statistics.
    $stats = new table(2, true);
    $stats->addHeader(">> Statistical breakdown");
    $miningRunsJoined = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "'");
    $miningRunsJoined = $miningRunsJoined[0];
    $OpjoinUps = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "'");
    $OpjoinUps = $OpjoinUps[0];
    $joinUps = $DB->getCol("SELECT COUNT(id) FROM (SELECT * from joinups WHERE userid='" . $ID . "' GROUP BY run) as uJoinups");
    $joinUps = $joinUps[0];
    $haulingRuns = $DB->getCol("SELECT COUNT(id) FROM hauled WHERE hauler='" . $ID . "'");
    $haulingRuns = $haulingRuns[0];
    $timeMining = $DB->getCol("SELECT SUM(parted - joined) FROM joinups WHERE userid='" . $ID . "' AND parted >1");
    $timeMining = $timeMining[0];
    $timesKicked = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "' AND status='1'");
    $timesKicked = $timesKicked[0];
    $timesRemoved = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "' AND status='2'");
    $timesRemoved = $timesRemoved[0];
    $timesBanned = $DB->getCol("SELECT COUNT(id) FROM joinups WHERE userid='" . $ID . "' AND status='3'");
    $timesBanned = $timesBanned[0];
    $timesCharity = $DB->getCol("SELECT COUNT(id) FROM (SELECT * from joinups WHERE userid='" . $ID . "' GROUP BY run) as uJoinups WHERE userid='" . $ID . "' AND charity='1'");
    $timesCharity = $timesCharity[0];
    $tmec = $DB->getCol("SELECT AVG(tmec) FROM runs WHERE isOfficial = 1");
    $tmecJoined = $DB->getCol("SELECT AVG(runs.tmec) FROM joinups, runs WHERE joinups.userid='" . $ID . "' AND joinups.run = runs.id AND runs.endtime > 0 AND runs.isOfficial = 1");
    $tmecNotJoined = $DB->getCol("SELECT AVG(runs.tmec) FROM joinups, runs WHERE joinups.userid='" . $ID . "' AND joinups.run <> runs.id AND runs.endtime > 0 AND runs.isOfficial = 1");
    $tmecDiff = $tmecJoined[0] - $tmecNotJoined[0];
    $stats->addRow();
    $stats->addCol("Mining operations joined:");
    if ($miningRunsJoined > 0) {
        $stats->addCol(number_format($joinUps, 0));
    } else {
        $stats->addCol("never joined.");
    }
    $stats->addRow();
    $stats->addCol("Total operations joinups:");
    if ($OpjoinUps > 0) {
        $stats->addCol(number_format($OpjoinUps, 0));
    } else {
        $stats->addCol("never joined.");
    }
    $stats->addRow();
    $stats->addCol("Hauling runs:");
    if ($haulingRuns > 0) {
        $stats->addCol(number_format($haulingRuns, 0));
    } else {
        $stats->addCol("never hauled.");
    }
    $stats->addRow();
    $stats->addCol("Time spent mining:");
    if ($timeMining > 0) {
        $stats->addCol(numberToString($timeMining));
    } else {
        $stats->addCol("never mined.");
    }
    $stats->addRow();
    $stats->addCol("Average TMEC:");
    $stats->addCol(number_format($tmec[0], 3));
    $stats->addRow();
    $stats->addCol("Average TMEC on Ops <b>with</b> " . $username . ":");
    $stats->addCol(number_format($tmecJoined[0], 3));
    $stats->addRow();
    $stats->addCol("Average TMEC on Ops <b>without</b> " . $username . ":");
    $stats->addCol(number_format($tmecNotJoined[0], 3));
    $stats->addRow();
    $stats->addCol("TMEC difference:");
    if ($tmecDiff >= 0) {
        $stats->addCol("<font color=\"#00ff00\">" . number_format($tmecDiff, 3), true . "</font>");
    } else {
        $stats->addCol("<font color=\"#ff0000\">" . number_format($tmecDiff, 3), true . "</font>");
    }
    $stats->addRow();
    $stats->addCol("Times removed from OP:");
    $stats->addCol(number_format($timesRemoved, 0));
    $stats->addRow();
    $stats->addCol("Times kicked from OP:");
    $stats->addCol(number_format($timesKicked, 0));
    $stats->addRow();
    $stats->addCol("Times banned from OP:");
    $stats->addCol(number_format($timesBanned, 0));
    $stats->addRow();
    $stats->addCol("Times declared charity:");
    $stats->addCol(number_format($timesCharity, 0));
    /*
     * Assemble the heavy-duty SQL query.
     * It is dynamic because this way we can easily add ores from 
     * config-system.php to the system without code rewrite.
     */
    /*
    	global $DBORE;
    	global $ORENAMES;
    	foreach ($DBORE as $ORE) {
    		$new = $ORE;
    		if ($last) {
    			$SQLADD .= "SUM(" . $last . ") AS total" . $last . ", ";
    		}
    		$last = $new;
    	}
    	$SQLADD .= "SUM(" . $last . ") AS total" . $last . " ";
    	$SQL = "SELECT " . $SQLADD . " FROM hauled WHERE hauler='" . $ID . "'";
    
    	// Now query it.
    	$totalOREDB = $DB->query("$SQL");
    	
    
    if (DB::isError($totalOREDB)) {
        *
         * This is not what you would really want to do in
         * your program.  It merely demonstrates what kinds
         * of data you can get back from error objects.
         *
        echo 'Standard Message: ' . $totalOREDB->getMessage() . "\n";
        echo '\n ';
        echo 'Standard Code: ' . $totalOREDB->getCode() . "\n";
        echo '\n ';
        echo 'DBMS/User Message: ' . $totalOREDB->getUserInfo() . "\n";
        echo '\n ';
        echo 'DBMS/Debug Message: ' . $totalOREDB->getDebugInfo() . "\n";
        echo '\n ';
        exit;
    }
    
    	// Create table.
    	$totalOre_table = new table(2, true);
    	$totalOre_table->addHeader(">> Total ore hauled");
    
    	// Loop through the result (single result!)
    	if ($totalOREDB->numRows() > 0) {
    		while ($totalORE = $totalOREDB->fetchRow()) {
    			// Now check each ore type.
    			foreach ($ORENAMES as $ORE) {
    				// And ignore never-hauled ore
    				if ($totalORE[total . $ORE] > 0) {
    					// We got some ore!
    					$totalOre_table->addRow();
    					$totalOre_table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . $ORE . ".png\">Total " . $ORE . " hauled:");
    					$totalOre_table->addCol(number_format($totalORE[total . $ORE]));
    					$gotOre = true;
    				}
    			}
    		}
    		if ($gotOre) {
    			$oretable_r = "<br>" . $totalOre_table->flush();
    		}
    	}
    */
    // Image thingy.
    // We serve small images IGB.
    global $IGB;
    global $IGB_VISUAL;
    if ($IGB && $IGB_VISUAL) {
        $image = "<img src=\"portrait:" . $api->getCharacterID() . "\" SIZE=\"128\">";
    } else {
        $image = $profile->getImage("large");
    }
    $picTable = new table(true, 1);
    $picTable->addHeader(">> Picture of " . $username);
    $picTable->addRow();
    $picTable->addCol($image);
    $imageTable = $picTable->flush();
    // About
    if ($profile->GetAbout() && !$profile->isOwn()) {
        $aboutTable = new table(1, true);
        $aboutTable->addHeader(">> " . $username . " says...");
        $aboutTable->addRow();
        $aboutTable->addCol(nl2br($profile->GetAbout()));
        $aboutTable = "<br>" . $aboutTable->flush();
    }
    if ($profile->isOwn()) {
        $aboutTable = new table(1, true);
        $aboutTable->addHeader(">> Enter a public viewable text here");
        $aboutTable->addRow();
        $form = "<form action=\"index.php\" method=\"POST\">";
        $form .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
        $form .= "<input type=\"hidden\" name=\"action\" value=\"modprofile\">";
        $form .= "<input type=\"hidden\" name=\"id\" value=\"" . $ID . "\">";
        $aboutTable->addCol("<textarea rows=\"18\" cols=\"80\" name=\"about\">" . $profile->GetAbout() . "</textarea>");
        $aboutTable->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Update about\">");
        $aboutTable = "<br>" . $form . $aboutTable->flush() . "</form>";
    }
    // quick "jump to" -thingy.
    $peeps = $DB->query("SELECT DISTINCT username,id FROM users WHERE deleted = 0 AND canLogin = 1 ORDER BY username ASC");
    if ($peeps->numRows() > 0) {
        while ($p = $peeps->fetchRow()) {
            if ($ID == $p[id]) {
                $pdm .= "<option SELECTED value=\"" . $p[id] . "\">" . ucfirst($p[username]) . " (current)</option>";
            } else {
                $pdm .= "<option value=\"" . $p[id] . "\">" . ucfirst($p[username]) . "</option>";
            }
        }
        $pdm = "<select name=\"id\">" . $pdm . "</select></form>";
        $quickChooser = new table(1, true);
        $quickChooser->addHeader(">> Quick jump to profile");
        $quickChooser->addRow();
        $quickChooser->addCol($pdm);
        $quickChooser->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Switch\">");
        $quickChooser = "<form action=\"index.php\" method=\"GET\"><input type=\"hidden\" name=\"action\" value=\"profile\">" . $quickChooser->flush() . "</form>";
    }
    $page = "<h2>View profile</h2>" . $quickChooser . $imageTable . "<br>" . $table->flush() . "<br>" . $stats->flush() . $oretable_r . $aboutTable;
    return $page;
}
コード例 #22
0
 public function makeConstellationTable()
 {
     global $STATIC_DB;
     // First we check if the system name we got is valid.
     if ($this->valid()) {
         // It is, so lets load all other systems in the same region and constellation.
         $otherSystems = $this->DB->query("SELECT * FROM {$STATIC_DB}.mapSolarSystems WHERE constellationID = '" . $this->constellationID . "' AND regionID ='" . $this->regionID . "' ORDER BY solarSystemName ASC");
         // Sanity check: Do we have more than 0?
         if ($otherSystems->numRows() > 0) {
             // Create the table header.
             $table = new table(2, true);
             $table->addHeader(">> Other Solarsystems in " . $this->regionName);
             // We need this for a new table line.
             $newline = true;
             // Loop through all solarsystems.
             while ($otherSystem = $otherSystems->fetchRow()) {
                 // If this is a new table row, add one.
                 if ($newline) {
                     $table->addRow();
                     $newline = false;
                 } else {
                     $newline = true;
                 }
                 // Add the information.
                 $curRuns = $this->DB->getCol("SELECT COUNT(location) FROM runs WHERE location = '" . $otherSystem['solarSystemName'] . "' AND endtime IS NULL");
                 if ($curRuns[0] > 0) {
                     $curRuns = "(" . $curRuns[0] . " active runs)";
                 } else {
                     $curRuns = "";
                 }
                 $table->addCol("<a href=\"index.php?action=browse&mode=0&id=" . $otherSystem['solarSystemID'] . "\">" . $otherSystem['solarSystemName'] . "</a> (" . number_format($otherSystem['security'], 1) . ") {$curRuns}");
             }
         }
         // Add missing column, if any.
         if (!$newline) {
             $table->addCol();
         }
         // Return the table.
         return $table->flush();
     }
 }
コード例 #23
0
ファイル: listUsers.php プロジェクト: nuxi/MiningBuddy
function listUsers()
{
    // Some major vars importing...
    global $DB;
    global $MySelf;
    // Are we allowed to be here?
    if (!$MySelf->canSeeUsers()) {
        makeNotice("You are not allowed to list users!", "error", "forbidden");
    }
    // Easy-for-the-coder table generator.
    $fields = array("ID", "Username", "Last Login", "can Login", "Confirmed", "Email OK", "API verified");
    // Show only new users.
    if ($_GET["newusers"] == "true") {
        $users = $DB->Query("SELECT * FROM users WHERE confirmed='0' AND emailvalid='1' AND deleted ='0' ORDER BY username ASC;");
        $showOnlyNew = true;
        $newOnlyUrlAddition = "&newusers=true";
    } else {
        // Sorting switch, called by browser.
        switch ("{$_GET['sort']}") {
            case "0":
                $SORT = "id";
                break;
            case "1":
                $SORT = "username";
                break;
            case "2":
                $SORT = "lastlogin";
                break;
            case "3":
                $SORT = "canLogin";
                break;
            case "4":
                $SORT = "confirmed";
                break;
            case "5":
                $SORT = "emailvalid";
                break;
            default:
                $SORT = "username";
                break;
        }
        // Normal or reverse sorting.
        if ($_GET["r"] == "true") {
            // Reverse sorting!
            $SORTORDER = "DESC";
        } else {
            // Normal Order
            $SORTORDER = "ASC";
        }
        // Limit folks.
        if (isset($_GET[sort])) {
            $sort = "&sort=" . $_GET[sort];
        }
        $folkCount = $DB->getCol("SELECT count(id) FROM users");
        if ($folkCount[0] > 25) {
            if (isset($_GET[l])) {
                $l = sanitize($_GET[l]);
            } else {
                $l = "a";
            }
            // make the clickable thingy.
            for ($p = "a"; $p != "aa"; $p++) {
                $count = $DB->getCol("SELECT id FROM users WHERE username LIKE '" . $p . "%' AND confirmed='1'");
                if ($count[0] > 0) {
                    $clickThingy .= " [<a href=\"index.php?action=editusers&l=" . $p . $sort . $newOnlyUrlAddition . "\">" . $p . "</a>]";
                } else {
                    $clickThingy .= " [" . $p . "]";
                }
            }
        }
        if ($_GET[sort] == "6") {
            $users = $DB->query("select * from users, api_keys where users.confirmed='1' AND users.deleted='0' AND api_keys.userid = users.id AND username LIKE '" . $l . "%' order by users.username {$SORTORDER}");
        } else {
            // Query the database according to rights.
            $users = $DB->query("select * from users  where deleted='0' AND confirmed='1' AND username LIKE '" . $l . "%' order by {$SORT} {$SORTORDER}");
        }
    }
    // Build the tables.
    $table = new table(7, true);
    $table->addHeader(">> Manage Users");
    $mode = array("bold" => true, "align" => "left");
    $table->addRow("#060644");
    $table->addCol($clickThingy, array("colspan" => "7", "align" => "center"));
    $table->addRow("#060622");
    $i = "0";
    foreach ($fields as $field) {
        if ($_GET["sort"] == "{$i}" && $_GET[r] != "true") {
            // Offer reverse sorting.
            $table->addCol("<a href=\"index.php?action=editusers&sort={$i}&r=true" . $newOnlyUrlAdditio . "\">{$field}</a>", $mode);
        } else {
            // Offer real sorting.
            $table->addCol("<a href=\"index.php?action=editusers&sort={$i}" . $newOnlyUrlAddition . "\">{$field}</a>", $mode);
        }
        $i++;
    }
    // create the database.
    if ($users->numRows() == 0 && $showOnlyNew == true) {
        $table->addRow();
        $table->addCol("There are no new users waiting.", array("align" => "center", "colspan" => "7"));
    } else {
        while ($row = $users->fetchRow()) {
            $table->addRow();
            $table->addCol("<a href=\"index.php?action=edituser&id={$row['id']}\">" . str_pad($row[id], 5, "0", STR_PAD_LEFT));
            $table->addCol(ucfirst($row[username]));
            // Handle folks that never logged in.
            if ("{$row['lastlogin']}" < 10) {
                $table->addCol("<i>never</i>");
            } else {
                $table->addCol(date("d.m.y H:i:s", $row[lastlogin]));
            }
            // Color the background accordingly.
            if ("{$row['canLogin']}" == "1") {
                $fcolor = "#00ff00";
            } else {
                $fcolor = "#ff0000";
            }
            $table->addCol("<a href=\"index.php?action=toggleLogin&id=" . $row[id] . "\"><font color=\"" . $fcolor . "\">" . yesno($row[canLogin]) . "</font></a>");
            // Color the background accordingly.
            if ("{$row['confirmed']}" == "1") {
                $fcolor = "#00ff00";
            } else {
                $fcolor = "#ff0000";
            }
            if ($newOnlyUrlAddition) {
                $table->addCol("<font color=\"" . $fcolor . "\"><a href=\"index.php?action=quickconfirm&id=" . $row[id] . "\">" . yesno($row[confirmed]) . "</a></font>");
            } else {
                $table->addCol("<font color=\"" . $fcolor . "\">" . yesno($row[confirmed]) . "</font>");
            }
            // Color the background accordingly.
            if ("{$row['emailvalid']}" == "1") {
                $fcolor = "#00ff00";
            } else {
                $fcolor = "#ff0000";
            }
            $table->addCol("<font color=\"" . $fcolor . "\">" . yesno($row[emailvalid]) . "</font>");
            $api = new api($row[id], true);
            if ($api->valid()) {
                // Api key submited and valid.
                $apiText = "<font color=\"#00ff00\">API valid</font>";
            } else {
                // Check wheter key is submited or "just" not valid.
                if ($api->getApiID() > 0) {
                    // Api key submited but not valid.
                    $apiText = "<font color=\"#FF8000\">API invalid</font>";
                } else {
                    // No api key submited.
                    $apiText = "<font color=\"#999999\">No api key</font>";
                }
            }
            $table->addCol($apiText, array("bgcolor" => "{$tdcolor}"));
        }
    }
    if ($showOnlyNew) {
        $add = "<a href=\"index.php?action=editusers\">Show active users</a>";
    } else {
        $add = "<a href=\"index.php?action=editusers&newusers=true\">Show pending requests</a>";
    }
    $table->addHeader("Click on an ID to edit/view an user. " . $add);
    return "<h2>User Management</h2>" . $table->flush();
}
コード例 #24
0
ファイル: makeShipValue.php プロジェクト: nuxi/MiningBuddy
function makeShipValue()
{
    // Get the globals.
    global $TIMEMARK;
    global $SHIPTYPES;
    global $DBSHIP;
    global $DB;
    // load the values.
    $shipvaluesDS = $DB->query("select * from shipvalues order by id DESC limit 1");
    $shipvalues = $shipvaluesDS->fetchRow();
    // Create the table.
    $table = new table(6, true);
    //(8, true)
    $table->addHeader(">> Manage ship values (Values may be as little as 0.01% and as high as 999.99%)", array("bold" => true, "colspan" => 6));
    $table->addRow();
    $table->addCol("Ship Type", array("colspan" => 2, "bold" => true));
    //	$table->addCol("Enabled", array (
    //		"bold" => true
    //	));
    $table->addCol("Value", array("bold" => true));
    $table->addCol("Ship Type", array("colspan" => 2, "bold" => true));
    //	$table->addCol("Enabled", array (
    //		"bold" => true
    //	));
    $table->addCol("Value", array("bold" => true));
    // How many Ships are there in total? Ie, how long has the table to be?
    $tableLength = ceil(count($SHIPTYPES) / 2) - 2;
    for ($i = 0; $i <= $tableLength; $i++) {
        $table->addRow();
        $SHIP = $SHIPTYPES[$i];
        // Ship columns for LEFT side.
        $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ships/ship.png\">");
        $table->addCol($SHIP);
        //		if (getShipSettings($DBSHIP[$SHIP])) {
        //			$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
        //		} else {
        //			$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\">");
        //		}
        $table->addCol("<input type=\"text\" name=\"{$DBSHIP[$SHIP]}\"" . "size=\"6\" value=\"" . number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) . "\">" . " %");
        // Ship columns for RIGHT side.
        $SHIP = $SHIPTYPES[$i + $tableLength + 1];
        if ($SHIP != "") {
            $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ships/ship.png\">");
            $table->addCol($SHIP);
            //			if (getShipSettings($DBSHIP[$SHIP])) {
            //				$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
            //			} else {
            //				$table->addCol("<input name=\"" . $DBSHIP[$SHIP] . "Enabled\" value=\"true\" type=\"checkbox\">");
            //			}
            $table->addCol("<input type=\"text\" name=\"{$DBSHIP[$SHIP]}\"" . "size=\"6\" value=\"" . number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) . "\">" . " %");
        } else {
            $table->addCol("");
            $table->addCol("");
            $table->addCol("");
            //			$table->addCol("");
        }
    }
    $form .= "<input type=\"hidden\" name=\"action\" value=\"changeship\">";
    $form .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $form .= "<input type=\"submit\" name=\"change\" value=\"Modify ship settings\">";
    $table->addHeaderCentered($form, array("colspan" => 6, "align" => "center"));
    // return the page
    return "<h2>Modify ship settings</h2><form action=\"index.php\"method=\"post\">" . $table->flush();
}
コード例 #25
0
ファイル: globalStatistics.php プロジェクト: nuxi/MiningBuddy
function globalStatistics()
{
    // We need some stuff.
    global $DB;
    global $MySelf;
    /*
     * Global Information
     */
    // Create the header of the table
    $stat_table = new table(2, true);
    $stat_table->addHeader(">> Global Information for " . getConfig("sitename"));
    // Total Users
    $temp = $DB->getCol("SELECT COUNT(id) FROM users WHERE deleted='0'");
    $totalUsers = $temp[0];
    $stat_table->addRow();
    $stat_table->addCol("Total user accounts:");
    $stat_table->addCol(number_format($totalUsers, 0));
    // Total Logins
    $temp = $DB->getCol("SELECT COUNT(authkey) FROM auth");
    $temp = $temp[0];
    $stat_table->addRow();
    $stat_table->addCol("Total logins:");
    $stat_table->addCol(number_format($temp, 0));
    // Total failed logins
    $temp = $DB->getCol("SELECT COUNT(incident) FROM failed_logins");
    $temp = $temp[0];
    $stat_table->addRow();
    $stat_table->addCol("Total failed logins:");
    $stat_table->addCol(number_format($temp, 0));
    // Total API keys
    $temp = $DB->getCol("SELECT COUNT(userid) FROM api_keys");
    $totalApiKeys = $temp[0];
    if ($totalApiKeys > 0) {
        $stat_table->addRow();
        $stat_table->addCol("Total API keys stored:");
        $stat_table->addCol(number_format($totalApiKeys, 0));
        // Total API keys
        $temp = $DB->getCol("SELECT COUNT(userid) FROM api_keys WHERE api_valid=1");
        $totalValidApiKeys = $temp[0];
        $stat_table->addRow();
        $stat_table->addCol("Total API keys validated:");
        $stat_table->addCol(number_format($totalValidApiKeys, 0));
        // Total API keys percentage
        $stat_table->addRow();
        $stat_table->addCol("Percent of stored keys valid:");
        $stat_table->addCol(number_format($totalValidApiKeys * 100 / $totalApiKeys, 2) . "%");
        // Total API keys percentage (over all users)
        $stat_table->addRow();
        $stat_table->addCol("Percent of pilots submited API keys:");
        $stat_table->addCol(number_format($totalApiKeys * 100 / $totalUsers, 2) . "%");
    }
    /*
     * Mining Information
     */
    // Create the header of the table
    $mining_table = new table(2, true);
    $mining_table->addHeader(">> Mining Information for " . getConfig("sitename"));
    // Total Mining Operations
    $temp = $DB->getCol("SELECT COUNT(id) FROM runs WHERE isOfficial = 1");
    $totalMiningOps = $temp[0];
    $mining_table->addRow();
    $mining_table->addCol("Total Mining Operations:");
    $mining_table->addCol(number_format($totalMiningOps, 0));
    // Total Number of Joins
    $temp = $DB->getCol("SELECT COUNT( uJoinups ) FROM (SELECT COUNT( id ) AS uJoinups FROM joinups GROUP BY `run`,`userid`) AS suJoinups");
    $totalJoinUps = $temp[0];
    $mining_table->addRow();
    $mining_table->addCol("Total joinups:");
    $mining_table->addCol(number_format($totalJoinUps, 0));
    // Total Hauling Runs
    $temp = $DB->getCol("SELECT COUNT(id) FROM hauled");
    $totalHaulingRuns = $temp[0];
    $mining_table->addRow();
    $mining_table->addCol("Total Hauling Runs:");
    $mining_table->addCol(number_format($totalHaulingRuns, 0));
    // Total ISK Mined
    $mining_table->addRow();
    $mining_table->addCol("Total ISK mined:");
    $totalIskMined = calculateTotalIskMined();
    $mining_table->addCol(number_format($totalIskMined) . " ISK");
    // Average TMEC
    $aTMEC = $DB->getCol("SELECT AVG(tmec) FROM runs WHERE isOfficial = 1");
    $aTMEC = $aTMEC[0];
    $mining_table->addRow();
    $mining_table->addCol("Average TMEC:");
    if ($aTMEC <= 0) {
        $aTMEC = 0;
    }
    $mining_table->addCol(number_format($aTMEC, 3));
    // Total time spent mining
    $temp = $DB->getCol("SELECT SUM(endtime-starttime) AS time FROM runs WHERE endtime >0 AND isOfficial = 1");
    $time = $temp[0];
    if ($time > 0) {
        $totalTimeSpentMining = $time;
        $string = numberToString($time);
    } else {
        $string = "Never mined at all!";
    }
    $mining_table->addRow();
    $mining_table->addCol("Total time spent mining:");
    $mining_table->addCol($string);
    // Total pilot time
    $time = $DB->getCol("select SUM(parted-joined) as time from joinups WHERE parted >0");
    $time = $time[0];
    $mining_table->addRow();
    $mining_table->addCol("Total time combined from all pilots:");
    if ($time > 0) {
        $totalPilotTime = $time;
        $string = numberToString($time);
    } else {
        $string = "Never mined at all!";
    }
    $mining_table->addCol($string);
    /*
     * Money Stuff
     */
    $trans_Count = $DB->getCol("SELECT COUNT(id) FROM transactions");
    $trans_Count = $trans_Count[0];
    if ($trans_Count > 0) {
        $trans = new table(2, true);
        $trans->addHeader(">> Financial Statistics");
        $trans->addRow();
        $trans->addCol("Total Transactions made:");
        $trans->addCol(number_format($trans_Count, 0));
        $tmw = $DB->getCol("SELECT SUM(amount) FROM transactions WHERE type ='1'");
        $tmd = $DB->getCol("SELECT SUM(amount) FROM transactions WHERE type ='0'");
        $tmw = $tmw[0];
        $tmd = $tmd[0];
        $trans->addRow();
        $trans->addCol("Total Money withdrawn:");
        $trans->addCol(number_format($tmw * -1, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Total Money deposited:");
        $trans->addCol(number_format($tmd, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Difference:");
        $trans->addCol(number_format($tmd + $tmw, 2) . " ISK");
        /*
         * Abbreviations:
         * por - PayOutRequests
         * pord - PayOutRequests Done
         * port - PayOutRequests Total
         * portd - PayOutRequests Total Done
         */
        $por = $DB->getCol("SELECT COUNT(request) FROM payoutRequests");
        $port = $DB->getCol("SELECT SUM(amount) FROM payoutRequests");
        $portd = $DB->getCol("SELECT SUM(amount) FROM payoutRequests WHERE payoutTime is NULL");
        $pord = $DB->getCol("SELECT COUNT(request) FROM payoutRequests WHERE payoutTime is NULL");
        $por = $por[0];
        $pord = $pord[0];
        $port = $port[0];
        $portd = $portd[0];
        $trans->addRow();
        $trans->addCol("Total payout requests:");
        $trans->addCol(number_format($por, 0));
        $trans->addRow();
        $trans->addCol("Payout requests fullfilled:");
        $trans->addCol(number_format($por - $pord, 0));
        $trans->addRow();
        $trans->addCol("Payout requests pending:");
        $trans->addCol(number_format($pord, 0));
        $trans->addRow();
        $trans->addCol("Total payout requested:");
        $trans->addCol(number_format($port, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Total requested paid:");
        $trans->addCol(number_format($port - $portd, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Total requested open:");
        $trans->addCol(number_format($portd, 2) . " ISK");
        $trans->addHeader("A positive difference means the Corp owes the players, a negative difference means the player owes the Corp.");
        $trans_r = "<br>" . $trans->flush();
    }
    /*
     * Mining Statistics
     */
    // Create the header of the table
    $miningStats_table = new table(2, true);
    $miningStats_table->addHeader(">> Mining Statistics for " . getConfig("sitename"));
    // Average ISK / OP
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average ISK per Op:");
    $miningStats_table->addCol(number_format($totalIskMined / $totalMiningOps, 2) . " ISK");
    // Average ISK/ Hour
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average ISK per hour:");
    $miningStats_table->addCol(number_format($totalIskMined / ceil($totalTimeSpentMining / 3600), 2) . " ISK");
    // Average joinups / Op
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average Joinups per Op:");
    $miningStats_table->addCol(number_format($totalJoinUps / $totalMiningOps, 2));
    // Average hauls per OP:
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average hauls per Op:");
    $miningStats_table->addCol(number_format($totalHaulingRuns / $totalMiningOps, 2));
    /*
     * Hauler statistics
     */
    $haulers = $DB->query("SELECT DISTINCT hauler, COUNT(miningrun) AS runs FROM hauled GROUP BY hauler ORDER BY runs DESC LIMIT 15");
    if ($haulers->numRows() > 0) {
        $hauler_stats = new table(2, true);
        $hauler_stats->addHeader("Most hauling trips");
        while ($h = $haulers->fetchRow()) {
            // place counter.
            $place++;
            $hauler_stats->addRow();
            $hauler_stats->addCol("Place #" . $place . ":");
            $hauler_stats->addCol(makeProfileLink($h[hauler]) . " with " . number_format($h[runs]) . " runs!");
        }
        $hauler_stats_table = "<br>" . $hauler_stats->flush();
    }
    /*
     * Most frequent joiners
     */
    $MFJDB = $DB->query("SELECT COUNT(userid) AS count, userid FROM (SELECT * FROM joinups GROUP BY userid,run) AS ujoinups GROUP BY userid ORDER BY count DESC LIMIT 15");
    if ($MFJDB->numRows() > 0) {
        // Create the header of the table
        $frequentJoiners_table = new table(2, true);
        $frequentJoiners_table->addHeader(">> Most frequent joiners for " . getConfig("sitename"));
        $place = "1";
        while ($FJ = $MFJDB->fetchRow()) {
            $frequentJoiners_table->addRow();
            $frequentJoiners_table->addCol("Place #" . $place . ":");
            $frequentJoiners_table->addCol(makeProfileLink($FJ[userid]) . " with " . $FJ[count] . " joinups!");
            $place++;
        }
        $MFJ_r = "<br>" . $frequentJoiners_table->flush();
    }
    /*
     * Pilot record with mining time
     */
    $PMT = $DB->query("select SUM(parted-joined) AS totaltime, userid from joinups WHERE parted >0 GROUP BY userid ORDER BY totaltime DESC LIMIT 15");
    if ($PMT->numRows() > 0) {
        // Create the header of the table
        $mostOnline_table = new table(2, true);
        $mostOnline_table->addHeader(">> Most time spent mining");
        $place = 1;
        while ($P = $PMT->fetchRow()) {
            $time = $P[totaltime];
            if ($time > 0) {
                $string = numberToString($time);
                $mostOnline_table->addRow();
                $mostOnline_table->addCol("Place #" . $place . ":");
                $mostOnline_table->addCol(makeProfileLink($P[userid]) . " with " . $string);
                $place++;
            }
        }
        $MO_r = "<br>" . $mostOnline_table->flush();
    }
    /*
     * Longest OPS
     */
    $LOPS = $DB->query("select SUM(endtime-starttime) AS totaltime, id, location FROM runs WHERE endtime > 0 AND isOfficial = 1 GROUP BY id ORDER BY totaltime DESC LIMIT 15");
    if ($LOPS->numRows() > 0) {
        // Create the header of the table
        $lops_table = new table(2, true);
        $lops_table->addHeader(">> Longest Ops for " . getConfig("SITENAME"));
        $place = 1;
        while ($OP = $LOPS->fetchRow()) {
            $time = $OP[totaltime];
            if ($time > 0) {
                $string = numberToString($time);
                // Make system clickable.
                $system = new solarSystem($OP[location]);
                $loc = $system->makeFancyLink();
                $lops_table->addRow();
                $lops_table->addCol("Place #" . $place . ": Operation <a href=\"index.php?action=show&id=" . $OP[id] . "\">#" . str_pad($OP[id], 4, "0", STR_PAD_LEFT) . "</a> in " . $loc . ":");
                $lops_table->addCol($string);
                $place++;
            }
        }
        $LOPS_r = "<br>" . $lops_table->flush();
    }
    /*
     * Highest TMEC runs
     */
    // Load the top runs out of the database.
    $TMECDB = $DB->query("SELECT * FROM runs WHERE isOfficial = 1 AND endtime > 0 ORDER BY tmec DESC LIMIT 15");
    // Check that we have any!
    if ($TMECDB->numRows() > 0) {
        // Create table header for tmec.
        $TMEC = new table(3, true);
        $TMEC->addHeader(">> Highest rated TMEC Ops");
        // Reset first place again.
        $place = 1;
        // Now loop through the winners.
        while ($r = $TMECDB->fetchRow()) {
            // Calculate TMEC
            $thisTMEC = calcTMEC($r[id]);
            // This this is TMEC is zero or below.
            if ($thisTMEC <= 0) {
                break;
            }
            // If TMEC > 0, add it.
            $TMEC->addRow();
            // Load the solarsystem its in.
            $system = new solarSystem($r[location]);
            $location = $system->makeFancyLink();
            // Add tmec stuff.
            $TMEC->addCol("Place #" . $place . ":");
            $TMEC->addCol("Op #<a href=\"index.php?action=show&id=" . $r[id] . "\">" . str_pad($r[id], 4, "0", STR_PAD_LEFT) . "</a> in " . $location);
            $TMEC->addCol("Scored a TMEC of " . $thisTMEC . "!");
            // Increase place by one.
            $place++;
        }
        // Render the table.
        $TMEC_r = "<br>" . $TMEC->flush();
    }
    /* 
     * Total mined ore
     */
    /*
     * Assemble the heavy-duty SQL query.
     * It is dynamic because this way we can easily add ores from 
     * config-system.php to the system without code rewrite.
     */
    global $DBORE;
    global $ORENAMES;
    foreach ($DBORE as $ORE) {
        $new = $ORE;
        if ($last) {
            $SQLADD .= "(select coalesce(SUM(Quantity),0) from hauled where Item = '" . $last . "') AS total" . $last . ", ";
        }
        $last = $new;
    }
    $SQLADD .= "(select coalesce(SUM(Quantity),0) from hauled where Item = '" . $last . "') AS total" . $last . " ";
    $SQL = "SELECT " . $SQLADD;
    //$SQL = "select Item, coalesce(SUM(Quantity),0) as total from hauled group by Item";
    // Now query it.
    $totalOREDB = $DB->query("{$SQL}");
    // Create table.
    $totalOre_table = new table(2, true);
    $totalOre_table->addHeader(">> Total ore mined for " . getConfig("SITENAME"));
    // Loop through the result (single result!)
    if ($totalOREDB->numRows() > 0) {
        echo "<!-- Got rows for ore stats -->";
        while ($totalORE = $totalOREDB->fetchRow()) {
            // Now check each ore type.
            foreach ($ORENAMES as $ORE) {
                // And ignore never-hauled ore
                if ($totalORE[total . $DBORE[$ORE]] > 0) {
                    // We got some ore!
                    $totalOre_table->addRow();
                    $totalOre_table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . $ORE . ".png\">Total " . $ORE . ":");
                    $totalOre_table->addCol(number_format($totalORE[total . $DBORE[$ORE]]));
                    $gotOre = true;
                }
            }
        }
        if ($gotOre) {
            $oretable_r = "<br>" . $totalOre_table->flush();
        }
    }
    /*
     * Assemble the heavy-duty SQL query.
     * It is dynamic because this way we can easily add ships from 
     * config-system.php to the system without code rewrite.
     */
    global $DBSHIP;
    global $SHIPNAMES;
    foreach ($DBSHIP as $SHIP) {
        $new = $SHIP;
    }
    /*
     * Most beloved Systems
     */
    $MBS = $DB->query("select SUM(endtime-starttime) as timespent, location FROM runs WHERE endtime > 0 AND isOfficial = 1 GROUP BY location ORDER BY timespent DESC LIMIT 10");
    if ($MBS->numRows() > 0) {
        $MBST = new table(2, true);
        $MBST->addHeader(">> Most loved locations");
        while ($LOC = $MBS->fetchRow()) {
            if ($LOC[timespent] > 0) {
                $MBST->addRow();
                $system = new solarSystem($LOC[location]);
                $MBST->addCol($system->makeFancyLink());
                $MBST->addCol(numberToString($LOC[timespent]));
            }
        }
        $MBST_r = "<br>" . $MBST->flush();
    }
    /*
     * Most charitable folks
     */
    $charity = $DB->query("SELECT users.username, COUNT(uJoinups.charity) as NOBLE FROM (SELECT * FROM joinups GROUP BY userid,run) as uJoinups, users WHERE users.id = uJoinups.userid AND uJoinups.charity=1 GROUP BY users.username ORDER BY NOBLE DESC, username ASC LIMIT 15");
    if ($charity->numRows() > 0) {
        $charity_table = new table(2, true);
        $charity_table->addHeader(">> Most charitable pilots");
        unset($j);
        while ($c = $charity->fetchRow()) {
            $j++;
            $charity_table->addRow();
            $charity_table->addCol("Place #" . $j . ":");
            $charity_table->addCol(makeProfileLink(usernameToID($c[username])) . " with " . $c[NOBLE] . " charitable acts!");
            $charityCount = $charityCount + $c[NOBLE];
        }
        $charity_table->addHeader("A total of {$charityCount} charitable actions have been recorded.");
        $charity_table = "<br>" . $charity_table->flush();
    }
    $page = "<h2>Global statistics</h2>" . $stat_table->flush() . $trans_r . "<br>" . $mining_table->flush() . "<br>" . $miningStats_table->flush() . $hauler_stats_table . $MFJ_r . $MO_r . $charity_table . $LOPS_r . $TMEC_r . $oretable_r . $MBST_r;
    return $page;
}
コード例 #26
0
ファイル: payout.php プロジェクト: nuxi/MiningBuddy
function payout()
{
    // Some globals needed.
    global $DB;
    global $TIMEMARK;
    global $MySelf;
    global $IGB;
    global $IGB_VISUAL;
    // Are we allowed to do this?
    if (!$MySelf->isAccountant()) {
        makeNotice("You are not an accountant to your corporation. Access denied.", "error", "Access denied");
    }
    /*
     * Amount of ISK owned.
     */
    $iskOwned = new table(2, true);
    $iskOwned->addHeader(">> Outstanding ISK");
    // Load all unique members from the database.
    $uniqeMembers = $DB->query("SELECT DISTINCT id FROM users WHERE deleted='0' ORDER BY username ASC");
    // Create a row for each member.
    while ($id = $uniqeMembers->fetchRow()) {
        $playerCreds = getCredits($id['id']);
        // We need this later on...
        $allPeeps[$id['id']] = ucfirst(idToUsername($id['id']));
        // if the member has more or less than zero isk, list him.
        if ($playerCreds != 0) {
            $iskOwned->addRow();
            $iskOwned->addCol("<a href=\"index.php?action=showTransactions&id=" . $id['id'] . "\">" . $allPeeps[$id['id']] . "</a>");
            $iskOwned->addCol(number_format($playerCreds, 2) . " ISK");
        }
    }
    // Show the total isk owned.
    $outstanding = totalIskOwned();
    $iskOwned->addRow("#060622");
    $iskOwned->addCol(">> Total Outstanding ISK:");
    $iskOwned->addCol(totalIskOwned() . " ISK");
    /*
     * Show a drop down menu to create a menu to see everyones transaction log.
     */
    $freeSelect = new table(2, true);
    $freeSelect->addHeader(">> Lookup specific transaction log");
    // Create a PDM for all the peoples.
    foreach ($allPeeps as $peep) {
        $pdm .= "<option value=\"" . array_search($peep, $allPeeps) . "\">{$peep}</option>";
    }
    $freeSelect->addRow();
    $freeSelect->addCol("Show log of ", array("align" => "right"));
    $freeSelect->addCol("<select name=\"id\">{$pdm}</select>");
    $freeSelect->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Lookup log in Database\">");
    unset($pdm);
    /*
     * Show current requests
     */
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NULL ORDER BY time DESC");
    if ($IGB && $IGB_VISUAL) {
        $table = new table(6, true);
    } else {
        $table = new table(5, true);
    }
    $table->addHeader(">> Pending payout requests");
    $table->addRow("#060622");
    $table->addCol("request");
    $table->addCol("applicant");
    if ($IGB && $IGB_VISUAL) {
        $table->addCol("right click menu");
    }
    $table->addCol("time");
    $table->addCol("amount");
    $table->addCol("Payout");
    while ($request = $requests->fetchRow()) {
        if ($IGB && $IGB_VISUAL) {
            $api = new api($request['applicant']);
            //			$profile = new profile($request['applicant']);
            if ($api->valid() && ($IGB && $IGB_VISUAL)) {
                $rcm = " [<a href=\"showinfo:1378//" . $api->getCharacterID() . "\">RCM</a>]";
            }
        }
        $table->addRow();
        $table->addCol("#" . str_pad($request['request'], "5", "0", STR_PAD_LEFT));
        $table->addCol("<a href=\"index.php?action=showTransactions&id={$request['applicant']}\">" . ucfirst(idToUsername($request['applicant'])) . "</a>");
        if ($IGB && $IGB_VISUAL) {
            $table->addCol($rcm);
        }
        $table->addCol(date("d.m.y H:i:s", $request['time']));
        if (getCredits($request['applicant']) < $request['amount']) {
            $class .= "red";
        }
        if ($IGB && $IGB_VISUAL) {
            $table->addCol("<input type=\"text\" class=\"{$class}\" name=\"dumb\" readonly value=\"" . number_format($request['amount'], 2) . "\"> ISK");
        } else {
            $table->addCol(number_format($request['amount'], 2) . " ISK", array("class" => $class));
        }
        // Can the user still cover his request with cash?
        $table->addCol("<input type=\"checkbox\" name=\"" . $request['request'] . "\" value=\"true\">");
        $haveRequest = true;
        //} else {
        //	$table->addCol("<i>not enough ISK</i>");
        //}
    }
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Mark as paid\">");
    $funnyForm = "<form action=\"index.php\" method=\"POST\">";
    $funnyForm .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $funnyForm .= "<input type=\"hidden\" name=\"action\" value=\"payout\">";
    $funnyForm .= $table->flush();
    $funnyForm .= "</form>";
    /*
     * Show fulfilled requests
     */
    if (is_numeric($_GET['page']) && $_GET['page'] > 0) {
        $page = "LIMIT " . $_GET['page'] * 20 . ", 20";
    } elseif ($_GET['page'] == "all") {
        $page = "";
    } else {
        $page = "LIMIT 20";
    }
    $requests = $DB->query("SELECT * FROM payoutRequests WHERE payoutTime IS NOT NULL ORDER BY time DESC {$page}");
    $table_done = new table(6, true);
    $table_done->addHeader(">> Fulfilled payout requests");
    $table_done->addRow("#060622");
    $table_done->addCol("request");
    $table_done->addCol("applicant");
    $table_done->addCol("time");
    $table_done->addCol("amount");
    $table_done->addCol("Payout time");
    $table_done->addCol("Authorized by");
    while ($request = $requests->fetchRow()) {
        $table_done->addRow();
        $table_done->addCol("#" . str_pad($request['request'], "5", "0", STR_PAD_LEFT));
        $table_done->addCol("<a href=\"index.php?action=showTransactions&id={$request['applicant']}\">" . ucfirst(idToUsername($request['applicant'])) . "</a>");
        $table_done->addCol(date("d.m.y H:i:s", $request['time']));
        $table_done->addCol(number_format($request['amount'], 2) . " ISK");
        $table_done->addCol(date("d.m.y H:i:s", $request['payoutTime']));
        $table_done->addCol(ucfirst(idToUsername($request['banker'])));
        $haveOldRequests = true;
    }
    // The "show this many payouts"-part.
    $count = $DB->getCol("SELECT COUNT(request) FROM payoutRequests WHERE payoutTime IS NOT NULL");
    $countSteps = floor($count[0] / 20);
    $showMore = "Switch to page >> ";
    for ($i = 1; $i <= $countSteps; $i++) {
        $thisStep = str_pad($i, 2, "0", STR_PAD_LEFT);
        $showMore .= "[<a href=\"index.php?action=payout&page=" . $thisStep . "\">" . $thisStep . "</a>] ";
    }
    $showMore .= "[<a href=\"index.php?action=payout&page=all\">All</a>] ";
    $table_done->addHeader($showMore);
    $html = "<h2>Manage Payouts</h2>" . $iskOwned->flush() . "<br><br>";
    $html .= "<form action=\"index.php\" method=\"GET\">" . $freeSelect->flush() . "<input type=\"hidden\" name=\"action\" value=\"showTransactions\"></form><br>";
    if ($haveRequest) {
        $html .= $funnyForm . "<br>";
    } else {
        $html .= "<i>No open requests.</i><br><br>";
    }
    if ($haveOldRequests) {
        $html .= $table_done->flush();
    } else {
        $html .= "<br><i>No payouts at all.</i>";
    }
    return $html;
}
コード例 #27
0
ファイル: browser.php プロジェクト: nuxi/MiningBuddy
function browser()
{
    // Wash the incoming.
    numericCheck(sanitize($_GET[mode]));
    numericCheck(sanitize($_GET[id]));
    $id = $_GET[id];
    $mode = $_GET[mode];
    global $DB;
    // We differ between 0 = system (detailed), 1 = constellation and 2 = region.
    switch ($_GET[mode]) {
        case "0":
            $solar = new solarSystem($id);
            $table = $solar->makeInfoTable();
            //Current Runs in System
            $openRuns = $DB->query("SELECT * FROM runs WHERE location = '" . $solar->getName() . "' AND endtime IS NULL ORDER BY id");
            if ($openRuns->numRows() > 0) {
                $openRunsTable = new table(2, true);
                $openRunsTable->addHeader(">> Current runs in " . $solar->getName());
                // We need this for a new table line.
                $newline = true;
                // Loop through all solarsystems.
                while ($openRun = $openRuns->fetchRow()) {
                    // If this is a new table row, add one.
                    if ($newline) {
                        $openRunsTable->addRow();
                        $newline = false;
                    } else {
                        $newline = true;
                    }
                    // Add the information.
                    $openRunsTable->addCol("<a href=\"index.php?action=show&id=" . $openRun[id] . "\">#" . str_pad($openRun[id], 4, "0", STR_PAD_LEFT . "</a>"));
                }
                if (!$newline) {
                    $openRunsTable->addCol();
                }
                $openRunsStuff = $openRunsTable->flush();
            }
            //Past Runs in System
            $Runs = $DB->query("SELECT * FROM runs WHERE location = '" . $solar->getName() . "' AND endtime > 0 ORDER BY id");
            if ($Runs->numRows() > 0) {
                $RunsTable = new table(2, true);
                $RunsTable->addHeader(">> Past runs in " . $solar->getName());
                // We need this for a new table line.
                $newline = true;
                // Loop through all solarsystems.
                while ($Run = $Runs->fetchRow()) {
                    // If this is a new table row, add one.
                    if ($newline) {
                        $RunsTable->addRow();
                        $newline = false;
                    } else {
                        $newline = true;
                    }
                    // Add the information.
                    $RunsTable->addCol("<a href=\"index.php?action=show&id=" . $Run[id] . "\">#" . str_pad($Run[id], 4, "0", STR_PAD_LEFT . "</a>"));
                }
                if (!$newline) {
                    $RunsTable->addCol();
                }
                // Get the total time spent in this System.
                $time = $DB->getCol("SELECT SUM(endtime - starttime) FROM runs WHERE location='" . $solar->getName() . "'");
                $time = numberToString($time[0]);
                $RunsTable->addHeaderCentered("Time spent in " . $solar->makeFancyLink() . ": " . $time);
                $RunsStuff = $RunsTable->flush();
            }
            $solarStuff = $solar->makeConstellationTable();
            break;
    }
    return "<h2>Solar System Information</h2>" . $table . "<br>" . $solarStuff . "<br>" . $openRunsStuff . "<br>" . $RunsStuff;
}
コード例 #28
0
ファイル: showFailedLogins.php プロジェクト: nuxi/MiningBuddy
function showFailedLogins($limit, $user = false)
{
    global $DB;
    $user = sanitize(stripslashes($user));
    // Specify a user, if given.
    if ($user) {
        $addQuery = "WHERE username = '******'";
    } else {
        $addQuery = "";
    }
    // Set the default results (10)
    if ($limit < 1) {
        $limit = 10;
    }
    // Ask the oracle.
    $FailedDB = $DB->query("SELECT * FROM failed_logins {$addQuery} order by incident desc LIMIT {$limit} ");
    // Check for results.
    if ($FailedDB->numRows() > 0) {
        // We have failed logins.
        $table = new table(5, true);
        // Add a table header accordingly.
        if ($user) {
            $table->addHeader("Failed logins for user " . ucfirst(stripslashes($user)) . ".");
        } else {
            $table->addHeader("Failed logins");
        }
        // Add Table Description
        $table->addRow();
        $table->addCol("Incident");
        $table->addCol("Occurance");
        $table->addCol("IP");
        $table->addCol("Username");
        $table->addCol("Valid Username");
        // 		$table->addCol("Agent");
        // Add the data-rows.
        while ($log = $FailedDB->fetchRow()) {
            $table->addRow();
            $table->addCol(str_pad($log['incident'], 4, "0", STR_PAD_LEFT));
            $table->addCol(date("d.m.y h:i:s", $log['time']));
            $table->addCol($log['ip']);
            if ($log['username_valid']) {
                $userID = usernameToID(stripslashes(sanitize($log['username'])), "Failed_Login");
                if ($userID == -1) {
                    $link = ucfirst(stripslashes(sanitize($log['username'])));
                } else {
                    $link = "<a href=\"index.php?action=edituser&id={$userID}\">" . ucfirst(stripslashes(sanitize($log['username']))) . "</a>";
                }
                $table->addCol($link);
            } else {
                $table->addCol(ucfirst(sanitize($log['username'])));
            }
            $table->addCol(yesno($log['username_valid']));
            // 			$table->addCol($log['agent']);
        }
        $table->addHeaderCentered("Securing your system is your responsibility!");
        return "<br>" . $table->flush();
    } else {
        // No failed logins.
        return false;
    }
}
コード例 #29
0
ファイル: makeOreWorth.php プロジェクト: nuxi/MiningBuddy
function makeOreWorth()
{
    // Get the globals.
    global $TIMEMARK;
    global $ORENAMES;
    global $DBORE;
    global $DB;
    global $OTYPENAME;
    global $PRICECRITERIA;
    // Where do I get Ore Values?
    $Market = getConfig("useMarket");
    if ($Market) {
        // Update prices from Eve-Central and store.
        if ($Market == "eve-central") {
            $CURRENTTIME = date(U) - getConfig("timeOffset") * 60 * 60;
            $itemListDB = $DB->query("SELECT * FROM `itemList` ORDER BY `itemName` DESC");
            $orderType = $OTYPENAME[getConfig("orderType")];
            $priceCrit = $PRICECRITERIA[getConfig("priceCriteria")];
            for ($i = 0; $i <= $itemListDB->numRows(); $i++) {
                $itemInfo = $itemListDB->fetchRow();
                $quoteAge = $CURRENTTIME - $itemInfo['updateTime'];
                if ($quoteAge >= 3600) {
                    $currentPrice = getMarketPrice($itemInfo['itemID'], $orderType, $priceCrit);
                    $DB->query("UPDATE itemList SET `updateTime` = {$CURRENTTIME}, `value` = {$currentPrice} WHERE `itemID` = " . $itemInfo['itemID']);
                }
            }
        } else {
            if ($Market == "eve-marketdata") {
            } else {
                if ($Market == "eve-marketeer") {
                    $regionID = getConfig("useRegion");
                    $url = "http://www.evemarketeer.com/api/info/{$itemID}/xml/{$regionID}/buy_highest5";
                    $xml = getXMLobj($url);
                    echo $xml[row][buy_highest5];
                }
            }
        }
    } else {
        // load the values.
        $orevaluesDS = $DB->query("select a.item, a.Worth, a.time, a.modifier from orevalues a where time = (select max(time) from orevalues b where a.item = b.item) group by item ORDER BY time DESC");
        while ($row = $orevaluesDS->fetchRow()) {
            $orevalues[$row[item]] = $row;
        }
    }
    if ($Market) {
        $headerText = ">> Manage ore values<br><font color=\"#ff0000\"><b>Ore values are current market values.</b></font>";
    } else {
        $headerText = ">> Manage ore values";
    }
    // Create the table.
    $table = new table(8, true);
    $table->addHeader($headerText, array("bold" => true, "colspan" => 8));
    $OPTYPE = isset($_REQUEST[optype]) ? $_REQUEST[optype] : "";
    $table->addRow();
    $table->addCol("Op Type:");
    $ops = $DB->getAll("select opName from opTypes;");
    if ($DB->isError($ops)) {
        die($ops->getMessage());
    }
    $opSelect = "<select name='optype' onChange='window.location = \"?action=changeow&optype=\"+this.value'>\n";
    $opSelect .= "<option value=''>Standard</option>\n";
    foreach ($ops as $op) {
        $default = $op[opName] == $OPTYPE ? "selected" : "";
        $opSelect .= "<option {$default} value='" . $op[opName] . "'>" . $op[opName] . "</option>\n";
    }
    $opSelect .= "</select>";
    $table->addCol($opSelect, array("colspan" => 7));
    $table->addRow();
    $table->addCol("Ore Name", array("colspan" => 2, "bold" => true));
    $table->addCol("Enabled", array("bold" => true));
    $table->addCol("Value", array("bold" => true));
    $table->addCol("Ore Name", array("colspan" => 2, "bold" => true));
    $table->addCol("Enabled", array("bold" => true));
    $table->addCol("Value", array("bold" => true));
    // How many ores are there in total? Ie, how long has the table to be?
    $tableLength = ceil(count($ORENAMES) / 2) - 1;
    for ($i = 0; $i <= $tableLength; $i++) {
        $right = 0;
        $table->addRow();
        for ($side = 0; $side <= 1; $side++) {
            $ORE = $ORENAMES[$i + ($tableLength + 1) * $side];
            // Fetch the right image for the ore.
            $ri_words = str_word_count($ORE, 1);
            $ri_max = count($ri_words);
            $ri = strtolower($ri_words[$ri_max - 1]);
            if ($ORE != "") {
                $table->addCol("<img width=\"32\" height=\"32\" src=\"./images/ores/" . $ORE . ".png\">");
                $table->addCol($ORE);
                if (getOreSettings($DBORE[$ORE], $OPTYPE)) {
                    $table->addCol("<input name=\"" . $DBORE[$ORE] . "Enabled\" value=\"true\" type=\"checkbox\" checked=\"checked\">");
                } else {
                    $table->addCol("<input name=\"" . $DBORE[$ORE] . "Enabled\" value=\"true\" type=\"checkbox\">");
                }
                if ($Market == 1) {
                    $thisPrice = getPriceCache($ORE);
                    $table->addCol("<input type=\"text\" style=\"text-align: right\" name=\"{$DBORE[$ORE]}\"" . "size=\"10\" value=\"" . $thisPrice . "\">");
                } else {
                    $table->addCol("<input type=\"text\" style=\"text-align: right\" name=\"{$DBORE[$ORE]}\"" . "size=\"10\" value=\"" . $orevalues[$DBORE[$ORE]][Worth] . "\">");
                }
            } else {
                $table->addCol("");
                $table->addCol("");
                $table->addCol("");
                $table->addCol("");
            }
        }
    }
    $form .= "<input type=\"hidden\" name=\"action\" value=\"changeore\">";
    $form .= "<input type=\"hidden\" name=\"check\" value=\"check\">";
    $form .= "<input type=\"hidden\" name=\"optype\" value=\"{$OPTYPE}\">";
    $form .= "<input type=\"submit\" name=\"change\" value=\"Modify ore settings\">";
    $table->addHeaderCentered($form, array("colspan" => 8, "align" => "center"));
    // return the page
    return "<h2>Modify ore settings</h2><form action=\"index.php\"method=\"post\">" . $table->flush();
}
コード例 #30
0
ファイル: lotto_buyTickets.php プロジェクト: nuxi/MiningBuddy
function lotto_buyTickets()
{
    // Set some needed variables.
    global $DB;
    global $MySelf;
    $ID = $MySelf->getID();
    $myMoney = getCredits($ID);
    $affordable = floor($myMoney / 1000000);
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Get my credits
    $MyStuff = $DB->getRow("SELECT lottoCredit, lottoCreditsSpent FROM users WHERE id='" . $MySelf->getID() . "'");
    $Credits = $MyStuff[lottoCredit];
    $CreditsSpent = $MyStuff[lottoCreditsSpent];
    // User submited this form already!
    if ($_POST[check]) {
        numericCheck($_POST[amount], 0, $affordable);
        if ($_POST[amount] == 0) {
            makeNotice("You cannot buy zero tickets.", "warning", "Too few tickets.", "index.php?action=lotto", "[whoops]");
        }
        confirm("Please authorize the transaction of " . number_format($_POST[amount] * 1000000, 2) . " ISK in order to buy {$_POST['amount']} lotto credits.");
        // Get the old ticket count, and add the new tickets on top of those.
        $oldCount = $DB->getCol("SELECT lottoCredit FROM users WHERE id='{$ID}' LIMIT 1");
        $newcount = $oldCount[0] + $_POST[amount];
        // Update the database to reflect the new ticket count.
        $check = $DB->query("UPDATE users SET lottoCredit='{$newcount}' WHERE id='{$ID}' LIMIT 1");
        // Check that we were successful.
        if ($DB->affectedRows() != 1) {
            makeNotice("I was unable to add {$newcount} tickets to {$user} stack of {$count} tickets! Danger will robonson, danger!", "error", "Unable to comply.");
        }
        // Make him pay!
        global $TIMEMARK;
        $transaction = new transaction($ID, 1, $_POST[amount] * 1000000);
        $transaction->setReason("lotto credits bought");
        if ($transaction->commit()) {
            // all worked out!
            makeNotice("Your account has been charged the amount of " . number_format($_POST[amount] * 1000000, 2) . " ISK.", "notice", "Credits bought", "index.php?action=lotto", "[OK]");
        } else {
            // We were not successfull
            makeNotice("I was unable to add {$newcount} tickets to {$user} stack of {$count} tickets! Danger will robonson, danger!", "error", "Unable to comply.");
        }
    }
    // Prepare the drop-down menu.
    if ($affordable >= 1) {
        $ddm = "<select name=\"amount\">";
        for ($i = 1; $i <= $affordable; $i++) {
            if ($i == 1) {
                $ddm .= "<option value=\"{$i}\">Buy {$i} tickets</option>";
            } else {
                $ddm .= "<option value=\"{$i}\">Buy {$i} tickets</option>";
            }
        }
        $ddm .= "</select>";
    } else {
        // Poor user.
        $ddm = "You can not afford any credits.";
    }
    // Create the table.
    $table = new table(2, true);
    $table->addHeader(">> Buy lotto credits");
    $table->addRow();
    $table->addCol("Here you can buy lotto tickets for 1.000.000,00 ISK each. " . "Your account currently holds " . number_format($myMoney, 2) . " ISK, so " . "you can afford {$affordable} tickets. Please choose the amount of credits you wish " . "to buy.", array("colspan" => 2));
    $table->addRow();
    $table->addCol("Your credits:");
    $table->addCol($Credits);
    $table->addRow();
    $table->addCol("Total spent credits:");
    $table->addCol($CreditsSpent);
    $table->addRow();
    $table->addCol("Purchase this many credits:");
    $table->addCol($ddm);
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" value=\"Buy credits\">");
    $table->addRow("#060622");
    $table->addCol("[<a href=\"index.php?action=lotto\">Cancel request</a>]", array("colspan" => 2));
    // Add some more html form stuff.
    $html = "<h2>Buy Lotto credits</h2>";
    $html .= "<form action=\"index.php\" method=\"POST\">";
    $html .= $table->flush();
    $html .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $html .= "<input type=\"hidden\" name=\"action\" value=\"lottoBuyCredits\">";
    $html .= "</form>";
    // Return the mess we made.
    return $html;
}