예제 #1
0
function toggleLogin()
{
    global $DB;
    global $MySelf;
    global $IS_DEMO;
    if ($IS_DEMO) {
        makeNotice("The user would have been changed. (Operation canceled due to demo site restrictions.)", "notice", "Password change confirmed");
    }
    // Are we allowed to Manage Users?
    if (!$MySelf->canManageUser()) {
        makeNotice("You are not allowed to edit Users!", "error", "forbidden");
    }
    if ($MySelf->getID() == $_GET[id]) {
        makeNotice("You are not allowed to block yourself!", "error", "forbidden");
    }
    // Wash ID.
    numericCheck($_GET[id]);
    $ID = sanitize($_GET[id]);
    // update login capability.
    $DB->query("UPDATE users SET canLogin=1 XOR canLogin WHERE id='" . $ID . "' LIMIT 1");
    $username = idToUsername("{$ID}");
    $p = substr($username, 0, 1);
    // Return.
    header("Location: index.php?action=editusers&l={$p}");
}
예제 #2
0
function deleteAPIKey()
{
    global $MySelf;
    global $DB;
    if ($MySelf->canManageUser()) {
        numericCheck($_GET[id]);
        $api = new api($_GET[id]);
        $api->deleteApiKey();
        makeNotice("Api key for user " . ucfirst(idToUsername($_GET[id])) . " has been deleted from the database", "notice", "API deleted.", "index.php?action=edituser&id=" . $_GET[id], "[OK]");
    }
    makeNotice("You do not have permission to modify users.", "warning", "Access denied.");
}
예제 #3
0
function createTransaction()
{
    // We need globals.
    global $DB;
    global $MySelf;
    global $TIMEMARK;
    // Are we allowed to poke in here?
    if (!$MySelf->isAccountant()) {
        makeNotice("Umm, you are not allowed to do this. Really. You are not.", "warning", "You are not supposed to be here");
    }
    // Check the ints.
    numericCheck($_POST[wod], 0, 1);
    numericCheck($_POST[amount], 0);
    numericCheck($_POST[id], 0);
    // Its easier on the eyes.
    $type = $_POST[wod];
    $amount = $_POST[amount];
    $id = $_POST[id];
    $username = idToUsername($id);
    // invert the amount if we have a withdrawal.
    if ($_POST[wod] == 1) {
        $dir = "withdrawed";
        $dir2 = "from";
        $hisMoney = getCredits($id);
        if ($hisMoney < $amount) {
            $ayee = $hisMoney - $amount;
            confirm("WARNING:<br>{$username} can NOT afford this withdrawal. If you choose to " . "authorize this transaction anyway his account will be at " . number_format($ayee, 2) . " ISK.");
        }
    } else {
        $amount = $_POST[amount];
        $dir = "deposited";
        $dir2 = "into";
    }
    // We use custom reason, if set.
    if ($_POST[reason2] != "") {
        $reason = sanitize($_POST[reason2]);
    } else {
        $reason = sanitize($_POST[reason1]);
    }
    // Create transaction.
    $transaction = new transaction($id, $type, $amount);
    $transaction->setReason($reason);
    // Success?
    if (!$transaction->commit()) {
        // Nope :(
        makeNotice("Unable to create transaction. Danger, Will Robinson, DANGER!", "error", "Internal Error", "index.php?action=edituser&id={$id}", "[Back]");
    } else {
        // Success !
        makeNotice("You successfully {$dir} {$amount} ISK {$dir2} " . $username . "'s account.", "notice", "Transaction complete", "index.php?action=edituser&id={$id}", "[Ok]");
    }
}
예제 #4
0
파일: popCan.php 프로젝트: nuxi/MiningBuddy
function popCan()
{
    // We need the globals, as always,
    global $DB;
    global $MySelf;
    $UserID = $MySelf->getID();
    // Is the ID sane?
    if ($_GET[id] != "all") {
        if (empty($_GET[id]) || !is_numeric($_GET[id]) || $_GET[id] < 1) {
            makeNotice("Invalid container selected for popping!", "error");
        } else {
            $LIMIT = " AND id='{$_GET['id']}' LIMIT 1";
        }
    } else {
        confirm("Are you sure you want to pop all your cans?");
    }
    // Delete the can from the list.
    $DB->query("DELETE FROM cans WHERE pilot='{$UserID}' {$LIMIT}");
    // And tell the user what happened.
    $canspopped = $DB->affectedRows();
    // Do we want to go back to the run or the canpage?
    if (isset($_GET[runid])) {
        $bl = "index.php?action=show&id=" . $_GET[runid];
    } else {
        $bl = "index.php?action=cans";
    }
    if ($canspopped == 1) {
        // ONE can has been popped.
        makeNotice("The can has been popped.", "notice", "POP!", $bl, "That was fun!");
    } elseif ($canspopped > 1) {
        // TWO OR MORE cans have been popped.
        makeNotice("{$canspopped} cans have been popped.", "notice", "POP!", $bl, "That was fun!");
    } else {
        // ZERO OR LESS cans have been popped.
        $col = $DB->getRow("SELECT id, pilot FROM cans WHERE id='{$_GET['id']}'");
        if (userInRun($MySelf->getID(), $col[id])) {
            $DB->query("DELETE FROM cans WHERE id='{$col['id']}' LIMIT 1");
            if ($DB->affectedRows() == 1) {
                makeNotice("You just popped a can belonging to " . idToUsername($col[pilot]) . ".", "notice", "POP!", $bl, "That was fun!");
            } else {
                makeNotice("The can could not be popped!", "error", "Internal Error", $bl, "[cancel]");
            }
        } else {
            makeNotice("The can could not be popped!", "error", "Internal Error", $bl, "[cancel]");
        }
    }
}
예제 #5
0
function runSupervisor($id, $capped = false)
{
    // ID valid?
    numericCheck($id, 0);
    //	if (!numericCheck($id, 0)) {
    //		makeNotice("Internal Error: Invalid RUN selected for runSupervisor.");
    //	}
    // Query the database.
    global $DB;
    $DS = $DB->getCol("SELECT supervisor FROM runs WHERE id='{$id}'");
    // Return the supervisor.
    if ($capped) {
        return ucfirst(idToUsername($DS[0]));
    } else {
        return idToUsername($DS[0]);
    }
}
예제 #6
0
function transferMoney()
{
    // Globals
    global $MySelf;
    global $DB;
    global $TIMEMARK;
    $MyCredits = getCredits($MySelf->getID());
    // Can we afford even the most basic transactions?
    if (!numericCheckBool($MyCredits, 0)) {
        makeNotice("You can not afford any transaction.", "warning", "Out of money", "index.php?action=manageWallet", "[cancel]");
    }
    // Did we supply an isk amount at all?
    if ($_POST[amount] == "") {
        makeNotice("You did not specify an ISK amount. Please go back, and try again.", "warning", "How much?", "index.php?action=manageWallet", "[cancel]");
    }
    if (!is_numeric($_POST[amount])) {
        makeNotice("The frog looks at you and your cheque with the amount of \"" . $_POST[amount] . "\". The frog is unsure how much ISK that is and instead decides to lick your face in a friendly manner, then it closes the teller and goes for lunch.", "warning", "Huh?");
    }
    // Check for sanity.
    if (!numericCheckBool($_POST[to], 0)) {
        makeNotice("The supplied reciver is not valid.", "warning", "Invalid ID", "index.php?action=manageWallet", "[cancel]");
    }
    if (!numericCheckBool($_POST[amount], 0)) {
        makeNotice("You need to specify a positive ISK value.", "error", "Invalid amount", "index.php?action=manageWallet", "[cancel]");
    }
    if (!numericCheckBool($_POST[amount], 0, $MyCredits)) {
        makeNotice("You can not afford this transaction.", "warning", "Out of money", "index.php?action=manageWallet", "[cancel]");
    }
    // Ok so now we know: The reciver is valid, the sender has enough money.
    $from = "<br><br>From: " . ucfirst($MySelf->getUsername());
    $to = "<br>To: " . ucfirst(idToUsername($_POST[to]));
    $amount = "<br>Amount: " . number_format($_POST[amount], 2) . " ISK";
    $reason = "<br>Reason: " . $_POST[reason];
    confirm("Please authorize this transaction:" . $from . $to . $amount . $reason);
    // Lets do it.
    $transaction = new transaction($_POST[to], 0, $_POST[amount]);
    $transaction->setReason("Cash transfer from " . ucfirst($MySelf->getUsername()) . " to " . ucfirst(idToUsername($_POST[to])) . ": " . $_POST[reason]);
    $transaction->isTransfer(true);
    $transaction->commit();
    // Send'em back.
    makeNotice($amount . " has been transfered from your into " . ucfirst(idToUsername($_POST[to])) . " account.", "notice", "Cash transfered", "index.php?action=manageWallet", "[OK]");
}
예제 #7
0
function showTransactions()
{
    // Global Fun!
    global $DB;
    global $MySelf;
    // Are we allowed to do this?
    if (!$MySelf->isAccountant()) {
        makeNotice("You are not an accountant to your corporation. Access denied.", "error", "Access denied");
    }
    if (isset($_GET['auth'])) {
        $auth = true;
    } else {
        $auth = false;
    }
    // Sanity check.
    numericCheck($_GET['id'], 0);
    $username = idToUsername($_GET['id']);
    $id = $_GET['id'];
    // Load the transaction log.
    $account = $auth ? "'s TEST Auth" : "";
    $page = "<h2>Transaction log for " . ucfirst($username) . "{$account}</h2>";
    $users = $DB->query("select id, username from users where ((authID in (select authID from users where id = '{$id}') and '{$auth}' = 1) or id = '{$id}')");
    while ($user = $users->fetchRow()) {
        $userid = $user['id'];
        $username = $user['username'];
        $trans = getTransactions($userid);
        if (!$trans) {
            $page .= "<b>There are no transactions for {$username}.</b>";
        } else {
            $page .= $trans;
        }
        $page .= "<br>";
    }
    // Add the backlink.
    $page .= "<br><a href=\"index.php?action=payout\">Back to Payouts</a>";
    // Return the page.
    return $page;
}
예제 #8
0
function makeEmailReceipt($runid, $array)
{
    // Set variables.
    global $DB;
    global $DBORE;
    global $ORENAMES;
    global $MB_EMAIL;
    //Edit Starts Here
    global $DBSHIP;
    global $SHIPNAMES;
    //Edit Ends Here
    global $VERSION;
    global $URL;
    // Load the run
    $RUN = $DB->query("SELECT * FROM runs WHERE id='{$runid}' LIMIT 2");
    if ($RUN->numRows() != 1) {
        // This run does not exist!
        return;
    } else {
        $RUN = $RUN->fetchRow();
    }
    // Load the ore values
    $oreValues = $DB->query("SELECT * FROM orevalues WHERE id='" . $RUN[oreGlue] . "' LIMIT 1");
    $oreValues = $oreValues->fetchRow();
    //Edit Starts Here
    // Load the ship values
    $shipValues = $DB->query("SELECT * FROM shipvalues WHERE id='" . $RUN[shipGlue] . "' LIMIT 1");
    $shipValues = $shipValues->fetchRow();
    //Edit Ends Here
    // Get total number of people who joined.
    $totalPeople = $DB->getCol("SELECT count(DISTINCT userid) FROM joinups WHERE run='{$runid}'");
    $totalPeople = $totalPeople[0];
    /*
     * Taxes, net value etc
     */
    $grossValue = getTotalWorth($runid);
    $corpTax = $DB->getCol("SELECT corpkeeps FROM runs WHERE id='{$runid}' LIMIT 1");
    $corpTax = $corpTax[0];
    $taxes = $grossValue * $corpTax / 100;
    $netValue = $grossValue - $taxes;
    $myShareGross = $grossValue / $totalPeople;
    // No ores mined. Bye-bye.
    if ($grossValue < 1) {
        return;
    }
    /*
     * Get the longest name of the ores.
     */
    foreach ($ORENAMES as $howlong) {
        $length = strlen($howlong);
        if ($length > $winner) {
            $winner = $length;
        }
    }
    /*
     * Get all the ores.
     */
    foreach ($DBORE as $ORE) {
        if ($RUN[$ORE] > 0) {
            $oreType = str_pad(array_search($ORE, $DBORE), $winner, " ");
            $oreAmount = str_pad(number_format($RUN[$ORE]), 11, " ");
            $ppu = $oreValues[$ORE . "Worth"];
            $oreValue = str_pad(number_format($ppu) . " ISK", 11, " ");
            $remainder = 70 - (strlen($oreType) + strlen($oreAmount) + strlen($oreValue));
            $oreTotalValue = str_pad(number_format($ppu * $RUN[$ORE]) . " ISK", $remainder, " ", STR_PAD_LEFT);
            $l1 = strlen($oreAmount);
            $l1 = strlen($oreValue);
            $l1 = strlen($oreTotalValue);
            if ($OreLine) {
                $OreLine .= "\n";
            }
            $OreLine .= $oreType . $oreAmount . $oreValue . $oreTotalValue;
        }
    }
    /*
     * Replace the placeholders
     */
    $email = new email("receipt");
    $temp = $email->getTemplate();
    $temp = str_replace("{{ID}}", str_pad($runid, 5, "0", STR_PAD_LEFT), $temp);
    $temp = str_replace("{{ORESMINED}}", $OreLine, $temp);
    $temp = str_replace("{{VALUE}}", number_format($grossValue) . " ISK", $temp);
    $temp = str_replace("{{CORPTAXES}}", number_format($taxes) . " ISK", $temp);
    $temp = str_replace("{{NETVALUE}}", number_format($netValue) . " ISK", $temp);
    $temp = str_replace("{{GROSSSHARE}}", number_format($myShareGross) . " ISK", $temp);
    $template = $temp;
    /*
     * This ends the part thats generic for everyone. Now the personalized stuff.
     */
    $Atendees = $DB->query("SELECT DISTINCT userid FROM joinups WHERE run='{$runid}'");
    while ($atendee = $Atendees->fetchRow()) {
        // Reset the email back to the template.
        $temp = $template;
        /*
         * PROBLEM
         * 
         * Template is changed in email class, further modding in this loop
         * would require rewrite of either email class or this function.
         * 
         */
        die("PROBLEM");
        // Do some personalized stuff.
        $pilot = idToUsername($atendee[userid]);
        $temp = str_replace("{{USERNAME}}", ucfirst($pilot), $temp);
        $temp = str_replace("{{ACCOUNTBALANCE}}", str_pad("BALANCE: " . number_format(getCredits($atendee[userid])), 66, " ", STR_PAD_LEFT) . " ISK", $temp);
        $myShare = $array[$atendee[userid]];
        $temp = str_replace("{{NETSHARE}}", number_format($myShare) . " ISK", $temp);
        /*
         * transactions
         */
        $transactions = $DB->query("SELECT * FROM transactions WHERE owner ='{$atendee['userid']}' ORDER BY id DESC LIMIT 10");
        if ($transactions->numRows() > 0) {
            while ($trans = $transactions->fetchRow()) {
                // time type amount reason
                $transLine .= date("m.d.y h:i:", $trans[time]);
                if ($trans[type]) {
                    $transLine .= " [W]";
                } else {
                    $transLine .= " [D]";
                }
                $transLine .= " \"" . substr($trans[reason], 0, 33) . "\"";
                $length = strlen($transLine);
                $remainder = 70 - $length;
                $transLine .= str_pad(number_format($trans[amount]) . " ISK", $remainder, " ", STR_PAD_LEFT);
                // Add the line to the block.
                if ($transBlock) {
                    $transBlock .= "\n";
                }
                $transBlock .= $transLine;
                unset($transLine);
            }
        } else {
            $transLine = "No recent transactions.";
        }
        $temp = str_replace("{{ACCOUNT}}", $transBlock, $temp);
        // Mail, if opt-in.
        $userInfo = $DB->query("SELECT username, id, optIn, email FROM users WHERE id='" . $atendee[userid] . "' AND deleted='0'");
        $userInfo = $userInfo->fetchRow();
        if ($userInfo[email] && $userInfo[optIn]) {
            $to = $userInfo[email];
            $subject = "MiningBuddy Payout";
            $message = $email;
            $DOMAIN = $_SERVER['HTTP_HOST'];
            $headers = "From:" . $MB_EMAIL;
            mail($to, $subject, $message, $headers);
        }
    }
}
예제 #9
0
파일: kick.php 프로젝트: nuxi/MiningBuddy
function kick()
{
    // Set some vars.
    $joinID = $_GET[joinid];
    $state = $_GET[state];
    numericCheck($joinID, 0);
    numericCheck($state, 0, 3);
    global $DB;
    global $MySelf;
    global $TIMEMARK;
    // Get the RunID.
    $runID = $DB->getCol("SELECT run, joined FROM joinups WHERE id='{$joinID}' LIMIT 1");
    $runID = $runID[0];
    // Are we allowed to kick/ Ban?
    if (runSupervisor($runID) != $MySelf->getUsername() && !$MySelf->isOfficial()) {
        makeNotice("You are not allowed to kick/ban/remove people from a run. Only the run supervisor or a corporation official is allowed to do that.", "warning", "Not allowed");
    }
    // get the userid (to be kicked)
    $kicked = $DB->getCol("SELECT userid FROM joinups WHERE id='{$joinID}' LIMIT 1");
    $kicked = $kicked[0];
    // We cant kick ourselves.
    if ($kicked == $MySelf->getID()) {
        makeNotice("You can not remove, kick or ban yourself. Get someone else to do the job for you.", "notice", "Can not comply");
    }
    // get confirmations.
    switch ($state) {
        case "1":
            confirm("Are you sure you want to remove " . ucfirst(idToUsername($kicked)) . "?<br>" . "By removing the user he or she retains all shares of his ISK and is honorably discharged from this operation.");
            break;
        case "2":
            confirm("Are you sure you want to kick " . ucfirst(idToUsername($kicked)) . "?<br>" . "By kicking the user he or she loses all shares of his ISK and is dishonorably discharged from this operation.");
            break;
        case "3":
            confirm("Are you sure you want to ban " . ucfirst(idToUsername($kicked)) . "?<br>" . "By banning the user he or she loses all shares of his ISK and is dishonorably discharged from this operation and additionally the user can never rejoin his operation.");
            break;
    }
    /* 
     * Logic bomb work-around
     * If a user joins an op before it starts, and the leaves during the operation
     * he will receive huge bonuses while all the others will get negative amounts.
     * So we have to...
     * 
     * 1. Check if the op has started yet (current time < operation start)
     *  If "no" then we are not affected by the logic bomb.
     *  
     *  If "yes" then we need to set the kicktime AND the jointime to the current time.
     *  Why? If we just set the kicktime to the jointime then the "kicked at" time will
     *  always show the time of the op launch, never the real kick time. Also, the
     *  duration is always zero seconds, so the user will never receive any share from
     *  this run.
     */
    if ($TIMEMARK < $kicked[joined]) {
        $partedTime = $kicked[joined];
    } else {
        $partedTime = $TIMEMARK;
    }
    // Now lets handle kicks, bans and removals.
    $DB->query("update joinups set remover = '" . $MySelf->getID() . "' where run = '{$runID}' and userid = '{$kicked}' and parted IS NULL");
    $DB->query("update joinups set status = '{$state}' where run = '{$runID}' and userid = '{$kicked}' and parted IS NULL");
    $DB->query("update joinups set parted = '{$partedTime}' where run = '{$runID}' and userid = '{$kicked}' and parted IS NULL");
    // Thats it, for now.
    header("Location: index.php?action=show&id={$runID}");
}
예제 #10
0
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>";
}
예제 #11
0
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;
}
예제 #12
0
 $secsleft = str_pad($timeleft % 60, "2", "0", STR_PAD_LEFT);
 $poptime = $candroptime + $TTL;
 if ($secsleft < 1) {
     $secsleft = "00";
 }
 if ($minsleft >= 30) {
     $color = "#88ff88";
 } elseif ($minsleft < 29 && $minsleft >= 15) {
     $color = "#FFFF00";
 } elseif ($minsleft < 15) {
     $color = "#FF0000";
 }
 // Add the information to the table.
 $can_information->addRow();
 $can_information->addCol($can[name]);
 $can_information->addCol(ucfirst(idToUsername($can[pilot])));
 $system = new solarSystem($can[location]);
 $can_information->addCol(ucfirst($system->makeFancyLink()));
 $can_information->addCol(date("H:i:s", $can[droptime]));
 $can_information->addCol(date("H:i:s", $poptime));
 // Can popped already?
 if ($minsleft > 0) {
     $can_information->addCol("<font color=\"{$color}\">" . $minsleft . ":" . $secsleft . "</font>");
 } else {
     $can_information->addCol("<font color=\"{$color}\">POPPED</font>");
 }
 // Can full?
 if ($can[isFull]) {
     $can_information->addCol("<font color=\"#00ff00\">YES</font>");
 } else {
     $can_information->addCol("No");
예제 #13
0
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;
}
예제 #14
0
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;
}
예제 #15
0
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
// Calculate Payout:
$joinedPeople = $DB->query("SELECT DISTINCT userid FROM joinups WHERE run ='{$ID}' AND status < '2'");
$ISK = getTotalWorth($ID, true);
if ($ISK != 0) {
    $payout_info = new table(3, true);
    $payout_info->addHeader(">> Payout Information");
    $payout_info->addRow("060622");
    $payout_info->addCol("Pilot", array("bold" => true));
    $payout_info->addCol("Percent of Net", array("bold" => true));
    $payout_info->addCol("Payout", array("bold" => true));
    // get the payout array. Fun guaranteed.
    while ($peep = $joinedPeople->fetchRow()) {
        $payoutArray[idToUsername($peep[userid])] = calcPayoutPercent($ID, $peep[userid]);
    }
    // Calulate the percent-modifier.
    $percentModifier = 100 / array_sum($payoutArray);
    // Apply the modifier to the percentage.
    $names = array_keys($payoutArray);
    foreach ($names as $name) {
        $percent = $payoutArray[$name] * $percentModifier;
        $payout = $ISK / 100 * $percent;
        $payout_info->addRow();
        $payout_info->addCol(makeProfileLink(usernameToID($name)));
        $payout_info->addCol(number_format($percent, 2) . "%");
        if ($MySelf->isAccountant()) {
            $payout_info->addCol("<a href=\"index.php?action=showTransactions&id=" . usernameToID($name) . "\">" . number_format($payout, 2) . " ISK</a>");
        } else {
            $payout_info->addCol(number_format($payout, 2) . " ISK");
예제 #16
0
function getLogins($user)
{
    // Sanity
    global $DB;
    global $MySelf;
    numericCheck($user, 0);
    if (isset($_GET['loginPage'])) {
        numericCheck($_GET['loginPage']);
    }
    // ask the oracle.
    $logins = $DB->getCol("SELECT COUNT(authkey) as count FROM auth WHERE user='******'");
    $logins_count = $logins[0];
    $logins_pages = ceil($logins_count / 20);
    // No transactions yet.
    if ($logins_count < 1) {
        return false;
    }
    $currentPage = $_GET['loginPage'];
    // 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
    // Show all logins.
    $loginDS = $DB->query("SELECT * from auth where user = '******' ORDER BY issued DESC LIMIT {$min},20");
    $login_table = new table(3, true);
    $login_table->addHeader(">> " . ucfirst(idToUsername($user)) . "'s recent logins");
    $login_table->addRow("#060622");
    $login_table->addCol("Time / Date", array("bold" => true));
    $login_table->addCol("From IP", array("bold" => true));
    $login_table->addCol("Useragent", array("bold" => true));
    // Create a row for each login.
    while ($row = $loginDS->fetchRow()) {
        $login_table->addRow();
        $login_table->addCol(date("d.m.y H:i", $row['issued']));
        $login_table->addCol($row['ip']);
        $login_table->addCol(substr($row['agent'], 0, 60) . "...");
        $haveLogins = true;
    }
    // if we have more than 1 page, show the navbar.
    if ($logins_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 ($logins_pages > $currentPage) {
                $next = $currentPage + 1;
            }
            // All pages above 2 have a previous page.
            $prev = $currentPage - 1;
        }
        $login_table->addRow("#060622");
        // Show backlink, unless we are at page 1.
        if ($prev) {
            // We have a previous page (at page > 1)
            $login_table->addCol("<a href=\"index.php?action={$_GET['action']}&id={$_GET['id']}&loginPage={$prev}\">prev</a>", array("align" => "left", "width" => "20%"));
        } else {
            // No previos page (at page 1);
            $login_table->addCol(" ", array("width" => "20%"));
        }
        // Empty cell, where direct links used to be.
        $login_table->addCol(" ");
        // Next link
        if ($currentPage < $logins_pages) {
            // We have a next page. (at page < n)
            $login_table->addCol("<a href=\"index.php?action={$_GET['action']}&id={$_GET['id']}&loginPage={$next}\">next</a>", array("align" => "right"));
        } else {
            // This was the last page. (at page n)
            $login_table->addCol(" ");
        }
        // Show direct page links.
        if ($logins_pages > 1) {
            for ($i = 1; $i <= $logins_pages; $i++) {
                if ($currentPage == $i) {
                    $text .= "[{$i}]";
                } else {
                    $action = isset($_GET['action']) ? $_GET['action'] : "";
                    $id = isset($_GET['id']) ? $_GET['id'] : "";
                    $text .= "[<a href=\"index.php?action={$action}&id={$id}&loginPage={$i}\">{$i}</a>] ";
                }
            }
            $login_table->addRow("#060622");
            $login_table->addCol($text, array("colspan" => "3", "align" => "center"));
        }
    }
    // Return the html table.
    return $login_table->flush();
}
예제 #17
0
function onlineTime()
{
    // We need funky globals!
    global $DB;
    global $MySelf;
    global $TIMEMARK;
    /*
     * The change form.
     */
    $MySetting = $DB->query("SELECT * FROM onlinetime WHERE userid='" . $MySelf->getID() . "'");
    $MySetting = $MySetting->numRows();
    if ($MySetting == 0 || $_GET[edit]) {
        $setTable = new table(3, true);
        $setTable->addHeader(">> Set your online time");
        // Fetch el grande saved array. Ole!
        $myOnlineTime = $DB->getAssoc("SELECT * FROM onlinetime WHERE userid='" . $MySelf->getID() . "' LIMIT 1");
        $myOnlineTime = $myOnlineTime[$MySelf->getID()];
        // Loop through the hours.
        $j = 0;
        for ($i = 0; $i <= 23; $i++) {
            // Add a new row every 3rd time we are here, startign with first.
            if ($j == 0) {
                $setTable->addRow();
                $j = 3;
            }
            // 01-02, 02-03.. etc
            $p = str_pad($i, 2, "0", STR_PAD_LEFT) . "-" . str_pad($i + 1, 2, "0", STR_PAD_LEFT);
            // Wow this is ugly. Pre-select all values that are stored in the db.
            $ppdv0 = "<option value=\"0\">0</option>";
            $ppdv1 = "<option value=\"1\">1</option>";
            $ppdv2 = "<option value=\"2\">2</option>";
            $ppdv3 = "<option value=\"3\">3</option>";
            $column = "h" . str_pad($i, 2, "0", STR_PAD_LEFT);
            switch ($myOnlineTime[$column]) {
                case "0":
                    $ppdv0 = "<option selected value=\"0\">0</option>";
                    break;
                case "01":
                    $ppdv1 = "<option selected value=\"1\">1</option>";
                    break;
                case "2":
                    $ppdv2 = "<option selected value=\"2\">2</option>";
                    break;
                case "3":
                    $ppdv3 = "<option selected value=\"3\">3</option>";
                    break;
            }
            $ppd = $ppdv0 . $ppdv1 . $ppdv2 . $ppdv3;
            $s = "<select name=\"{$i}\">";
            $setTable->addCol($p . $s . $ppd . "</select>");
            // Substract one.
            $j--;
        }
        // explain:
        $setTable->addRow();
        $setTable->addCol("Code 0: You cant play at all. (sleep, work)", array("colspan" => 3));
        $setTable->addRow();
        $setTable->addCol("Code 1: You could, but normaly wouldnt, except for extreme cases.", array("colspan" => 3));
        $setTable->addRow();
        $setTable->addCol("Code 2: You can easily be online, but normaly are not.", array("colspan" => 3));
        $setTable->addRow();
        $setTable->addCol("Code 3: Your preffered online time.", array("colspan" => 3));
        $submitbutton = "<input type=\"hidden\" name=\"check\" value=\"true\">" . "<input type=\"hidden\" value=\"modonlinetime\" name=\"action\">" . "<input type=\"submit\" value=\"Update your OnlineTime\" name=\"submit\">";
        $setTable->addHeaderCentered("All times are EvE time!");
        $setTable->addHeaderCentered($submitbutton);
        $form .= "<form action=\"index.php\" method=\"POST\">";
        $form .= $setTable->flush();
        $form .= "</form>";
    } else {
        $editLink = "<br>[<a href=\"index.php?action=onlinetime&edit=true\">Edit your times</a>]";
    }
    $page = "<h2>Online Time</h2>" . $form;
    /*
     * Okay pheew. That was the table to set your own time. Now lets create
     * a table to show everyones online time.
     */
    $onlineTime = new table(25, true);
    $onlineTime->addHeader(">> Online Time of your corporation");
    $onlineTime->addRow("#060622");
    $onlineTime->addCol("Member");
    $onlineTime->addCol("00");
    $onlineTime->addCol("01");
    $onlineTime->addCol("02");
    $onlineTime->addCol("03");
    $onlineTime->addCol("04");
    $onlineTime->addCol("05");
    $onlineTime->addCol("06");
    $onlineTime->addCol("07");
    $onlineTime->addCol("08");
    $onlineTime->addCol("09");
    $onlineTime->addCol("10");
    $onlineTime->addCol("11");
    $onlineTime->addCol("12");
    $onlineTime->addCol("13");
    $onlineTime->addCol("14");
    $onlineTime->addCol("15");
    $onlineTime->addCol("16");
    $onlineTime->addCol("17");
    $onlineTime->addCol("18");
    $onlineTime->addCol("19");
    $onlineTime->addCol("20");
    $onlineTime->addCol("21");
    $onlineTime->addCol("22");
    $onlineTime->addCol("23");
    // Ask the oracle.
    $cutOff = $TIMEMARK - 2592000;
    // 30 days.
    $OT = $DB->getCol("select distinct id from users where canLogin='******' and lastlogin >= '{$cutOff}'  AND deleted='0'");
    // Pilots names are not store in the onlinetable. So we have to translate.
    foreach ($OT as $pilotID) {
        $pilots[] = idToUsername($pilotID);
    }
    // Anyone published his online time yet?
    if (count($pilots) >= 1) {
        $haveOnlineTime = true;
    }
    // Sort the pilots by name.
    asort($pilots);
    // Create a row for each pilot.
    foreach ($pilots as $pilot) {
        // Get the pilots online times.
        $id = usernameToID($pilot);
        $ot = $DB->query("SELECT * FROM onlinetime WHERE userid='" . $id . "'");
        // break off here if the user has not publishes his online time yet.
        if ($ot->numRows() == 0) {
            continue;
        }
        $ot = $ot->fetchRow();
        $onlineTime->addRow();
        // Pilot name
        $onlineTime->addCol(ucfirst($pilot));
        // And go through each hour, creating a nice coloured box.
        for ($i = 0; $i <= 23; $i++) {
            $column = "h" . str_pad($i, 2, "0", STR_PAD_LEFT);
            // #222733  |  #4f646e  |  #c2c957  |  #e6f137
            switch ($ot[$column]) {
                case "0":
                    $onlineTime->addCol(" ", array("bgcolor" => "#222733"));
                    break;
                case "01":
                    $onlineTime->addCol(" ", array("bgcolor" => "#4f646e"));
                    break;
                case "2":
                    $onlineTime->addCol(" ", array("bgcolor" => "#c2c957"));
                    break;
                case "3":
                    $onlineTime->addCol(" ", array("bgcolor" => "#e6f137"));
                    break;
            }
        }
    }
    // Return the hard labor.
    /* Return the Online Table, or, If no one published his online time yet,
     * print a message saying just that. */
    if ($haveOnlineTime) {
        // We have at least one person who sent in his times.
        return $page . $onlineTime->flush() . $editLink;
    } else {
        // No one ever sent in his times.
        return $page . "<b>No one sent in his/her onlinetimes yet. But you can be the first! :)</b><br>" . $editLink;
    }
}
예제 #18
0
function showShipValue()
{
    // Get the globals.
    global $SHIPTYPES;
    global $DBSHIP;
    global $DB;
    // load the values.
    if (!isset($_GET[id])) {
        // No ID requested, get latest
        $shipvaluesDS = $DB->query("select * from shipvalues ORDER BY ID DESC limit 1");
        $isLatest = true;
    } else {
        if (!is_numeric($_GET[id]) || $_GET[ID] < 0) {
            // ID Set, but invalid
            makeNotice("Invalid ID given for ship values! Please go back, and try again!", "warning", "Invalid ID");
        } else {
            // VALID id
            $shipvaluesDS = $DB->query("select * from shipvalues WHERE id='" . sanitize($_GET[id]) . "' limit 1");
        }
    }
    // Check for a winner.
    if ($shipvaluesDS->numRows() <= 0) {
        makeNotice("Invalid ID given for ship values! Please go back, and try again!", "warning", "Invalid ID");
    }
    // Check for latest shipvalue
    if (!$isLatest) {
        $latest = $DB->query("select * from shipvalues ORDER BY ID DESC limit 1");
        $latest = $latest->fetchRow();
        if ($latest[id] == sanitize($_GET[id])) {
            $isLatest = true;
        }
    }
    $shipvalues = $shipvaluesDS->fetchRow();
    // 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} Ship Values (dated: " . date("m.d.y H:i:s", $shipvalues[time]) . ", modified by " . ucfirst(idToUsername($shipvalues[modifier])) . ")", array("bold" => true));
    $table->addRow();
    $table->addCol("Ship Type", array("colspan" => 2, "bold" => true));
    $table->addCol("Value", array("bold" => true));
    if (!$isLatest) {
        $table->addCol("Diff", array("bold" => true));
    }
    $table->addCol("Ship Type", array("colspan" => 2, "bold" => true));
    $table->addCol("Value", array("bold" => true));
    if (!$isLatest) {
        $table->addCol("Diff", array("bold" => true));
    }
    // How many shiptypes 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);
        $table->addCol(number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) . " %");
        if (!$isLatest) {
            $diff = number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) - number_format($latest[$DBSHIP[$SHIP] . Value] * 100, 2) . " %";
            if ($diff > 0) {
                $color = "#00ff00";
            } elseif ($diff == 0) {
                $color = "";
            } elseif ($diff <= 0) {
                $color = "#ff0000";
            }
            $table->addCol("<font color=\"{$color}\">{$diff}</font>");
        }
        // 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);
            $table->addCol(number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) . " %");
            if (!$isLatest) {
                $diff = number_format($shipvalues[$DBSHIP[$SHIP] . Value] * 100, 2) - number_format($latest[$DBSHIP[$SHIP] . Value] * 100, 2) . " %";
                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=showshipvalue\">here</a> to see up-to-date Values.", array("colspan" => 8));
    }
    /*
     * Create a list of all previous changes.
     */
    $AllChanges = $DB->query("SELECT time,id FROM shipvalues ORDER BY time ASC");
    while ($ds = $AllChanges->fetchRow()) {
        if ($ds[time] > 0) {
            if ($ds[time] == $shipvalues[time]) {
                $otherValues .= "[" . date("d.m.y", $ds[time]) . "] ";
            } else {
                $otherValues .= "[<a href=\"index.php?action=showshipvalue&id={$ds['id']}\">" . date("d.m.y", $ds[time]) . "</a>] ";
            }
        }
    }
    $table->addRow("#060622");
    $table->addCol("Other quotes:");
    $table->addCol($otherValues, array("colspan" => $colspan));
    // return the page
    return "<h2>Ship Quotes</h2>" . $table->flush();
}
예제 #19
0
function makeProfileLink($ID)
{
    numericCheck($ID, 0);
    $username = ucfirst(idToUsername($ID));
    return "<a href=\"index.php?action=profile&id=" . $ID . "\">" . $username . "</a>";
}
예제 #20
0
function addEventToDB()
{
    global $MySelf;
    global $DB;
    // is the events module active?
    if (!getConfig("events")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Are we allowed to add Events?
    if (!$MySelf->canEditEvents()) {
        makeNotice("You are not allowed to add events!", "error", "Forbidden!");
    }
    // Do we have a short description?
    if (empty($_POST[sdescr])) {
        makeNotice("You need to supply a short description!", "error", "Important field missing!");
    }
    // Do we have an officer?
    if (empty($_POST[officer])) {
        makeNotice("You need to supply who is in command!", "error", "Important field missing!");
    }
    // Choose which supplied officer we use.
    if (!empty($_POST[officer2])) {
        sanitize($officer = sanitize($_POST[officer2]));
    } else {
        sanitize($officer = sanitize($_POST[officer]));
    }
    // Choose which system we use.
    if (!empty($_POST[system2])) {
        $system = strtolower($_POST[system2]);
    } else {
        $system = strtolower($_POST[system]);
    }
    // Check that we still have a valid systemname.
    if (empty($system)) {
        makeNotice("No valid Systemname found! Please go back, and try again.", "warning", "No system name", "index.php?action=addevent", "[cancel]");
    }
    // Do we have an ETD?
    if (empty($_POST[dur])) {
        makeNotice("You need to tell me the guessed runtime!", "error", "Important field missing!");
    }
    // Collateral?
    if (!is_numeric($_POST[collateral]) && $_POST[collateral] < 0) {
        makeNotice("You need to supply a valid collateral!", "error", "Important field missing!");
    }
    // Do we have an ETD?
    if ($_POST[payment] < 0) {
        makeNotice("You need to give the folks some money!", "error", "Important field missing!");
    }
    // Startting time goodness.
    $myTime = array("day" => "{$_POST['ST_day']}", "month" => "{$_POST['ST_month']}", "year" => "{$_POST['ST_year']}", "hour" => "{$_POST['ST_hour']}", "minute" => "{$_POST['ST_minute']}");
    $starttime = humanTime("toUnix", $myTime);
    // is the time valid?
    if (!$starttime) {
        makeNotice("Invalid time supplied!", "error", "Invalid Time!");
    }
    // Lets see what ships are required.
    $SHIPTYPES = array("shuttles", "frigates", "destroyers", "cruisers", "bcruiser", "scruiser", "bship", "dread", "carrier", "titan", "barges", "indies", "freighter", "jfreighter", "exhumer");
    foreach ($SHIPTYPES as $ship) {
        if ($_POST[$ship] == "on") {
            $wantedships[] = $ship;
        }
    }
    $ships = serialize($wantedships);
    $p = $DB->query("INSERT INTO events (sdesc, officer, system, security, type, starttime, " . "duration, difficulty, payment, collateral, notes, ships)\r\n\t               values (?,?,?,?,?,?,?,?,?,?,?,?)", array(sanitize($_POST[sdescr]), $officer, $system, sanitize($_POST[security]), sanitize($_POST[type]), sanitize($starttime), sanitize($_POST[dur]), sanitize($_POST[difficulty]), sanitize($_POST[payment]), sanitize($_POST[collateral]), sanitize($_POST[notes]), "{$ships}"));
    if ($DB->affectedRows() == 1) {
        // Prepare the announcement email.
        global $SITENAME;
        global $VERSION;
        global $URL;
        // Bloody hack to get latest ID. No one will ever know. ;)
        $lastID = $DB->getCol("SELECT max(ID) from events;");
        $risks = array("No risk involved.", "Only inferior forces suspected.", "Somewhat risky.", "Moderate risk.", "Extreme risks are involved.", "No survivors expected.");
        $risk_index = $_POST[difficulty];
        // Fix the template up.
        $email = str_replace("{{ID}}", str_pad("{$lastID['0']}", "5", "0", STR_PAD_LEFT), getTemplate("newevent", "email"));
        $email = str_replace("{{SDESCR}}", $_POST[sdescr], $email);
        $email = str_replace("{{TYPE}}", $_POST[type], $email);
        // In case of a numeric value we have to translate that into plain english.
        if (is_numeric($_POST[officer])) {
            $officer = idToUsername($_POST[officer]);
        } else {
            $officer = sanitze($_POST[officer]);
        }
        $email = str_replace("{{FLAGOFFICER}}", ucfirst($officer), $email);
        $email = str_replace("{{SYSTEM}}", $_POST[system], $email);
        $email = str_replace("{{SECURITY}}", $_POST[security], $email);
        $email = str_replace("{{STARTTIME}}", date("d.m.y H:i:s", $starttime), $email);
        $email = str_replace("{{DURATION}}", $_POST[dur], $email);
        $email = str_replace("{{RISK}}", $risks[$risk_index], $email);
        $email = str_replace("{{PAYMENT}}", $_POST[payment], $email);
        $email = str_replace("{{COLLATERAL}}", number_format($_POST[collateral], 2), $email);
        $email = str_replace("{{NOTES}}", $_POST[notes], $email);
        $email = str_replace("{{SITENAME}}", $SITENAME, $email);
        $email = str_replace("{{URL}}", $URL, $email);
        $email = str_replace("{{VERSION}}", $VERSION, $email);
        // mail the user.
        mailUser($email, "New event added!");
        // Tell the admin what we did.
        makeNotice("Event added to the database and users who are opt-in got an email.", "notice", "New Event added.", "index.php?action=showevents", "[OK]");
    } else {
        makeNotice("Something went horribly wrong! AIEE!!", "error", "Mummy!");
    }
}
예제 #21
0
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();
}
예제 #22
0
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;
}
예제 #23
0
function editUser()
{
    // We need global variables and object.
    global $DB;
    global $MySelf;
    global $IS_DEMO;
    if ($IS_DEMO && $_POST[id] == "1") {
        makeNotice("The user would have been changed. (Operation canceled due to demo site restrictions.)", "notice", "Password change confirmed");
    }
    // Are we allowed to Manage Users?
    if (!$MySelf->canManageUser()) {
        makeNotice("You are not allowed to edit Users!", "error", "forbidden");
    }
    // Sanitize the ID
    $ID = sanitize($_POST[id]);
    $SELF = $MySelf->getID();
    if (!is_numeric($ID)) {
        // Yikes! Non-Number!
        makeNotice("Variable is not numeric! (in editUser)", "error");
    }
    // Load the dataset.
    $userDS = $DB->query("SELECT * FROM users WHERE id='{$ID}' LIMIT 1");
    $user = $userDS->fetchRow();
    // Non-admin tries to edit an admin, err no.
    if ($user[isAdmin] && !$MySelf->isAdmin()) {
        makeNotice("Only an Administrator may edit another Administrator. You do have the rights to edit users, but you are not allowed to modify an Administrators account.", "warning", "Insufficient rights!", "index.php?action=edituser&id={$ID}", "Cancel");
    }
    // Do we want to delete the user?
    if ($_POST[delete] == "true") {
        if ($ID == $SELF) {
            makeNotice("You can not delete yourself! Why would you do such a thing? " . "Life is not that bad, c'mon...'", "warning", "Operation canceled", "index.php?action=edituser&id={$ID}", "get yourself together, man");
        }
        // Are we allowed to delete users?
        if (!$MySelf->canDeleteUser()) {
            makeNotice("You are not authorized to do that!", "error", "Forbidden");
        }
        // Get confirmation
        confirm("You are about to delete " . ucfirst(idToUsername($ID)) . ". Are you sure?");
        $DB->query("UPDATE users SET deleted='1' WHERE id='{$ID}' LIMIT 1");
        if ($DB->affectedRows() == 1) {
            makeNotice("The Account has been deleted.", "notice", "Account deleted", "index.php?action=editusers", "Back to editing Users");
        } else {
            makeNotice("Error deleting the user!", "error");
        }
    }
    // Activate the account, or disable it.
    if ("{$_POST['canLogin']}" == "on") {
        $DB->query("UPDATE users SET active='1' WHERE id ='{$ID}' LIMIT 1");
    } else {
        if ($ID == $SELF) {
            makeNotice("You can not deactivate yourself!", "error", "Err..", "index.php?action=edituser&id={$ID}", "Back to yourself ;)");
        } else {
            $DB->query("UPDATE users SET active='0' WHERE id ='{$ID}'");
        }
    }
    // Confirm the account.
    if ("{$_POST['confirm']}" == "true") {
        $DB->query("UPDATE users SET confirmed='1' WHERE id ='{$ID}' LIMIT 1");
        lostPassword($user[username]);
        $ADD = " Due to confirmation I have sent an email to the user with his password.";
    }
    // Force the users email to be valid.
    if ("{$_POST['SetEmailValid']}" == "true") {
        $DB->query("UPDATE users SET emailvalid='1' WHERE id ='{$ID}' LIMIT 1");
    }
    global $IS_DEMO;
    if (!$IS_DEMO) {
        // Set the new email.
        if (!empty($_POST[email])) {
            $email = sanitize("{$_POST['email']}");
            $DB->query("UPDATE users SET email='{$email}' WHERE id ='{$ID}'");
        }
        // Set the new Password.
        if (!empty($_POST[password])) {
            $password = encryptPassword(sanitize("{$_POST['password']}"));
            $DB->query("UPDATE users SET password='******' WHERE id ='{$ID}'");
        }
        // Change (shudder) the username.
        if ($_POST[username_check] == "true" && $_POST[username] != "") {
            if ($MySelf->isAdmin() && $MySelf->canManageUser()) {
                // Permissions OK.
                $new_username = sanitize($_POST[username]);
                // Check for previously assigned username
                $count = $DB->getCol("SELECT COUNT(username) FROM users WHERE username='******'");
                if ($count[0] > 0) {
                    // Username exists already.
                    makeNotice("The new username \"{$new_username}\" already exists. Unable to complete operation.", "error", "Username exists!");
                } else {
                    // Username free. Update DB.
                    $DB->query("UPDATE users SET username='******' WHERE ID='" . $ID . "' LIMIT 1");
                    // Check for failure, not success.
                    if ($DB->affectedRows() != 1) {
                        // Something is wrong :(
                        makeNotice("DB Error: Internal Error: Unable to update the username.", "error", "Internal Error");
                    }
                }
            } else {
                // Insufficient permissions
                makeNotice("Inusfficient rights to change username.", "error", "Insufficient Rights");
            }
        }
    }
    // Are we allowed to edit ranks?
    if ($MySelf->canEditRank()) {
        // Set the new Rank.
        if (is_numeric($_POST[rank]) && $_POST[rank] >= 0) {
            $rank = sanitize("{$_POST['rank']}");
            $DB->query("UPDATE users SET rank='{$rank}' WHERE id ='{$ID}'");
        }
        // toggle the opt-in setting.
        // Its a checkbox. So we have to endure the pain.
        if ($_POST[optIn]) {
            $state = 1;
        } else {
            $state = 0;
        }
        $DB->query("UPDATE users SET optIn='{$state}' WHERE id='{$ID}' LIMIT 1");
        // Do the permissions.
        $permissions = array("canLogin", "canJoinRun", "canCreateRun", "canCloseRun", "canDeleteRun", "canAddHaul", "canChangePwd", "canChangeEmail", "canChangeOre", "canAddUser", "canSeeUsers", "canDeleteUser", "canEditRank", "canManageUser", "canSeeEvents", "canEditEvents", "canDeleteEvents", "isLottoOfficial", "canPlayLotto", "isOfficial", "isAdmin", "isAccountant");
        // Loop through each of the resources.
        foreach ($permissions as $perm) {
            // Convert the html "on" to "1" and "0", respectively
            if ($_POST[$perm] == "on") {
                $state = "1";
            } else {
                $state = "0";
            }
            // Update the database.
            $DB->query("UPDATE users SET {$perm}='{$state}' WHERE id ='{$ID}'");
        }
    }
    makeNotice("User data has been updated. {$ADD}", "notice", "User updated", "index.php?action=edituser&id={$ID}", "[OK]");
}
예제 #24
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;
}
예제 #25
0
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;
}
예제 #26
0
                $partlog_info->addCol("<i>soon(tm)</i>");
                $partlog_info->addCol(numberToString($TIMEMARK - $join[joined]));
                $partlog_info->addCol("<font color=\"#00ff00\">ACTIVE</font>");
            }
            $partlog_info->addCol(joinAs($join[shiptype]));
        } else {
            $partlog_info->addCol("request pending");
            $partlog_info->addCol("request pending");
            $partlog_info->addCol("request pending");
            $partlog_info->addCol("request pending");
            $partlog_info->addCol(joinAs($join[shiptype]));
        }
        // Get the removal reason.
        switch ($join[status]) {
            default:
            case "0":
                $reason = " ";
                break;
            case "1":
                $reason = "removed by " . ucfirst(idToUsername($join[remover]));
                break;
            case "2":
                $reason = "<font color=\"#ffff00\">kicked</font> by " . ucfirst(idToUsername($join[remover]));
                break;
            case "3":
                $reason = "<font color=\"#ff0000\">banned</font> by " . ucfirst(idToUsername($join[remover]));
                break;
        }
        $partlog_info->addCol($reason);
    }
}