function leaveRun() { // Access the globals. global $DB; global $TIMEMARK; global $MySelf; $runid = $_GET[id]; $userid = $MySelf->getID(); // Are we actually still in this run? if (userInRun($userid, $runid) == "none") { makeNotice("You can not leave a run you are currently not a part of.", "warning", "Not you run.", "index.php?action=show&id={$runid}", "[cancel]"); } // Is $runid truly an integer? numericCheck($runid); // Oh yeah? if (runIsLocked($runid)) { confirm("Do you really want to leave mining operation #{$runid} ?<br><br>Careful: This operation has been locked by " . runSupervisor($runid, true) . ". You can not rejoin the operation unless its unlocked again."); } else { confirm("Do you really want to leave mining operation #{$runid} ?"); } // Did the run start yet? If not, delete the request. $runStart = $DB->getCol("SELECT starttime FROM runs WHERE id='{$runid}' LIMIT 1"); if ($TIMEMARK < $runStart[0]) { // Event not started yet. Delete. $DB->query("DELETE FROM joinups WHERE run='{$runid}' AND userid='{$userid}'"); } else { // Event started, just mark inactive. $DB->query("update joinups set parted = '{$TIMEMARK}' where run = '{$runid}' and userid = '{$userid}' and parted IS NULL"); } makeNotice("You have left the run.", "notice", "You left the Op.", "index.php?action=show&id={$runid}", "[OK]"); }
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]"); } } }
function joinRun() { // Access the globals. global $DB; global $TIMEMARK; global $MySelf; $runid = (int) $_GET[id]; $userid = $MySelf->GetID(); // Are we allowed to join runs? if (!$MySelf->canJoinRun()) { makeNotice("You are not allowed to join mining operations. Please ask your CEO to unblock your account.", "error", "Forbidden"); } // Is $runid truly an integer? numericCheck($runid); // Is the run still open? if (!miningRunOpen($runid)) { makeNotice("This mining operation has been closed!", "warning", "Can not join", "index.php?action=show&id={$runid}"); } // Are we banned from the run? $State = $DB->getCol("SELECT status FROM joinups WHERE run='{$runid}' and userid='" . $MySelf->getID() . "'ORDER BY id DESC LIMIT 1"); $State = $State[0]; switch ($State) { case "2": // We have been kicked. $kicked = true; break; case "3": // We have been banned! if (runSupervisor($runid) == $MySelf->getUsername() || $MySelf->isOfficial()) { $banned = "You have been banned from this operation but your rank overrides this block."; } else { makeNotice("You have been banned from this operation. You can not rejoin it.", "warning", "You are banned.", "index.php?action=list", "[cancel]"); } break; } // Is the run locked? if (runIsLocked($runid)) { makeNotice("You can not join this run as this run has been locked by " . runSupervisor($runid) . ".", "notice", "Mining operation locked", "index.php?action=show&id={$runid}", "[Cancel]"); } // Join with shiptype. if (!$_GET['confirmed-ship']) { $table = new table(1, true); $table->addHeader(">> Join an Operation"); // If we have been kicked, inform the user. if ($kicked) { $table->addRow("#880000"); $table->addCol("Warning: You have been recently kicked. Please check if you are allowed to rejoin to avoid a ban."); } // If we are banned by an official, inform the user. if ($banned) { $table->addRow("#880000"); $table->addCol($banned); } $table->addRow(); $table->addCol($form . "Join the Operation in " . ucfirst(getLocationOfRun($runid)) . "."); $table->addRow(); $table->addCol("You have requested to join mining operation #{$runid}. Please choose the shipclass " . "you are going to join up with."); $table->addRow(); $table->addCol("Shiptype: " . $hiddenstuff . joinAs(), array("align" => "center")); $table->addRow("#444455"); $table->addCol("<input type=\"submit\" name=\"submit\" value=\"Join mining operation\">" . $form_end, array("align" => "center")); $page = "<h2>Join an Operation.</h2>"; $page .= "<form action=\"index.php\" method=\"GET\">"; $page .= "<input type=\"hidden\" name=\"id\" value=\"{$runid}\">"; $page .= "<input type=\"hidden\" name=\"confirmed-ship\" value=\"true\">"; $page .= "<input type=\"hidden\" name=\"confirmed\" value=\"true\">"; $page .= "<input type=\"hidden\" name=\"multiple\" value=\"true\">"; $page .= "<input type=\"hidden\" name=\"action\" value=\"joinrun\">"; $page .= $table->flush(); $page .= "</form>"; return $page; } // Sanitize the Shiptype. global $SHIPTYPES; $ShiptypesCount = count($SHIPTYPES); if (!numericCheck($_GET[shiptype], 0, $ShiptypesCount)) { makeNotice("The shiptype you tried to join up with is invalid, please go back, and try again.", "warning", "Shiptype invalid!", "index.php?action=show&id={$_GET['id']}"); } else { $shiptype = $_GET[shiptype]; } // Warn the user if he is already in another run. $joinedothers = $DB->query("select run from joinups where userid='{$userid}' and parted IS NULL order by run"); // And check for that just now. if ($joinedothers->numRows() > 0) { confirm("You joined another mining operation already!<br>Are you sure you want to join multiple runs at the same time?"); } // Get the correct time to join (in case event hasnt started yet) $startOfRun = $DB->getCol("SELECT starttime FROM runs WHERE id='{$runid}' LIMIT 1"); if ($startOfRun[0] > $TIMEMARK) { $time = $startOfRun[0]; } else { $time = $TIMEMARK; } // Dont allow him to join the same mining run twice. if (userInRun($MySelf->getID(), "{$runid}") == "none") { // Mark user as joined. $DB->query("insert into joinups (userid, run, joined, shiptype) values (?,?,?,?)", array("{$userid}", "{$runid}", "{$time}", "{$shiptype}")); // Forward user to his joined run. makeNotice("You have joined the Mining Operation.", "notice", "Joining confirmed", "index.php?action=show&id={$id}"); } else { // Hes already in that run. makeNotice("You are already in that mining run!", "notice", "Joinup not confirmed", "index.php?action=show&id={$id}"); } }
function makeMenu($page = false) { // We need some globals. global $SITENAME; global $IGB; global $MySelf; global $TIMEMARK; global $UPDATE; global $IGB_VISUAL; $mining_AddHaul = ""; $mining_canTimer = ""; $mining_addOp = ""; $admin_addUser = ""; $admin_Ore = ""; $admin_Ships = ""; $admin_viewUser = ""; $events_add = ""; $events_view = ""; $operationsModule = ""; $eventsModule = ""; $lottoModule = ""; $adminModule = ""; $pref_emailValid = ""; /* * Mining related Menues. */ // Create Run if ($MySelf->canCreateRun()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $mining_addOp = "[<a href=\"index.php?action=newrun\">Add Op</a>]"; } else { // Using a real browser. $mining_addOp = "<a class='menu' href=\"index.php?action=newrun\">> Add Op</a>"; } } // Add Haul if ($MySelf->canAddHaul() && userInRun($MySelf->getID())) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $mining_AddHaul = "[<a href=\"index.php?action=addhaul\">Add Haul</a>]"; } else { // Using a real browser. $mining_AddHaul = "<a class='menu' href=\"index.php?action=addhaul\">> Add Haul</a>"; } } // See all ops link. if ($IGB && $IGB_VISUAL) { $mining_AllOps = "[<a href=\"index.php?action=list\">List Ops</a>]"; } else { $mining_AllOps = "<a class='menu' href=\"index.php?action=list\">> List Ops</a>"; } // Ore Quotes if ($IGB && $IGB_VISUAL) { $mining_oreQuotes = "[<a href=\"index.php?action=showorevalue\">Quotes</a>]"; } else { $mining_oreQuotes = "<a class='menu' href=\"index.php?action=showorevalue\">> Quotes</a>"; } // Can timer link if (getConfig("cargocontainer")) { if ($IGB && $IGB_VISUAL) { $mining_canTimer = "[<a href=\"index.php?action=cans\">Can Timer</a>]"; } else { $mining_canTimer = "<a class='menu' href=\"index.php?action=cans\">> Can Timer</a>"; } } // Statistics if ($IGB && $IGB_VISUAL) { $mining_stats = "[<a href=\"index.php?action=globstats\">Statistics</a>]"; } else { $mining_stats = "<a class='menu' href=\"index.php?action=globstats\">> Statistics</a>"; } // Hierarchy if ($IGB && $IGB_VISUAL) { $mining_hier = "[<a href=\"index.php?action=hierarchy\">Hierarchy</a>]"; } else { $mining_hier = "<a class='menu' href=\"index.php?action=hierarchy\">> Hierarchy</a>"; } // Ship Values if ($IGB && $IGB_VISUAL) { $mining_shipValues = "[<a href=\"index.php?action=showshipvalue\">Ship Values</a>]"; } else { $mining_shipValues = "<a class='menu' href=\"index.php?action=showshipvalue\">> Ship Values</a>"; } // Assemble the mining Module link. if ($IGB && $IGB_VISUAL) { $miningModule = $mining_AllOps . " " . $mining_AddHaul . " " . $mining_canTimer . " " . $mining_oreQuotes . " " . $mining_ShipValues . " " . $mining_addOp . " " . $mining_stats . ""; } else { $miningModule = "<div>"; $miningModule .= "<img src=\"./images/m-mining.png\">"; $miningModule .= $mining_AllOps; $miningModule .= $mining_AddHaul; $miningModule .= $mining_canTimer; $miningModule .= $mining_oreQuotes; $miningModule .= $mining_shipValues; $miningModule .= $mining_addOp; $miningModule .= $mining_stats; $miningModule .= $mining_hier; $miningModule .= "</div><div class='clear'></div>"; } /* * Preferences Stuff */ // Is our Email validated? if (!$MySelf->getEmailvalid()) { // No, its not! if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $pref_emailValid = "[<a href=\"index.php?action=revalidate\">confirm email</a>]"; } else { // Using a real browser. $pref_emailValid = "<a class='menu' href=\"index.php?action=revalidate\">> Validate Email</a>"; } } if ($IGB && $IGB_VISUAL) { $pref_Pref = "[<a href=\"index.php?action=preferences\">Preferences</a>]"; } else { $pref_Pref = "<a class='menu' href=\"index.php?action=preferences\">> Preferences</a>"; } if ($IGB && $IGB_VISUAL) { $pref_Prof = "[<a href=\"index.php?action=profile&id=" . $MySelf->getID() . "\">Profile</a>]"; } else { $pref_Prof = "<a class='menu' href=\"index.php?action=profile&id=" . $MySelf->getID() . "\">> Profile</a>"; } if ($IGB && $IGB_VISUAL) { $pref_Style = "[<a href=\"index.php?action=profile&id=" . $MySelf->getID() . "\">Style</a>]"; } else { $pref_Style = "<a class='menu' href=\"index.php?action=style&id=" . $MySelf->getID() . "\">> Style</a>"; } // Assemble the Preferences module if ($IGB && $IGB_VISUAL) { $prefModule = $pref_Pref . " " . $pref_Prof . " " . $pref_emailValid . ""; } else { $prefModule = "<div>"; $prefModule .= "<img border=\"0\" src=\"images/m-preferences.png\">"; $prefModule .= $pref_Pref; $prefModule .= $pref_Prof; $prefModule .= $pref_emailValid; $prefModule .= $pref_Style; $prefModule .= "</div><div class='clear'></div>"; } /* * Logout Stuff */ if ($IGB && $IGB_VISUAL) { // Are we IGB && Passwordless login? if (getConfig("trustSetting") == 2 && $IGB) { $logoutModule = "<i>Can not logout due to fast login.</i>"; } else { $logoutModule = "[<a href=\"index.php?auth=logout\">Logout</a>]"; } } else { if (getConfig("trustSetting") == 2 && $IGB) { $logoutModule = ""; } else { $logoutModule = "<div>"; $logoutModule .= "<img src=\"images/m-logout.png\">"; $logoutModule .= "<a class='menu' href=\"index.php?action=switch\">> Switch Character</a>"; $logoutModule .= "<a class='menu' href=\"index.php?auth=logout\">> Logout</a>"; $logoutModule .= "</div><div class='clear'></div>"; } } /* * Administrative Stuff */ // Are we allowed to change the ore value, edit it? if ($MySelf->canChangeOre()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_Ore = "[<a href=\"index.php?action=changeow\">Edit Items</a>]"; } else { // Using a real browser. $admin_Ore = "<a class='menu' href=\"index.php?action=changeow\">> Edit Items</a>"; } } // Are we allowed to change the ship value, edit it? if ($MySelf->canChangeOre()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_Ships = "[<a href=\"index.php?action=changesv\">Edit Ships</a>]"; } else { // Using a real browser. $admin_Ships = "<a class='menu' href=\"index.php?action=changesv\">> Edit Ships</a>"; } } // Site configuration if ($MySelf->isAdmin()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_site = "[<a href=\"index.php?action=configuration\">Site Settings</a>]"; } else { // Using a real browser. $admin_site = "<a class='menu' href=\"index.php?action=configuration\">> Site Settings</a>"; } } // Site Maintenance if ($MySelf->isAdmin()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_maint = "[<a href=\"index.php?action=maintenance\">Maintenance</a>]"; } else { // Using a real browser. $admin_maint = "<a class='menu' href=\"index.php?action=maintenance\">> Maintenance</a>"; } } // Manage Ranks if ($MySelf->canEditRank()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_ranks = "[<a href=\"index.php?action=showranks\">Edit Ranks</a>]"; } else { // Using a real browser. $admin_ranks = "<a class='menu' href=\"index.php?action=showranks\">> Edit Ranks</a>"; } } // Are we allowed to view Users? if ($MySelf->canSeeUsers()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_viewUser = "******"index.php?action=editusers\">List Users</a>]"; } else { // Using a real browser. $admin_viewUser = "******"index.php?action=editusers\">> List Users</a>"; } } // Are we allowed to if ($MySelf->canAddUser()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $admin_addUser = "******"index.php?action=newuser\">Add User</a>]"; } else { // Using a real browser. $admin_addUser = "******"index.php?action=newuser\">> Add User</a>"; } } // Assemble the module. if ($admin_addUser || $admin_Ore || $admin_Ships || $admin_viewUser) { if ($IGB && $IGB_VISUAL) { $adminModule = $admin_site . " " . $admin_ranks . " " . $admin_viewUser . " " . $admin_addUser . " " . $admin_Ore . " " . $admin_Ships . ""; } else { $adminModule = "<div>"; $adminModule .= "<img src=\"images/m-administration.png\">"; $adminModule .= $admin_site; $adminModule .= $admin_maint; $adminModule .= $admin_viewUser; $adminModule .= $admin_addUser; $adminModule .= $admin_ranks; $adminModule .= $admin_Ore; $adminModule .= $admin_Ships; $adminModule .= "</div><div class='clear'></div>"; } } /* * Events Stuff */ if (getConfig("events")) { // Are we allowed to see events? if ($MySelf->canSeeEvents()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $events_view = "[<a href=\"index.php?action=showevents\">Schedule</a>]"; } else { // Using a real browser. $events_view = "<a class='menu' href=\"index.php?action=showevents\">> Schedule</a>"; } } // Are we allowed to add events? if ($MySelf->canEditEvents()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $events_add = "[<a href=\"index.php?action=addevent\">Add Event</a>]"; } else { // Using a real browser. $events_add = "<a class='menu' href=\"index.php?action=addevent\">> Add Event</a>"; } } } // El grande Online Thingy if ($IGB && $IGB_VISUAL) { $events_OnlineTimer = "[<a href=\"index.php?action=onlinetime\">Online Time</a>]"; } else { $events_OnlineTimer = "<a class='menu' href=\"index.php?action=onlinetime\">> Online Time</a>"; } // Assemblte Events module if ($events_add || $events_view) { if ($IGB && $IGB_VISUAL) { $eventsModule = $events_view . " " . $events_add . " " . $events_OnlineTimer . ""; } else { $eventsModule = "<div>"; $eventsModule .= "<img src=\"./images/m-events.png\">"; $eventsModule .= $events_view; $eventsModule .= $events_add; $eventsModule .= $events_OnlineTimer; $eventsModule .= "</div><div class='clear'></div>"; } } /* * Wallet stuff */ if ($IGB && $IGB_VISUAL) { $walletModule = "[<a href=\"index.php?action=manageWallet\">Manage Wallet</a>]"; if ($MySelf->isAccountant()) { $walletModule .= " [<a href=\"index.php?action=payout\">Manage Payouts</a>]"; } } else { $walletModule = "<div><img src=\"./images/wallet.png\">"; $walletModule .= "<a class='menu' href=\"index.php?action=manageWallet\">> Manage Wallet</a>"; if ($MySelf->isAccountant()) { $walletModule .= "<a class='menu' href=\"index.php?action=payout\">> Manage Payouts</a>"; } $walletModule .= "</div><div class='clear'></div>"; } /* * Lotto related things. */ $LOTTO = getConfig("Lotto"); if ($LOTTO) { // Are we allowed to play Lotto? if ($MySelf->canPlayLotto()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $lotto_Play = "[<a href=\"index.php?action=lotto\">Lotto</a>]"; } else { // Using a real browser. $lotto_Play = "<a class='menu' href=\"index.php?action=lotto\">> Lotto</a>"; } } if ($MySelf->isLottoOfficial()) { // Yeah we are allowed to do this. if ($IGB && $IGB_VISUAL) { // Browswing in the iGB. $lotto_Admin = "[<a href=\"index.php?action=editLotto\">Admin Lotto</a>]"; } else { // Using a real browser. $lotto_Admin = "<a class='menu' href=\"index.php?action=editLotto\">> Admin Lotto</a>"; } } if ($lotto_Admin || $lotto_Play) { // Assemble the Lotto module. if ($IGB && $IGB_VISUAL) { $lottoModule = $lotto_Play . " " . $lotto_Admin . ""; } else { $lottoModule = "<div>"; $lottoModule .= "<img src=\"./images/m-lotto.png\">"; $lottoModule .= $lotto_Play; $lottoModule .= $lotto_Admin; $lottoModule .= "</div><div class='clear'></div>"; } } } /* * Open operations Module */ if ($IGB && $IGB_VISUAL) { // tough luck. } else { $runs = sidebarOpenRuns(); if ($runs) { $operationsModule = "<div>"; $operationsModule .= "<img src=\"./images/m-runs-in-progress.png\">"; $operationsModule .= sidebarOpenRuns() . ""; $operationsModule .= "</div><div class='clear'></div>"; } } /* * Show the time. */ $clockScript = "<script>\n\tvar eveTime = new Date({$TIMEMARK}*1000);\n\teveTime.setHours(eveTime.getHours()-3);\n\tvar eveTimeRefreshRate = 20;// seconds\n\tvar eveTimeZone = '';\n\tfunction updateTime(){\n\t\teveTime = new Date(eveTime.getTime()+(eveTimeRefreshRate * 1000));\n\t\tminutes = eveTime.getMinutes();\n\t\tif(minutes.length < 2){\n\t\t\tminutes = '0' + minutes;\n\t\t}\n\t\thours = eveTime.getHours();\n\t\tif(hours.length < 2){\n\t\t\thours = '0' + hours;\n\t\t}\n\t\t\$('#eveTime').html(hours + ':' + minutes + ' EvE');\n\t\tsetTimeout('updateTime()', eveTimeRefreshRate * 1000);\n\t}\n\tsetTimeout('updateTime()', eveTimeRefreshRate * 1000);\n\t\n\t\$('#menu img').click(function() {\n\t \$(this).siblings().toggle('slow');\n\t});\n\t\n\t\n\t</script>"; $clock = "<b><hr><center id='eveTime'>" . date("H:i", $TIMEMARK) . " EvE</center><hr>{$clockScript}</b>"; /* * Assemble the module-block. */ if ($IGB && $IGB_VISUAL) { global $VERSION; $menu = new table(2, true, "width=\"99%\""); // Add the beta warning for the IGB global $IS_BETA; if ($IS_BETA) { $BETAWARNING = "<font color=\"#ff0000\"> - <b>This is a BETA release! Watch out for bugs!</b></font>"; } // Add the Version bar. $menu->addHeader($VERSION . $BETAWARNING); // Create the mining Menu. $menu->addRow(); $menu->addCol("Mining >>", array("align" => "right", "bold" => "true")); $menu->addCol($miningModule); if ($events_add || $events_view) { $menu->addRow(); $menu->addCol("Events >>", array("align" => "right", "bold" => "true")); $menu->addCol($eventsModule); } // Wallet Menu. $menu->addRow(); $menu->addCol("Wallet >>", array("align" => "right", "bold" => "true")); $menu->addCol($walletModule); // Preferences. $menu->addRow(); $menu->addCol("Preferences >>", array("align" => "right", "bold" => "true")); $menu->addCol($prefModule); // Ore managagement. if ($admin_Ore || $admin_viewUser || $admin_addUser) { $menu->addRow(); $menu->addCol("Admin >>", array("align" => "right", "bold" => "true")); $menu->addCol($adminModule); } // Logout. $menu->addRow(); $menu->addCol("Exit >>", array("align" => "right", "bold" => "true")); $menu->addcol($logoutModule); $menu->addHeader("Logged in as <font color=\"00aa00\">%%USERNAME%%</font>, Rank: <font color=\"00aa00\">%%RANK%%</font>, {$DIV_MENU} Credits: <font color=\"00aa00\">%%CREDITS%%</font>."); $modules = $menu->flush(); } else { $modules = $UPDATE . $miningModule . $operationsModule . $walletModule . $eventsModule . $lottoModule . $prefModule . $adminModule . $logoutModule . $clock; } // And return it all. if ($page) { return str_replace("%%MENU%%", $modules, $page); } else { return $modules; } }
function addHaul() { // Globals. global $DB; global $DBORE; global $ORENAME_STR; global $TIMEMARK; global $MySelf; global $STATIC_DB; // Some more settings we need $userID = $MySelf->getID(); // is the POST[id] truly a number? numericCheck($_POST[id]); $ID = sanitize($_POST[id]); // Are we allowed to haul? if (!$MySelf->canAddHaul()) { makeNotice("You are not allowed to haul to runs!", "error", "forbidden"); } // Is the run still open? if (!miningRunOpen($ID)) { makeNotice("This mining operation has been closed!", "warning", "Can not join"); } // Is the user in the run? if (userInRun($MySelf->getUsername(), "{$ID}") == "none") { makeNotice("You need to join that run before you can haul to it!", "error", "Need to join", "index.php?action=show&id={$ID}"); } // Mr. Proper $location = sanitize($_POST[location]); $location2 = sanitize($_POST[location2]); // Use manual input, if given. if ($location2) { $location = $location2; } // We dont accept empty locations. if ($location == "") { makeNotice("You need to supply a target location!", "error", "Commit haul denied.", "index.php?action=addhaul", "[Cancel]"); } // Get the current ore amount for the selected run. $results = $DB->query("select * from runs where id='{$ID}' limit 1"); /* Even tho its only one row (result) we are going to loop * through it. Just to be on the safe side. While we are at it, * we add the submited ore amount to the already stored amount. * * Note: I explicitly *allow* negative amounts to be "added", in * case the hauler got destroyed on his way back. */ /* while ($row = $results->fetchRow()) { foreach ($DBORE as $ORE) { $newcount = $row[$ORE] + $_POST[$ORE]; $DB->query("update runs set $ORE = '" . $newcount . "' where id = '$ID'"); } } */ /* * But wait! There is more! * Someone hauled our ore, lets record that in the * hauled database, along with a timestamp and whatever * he hauled. */ // Lets create the raw entry fist. $OPTYPE = $DB->getCol("select optype from runs where id = {$ID}"); $OPTYPE = $OPTYPE[0]; // Now loop through all the ore-types. foreach ($_POST as $ORE => $QTY) { $oreResult = $DB->query("select count(typeName) as v from {$STATIC_DB}.invTypes where replace(replace(typeName,' ',''),'-','') = '{$ORE}'"); // Check the input, and insert it! $validOre = $oreResult->fetchRow(); if ($validOre[v] > 0 && !empty($QTY) && is_numeric($QTY) && $QTY > 0) { // Is that ore-type actually enabled? if (getOreSettings($ORE, $OPTYPE) == 0 && $OPTYPE != "Shopping") { makeNotice("Your corporation has globally disabled the mining and hauling of {$ORE}. Please ask your CEO to re-enable {$ORE} globally.", "error", "{$ORE} disabled!", "index.php?action=show&id={$ID}", "[back]"); } else { if ($OPTYPE == "Shopping") { $QTY = $QTY * -1; } } // Now insert the database. $DB->query("insert into hauled (miningrun, hauler, time, location, Item, Quantity) values (?,?,?,?,?,?)", array("{$ID}", "{$userID}", "{$TIMEMARK}", "{$location}", "{$ORE}", "{$QTY}")); //$DB->query("UPDATE hauled SET Item = '$ORE', Quantity = '$_POST[$ORE]' WHERE time ='$TIMEMARK' and hauler = '$userID'"); $changed = $changed + $DB->affectedRows(); } } // Delete the haul again if nothing (useful) was entered. if ($changed < 1) { makeNotice("No valid Ore information found in your query, aborted.", "warning", "Haul not accepted", "index.php?action=show&id={$ID}", "[cancel]"); } /* * All done. */ makeNotice("Your hauling information has been entered into the database.", "notice", "Hauling recorded.", "index.php?action=show&id={$ID}"); }
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Inside: * Database business ONLY */ // We have to SELECT the most fitting ID. This can be done in three ways. if ("{$_GET['id']}" >= 0 && is_numeric($_GET['id'])) { // Way Nr. 1: The user specified an ID. $ID = $_GET['id']; } else { // Way Nr. 2: The user is in a Mining run, but has not given us an ID. Use the joined MiningOP ID. $ID = userInRun($userID, "check"); if (!$ID) { // Way Nr. 2: The user is not in a run and has not given us an ID. Select the most up to date, not-yet-closed OP. $results = $DB->query("SELECT * FROM runs WHERE endtime is NULL order by id desc limit 1"); if ($results->numRows() == "0") { // Total failure: No operations in Database! MakeNotice("There are no mining operations in the database! You have to create an operation prior to join.", "warning", "Not joined"); } $getid = $results->fetchRow(); $ID = $getid['run']; } } // Now lets fetch the Dataset. $select = ""; $r = $DB->query("select item, sum(Quantity) as total from hauled where miningrun = '{$ID}' group by item having sum(Quantity) <> 0"); while ($r2 = $r->fetchRow()) {
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>"; }
if ($totalISK > 0) { $closed = $DB->getCol("SELECT endtime FROM runs WHERE id='" . $ID . "' LIMIT 1"); if ($closed[0] < 1) { $general_info->addRow(); $general_info->addCol("Total ISK so far:"); $general_info->addCol(number_format($totalISK, 2) . " ISK"); $general_info->addRow(); $general_info->addCol("ISK per hour:"); $general_info->addCol(number_format($totalISK / ($secRunTime / 60) * 60) . " ISK"); } } // Row: Actions $general_info->addRow(); $general_info->addCol("Actions:", $common_mode); // Lets switch wether the user is currently in this run or not. $jointime = userInRun($MySelf->getUsername(), $ID); if ($jointime == "none") { // Is NOT in this run, give option to join. if (!runIsLocked($ID)) { if ($MySelf->canJoinRun()) { $join = "[<a href=\"index.php?action=joinrun&id={$ID}\">Join this OP</a>]"; } else { $join = "You are not allowed to join operations."; } } else { $join = ucfirst(runSupervisor($ID)) . " has locked this run."; } } else { // User IS in this run. // Are we allowed to haul? if ($row['endtime'] == "" && $MySelf->canAddHaul()) {
function addCanToDatabase() { // We need some more globals. global $DB; global $TIMEMARK; global $MySelf; global $PREFS; // Change of prefs? switch ($_POST[canprefs]) { case "0": $PREFS->setPref("CanNaming", "0"); break; case "1": $PREFS->setPref("CanNaming", "1"); break; case "2": $PREFS->setPref("CanNaming", "2"); break; } if ($_POST[forRun]) { $PREFS->setPref("CanForRun", "1"); } else { $PREFS->setPref("CanForRun", "0"); } // Save the modified Preferences. $PREFS->storePrefs(); // Wash the incoming stuff. $cantag = sanitize("{$_POST['cantag']}"); $location = sanitize("{$_POST['location']}"); $location2 = sanitize("{$_POST['location2']}"); $droptime = date("U", strtotime(sanitize("{$_POST['droptime']}"))); $id = $MySelf->getID(); // If user entered special location, use that. if ($location2 != "") { $location = $location2; } // 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']}"); $droptime = humanTime("toUnix", $myTime); // is the time valid? if (!$droptime) { makeNotice("Invalid time supplied!", "error", "Invalid Time!"); } // We got a name? if (empty($cantag)) { makeNotice("You need to supply a name for your can!", "error", "Can not added", "index.php?action=cans", "[cancel]"); } // We got a location? if (empty($location)) { makeNotice("You need to supply the location of your can!", "error", "Can not added", "index.php?action=cans", "[cancel]"); } // Can for mining operation? $myRun = userInRun($MySelf->getID()); if ($_POST[forRun] && $myRun) { $forrun = $myRun; } else { $forrun = -1; } // Insert the can into the database. $P = $DB->query("INSERT INTO cans (pilot, location, droptime, name, miningrun) VALUES (?,?,?,?,?)", array("{$id}", "{$location}", "{$droptime}", "{$cantag}", $forrun)); // Did we encounter an error? if ($DB->affectedRows() == 1) { $to_old = $TIMEMARK - 7200; $DB->query("DELETE FROM cans WHERE droptime < {$to_old}"); if ($DB->affectedRows() > 0) { makeNotice("Mining can added. I also popped " . $DB->affectedRows() . " Cans, " . "which were older than 2 hours.", "notice", "Old cans popped", "index.php?action=cans", "[ok]"); } header("Location: index.php?action=cans"); } else { makeNotice("Unable to create can in database:<br>" . $P->getMessage(), "error", "Internal error"); } }
$can_information = new table(8, true); $modes = array("bold" => true); $can_information->addHeader(">> Cargo containers in space, belonging to this Op"); if ($CansDS->numRows() > 0) { $TTL = getConfig("canLifeTime") * 60; // Table headers. $can_information->addRow("#060622"); $can_information->addCol("Name of Can", $modes); $can_information->addCol("Owner of Can", $modes); $can_information->addCol("Location of Can", $modes); $can_information->addCol("Droptime", $modes); $can_information->addCol("est. Poptime", $modes); $can_information->addCol("Time left", $modes); $can_information->addCol("Can is full", $modes); // Are we allowed to pop cans? if (userInRun($MySelf->getID(), $row[id]) && $MySelf->canAddHaul()) { $iCanPopCans = true; } // We are. Lets add a "pop can" column. if ($iCanPopCans) { $can_information->addCol("Pop can", $modes); } else { $can_information->addCol("", $modes); } // Loop through the cans. while ($can = $CansDS->fetchRow()) { // Calculate droptimes, poptimes et all. $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);
function addhaulpage() { // Needed globals global $DB; global $ORENAMES; global $DBORE; global $MySelf; // Some needed variables $USER = $MySelf->getID(); $ORESETTINGS = getOreSettings(); // Get the run the user is on. if (!empty($_GET[id])) { // We supplied our own ID. $ID = sanitize((int) $_GET[id]); numericCheck($_GET[id], 0); } else { // No idd supplied, get our own :P $ID = userInRun($MySelf->getID()); } // No ID found. if (!$ID) { makeNotice("Either you have selected an invalid run, you have not joined that run or it is no longer open.", "warning", "Unable to register your haul"); } $OPTYPE = $DB->getCol("select optype from runs where id = {$ID}"); $OPTYPE = $OPTYPE[0]; // Create the table! $haulpage = new table(2, true); $mode = array("bold" => true, "align" => "right"); $haulpage->addHeader(">> Register new Hauling"); $haulpage->addRow(); if ($OPTYPE == "Shopping") { $haulpage->addCol("Shopping for Op: #<a href=\"index.php?action=show&id={$ID}\">" . str_pad($ID, 5, "0", STR_PAD_LEFT) . "</a> Add *positive* values for purchases", array("align" => "left")); } else { $haulpage->addCol("Hauling for Op: #<a href=\"index.php?action=show&id={$ID}\">" . str_pad($ID, 5, "0", STR_PAD_LEFT) . "</a>", array("align" => "left")); } // fetch the system the haul is taking place in.. // $location = $DB->getCol("select location from runs where endtime is NULL and id='$ID' order by id desc limit 1"); // $runLocation = $location[0]; $runLocation = getLocationOfRun($ID); // make the targeted system click-able. $sytem = new solarSystem($runLocation); // Assemble a PDM with all the destinations for the current run. $locations = $DB->query("SELECT location FROM hauled WHERE miningrun='{$ID}' ORDER BY location ASC"); if ($locations->numRows()) { while ($loc = $locations->fetchRow()) { if ($loc[location] != "") { $pdmSystems[] = $loc[location]; } } } // Get the location the last haul was brought to at. $lastHaulLocation = $DB->getCol("SELECT location FROM hauled WHERE miningrun='{$ID}' AND hauler='" . $MySelf->getID() . "' ORDER BY time DESC LIMIT 1"); $lastHaulLocation = $lastHaulLocation[0]; // Get a list of neighbouring systems. $neighbouringSystems = $sytem->getNeighbouringSystems(); // Lets pick the right system. if ($lastHaulLocation) { // Use the last system stuff was hauled to. $location = $lastHaulLocation; } else { // Or, if thats empty, the system the op is in. $location = $runLocation; } if (is_array($pdmSystems)) { $Systems = array_merge($neighbouringSystems, $pdmSystems); } else { $Systems = $neighbouringSystems; } sort($Systems); // unset($pdmSystems); // unset($neighbouringSystems); // unset($loc); // unset($locations); foreach ($Systems as $s) { if ($s == $location) { $pdm .= "<option value=\"" . strtolower($s) . "\" SELECTED>" . ucfirst($s) . "</option>"; } else { $pdm .= "<option value=\"" . strtolower($s) . "\">" . ucfirst($s) . "</option>"; } } $pdm = "<select name=\"location\">" . $pdm . "</select>"; $haulpage->addCol("System hauling to: " . $pdm . " -or- <input type=\"text\" name=\"location2\" value=\"\">", array("align" => "right")); $haulpage->addRow(); $haulpage->addCol("<hr>", array("colspan" => "2")); // Now we need the sum of all ores. $totalOres = count($ORENAMES); /* // And the sum of all ENABLED ores. $totalEnabledOres = $DB->getCol("select count(name) as active from config where name LIKE '%Enabled' AND value='1'"); $totalEnabledOres = $totalEnabledOres[0]; */ /* * This is evil. We have to create an array that we fill up sorted. * It aint cheap. First, we loop through all the ore values. */ for ($p = 0; $p < $totalOres; $p++) { // Then we check each ore if it is enabled. $ORE = $DBORE[$ORENAMES[$p]]; if (getOreSettings($ORE, $OPTYPE)) { // If the ore is enabled, add it to the array. $left[] = $ORE; } else { // add to disabled-array. $disabledOres[] = $ORE; } } $totalEnabledOres = count($left); // No ores enabled? if ($totalEnabledOres == 0 && $OPTYPE != "Shopping") { makeNotice("Your CEO has disabled *all* the Oretypes. Please ask your CEO to reactivate at leat one Oretype.", "error", "No valid Oretypes!"); } $ajaxHaul = isset($_GET[ajaxHaul]); if ($ajaxHaul || $OPTYPE == "Shopping") { $haulpage->addRow(); $script = "<script>\nvar selectedItems = \"\";\nvar currentQuery;\nvar int;\nfunction lookForItem(txt){\n\tcurrentQuery = txt;\n\tclearInterval(int);\n\tif(txt.value.length>2){\n\t\tvar int=self.setInterval('execQuery()',2000);\n\t}\n}"; $script .= "\nfunction execQuery(){\n\tclearInterval(int);\n\tvar txt = currentQuery;\n\t\$.ajax({\n\t\turl: 'index.php?action=getItemList&ajax&q=' + txt.value,\n\t\tsuccess: function(data){\$('#ajaxItemList').html(data);}\n\t});\n\t\n}"; $script .= "\nfunction addItem(selection){\n\t//\$(selection).animate({background-color:yellow;});\n\tvar item = selection.innerHTML;\n\tvar dbore = selection.name;\n\t//\$(selection).animate({background-color:none;});\n\tif(selectedItems.split(',').indexOf(item) == -1 ){\n\t\tvar print = \$('#selectedItemList').html() + '<div>Add <input type=\"text\" size=\"5\" name=\"' + dbore + '\" value=\"0\">' + item + '</div>';\n\t\t\$('#selectedItemList').html(print);\n\t\tif(selectedItems.length == 0){\n\t\t\tselectedItems = item;\n\t\t} else {\n\t\t\tselectedItems += ',' + item;\n\t\t}\n\t}\n}\n</script> "; $haulpage->addCol("Search for an item:<input name='itemSearch' onkeyup='lookForItem(this)' />, then click the item name below.", array("colspan" => 2)); $haulpage->addRow(); $haulpage->addCol("<div id='selectedItemList'></div>", array("colspan" => 2)); $haulpage->addRow(); $haulpage->addCol("<div id='ajaxItemList'></div>", array("colspan" => 2)); } else { // The table is, rounded up, exactly half the size of all enabled ores. $tableLength = ceil($totalEnabledOres / 2); // Now, copy the lower second half into a new array. $right = array_slice($left, $tableLength); /* * So now we have an array of all the enabled ores. All we * need to do now, is create a nice, handsome table of it. * Loop through this array. */ for ($i = 0; $i < $tableLength; $i++) { // Fetch the right image for the ore. $ri_words = str_word_count(array_search($left[$i], $DBORE), 1); $ri_max = count($ri_words); $ri = strtolower($ri_words[$ri_max - 1]); // Add a row. $haulpage->addRow(); // left side. $haulpage->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($left[$i], $DBORE) . ".png\">" . "Add <input type=\"text\" size=\"5\" name=\"{$left[$i]}\" value=\"0\"> " . array_search($left[$i], $DBORE)); // We need an ore type (just in case of odd ore numbers) if ($right[$i] != "") { // right side. // Fetch the right image for the ore. $ri_words = str_word_count(array_search($right[$i], $DBORE), 1); $ri_max = count($ri_words); $ri = strtolower($ri_words[$ri_max - 1]); // Add the column. $haulpage->addCol("<img width=\"20\" height=\"20\" src=\"./images/ores/" . array_search($right[$i], $DBORE) . ".png\">" . "Add <input type=\"text\" size=\"5\" name=\"" . $right[$i] . "\" value=\"0\"> " . array_search($right[$i], $DBORE)); } else { // We have an odd number of ores: add empty cell. $haulpage->addCol(""); } } } /* // Print out all disabled ore types: $disabledOreCount = count($disabledOres); // add the "," between words, but not before the first one, and an "and" between the last one. for ($i = 0; $i < $disabledOreCount; $i++) { if ($disabledOreCount == $i +1) { $disabledOresText .= " and " . array_search($disabledOres[$i], $DBORE); } else if (empty ($disabledOresText)) { $disabledOresText = array_search($disabledOres[$i], $DBORE); } else { $disabledOresText .= ", " . array_search($disabledOres[$i], $DBORE); } } // Display the ore-disables-disclaimer. (Only if there are disabled oretypes.) if (!empty ($disabledOresText)) { $disabledOresText = "The following Oretypes has been disabled by the CEO: $disabledOresText."; } */ $haulpage->addRow(); $haulpage->addCol("<hr>", array("colspan" => "2")); $haulpage->addHeaderCentered("<input type=\"submit\" name=\"haul\" value=\"Commit haul to database\">"); // Render the page... $form_stuff .= "<input type=\"hidden\" value=\"check\" name=\"check\">"; $form_stuff .= "<input type=\"hidden\" value=\"addhaul\" name=\"action\">"; $form_stuff .= "<input type=\"hidden\" value=\"" . $ID . "\" name=\"id\">"; $form_stuff .= "</form>"; $html = "<h2>Submit new transport manifest (<a href='?" . $_SERVER['QUERY_STRING'] . "&ajaxHaul'>ajax</a>)</h2><form action=\"index.php\" method=\"post\">" . $haulpage->flush() . $form_stuff; /* // print out all the disabled oretypes. if (!empty ($disabledOresText)) { $page .= "<br><i>" . $disabledOresText . "</i>"; }*/ // Return the page return $script . $html . $page; }