public function GetOutput($Db) { $Notifs = new eveApiNotifications($Db); $full_url = FULL_URL; // TODO $time_start = microtime_float(); if (!$Notifs->fetch(CHAR_ID, USER_ID, API_KEY)) { $this->Output = $Notifs->Error; return false; } $time_end = microtime_float(); $time_api = $time_end - $time_start; $this->Updated = APITime($Notifs); $this->Title = "Notifications for " . USER_NAME; if (count($Notifs->Notifications) > 0) { $this->Output .= "<span style=\"font-size:80%; font-weight: bold;\">"; if ($Notifs->unread > 0) { $this->Output .= $Notifs->unread . " unread notification" . ($Notifs->unread == 1 ? ", " : "s, "); } $this->Output .= count($Notifs->Notifications) . " notifications total<br>"; if ($Notifs->Message != "") { $this->Output .= $Notifs->Message . "<br>"; } $this->Output .= "</span>"; $idsToResolve = array(); foreach ($Notifs->Notifications as $message) { // get a list of all ids referenced if (!in_array((string) $message["senderID"], $idsToResolve)) { $idsToResolve[] = (string) $message["senderID"]; } } $ids = idlookup($Db->link, $idsToResolve); $this->Output .= "<br><table class=\"fancy notification\" style=\"font-size:83%;\" border=1>"; $this->Output .= "<tr><th>!</th><th>date</th><th>sender</th><th>type</th></tr>"; $alt = " class=\"main\""; foreach ($Notifs->Notifications as $message) { if ($alt == " class=\"main\"") { $alt = " class=\"alt\""; } else { $alt = " class=\"main\""; } $this->Output .= "<tr{$alt}>"; $this->Output .= "<td>" . ($message["read"] != 1 ? "<b>#</b>" : "") . "</td>"; $this->Output .= "<td>" . $message["sentDate"] . "</td>"; $this->Output .= "<td>" . $ids[(int) $message["senderID"]] . "</td>"; $this->Output .= "<td>" . notif_type_lookup($message["typeID"]) . "</td>"; $this->Output .= "</tr>"; } $this->Output .= "</table>"; } else { $this->Output .= "<br>Character has no recent notifications.<br>"; } $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start); return true; }
public function GetOutput($Db) { $Mail = new eveApiMails($Db); $full_url = FULL_URL; // TODO $time_start = microtime_float(); if (!$Mail->fetch(CHAR_ID, USER_ID, API_KEY)) { $this->Output = $Mail->Error; return false; } $time_end = microtime_float(); $time_api = $time_end - $time_start; $this->Updated = APITime($Mail); $this->Title = "Mail for " . CHAR_NAME; if (count($Mail->Messages) > 0) { $idsToResolve = array(); foreach ($Mail->Messages as $message) { // get a list of all ids referenced foreach (explode(",", $message["toCorpOrAllianceID"] . "," . $message["toCharacterIDs"] . "," . $message["senderID"]) as $str) { if ($str != "" && !in_array($str, $idsToResolve)) { $idsToResolve[] = $str; } } } $ids = idlookup($Db->link, $idsToResolve); if (isset($_GET['mail'])) { $ret = $Mail->fetchMailBody(CHAR_ID, USER_ID, API_KEY, $_GET['mail']); if (!$ret) { $this->Output = "Error fetching mail {$_GET['mail']}: " . $Mail->Error; return false; } foreach ($Mail->Messages as $message) { if ($message["messageID"] != $_GET['mail']) { continue; } else { $this->Output .= "<h3>{$message['title']}</h3><h5 style=\"display: inline;\">Sent by " . $ids[(int) $message["senderID"]] . " on {$message['sentDate']}</h5><br><br>"; break; } } $this->Output .= parse_ccptml($ret) . "<br><br>"; $this->Output .= "<a href=\"{$full_url}&view=mail\">[back]</a><br><br>"; } else { $this->Output .= "<span style=\"font-size:80%; font-weight: bold;\">"; /*if ($Mail->unread > 0) $this->Output .= $Mail->unread." unread message".($Mail->unread ==1?", ":"s, ");*/ $this->Output .= count($Mail->Messages) . " messages total<br>"; if ($Mail->Message != "") { $this->Output .= $Mail->Message . "<br>"; } $this->Output .= "</span>"; $this->Output .= "<br><table class=\"fancy Mail\" style=\"font-size:83%;\" border=1>"; $this->Output .= "<tr><th>date</th><th>sender</th><th>title</th><th>recipients</th></tr>"; $alt = " class=\"main\""; foreach ($Mail->Messages as $message) { if ($alt == " class=\"main\"") { $alt = " class=\"alt\""; } else { $alt = " class=\"main\""; } if ((int) $message["toListID"] == 0 || (string) $message["toListID"] == "") { $to = array(); if ($message["toCorpOrAllianceID"] != "") { $to += explode(",", $message["toCorpOrAllianceID"]); } if ($message["toCharacterIDs"] != "") { $to += explode(",", $message["toCharacterIDs"]); } $recp = ""; foreach ($to as $rec) { $recp .= $ids[(int) $rec] . ", "; } $recp = rtrim($recp, ", "); } else { $recp = "(mailing list)"; } $this->Output .= "<tr{$alt} style=\"cursor: pointer;\" onclick=\"document.location='{$full_url}&view=mail&mail=" . $message["messageID"] . "'\">"; //$this->Output .= "<td>".($message["read"]!=1?"<b>#</b>":"")."</td>"; $this->Output .= "<td>" . $message["sentDate"] . "</td>"; $this->Output .= "<td>" . $ids[(int) $message["senderID"]] . "</td>"; $this->Output .= "<td>" . $message["title"] . "</td>"; $this->Output .= "<td>" . $recp . "</td>\n"; $this->Output .= "</tr>"; } $this->Output .= "</table>"; } } else { $this->Output .= "<br>Character has no recent mails.<br>"; } $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start); return true; }
public function loadAPI() { $orderstates = array(0 => "Pending", 1 => "???", 2 => "Complete", 3 => "Cancelled", 4 => "Partial"); $results = $this->api->xpath("/eveapi/result/rowset[@name='orders']/row"); if (CORP_MODE) { $idsTR = array(); foreach ($results as $entry) { $idsTR[] = (int) $entry["charID"]; } $ids = idlookup($this->Db->link, $idsTR); } $entries = array(); foreach ($results as $entry) { $new = array(); $new["bid"] = (int) $entry["bid"]; $timeleft = orders_timeleft($entry); $active = (int) $entry["orderState"] == 0 && $timeleft > 0; $new["active"] = $active; $new["date"] = $active ? str_replace(" ", " ", orders_time($timeleft)) : (string) $entry["issued"]; $new["orderID"] = (int) $entry["orderID"]; if (CORP_MODE) { $new["owner"] = $ids[(int) $entry["charID"]]; $new["div"] = (int) $entry["accountKey"] - 999; } $new["station"] = $this->Db->getNameFromStationId((string) $entry["stationID"]); $new["initvol"] = (int) $entry["volEntered"]; $new["remaining"] = (int) $entry["volRemaining"]; $new["minvol"] = (int) $entry["minVolume"]; $new["ostate"] = (int) $entry["orderState"]; $new["state"] = $orderstates[(int) $entry["orderState"]]; if ((int) $entry["orderState"] == 3 && (int) $entry["volEntered"] != (int) $entry["volRemaining"]) { $new["ostate"] = 4; $new["state"] = "Partial"; } $new["type"] = $this->Db->getNameFromTypeId((int) $entry["typeID"]); if ($new["type"] == "") { $new["type"] = "<b><span style='font-size:80%;'>[UNKNOWN ITEM TYPE " . $entry["typeID"] . "]</span></b>"; } $range = (int) $entry["range"] . " jumps"; switch ($range) { case 32767: $range = "Region"; break; case 0: $range = "Station"; break; case -1: $range = "Station"; break; case 1: $range = "Adjacent"; break; } $new["range"] = $range; $new["accountKey"] = (int) $entry["accountKey"]; $new["duration"] = (int) $entry["duration"] . " days"; $new["escrow"] = (int) $entry["escrow"]; $new["price"] = (double) $entry["price"]; $entries[] = $new; } $this->entries = $entries; return true; }
public function GetOutput($Db) { $Mail = new eveApiMails($Db); $full_url = FULL_URL; // TODO $time_start = microtime_float(); if (!$Mail->fetch(CHAR_ID, USER_ID, API_KEY)) { $this->Output = $Mail->Error; return false; } $time_end = microtime_float(); $time_api = $time_end - $time_start; $this->Updated = APITime($Mail); $this->Title = "Mail for " . CHAR_NAME; if (count($Mail->Messages) > 0) { $idsToResolve = array(); foreach ($Mail->Messages as $message) { // get a list of all ids referenced foreach (explode(",", $message["toCorpOrAllianceID"] . "," . $message["toCharacterIDs"] . "," . $message["senderID"]) as $str) { if ($str != "" && !in_array($str, $idsToResolve)) { $idsToResolve[] = $str; } } } $ids = idlookup($Db->link, $idsToResolve); if (isset($_GET['mail'])) { $ret = $Mail->fetchMailBody(CHAR_ID, USER_ID, API_KEY, $_GET['mail']); if (!$ret) { $this->Output = "Error fetching mail {$_GET['mail']}: " . $Mail->Error; return false; } if (isset($_GET['ajax'])) { die(json_encode(["result" => "success", "body" => (string) $ret])); } foreach ($Mail->Messages as $message) { if ($message["messageID"] != $_GET['mail']) { continue; } else { $this->Output .= "<h3>{$message['title']}</h3><h5 style=\"display: inline;\">Sent by " . $ids[(int) $message["senderID"]] . " on {$message['sentDate']}</h5><br><br>"; break; } } $this->Output .= parse_ccptml($ret) . "<br><br>"; $this->Output .= "<a href=\"{$full_url}&view=mail\">[back]</a><br><br>"; } else { $this->Output .= "<span style=\"font-size:80%; font-weight: bold;\">"; /*if ($Mail->unread > 0) $this->Output .= $Mail->unread." unread message".($Mail->unread ==1?", ":"s, ");*/ $this->Output .= count($Mail->Messages) . " messages total<br>"; if (isset($_SESSION) && isset($_SESSION['mailFormatted']) && $_SESSION['mailFormatted'] == true) { $this->Output .= "Message Formatting: <input type=\"button\" value=\"Formatted\" id=\"changeMessageFormatting\">"; } else { $this->Output .= "Message Formatting: <input type=\"button\" value=\"Unformatted\" id=\"changeMessageFormatting\">"; } if ($Mail->Message != "") { $this->Output .= $Mail->Message . "<br>"; } $this->Output .= "</span>"; $this->Output .= "<br><table class=\"fancy Mail\" style=\"font-size:83%;\" border=1>"; $this->Output .= "<tr><th>date</th><th>sender</th><th>title</th><th>recipients</th></tr>"; $alt = " class=\"main\""; $ids1 = array(); foreach ($Mail->Messages as $message) { $ids1[] = (string) $message['senderID']; $kindaID = explode(",", (string) $message['toCharacterIDs']); $kindaID2 = explode(",", (string) $message['toCorpOrAllianceID']); $ids1 = array_merge($ids1, $kindaID, $kindaID2); } $ids1 = array_unique($ids1); $redIDS = GetRedIDS($ids1, $Db); if (isset($redIDS[0]) && $redIDS[0] == 0) { $redIDS = array(); } foreach ($Mail->Messages as $message) { $sentTo = explode(",", (string) $message['toCharacterIDs']); $sentToGroup = explode(",", (string) $message['toCorpOrAllianceID']); $intersect = array_intersect($redIDS, $sentTo); $intersect2 = array_intersect($redIDS, $sentToGroup); if (in_array((string) $message['senderID'], $redIDS) || !empty($intersect) || !empty($intersect2)) { if (strpos(strtolower($alt), 'main') !== false) { $alt = " class=\"redAlt messageRow\""; } else { $alt = " class=\"redMain messageRow\""; } } else { if (strpos(strtolower($alt), 'main') !== false) { $alt = " class=\"alt messageRow\""; } else { $alt = " class=\"main messageRow\""; } } if ((int) $message["toListID"] == 0 || (string) $message["toListID"] == "") { $to = array(); if ($message["toCorpOrAllianceID"] != "") { $to += explode(",", $message["toCorpOrAllianceID"]); } if ($message["toCharacterIDs"] != "") { $to += explode(",", $message["toCharacterIDs"]); } $recp = ""; foreach ($to as $rec) { $recp .= $ids[(int) $rec] . ", "; } $recp = rtrim($recp, ", "); } else { $recp = "(mailing list)"; } $this->Output .= "<tr{$alt} style=\"cursor: pointer;\" href=\"{$full_url}&view=mail&mail=" . $message["messageID"] . "\">"; //$this->Output .= "<td>".($message["read"]!=1?"<b>#</b>":"")."</td>"; $this->Output .= "<td>" . $message["sentDate"] . "</td>"; $this->Output .= "<td>" . $ids[(int) $message["senderID"]] . "</td>"; $this->Output .= "<td>" . $message["title"] . "</td>"; $this->Output .= "<td>" . $recp . "</td>\n"; $this->Output .= "</tr>"; } $this->Output .= "</table>"; } } else { $this->Output .= "<br>Character has no recent mails.<br>"; } $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start); return true; }
public function loadAPI() { $result = $this->api->xpath("/eveapi/result/rowset/row"); usort($result, "contracts_default_sortfunc"); if ($this->corp) { $filtered = array(); foreach ($result as $entry) { if ($entry["issuerCorpID"] == CORP_ID && $entry["forCorp"] == "1" || $entry["acceptorID"] == CORP_ID || $entry["assigneeID"] == CORP_ID) { // TODO: should not depend on CORP_ID - api should be unaware of audit.php $filtered[] = $entry; } } $result = $filtered; } $result = array_slice($result, $this->start, $this->limit); $idsTR = array(); $locations = array(); $ctrctids = array(); $nonCourierIDs = array(); $this->count = count($result); foreach ($result as $entry) { $ctrctids[] = (double) $entry["contractID"]; if ($entry["type"] != "Courier") { $nonCourierIDs[] = (double) $entry["contractID"]; } } if ($this->getItems && $nonCourierIDs) { $items = $this->fetchItems($nonCourierIDs); } foreach ($result as $entry) { $idsTR[(double) $entry["issuerID"]] = "1"; $idsTR[(double) $entry["issuerCorpID"]] = "1"; if ((double) $entry["assigneeID"] != 0) { $idsTR[(double) $entry["assigneeID"]] = "1"; } if ((double) $entry["acceptorID"] != 0) { $idsTR[(double) $entry["acceptorID"]] = "1"; } if ((string) $entry["type"] == "Auction") { if (!$this->hasAuctions) { $this->fetchBids($ctrctids); if (count($this->bids) > 0) { foreach ($this->bids as $bidset) { foreach ($bidset as $bid) { $idsTR[$bid["bidderID"]] = "1"; } } } } } $locations[locationTranslate((double) $entry["startStationID"])] = "1"; $locations[locationTranslate((double) $entry["endStationID"])] = "1"; } $ids = idlookup($this->Db->link, array_keys($idsTR)); $this->Db->cacheLocationIds(array_keys($locations)); // ensuring only one lookup of each $locations = array(); foreach ($result as $entry) { $locations[$this->Db->getSystemFromStationId(locationTranslate((double) $entry["startStationID"]))] = "1"; $locations[$this->Db->getSystemFromStationId(locationTranslate((double) $entry["endStationID"]))] = "1"; } $this->Db->cacheLocationIds(array_keys($locations)); // system names $entries = array(); foreach ($result as $entry) { $new = array(); foreach ($entry->attributes() as $name => $value) { // copy item attributes $new[(string) $name] = (string) $value; } // todo $cid = (double) $entry["contractID"]; $new["issuer"] = $ids[(double) $entry["issuerID"]]; $new["issuerCorp"] = $ids[(double) $entry["issuerCorpID"]]; $new["assignee"] = (double) $entry["assigneeID"] != 0 ? $ids[(double) $entry["assigneeID"]] : ""; $new["acceptor"] = (double) $entry["acceptorID"] != 0 ? $ids[(double) $entry["acceptorID"]] : ""; $new["startStation"] = $this->Db->getLocationNameFromId(locationTranslate((double) $entry["startStationID"])); $new["endStation"] = $this->Db->getLocationNameFromId(locationTranslate((double) $entry["endStationID"])); $new["startSystemID"] = $this->Db->getSystemFromStationId(locationTranslate((double) $entry["startStationID"])); $new["endSystemID"] = $this->Db->getSystemFromStationId(locationTranslate((double) $entry["endStationID"])); $new["startSystem"] = $this->Db->getLocationNameFromId($new["startSystemID"]); $new["System"] = $new["startSystem"]; $new["endSystem"] = $this->Db->getLocationNameFromId($new["endSystemID"]); if ((string) $new["status"] == "CompletedByContractor") { $new["status"] = "Unclaimed"; } if (!CONTRACT_ACTIVE((string) $entry["status"])) { if ((string) $entry["status"] == "Failed") { $new["dateFinished"] = "FAILED"; } else { $new["dateFinished"] = (string) $entry["dateCompleted"]; } $new["timeRemaining"] = 0; } else { if ((string) $entry["type"] == "Courier" && (string) $entry["status"] == "InProgress") { $new["dateFinished"] = ""; // $entry["dateExpired"]; $new["timeRemaining"] = (int) (string) $entry["numDays"] * 3600 * 24 - (strtotime((string) $this->api->currentTime) - strtotime((string) $entry["dateAccepted"])); } else { $new["timeRemaining"] = strtotime((string) $entry["dateExpired"]) - strtotime((string) $this->api->currentTime); if ($new["timeRemaining"] < 0) { $new["dateFinished"] = (string) $entry["dateExpired"]; $new["timeRemaining"] = 0; $new["status"] = "Expired"; } else { $new["dateFinished"] = ""; } // $entry["dateExpired"]; } } if ($entry["title"] != "") { $new["desc"] = "<b>Title: </b>{$entry['title']}"; } else { $new["desc"] = ""; } if ((string) $entry["type"] == "Courier") { $new["desc"] .= ($new["desc"] = "" ? "<br>" : "") . "<b>Destination: </b>{$new['endStation']}"; if ((double) $entry["collateral"] != 0) { $new["desc"] .= "<br><b>Collateral: <span style=\"color:#aa0;\">" . number_format((double) $entry["collateral"], 2) . " ISK</span></b>"; } if ((double) $entry["acceptorID"] != 0) { $new["desc"] .= "<br><b>Accepted:</b> {$entry['dateAccepted']}</span>"; } } if ((string) $entry["type"] == "ItemExchange") { if ((double) $entry["reward"] > 0) { $new["Type"] = "WTB"; } else { if ((double) $entry["reward"] == (double) $entry["price"]) { $new["Type"] = "Gift"; } else { $new["Type"] = "WTS"; } } } else { $new["Type"] = (string) $entry["type"]; if ((string) $entry["type"] == "Auction") { if (isset($this->bids[$cid])) { $bid = $this->bids[$cid][0]; $new["price"] = $bid["amount"]; $new["desc"] .= "<br><b>Last Bid:</b> " . $bid["bidTime"] . "</span>"; $new["bidder"] = "#" . count($this->bids[$cid]) . ", " . $ids[$bid["bidderID"]]; } else { $new["bidder"] = ""; } } } if ($this->getItems && (string) $entry["type"] != "Courier") { $buying = $items[(double) $entry["contractID"]]["buying"]; $selling = $items[(double) $entry["contractID"]]["selling"]; if (count($buying) > 0 && count($selling) > 0) { $new["Type"] = "Trade"; } $new["buying"] = $buying; $new["selling"] = $selling; } $entries[] = $new; } if ($this->getItems) { if (count($this->typesToCache) > 0) { $types = array_keys($this->typesToCache); $this->Db->cacheItemTypes($types); $groupsToCache = array(); foreach ($types as $typeID) { $type = $this->Db->getTypeFromTypeId($typeID); $groupsToCache[] = $type["groupID"]; } $this->Db->cacheGroupTypes($groupsToCache); $this->Db->cacheMetaLevelsIDs($types); } foreach ($entries as &$entry) { $entry["buyingItems"] = ""; $entry["buyingItemsList"] = ""; $entry["sellingItems"] = ""; $entry["sellingItemsList"] = ""; if (isset($entry["buying"])) { listItems($this->Db, $entry["buying"], $entry["buyingItems"], $entry["buyingItemsList"]); listItems($this->Db, $entry["selling"], $entry["sellingItems"], $entry["sellingItemsList"]); } else { $entry["buying"] = array(); $entry["selling"] = array(); } } } usort($entries, "contracts_default_sortfunc"); $this->entries = $entries; return true; }