Beispiel #1
0
function listRuns()
{
    /* bgcolor and i are used to alternate the tablerow
     * background color.
     */
    $bgc = array("#222222", "#333333");
    $bgi = 0;
    // Our database.
    global $DB;
    global $MySelf;
    global $READONLY;
    global $PREFS;
    $sirstate = $PREFS->getPref("sirstate");
    /*
     * LIST OPEN RUNS
     */
    // Query it.
    $results = $DB->query("select * from runs where endtime IS NULL order by id");
    $mode = array("bold" => true);
    $table = new table(9, true);
    $table->addHeader(">> Currently active Operations");
    $table->addRow("#060622");
    $table->addCol("Run ID");
    $table->addCol("Supervisor");
    $table->addCol("Op Type");
    $table->addCol("Starttime");
    $table->addCol("Endtime");
    $table->addCol("Location");
    $table->addCol("Security");
    $table->addCol("Official run");
    $table->addCol("Locked");
    $runsExist = false;
    // Now we loop through each returned result.
    while ($row = $results->fetchRow()) {
        // Skip inofficial runs if user does not want to see them.
        if (!$sirstate && !$row['isOfficial'] && !($MySelf->getID() == $row['supervisor'])) {
            continue;
        }
        $table->addRow();
        $table->addCol("<a href=\"index.php?action=show&id={$row['id']}\">" . str_pad($row['id'], 5, "0", STR_PAD_LEFT) . "</a>");
        $table->addCol(makeProfileLink($row['supervisor']));
        $table->addCol($row['optype'] == "" ? "Standard" : $row['optype']);
        $table->addCol(date("d.m.y H:i", $row['starttime']));
        /* This handles the endtime. Prints endtime if it has already
         * ended, or "active" along with an "end run"-link if still open.
         */
        unset($tmp);
        if ($row['endtime'] == "") {
            $tmp = "<b>active</b>";
            // If access level is above or equal 3 give option to close run.
            if ($MySelf->canCloseRun()) {
                $tmp .= " (<a href=\"index.php?action=endrun&id={$row['id']}\">close run</a>)";
            }
        } else {
            $tmp = date("d.m.y H:i", $row['endtime']);
        }
        // Add the end-time to the table.
        $table->addCol($tmp);
        // Show the security status
        $System = new solarSystem($row['location']);
        if ($System->valid()) {
            $table->addCol($System->makeFancyLink());
            $table->addCol($System->getSecurity());
        } else {
            $table->addCol(ucfirst($row['location']));
            $table->addCol("?");
        }
        $table->addCol(yesno($row['isOfficial'], true));
        $table->addCol(yesno($row['isLocked'], true, true));
        $runsExist = true;
        // We wont print out table if there are no open runs.
    }
    /*
     *  LIST CLOSED RUNS
     */
    // Query it.
    if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) {
        $page = "LIMIT " . $_GET['page'] * 20 . ", 20";
    } elseif (isset($_GET['page']) && $_GET['page'] == "all") {
        $page = "";
    } else {
        $page = "LIMIT 20";
    }
    $results = $DB->query("SELECT * FROM runs WHERE endtime IS NOT NULL ORDER BY endtime DESC {$page}");
    // This is the table header.
    $table_closed = new table(11, true);
    $table_closed->addHeader(">> Archived Operations");
    $table_closed->addRow("#060622");
    $table_closed->addCol("Run ID");
    $table_closed->addCol("Supervisor");
    $table_closed->addCol("Op Type");
    $table_closed->addCol("Starttime");
    $table_closed->addCol("Endtime");
    $table_closed->addCol("Location");
    $table_closed->addCol("Security");
    $table_closed->addCol("Yield");
    $table_closed->addCol("TMEC(tm)");
    $table_closed->addCol("Was official");
    // Offer delete button.
    if ($MySelf->canDeleteRun() && !$READONLY) {
        $table_closed->addCol("Delete", $mode);
    } else {
        $table_closed->addCol("");
    }
    // Now we loop through each returned result.
    while ($row = $results->fetchRow()) {
        // Skip inofficial runs if user does not want to see them.
        if (!$sirstate && !$row['isOfficial'] && !($MySelf->getID() == $row['supervisor'])) {
            continue;
        }
        $table_closed->addRow();
        $table_closed->addCol("<a href=\"index.php?action=show&id={$row['id']}\">" . str_pad($row['id'], 5, "0", STR_PAD_LEFT) . "</a>");
        $table_closed->addCol(makeProfileLink($row['supervisor']));
        $table_closed->addCol($row['optype'] == "" ? "Standard" : $row['optype']);
        $table_closed->addCol(date("d.m.y H:i", $row['starttime']));
        /* This handles the endtime. Prints endtime if it has already
         * ended, or "active" along with an "end run"-link if still open.
         */
        unset($tmp);
        if ("{$row['endtime']}" == "") {
            $tmp = "<b>active</b>";
            // If access level is above or equal 3 give option to close run.
            if ($MySelf->canCloseRun()) {
                $tmp .= " (<a href=\"index.php?action=endrun&id={$row['id']}\">close run</a>)";
            }
        } else {
            $tmp = date("d.m.y H:i", $row['endtime']);
        }
        // Add the end-time to the table.
        $table_closed->addCol($tmp);
        // Show the security status
        $System = new solarSystem($row['location']);
        if ($System->valid()) {
            $table_closed->addCol($System->makeFancyLink());
            $table_closed->addCol($System->getSecurity());
        } else {
            $table_closed->addCol(ucfirst($row['location']));
            $table_closed->addCol("?");
        }
        // get the total ores gained.
        $totalIsk = getTotalWorth($row['id']);
        $table_closed->addCol(number_format($totalIsk, 2) . " ISK", array("style" => "text-align:right;"));
        // Add the TMEC
        if ($row['tmec'] == 0) {
            $TMEC = calcTMEC($row['id']);
        } else {
            $TMEC = $row['tmec'];
        }
        $table_closed->addCol($TMEC, array("style" => "text-align:right;"));
        // Add "run is official" bit.
        $table_closed->addCol(yesno($row['isOfficial'], true), array("style" => "text-align:right;"));
        $closedRunsExist = true;
        // We wont print out table if there are no open runs.
        // Add possible delete run button.
        if ($MySelf->canDeleteRun() && !$READONLY) {
            $table_closed->addCol("<a href=\"index.php?action=deleterun&id={$row['id']}\">delete</a>");
        } else {
            $table_closed->addCol("");
        }
    }
    // The "show this many ops"-part.
    $count = $DB->getCol("SELECT COUNT(id) FROM runs WHERE endtime > 0");
    $countSteps = floor($count[0] / 20);
    $showMore = "Switch to page >> ";
    for ($i = 1; $i <= $countSteps; $i++) {
        $thisStep = str_pad($i, 2, "0", STR_PAD_LEFT);
        $showMore .= "[<a href=\"index.php?action=list&page=" . $thisStep . "\">" . $thisStep . "</a>] ";
    }
    $showMore .= "[<a href=\"index.php?action=list&page=all\">All</a>] ";
    $table_closed->addHeader($showMore);
    // Fancy it up!
    $page = "<h2>Mining Operations</h2>";
    // Print the open runs table, IF there are open runs.
    if ($runsExist) {
        $page .= $table->flush() . "<br>";
    }
    // Print the closed runs table, IF there are closed runs.
    if ($closedRunsExist) {
        $page .= $table_closed->flush();
    } else {
        $page .= "<i>There are no (closed) mining operations in the database. Is this a fresh installation?</i>";
    }
    return $page;
}
Beispiel #2
0
    $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");
        }
        $totalPayout = $totalPayout + $payout;
        $totalPercent = $totalPercent + $percent;
    }
    $payout_info->addRow("060622");
    $payout_info->addCol("TOTAL", array("bold" => true));
    $payout_info->addCol(number_format($totalPercent, 2) . "%");
    $payout_info->addCol(number_format($totalPayout, 2) . " ISK");
}
Beispiel #3
0
 $haulingDB = $DB->query("select * from hauled where miningrun = '{$ID}' group by time ORDER BY time DESC");
 // Create the table header.
 $hauled_information = new table(4, true);
 $hauled_information->addHeader(">> Transport Manifest");
 $hauled_information->addRow("#060622");
 $hauled_information->addCol("Hauler", array("bold" => true));
 $hauled_information->addCol("Time", array("bold" => true));
 $hauled_information->addCol("Location", array("bold" => true));
 $hauled_information->addCol("Freight", array("bold" => true));
 // Delete uneeded vars.
 unset($temp);
 // Lets loop through the results!
 while ($row = $haulingDB->fetchRow()) {
     // The who hauled to where when stuff.
     $hauled_information->addRow(false, top);
     $hauled_information->addCol(makeProfileLink($row[hauler]));
     $hauled_information->addCol(date("H:i:s", $row[time]));
     $system = new solarSystem($row[location]);
     $hauled_information->addCol(ucfirst($system->makeFancyLink()));
     /* 
      * Now we loop through all the ore in the hauled database (result)
      * and print a Oretype: Amount for each Oretype that has an amount
      * greater or lesser than zero, but not zero.
      */
     $oc = 1;
     $singleHaulDB = $DB->query("select Item, Quantity from hauled where miningrun = '{$ID}' and time = {$row['time']} ORDER BY Item");
     while ($haul = $singleHaulDB->fetchRow()) {
         $ORE = $haul[Item];
         if ($haul[Quantity] > 0) {
             $temp .= number_format($haul[Quantity], 0) . " " . array_search($ORE, $DBORE) . "<br>";
         } elseif ($haul[Quantity]) {
Beispiel #4
0
function globalStatistics()
{
    // We need some stuff.
    global $DB;
    global $MySelf;
    /*
     * Global Information
     */
    // Create the header of the table
    $stat_table = new table(2, true);
    $stat_table->addHeader(">> Global Information for " . getConfig("sitename"));
    // Total Users
    $temp = $DB->getCol("SELECT COUNT(id) FROM users WHERE deleted='0'");
    $totalUsers = $temp[0];
    $stat_table->addRow();
    $stat_table->addCol("Total user accounts:");
    $stat_table->addCol(number_format($totalUsers, 0));
    // Total Logins
    $temp = $DB->getCol("SELECT COUNT(authkey) FROM auth");
    $temp = $temp[0];
    $stat_table->addRow();
    $stat_table->addCol("Total logins:");
    $stat_table->addCol(number_format($temp, 0));
    // Total failed logins
    $temp = $DB->getCol("SELECT COUNT(incident) FROM failed_logins");
    $temp = $temp[0];
    $stat_table->addRow();
    $stat_table->addCol("Total failed logins:");
    $stat_table->addCol(number_format($temp, 0));
    // Total API keys
    $temp = $DB->getCol("SELECT COUNT(userid) FROM api_keys");
    $totalApiKeys = $temp[0];
    if ($totalApiKeys > 0) {
        $stat_table->addRow();
        $stat_table->addCol("Total API keys stored:");
        $stat_table->addCol(number_format($totalApiKeys, 0));
        // Total API keys
        $temp = $DB->getCol("SELECT COUNT(userid) FROM api_keys WHERE api_valid=1");
        $totalValidApiKeys = $temp[0];
        $stat_table->addRow();
        $stat_table->addCol("Total API keys validated:");
        $stat_table->addCol(number_format($totalValidApiKeys, 0));
        // Total API keys percentage
        $stat_table->addRow();
        $stat_table->addCol("Percent of stored keys valid:");
        $stat_table->addCol(number_format($totalValidApiKeys * 100 / $totalApiKeys, 2) . "%");
        // Total API keys percentage (over all users)
        $stat_table->addRow();
        $stat_table->addCol("Percent of pilots submited API keys:");
        $stat_table->addCol(number_format($totalApiKeys * 100 / $totalUsers, 2) . "%");
    }
    /*
     * Mining Information
     */
    // Create the header of the table
    $mining_table = new table(2, true);
    $mining_table->addHeader(">> Mining Information for " . getConfig("sitename"));
    // Total Mining Operations
    $temp = $DB->getCol("SELECT COUNT(id) FROM runs WHERE isOfficial = 1");
    $totalMiningOps = $temp[0];
    $mining_table->addRow();
    $mining_table->addCol("Total Mining Operations:");
    $mining_table->addCol(number_format($totalMiningOps, 0));
    // Total Number of Joins
    $temp = $DB->getCol("SELECT COUNT( uJoinups ) FROM (SELECT COUNT( id ) AS uJoinups FROM joinups GROUP BY `run`,`userid`) AS suJoinups");
    $totalJoinUps = $temp[0];
    $mining_table->addRow();
    $mining_table->addCol("Total joinups:");
    $mining_table->addCol(number_format($totalJoinUps, 0));
    // Total Hauling Runs
    $temp = $DB->getCol("SELECT COUNT(id) FROM hauled");
    $totalHaulingRuns = $temp[0];
    $mining_table->addRow();
    $mining_table->addCol("Total Hauling Runs:");
    $mining_table->addCol(number_format($totalHaulingRuns, 0));
    // Total ISK Mined
    $mining_table->addRow();
    $mining_table->addCol("Total ISK mined:");
    $totalIskMined = calculateTotalIskMined();
    $mining_table->addCol(number_format($totalIskMined) . " ISK");
    // Average TMEC
    $aTMEC = $DB->getCol("SELECT AVG(tmec) FROM runs WHERE isOfficial = 1");
    $aTMEC = $aTMEC[0];
    $mining_table->addRow();
    $mining_table->addCol("Average TMEC:");
    if ($aTMEC <= 0) {
        $aTMEC = 0;
    }
    $mining_table->addCol(number_format($aTMEC, 3));
    // Total time spent mining
    $temp = $DB->getCol("SELECT SUM(endtime-starttime) AS time FROM runs WHERE endtime >0 AND isOfficial = 1");
    $time = $temp[0];
    if ($time > 0) {
        $totalTimeSpentMining = $time;
        $string = numberToString($time);
    } else {
        $string = "Never mined at all!";
    }
    $mining_table->addRow();
    $mining_table->addCol("Total time spent mining:");
    $mining_table->addCol($string);
    // Total pilot time
    $time = $DB->getCol("select SUM(parted-joined) as time from joinups WHERE parted >0");
    $time = $time[0];
    $mining_table->addRow();
    $mining_table->addCol("Total time combined from all pilots:");
    if ($time > 0) {
        $totalPilotTime = $time;
        $string = numberToString($time);
    } else {
        $string = "Never mined at all!";
    }
    $mining_table->addCol($string);
    /*
     * Money Stuff
     */
    $trans_Count = $DB->getCol("SELECT COUNT(id) FROM transactions");
    $trans_Count = $trans_Count[0];
    if ($trans_Count > 0) {
        $trans = new table(2, true);
        $trans->addHeader(">> Financial Statistics");
        $trans->addRow();
        $trans->addCol("Total Transactions made:");
        $trans->addCol(number_format($trans_Count, 0));
        $tmw = $DB->getCol("SELECT SUM(amount) FROM transactions WHERE type ='1'");
        $tmd = $DB->getCol("SELECT SUM(amount) FROM transactions WHERE type ='0'");
        $tmw = $tmw[0];
        $tmd = $tmd[0];
        $trans->addRow();
        $trans->addCol("Total Money withdrawn:");
        $trans->addCol(number_format($tmw * -1, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Total Money deposited:");
        $trans->addCol(number_format($tmd, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Difference:");
        $trans->addCol(number_format($tmd + $tmw, 2) . " ISK");
        /*
         * Abbreviations:
         * por - PayOutRequests
         * pord - PayOutRequests Done
         * port - PayOutRequests Total
         * portd - PayOutRequests Total Done
         */
        $por = $DB->getCol("SELECT COUNT(request) FROM payoutRequests");
        $port = $DB->getCol("SELECT SUM(amount) FROM payoutRequests");
        $portd = $DB->getCol("SELECT SUM(amount) FROM payoutRequests WHERE payoutTime is NULL");
        $pord = $DB->getCol("SELECT COUNT(request) FROM payoutRequests WHERE payoutTime is NULL");
        $por = $por[0];
        $pord = $pord[0];
        $port = $port[0];
        $portd = $portd[0];
        $trans->addRow();
        $trans->addCol("Total payout requests:");
        $trans->addCol(number_format($por, 0));
        $trans->addRow();
        $trans->addCol("Payout requests fullfilled:");
        $trans->addCol(number_format($por - $pord, 0));
        $trans->addRow();
        $trans->addCol("Payout requests pending:");
        $trans->addCol(number_format($pord, 0));
        $trans->addRow();
        $trans->addCol("Total payout requested:");
        $trans->addCol(number_format($port, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Total requested paid:");
        $trans->addCol(number_format($port - $portd, 2) . " ISK");
        $trans->addRow();
        $trans->addCol("Total requested open:");
        $trans->addCol(number_format($portd, 2) . " ISK");
        $trans->addHeader("A positive difference means the Corp owes the players, a negative difference means the player owes the Corp.");
        $trans_r = "<br>" . $trans->flush();
    }
    /*
     * Mining Statistics
     */
    // Create the header of the table
    $miningStats_table = new table(2, true);
    $miningStats_table->addHeader(">> Mining Statistics for " . getConfig("sitename"));
    // Average ISK / OP
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average ISK per Op:");
    $miningStats_table->addCol(number_format($totalIskMined / $totalMiningOps, 2) . " ISK");
    // Average ISK/ Hour
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average ISK per hour:");
    $miningStats_table->addCol(number_format($totalIskMined / ceil($totalTimeSpentMining / 3600), 2) . " ISK");
    // Average joinups / Op
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average Joinups per Op:");
    $miningStats_table->addCol(number_format($totalJoinUps / $totalMiningOps, 2));
    // Average hauls per OP:
    $miningStats_table->addRow();
    $miningStats_table->addCol("Average hauls per Op:");
    $miningStats_table->addCol(number_format($totalHaulingRuns / $totalMiningOps, 2));
    /*
     * Hauler statistics
     */
    $haulers = $DB->query("SELECT DISTINCT hauler, COUNT(miningrun) AS runs FROM hauled GROUP BY hauler ORDER BY runs DESC LIMIT 15");
    if ($haulers->numRows() > 0) {
        $hauler_stats = new table(2, true);
        $hauler_stats->addHeader("Most hauling trips");
        while ($h = $haulers->fetchRow()) {
            // place counter.
            $place++;
            $hauler_stats->addRow();
            $hauler_stats->addCol("Place #" . $place . ":");
            $hauler_stats->addCol(makeProfileLink($h[hauler]) . " with " . number_format($h[runs]) . " runs!");
        }
        $hauler_stats_table = "<br>" . $hauler_stats->flush();
    }
    /*
     * Most frequent joiners
     */
    $MFJDB = $DB->query("SELECT COUNT(userid) AS count, userid FROM (SELECT * FROM joinups GROUP BY userid,run) AS ujoinups GROUP BY userid ORDER BY count DESC LIMIT 15");
    if ($MFJDB->numRows() > 0) {
        // Create the header of the table
        $frequentJoiners_table = new table(2, true);
        $frequentJoiners_table->addHeader(">> Most frequent joiners for " . getConfig("sitename"));
        $place = "1";
        while ($FJ = $MFJDB->fetchRow()) {
            $frequentJoiners_table->addRow();
            $frequentJoiners_table->addCol("Place #" . $place . ":");
            $frequentJoiners_table->addCol(makeProfileLink($FJ[userid]) . " with " . $FJ[count] . " joinups!");
            $place++;
        }
        $MFJ_r = "<br>" . $frequentJoiners_table->flush();
    }
    /*
     * Pilot record with mining time
     */
    $PMT = $DB->query("select SUM(parted-joined) AS totaltime, userid from joinups WHERE parted >0 GROUP BY userid ORDER BY totaltime DESC LIMIT 15");
    if ($PMT->numRows() > 0) {
        // Create the header of the table
        $mostOnline_table = new table(2, true);
        $mostOnline_table->addHeader(">> Most time spent mining");
        $place = 1;
        while ($P = $PMT->fetchRow()) {
            $time = $P[totaltime];
            if ($time > 0) {
                $string = numberToString($time);
                $mostOnline_table->addRow();
                $mostOnline_table->addCol("Place #" . $place . ":");
                $mostOnline_table->addCol(makeProfileLink($P[userid]) . " with " . $string);
                $place++;
            }
        }
        $MO_r = "<br>" . $mostOnline_table->flush();
    }
    /*
     * Longest OPS
     */
    $LOPS = $DB->query("select SUM(endtime-starttime) AS totaltime, id, location FROM runs WHERE endtime > 0 AND isOfficial = 1 GROUP BY id ORDER BY totaltime DESC LIMIT 15");
    if ($LOPS->numRows() > 0) {
        // Create the header of the table
        $lops_table = new table(2, true);
        $lops_table->addHeader(">> Longest Ops for " . getConfig("SITENAME"));
        $place = 1;
        while ($OP = $LOPS->fetchRow()) {
            $time = $OP[totaltime];
            if ($time > 0) {
                $string = numberToString($time);
                // Make system clickable.
                $system = new solarSystem($OP[location]);
                $loc = $system->makeFancyLink();
                $lops_table->addRow();
                $lops_table->addCol("Place #" . $place . ": Operation <a href=\"index.php?action=show&id=" . $OP[id] . "\">#" . str_pad($OP[id], 4, "0", STR_PAD_LEFT) . "</a> in " . $loc . ":");
                $lops_table->addCol($string);
                $place++;
            }
        }
        $LOPS_r = "<br>" . $lops_table->flush();
    }
    /*
     * Highest TMEC runs
     */
    // Load the top runs out of the database.
    $TMECDB = $DB->query("SELECT * FROM runs WHERE isOfficial = 1 AND endtime > 0 ORDER BY tmec DESC LIMIT 15");
    // Check that we have any!
    if ($TMECDB->numRows() > 0) {
        // Create table header for tmec.
        $TMEC = new table(3, true);
        $TMEC->addHeader(">> Highest rated TMEC Ops");
        // Reset first place again.
        $place = 1;
        // Now loop through the winners.
        while ($r = $TMECDB->fetchRow()) {
            // Calculate TMEC
            $thisTMEC = calcTMEC($r[id]);
            // This this is TMEC is zero or below.
            if ($thisTMEC <= 0) {
                break;
            }
            // If TMEC > 0, add it.
            $TMEC->addRow();
            // Load the solarsystem its in.
            $system = new solarSystem($r[location]);
            $location = $system->makeFancyLink();
            // Add tmec stuff.
            $TMEC->addCol("Place #" . $place . ":");
            $TMEC->addCol("Op #<a href=\"index.php?action=show&id=" . $r[id] . "\">" . str_pad($r[id], 4, "0", STR_PAD_LEFT) . "</a> in " . $location);
            $TMEC->addCol("Scored a TMEC of " . $thisTMEC . "!");
            // Increase place by one.
            $place++;
        }
        // Render the table.
        $TMEC_r = "<br>" . $TMEC->flush();
    }
    /* 
     * Total mined ore
     */
    /*
     * Assemble the heavy-duty SQL query.
     * It is dynamic because this way we can easily add ores from 
     * config-system.php to the system without code rewrite.
     */
    global $DBORE;
    global $ORENAMES;
    foreach ($DBORE as $ORE) {
        $new = $ORE;
        if ($last) {
            $SQLADD .= "(select coalesce(SUM(Quantity),0) from hauled where Item = '" . $last . "') AS total" . $last . ", ";
        }
        $last = $new;
    }
    $SQLADD .= "(select coalesce(SUM(Quantity),0) from hauled where Item = '" . $last . "') AS total" . $last . " ";
    $SQL = "SELECT " . $SQLADD;
    //$SQL = "select Item, coalesce(SUM(Quantity),0) as total from hauled group by Item";
    // Now query it.
    $totalOREDB = $DB->query("{$SQL}");
    // Create table.
    $totalOre_table = new table(2, true);
    $totalOre_table->addHeader(">> Total ore mined for " . getConfig("SITENAME"));
    // Loop through the result (single result!)
    if ($totalOREDB->numRows() > 0) {
        echo "<!-- Got rows for ore stats -->";
        while ($totalORE = $totalOREDB->fetchRow()) {
            // Now check each ore type.
            foreach ($ORENAMES as $ORE) {
                // And ignore never-hauled ore
                if ($totalORE[total . $DBORE[$ORE]] > 0) {
                    // We got some ore!
                    $totalOre_table->addRow();
                    $totalOre_table->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . $ORE . ".png\">Total " . $ORE . ":");
                    $totalOre_table->addCol(number_format($totalORE[total . $DBORE[$ORE]]));
                    $gotOre = true;
                }
            }
        }
        if ($gotOre) {
            $oretable_r = "<br>" . $totalOre_table->flush();
        }
    }
    /*
     * Assemble the heavy-duty SQL query.
     * It is dynamic because this way we can easily add ships from 
     * config-system.php to the system without code rewrite.
     */
    global $DBSHIP;
    global $SHIPNAMES;
    foreach ($DBSHIP as $SHIP) {
        $new = $SHIP;
    }
    /*
     * Most beloved Systems
     */
    $MBS = $DB->query("select SUM(endtime-starttime) as timespent, location FROM runs WHERE endtime > 0 AND isOfficial = 1 GROUP BY location ORDER BY timespent DESC LIMIT 10");
    if ($MBS->numRows() > 0) {
        $MBST = new table(2, true);
        $MBST->addHeader(">> Most loved locations");
        while ($LOC = $MBS->fetchRow()) {
            if ($LOC[timespent] > 0) {
                $MBST->addRow();
                $system = new solarSystem($LOC[location]);
                $MBST->addCol($system->makeFancyLink());
                $MBST->addCol(numberToString($LOC[timespent]));
            }
        }
        $MBST_r = "<br>" . $MBST->flush();
    }
    /*
     * Most charitable folks
     */
    $charity = $DB->query("SELECT users.username, COUNT(uJoinups.charity) as NOBLE FROM (SELECT * FROM joinups GROUP BY userid,run) as uJoinups, users WHERE users.id = uJoinups.userid AND uJoinups.charity=1 GROUP BY users.username ORDER BY NOBLE DESC, username ASC LIMIT 15");
    if ($charity->numRows() > 0) {
        $charity_table = new table(2, true);
        $charity_table->addHeader(">> Most charitable pilots");
        unset($j);
        while ($c = $charity->fetchRow()) {
            $j++;
            $charity_table->addRow();
            $charity_table->addCol("Place #" . $j . ":");
            $charity_table->addCol(makeProfileLink(usernameToID($c[username])) . " with " . $c[NOBLE] . " charitable acts!");
            $charityCount = $charityCount + $c[NOBLE];
        }
        $charity_table->addHeader("A total of {$charityCount} charitable actions have been recorded.");
        $charity_table = "<br>" . $charity_table->flush();
    }
    $page = "<h2>Global statistics</h2>" . $stat_table->flush() . $trans_r . "<br>" . $mining_table->flush() . "<br>" . $miningStats_table->flush() . $hauler_stats_table . $MFJ_r . $MO_r . $charity_table . $LOPS_r . $TMEC_r . $oretable_r . $MBST_r;
    return $page;
}
Beispiel #5
0
function makeWelcome()
{
    // Load the globals.
    global $VERSION;
    global $SITENAME;
    global $IGB;
    global $IGB_VISUAL;
    global $MySelf;
    global $DB;
    global $ValidUntil;
    /* HTML stuff */
    $page = "<h2>Welcome to {$VERSION}!</h2>";
    /* The welcome table */
    $table = new table(2, true);
    $table->addHeader(">> Welcome to {$VERSION}");
    $table->addRow();
    $table->addCol("Logged in as:", array("bold" => true, "align" => "right"));
    $table->addCol(ucfirst($MySelf->getUsername()));
    $table->addRow();
    $table->addCol("Registered Rank:", array("bold" => true, "align" => "right"));
    $table->addCol($MySelf->getRankName());
    $table->addRow();
    $table->addCol("Latest login:"******"bold" => true, "align" => "right"));
    if ($MySelf->getLastlogin() < 1) {
        $table->addCol("This is your very first login! Welcome!");
    } else {
        $table->addCol(date("r", $MySelf->getLastlogin()));
    }
    $table->addRow();
    $table->addCol("Your account:", array("bold" => true, "align" => "right"));
    $table->addCol(number_format(getCredits($MySelf->getID()), 2) . " ISK");
    $table->addRow();
    $table->addCol("Your profile:", array("bold" => true, "align" => "right"));
    $table->addCol(makeProfileLink($MySelf->getID()));
    global $BLESSED;
    if ($BLESSED) {
        $table->addRow("#330000");
        $table->addCol("Installation Blessed!", array("bold" => true, "align" => "right"));
        $table->addCol("It is not affected by expiration. It runs with the highest priority on the server and all limitations have been lifted.");
    }
    // Set the filename to the announce textfile.
    $announceFile = "/path/to/your/announce/txt.file";
    // Check its existance...
    if (file_exists($announceFile)) {
        // Then load it.
        $globalAnnounce = file_get_contents($announceFile);
    }
    // Only display contents if more than X characters long.
    if (strlen($globalAnnounce) > 10) {
        // Create announcement table...
        $announceTable = new table(1, true);
        $announceTable->addHeader(">>> Important hosting information");
        $announceTable->addRow();
        $announceTable->addCol("{$globalAnnounce}");
        // ... and add it to the page.
        $page .= $announceTable->flush();
    }
    $page .= $table->flush();
    /* Show failed Logins to admins. */
    if ($MySelf->isAdmin()) {
        $page .= showFailedLogins("15");
    } else {
        $page .= showFailedLogins("10", $MySelf->getUsername());
    }
    /* permissions table */
    $permsTable = new table(1, true);
    $permsTable->addHeader(">> Your permissions");
    // Permissions matrix
    $perms = array("canLogin" => "log in.", "canJoinRun" => "join mining operations.", "canCreateRun" => "create new mining operations.", "canCloseRun" => "close mining operations.", "canDeleteRun" => "delete mining operations.", "canAddHaul" => "haul to mining operations.", "canSeeEvents" => "view scheduled events.", "canEditEvents" => "add and delete scheduled events.", "canChangePwd" => "change your own password.", "canChangeEmail" => "change your own email.", "canChangeOre" => "manage ore prices and enable/disable them.", "canAddUser" => "add new accounts.", "canSeeUsers" => "see other accounts.", "canDeleteUser" => "delete other accounts.", "canEditRank" => "edit other peoples ranks.", "canManageUser" => "grant and take permissions.", "isAccountant" => "manage the corporation wallet and authorize payments.", "isOfficial" => "create official mining runs (with payout).");
    $permDS = $DB->getAssoc("SELECT * FROM users WHERE id='" . $MySelf->getID() . "' AND deleted='0'");
    $keys = array_keys($perms);
    foreach ($keys as $key) {
        if ($permDS[$MySelf->getID()][$key] == 1) {
            $permsTable->addRow();
            $permsTable->addCol("You are allowed to " . $perms[$key]);
        }
    }
    $permsTable->addHeader("If you believe your permissions are faulty, consult your CEO immediatly.");
    // Show the balance
    $balance = getTransactions($MySelf->getID());
    $logins = getLogins($MySelf->getID());
    $page .= "<br>" . $balance . "<br>" . $permsTable->flush() . "<br>" . $logins;
    // .. then return it.
    return $page;
}
Beispiel #6
0
// Row: Mining Run ID
$general_info->addRow();
$general_info->addCol("Mining ID:", $common_mode);
$general_info->addCol(str_pad($row['id'], 5, "0", STR_PAD_LEFT));
// Row: Is official run?
$general_info->addRow();
$general_info->addCol("This run is official:", $common_mode);
$general_info->addCol(yesno($row['isOfficial'], true));
// Row: Op Type
$general_info->addRow();
$general_info->addCol("Op Type:", $common_mode);
$general_info->addCol($row['optype'] == "" ? "Standard" : $row['optype']);
// Row: Supervisor Name
$general_info->addRow();
$general_info->addCol("Supervisor:", $common_mode);
$general_info->addCol(makeProfileLink($row['supervisor']));
// Row: Taxes
$general_info->addRow();
$general_info->addCol("Corp Taxes:", $common_mode);
$general_info->addCol($row['corpkeeps'] . ".0%");
// Row: Starttime
$general_info->addRow();
$general_info->addCol("Starttime:", $common_mode);
$general_info->addCol(date("d.m.y H:i", $row['starttime']));
// Row: Endtime
if ($row['endtime'] == "") {
    // Run is still open.
    $endtime = "ACTIVE";
    $general_info->addRow();
    $general_info->addCol("Endtime:", $common_mode);
    // Row: Endtime
Beispiel #7
0
  * Now that we know that there was at least ONE user who is active we can
  * assemble a join and part log.
  */
 $partlog_info = new table(7, true);
 $partlog_info->addHeader(">> Attendance Log");
 $partlog_info->addRow("#080822");
 $partlog_info->addCol("Pilot", array("bold" => true));
 $partlog_info->addCol("Joined", array("bold" => true));
 $partlog_info->addCol("Parted", array("bold" => true));
 $partlog_info->addCol("Active Time", array("bold" => true));
 $partlog_info->addCol("State", array("bold" => true));
 $partlog_info->addCol("Shiptype", array("bold" => true));
 $partlog_info->addCol("Notes", array("bold" => true));
 while ($join = $joinlog->fetchRow()) {
     $partlog_info->addRow();
     $partlog_info->addCol(makeProfileLink($join[userid]));
     if ($TIMEMARK >= $join[joined]) {
         $partlog_info->addCol(date("H:i:s", $join[joined]));
         if ("{$join['parted']}" != "") {
             $partlog_info->addCol(date("H:i:s", $join[parted]));
             $partlog_info->addCol(numberToString($join[parted] - $join[joined]));
             $partlog_info->addCol("<font color=\"#ff0000\">INACTIVE</font>");
         } else {
             $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");