function browser() { // Wash the incoming. numericCheck(sanitize($_GET[mode])); numericCheck(sanitize($_GET[id])); $id = $_GET[id]; $mode = $_GET[mode]; global $DB; // We differ between 0 = system (detailed), 1 = constellation and 2 = region. switch ($_GET[mode]) { case "0": $solar = new solarSystem($id); $table = $solar->makeInfoTable(); //Current Runs in System $openRuns = $DB->query("SELECT * FROM runs WHERE location = '" . $solar->getName() . "' AND endtime IS NULL ORDER BY id"); if ($openRuns->numRows() > 0) { $openRunsTable = new table(2, true); $openRunsTable->addHeader(">> Current runs in " . $solar->getName()); // We need this for a new table line. $newline = true; // Loop through all solarsystems. while ($openRun = $openRuns->fetchRow()) { // If this is a new table row, add one. if ($newline) { $openRunsTable->addRow(); $newline = false; } else { $newline = true; } // Add the information. $openRunsTable->addCol("<a href=\"index.php?action=show&id=" . $openRun[id] . "\">#" . str_pad($openRun[id], 4, "0", STR_PAD_LEFT . "</a>")); } if (!$newline) { $openRunsTable->addCol(); } $openRunsStuff = $openRunsTable->flush(); } //Past Runs in System $Runs = $DB->query("SELECT * FROM runs WHERE location = '" . $solar->getName() . "' AND endtime > 0 ORDER BY id"); if ($Runs->numRows() > 0) { $RunsTable = new table(2, true); $RunsTable->addHeader(">> Past runs in " . $solar->getName()); // We need this for a new table line. $newline = true; // Loop through all solarsystems. while ($Run = $Runs->fetchRow()) { // If this is a new table row, add one. if ($newline) { $RunsTable->addRow(); $newline = false; } else { $newline = true; } // Add the information. $RunsTable->addCol("<a href=\"index.php?action=show&id=" . $Run[id] . "\">#" . str_pad($Run[id], 4, "0", STR_PAD_LEFT . "</a>")); } if (!$newline) { $RunsTable->addCol(); } // Get the total time spent in this System. $time = $DB->getCol("SELECT SUM(endtime - starttime) FROM runs WHERE location='" . $solar->getName() . "'"); $time = numberToString($time[0]); $RunsTable->addHeaderCentered("Time spent in " . $solar->makeFancyLink() . ": " . $time); $RunsStuff = $RunsTable->flush(); } $solarStuff = $solar->makeConstellationTable(); break; } return "<h2>Solar System Information</h2>" . $table . "<br>" . $solarStuff . "<br>" . $openRunsStuff . "<br>" . $RunsStuff; }
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; }
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; }
$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]) { // Negative amount (storno) $temp .= "<font color=\"#ff0000\">" . number_format($haul[Quantity], 0) . " " . array_search($ORE, $DBORE) . "</font><br>"; }
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 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] . "\">" . " " . "<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>"; }