function process_message_queue($gameno) { // Open database global $mysqli; // Get message queue $result = $mysqli->query("Select gameno, userno, message, to_email, messageno From sp_message_queue Where gameno={$gameno}"); if (!$result) { echo "E9" . $mysqli->error; } // Process each message if ($result->num_rows > 0) { while ($row = $result->fetch_row()) { // Email if required if ($row[3] == 1) { send_mail($row[1], $row[2]); } // Check for XML message to share libxml_use_internal_errors(true); $messagexml = SimpleXML_Load_String($row[2]); if ($messagexml and $row[1] == -7) { $apower = $messagexml->AttPowername; if (isset($apower)) { $mysqli->query("Insert Into sp_messages (gameno, userno, message) Select gameno, userno, '" . addslashes($row[2]) . "' From sp_resource Where gameno={$gameno} and powername='{$apower}'"); } $dpower = $messagexml->DefPowername; if (isset($dpower)) { $mysqli->query("Insert Into sp_messages (gameno, userno, message) Select gameno, userno, '" . addslashes($row[2]) . "' From sp_resource Where gameno={$gameno} and powername='{$dpower}'"); } } else { $mysqli->query("Insert Into sp_messages (gameno, userno, message) Values ({$gameno}, {$userno}, '" . addslashes($row[2]) . "')"); } // Remove from message queue $mysqli->query("Delete From sp_message_queue Where messageno={$row[4]}"); } } // Close result set $result->close(); }
<?php // Process orders from phase 1 screen // $Id: process_phase1.php 237 2014-07-10 07:28:53Z paul $ //? Assume no bad submits // All info should be in the SR_ORDERXML order, generated by SR_MOVE_QUEUE_INCM $result = $mysqli->query("select order_code From sp_orders Where gameno={$gameno} and userno={$userno} and ordername='SR_ORDERXML'"); $row = $result->fetch_row(); $result->close(); libxml_use_internal_errors(true); $orderxml = SimpleXML_Load_String($row[0]); // Update ORDERXML foreach ($_POST as $key => $val) { if (substr($key, 0, 1) == 'M') { // Minor force $order = $orderxml->xpath("/PAYSALARIES/PayTroops[Terrno/text()='" . substr($key, 1) . "']"); $order[0]->Minor = $val; $order[0]->Cost = ($order[0]->Minor + $order[0]->Major) * 10; } else { if (substr($key, 0, 1) == 'T') { // Tanks $order = $orderxml->xpath("/PAYSALARIES/PayTroops[Terrno/text()='" . substr($key, 1) . "']"); $order[0]->Major = $val; $order[0]->Cost = ($order[0]->Minor + $order[0]->Major) * 10; } else { if (substr($key, 0, 3) == 'BNK') { // Boomers nukes $order = $orderxml->xpath("/PAYSALARIES/Boomer[Number/text()='" . substr($key, 3) . "']"); $order[0]->Nukes = $val; } else { if (substr($key, 0, 3) == 'BNE') {
/** * Load up an RSS feed, parse its contents and return it. */ public function _LoadFeed($FeedURL, $NumEntries = 0, $CacheTime = 0, $FeedId = "", $RSSFeedSnippet = "", $helpLinks = false) { $reload = true; if ($CacheTime > 0) { if ($FeedId != "") { $FeedID = md5($FeedURL); } $reload = false; if (!is_dir(ISC_BASE_PATH . "/cache/feeds")) { @mkdir(ISC_BASE_PATH . "/cache/feeds/", 0777); } // Using a cached version that hasn't expired yet if (file_exists(ISC_BASE_PATH . "/cache/feeds/" . $FeedId) && filemtime(ISC_BASE_PATH . "/cache/feeds/" . $FeedId) > time() - $CacheTime) { $contents = file_get_contents(ISC_BASE_PATH . "/cache/feeds/" . $FeedId); // Cache was bad, recreate if (!$contents) { $reload = true; } } else { $reload = true; } } if ($reload === true) { $contents = PostToRemoteFileAndGetResponse($FeedURL); // Do we need to cache this version? if ($CacheTime > 0 && $contents != "") { @file_put_contents(ISC_BASE_PATH . "/cache/feeds/" . $FeedId, $contents); } } $output = ""; $count = 0; // Could not load the feed, return an error if (!$contents) { return false; } if ($xml = SimpleXML_Load_String($contents)) { $rss = new ISC_XML(); $entries = $rss->ParseRSS($xml); foreach ($entries as $entry) { $GLOBALS['RSSTitle'] = $entry['title']; $GLOBALS['RSSDescription'] = $entry['description']; $GLOBALS['RSSLink'] = $entry['link']; if ($RSSFeedSnippet != "") { if ($helpLinks) { preg_match('#/questions/([0-9]+)/#si', $entry['link'], $matches); if (!empty($matches)) { $GLOBALS['RSSLink'] = $matches[1]; } } $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($RSSFeedSnippet); } else { $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("PageRSSItem"); } if ($NumEntries > 0 && ++$count >= $NumEntries) { break; } } return $output; } else { return false; } }
private function HandleResponse($File, $Data) { if ($File === 'API/SupportedAPIList.json') { $Data = JSON_Decode($Data, true); if (!isset($Data['apilist']['interfaces'])) { return false; } foreach ($Data['apilist']['interfaces'] as $Interface) { $File = __DIR__ . '/API/' . $Interface['name'] . '.json'; $Interface = JSON_Encode($Interface, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; if (!File_Exists($File) || StrCmp(File_Get_Contents($File), $Interface) !== 0) { File_Put_Contents($File, $Interface); } } return true; } else { if ($File === 'ClientManifest/steam_client_publicbeta_osx' || $File === 'ClientManifest/steam_cmd_publicbeta_osx') { foreach ($this->ClientArchives as $Archive) { if (Preg_Match('/"' . Str_Replace('.', '\\.', $Archive) . '\\.([a-f0-9]{40})"/m', $Data, $Test) === 1) { $Test = $Test[1]; if (!isset($this->ETags[$Archive]) || $this->ETags[$Archive] !== $Test) { $this->Log('Downloading {lightblue}' . $Archive . '{normal} - checksum: ' . $Test); $this->ETags[$Archive] = $Test; $this->URLsToFetch[] = array('URL' => 'https://steamcdn-a.akamaihd.net/client/' . $Archive . '.' . $Test, 'File' => '.support/' . $Archive); } else { $this->Log('Matched {lightblue}' . $Archive . '{normal}, but we already have it cached'); } } else { $this->Log('{yellow}Failed to find {lightblue}' . $Archive); } } unset($Test); } else { if ($File === 'Random/ValveGroup.json' || $File === 'Random/SteamModerators.json') { LibXML_Use_Internal_Errors(true); $Data = SimpleXML_Load_String($Data); if ($Data === false || empty($Data->members->steamID64)) { return false; } $Data = Array_Values((array) $Data->members->steamID64); Sort($Data); $Data = JSON_Encode($Data, JSON_PRETTY_PRINT); } else { if ($File === 'Scripts/Dota2/heropickerdata.json') { $Data = JSON_Decode($Data, true); $Data = JSON_Encode($Data, JSON_PRETTY_PRINT); } else { if ($File === 'Scripts/Dota2/heropedia.js') { $Data = preg_replace('/\\?v=[0-9]+/', '?v=ayyvalve', $Data); } else { if (SubStr($File, 0, 13) === 'ItemSchemaURL') { $Data = JSON_Decode($Data, true); if (isset($Data['result']['items_game_url'])) { $this->URLsToFetch[] = array('URL' => $Data['result']['items_game_url'], 'File' => str_replace('ItemSchemaURL', 'ItemSchema', $File)); } return true; } else { if (SubStr($File, -4) === '.zip') { $File = __DIR__ . '/' . $File; File_Put_Contents($File, $Data); $Archive = SubStr(StrrChr($File, '/'), 1); if (SHA1_File($File) !== $this->ETags[$Archive]) { $this->Log('{lightred}Checksum mismatch for ' . $Archive); return false; } $this->ExtractClientArchives = true; return true; } else { if (SubStr($File, -5) === '.html') { if (StrrPos($Data, '</html>') === false) { return false; } } } } } } } } } $File = __DIR__ . '/' . $File; $Folder = dirname($File); if (!is_dir($Folder)) { $this->Log('{lightblue}Creating ' . $Folder); mkdir($Folder, 0755, true); } if (File_Exists($File) && StrCmp(File_Get_Contents($File), $Data) === 0) { return false; } File_Put_Contents($File, $Data); return true; }
function utl_xml_table($xmlstring, $id = '', $footer = 'NO') { libxml_use_internal_errors(true); $xml = SimpleXML_Load_String($xmlstring); if (!$xml) { if (stripos($xmlstring, '<table') === 0) { return $xmlstring; } else { if (stripos($xmlstring, '<strong') === 0) { $return = "<DIV class='expander'><DIV class='collHead'><i class='icon-plus-sign'></i> "; $return .= substr($xmlstring, 0, stripos($xmlstring, '<br>')); $return .= "</DIV><DIV class='collDetail' style='display:none'>"; $return .= substr($xmlstring, stripos($xmlstring, '<br>')); $return .= "</DIV>"; return $return; } else { return htmlspecialchars($xmlstring); } } // // Battle report section // } else { if ($xml->getName() == 'FIGHT') { $return = "<H6>Battle report for " . $xml->Terrname . "</H6>"; $return .= "<TABLE class='table table-condensed table-bordered battleTable'" . ($id != '' ? " ID='{$id}' " : "") . ">"; // Get number of columns $att_cols = 0; $def_cols = 0; $att_head = ''; $def_head = ''; $att_base = 1 + ("{$xml->LStarDice}" == "{$xml->AttPowername}" ? 1 : 0) + ("{$xml->TechDice}" == "{$xml->AttPowername}" ? 1 : 0); $def_base = 1 + ("{$xml->LStarDice}" == "{$xml->DefPowername}" ? 1 : 0) + ("{$xml->TechDice}" == "{$xml->DefPowername}" ? 1 : 0) + ("{$xml->DefAction}" == "Defend" ? 1 : 0); $att_cols++; $att_head .= '<TH>Dice Roll</TH>'; if (isset($xml->AttTanks)) { $att_cols++; $att_head .= '<TH>Tanks</TH>'; } if (isset($xml->AttArmies)) { $att_cols++; $att_head .= '<TH>Armies</TH>'; } if (isset($xml->AttBoomers)) { $att_cols++; $att_head .= '<TH>Boomers</TH>'; } if (isset($xml->AttNavies)) { $att_cols++; $att_head .= '<TH>Navies</TH>'; } $def_cols++; $def_head .= '<TH>Dice Roll</TH>'; if (isset($xml->DefTanks)) { $def_cols++; $def_head .= '<TH>Tanks</TH>'; } if (isset($xml->DefArmies)) { $def_cols++; $def_head .= '<TH>Armies</TH>'; } if (isset($xml->DefBoomers)) { $def_cols++; $def_head .= '<TH>Boomers</TH>'; } if (isset($xml->DefNavies)) { $def_cols++; $def_head .= '<TH>Navies</TH>'; } // Table header $return .= "<THEAD><TR><TH Rowspan='2' Valign'=Bottom'>Round</TH>"; $return .= "<TH Colspan='{$att_cols}' Style='vertical-align:top'>" . $xml->AttPowername . ("{$xml->LStarDice}" == "{$xml->AttPowername}" ? '<br/>+L-Star die' : '') . ("{$xml->TechDice}" == "{$xml->AttPowername}" ? '<br/>+Tech die' : '') . "</TH>"; $return .= "<TH Colspan='{$def_cols}' Style='vertical-align:top'>" . $xml->DefPowername . ("{$xml->LStarDice}" == "{$xml->DefPowername}" ? '<br/>+L-Star die' : '') . ("{$xml->TechDice}" == "{$xml->DefPowername}" ? '<br/>+Tech die' : '') . "<br/>" . $xml->DefAction . "</TH></TR>"; $return .= "<TR>" . $att_head . $def_head . "</TR></THEAD>"; // Table footer if ($footer == 'YES') { $return .= "<TFOOT><TR><TD Align='CENTER' Colspan='" . ($att_cols + $def_cols + 1) . "'>"; $return .= "<INPUT Type='button' Id='battleAttack' Value='Attack again'/>"; $return .= "<INPUT Type='button' Id='battleStop' Value='Stop attacking'/>"; $return .= "<INPUT Type='button' Id='refresh' onClick='location.reload();return false' value='Finished'/>"; $return .= "</TD></TR></TFOOT>"; } // Table body - first row $return .= "<TBODY class='battleBody'><TR><TD>Initial</TD>"; $return .= '<TD> </TD>'; if (isset($xml->AttTanks)) { $return .= '<TD>' . $xml->AttTanks . '</TD>'; } if (isset($xml->AttArmies)) { $return .= '<TD>' . $xml->AttArmies . '</TD>'; } if (isset($xml->AttBoomers)) { $return .= '<TD>' . $xml->AttBoomers . '</TD>'; } if (isset($xml->AttNavies)) { $return .= '<TD>' . $xml->AttNavies . '</TD>'; } $return .= '<TD> </TD>'; if (isset($xml->DefTanks)) { $return .= '<TD>' . $xml->DefTanks . '</TD>'; } if (isset($xml->DefArmies)) { $return .= '<TD>' . $xml->DefArmies . '</TD>'; } if (isset($xml->DefBoomers)) { $return .= '<TD>' . $xml->DefBoomers . '</TD>'; } if (isset($xml->DefNavies)) { $return .= '<TD>' . $xml->DefNavies . '</TD>'; } // Table body - remaining rows for ($ti = 1; $ti <= (int) $xml->Rounds; $ti++) { $return .= "<TR><TD>{$ti}</TD>"; $r = $xml->xpath("/FIGHT/R[@Id='R{$ti}']"); $r = $r[0]; if (isset($r->AttRoll)) { $return .= '<TD ' . ($r->AttDice > $att_base ? 'class="battleHighlight" ' : '') . 'title="' . $r->AttDice . ' dice +' . $r->AttMod . '">' . $r->AttRoll . '</TD>'; } if (isset($r->AttTanks)) { $return .= '<TD>' . $r->AttTanks . '</TD>'; } if (isset($r->AttArmies)) { $return .= '<TD>' . $r->AttArmies . '</TD>'; } if (isset($r->AttBoomers)) { $return .= '<TD>' . $r->AttBoomers . '</TD>'; } if (isset($r->AttNavies)) { $return .= '<TD>' . $r->AttNavies . '</TD>'; } if (isset($r->DefRoll)) { $return .= '<TD ' . ($r->DefDice > $def_base ? 'class="battleHighlight" ' : '') . 'title="' . $r->DefDice . ' dice +' . $r->DefMod . '">' . $r->DefRoll . '</TD>'; } if (isset($r->DefTanks)) { $return .= '<TD>' . $r->DefTanks . '</TD>'; } if (isset($r->DefArmies)) { $return .= '<TD>' . $r->DefArmies . '</TD>'; } if (isset($r->DefBoomers)) { $return .= '<TD>' . $r->DefBoomers . '</TD>'; } if (isset($r->DefNavies)) { $return .= '<TD>' . $r->DefNavies . '</TD>'; } $return .= "</TR>"; } $return .= "</TBODY></TABLE>"; return $return; // // Warhead attack report section, includes boomer shots // } else { if ($xml->getName() == 'WARHEADS') { $return = "<H6>Warhead deployment report for Strategic attack by " . $xml->AttPowername . (isset($xml->FromTerrname) ? " from " . $xml->FromTerrname : "") . "</H6>"; $return .= "<TABLE class='table table-condensed table-bordered battleTable'><THEAD>"; $return .= "<TR><TH rowspan='3'>Territory</TH><TH rowspan='3'>Owning Power</TH><TH rowspan='3'>Nukes</TH><TH rowspan='3'>Neutron Bombs</TH>"; if (isset($xml->TARGET->BlanketSlots)) { $return .= "<TH colspan='4'>L-Star</TH><TH rowspan='3'>Result</TH></TR><TR><TH colspan='2'>Blanket</TH><TH rowspan='2'>Slots</TH><TH rowspan='2'>Total hits</TH></TR><TR><TH>Slots</TH><TH>Hits</TH></TR></THEAD>"; } else { $return .= "<TH colspan='2'>L-Star</TH><TH rowspan='3'>Result</TH></TR><TR><TH>Slots</TH><TH>Hits</TH></TR></THEAD>"; } // Table body $return .= "<TBODY>"; foreach ($xml->xpath('//TARGET') as $target) { $return .= "<TR><TD>" . $target->Terrname . "</TD>"; $return .= "<TD>" . $target->Owner . "</TD>"; $return .= "<TD>" . $target->Nukes . "</TD>"; $return .= "<TD>" . $target->Neutron . "</TD>"; if (isset($target->BlanketSlots)) { $return .= "<TD>" . $target->BlanketSlots . "</TD><TD>" . $target->BlanketHits . "</TD>"; } $return .= "<TD>" . $target->TargettedSlots . "</TD><TD>" . $target->TargettedHits . "</TD>"; $return .= "<TD>" . $target->Result . "</TD>"; } $return .= "</TBODY></TABLE>"; return $return; // // Space blast report section // } else { if ($xml->getName() == 'SPACEBLAST') { $return = "<H6>Space blast report for " . $xml->AttNukes . " nuke attack by " . $xml->AttPowername . "</H6>"; $return .= "<TABLE class='table table-condensed table-bordered battleTable'><THEAD>"; $return .= "<TR><TH>Superpower</TH><TH>L-Stars</TH><TH>K-Sats</TH><TH>Slots</TH><TH>Hits</TH></TR></THEAD>"; $return .= "<TFOOT><TR><TH Colspan='5'>" . $xml->Result . "</TH></TR></TFOOT>"; // Table body $return .= "<TBODY>"; if (!isset($xml->Powername)) { $return .= "<TR><TD Colspan='5'>No Satellites</TD></TR>"; } else { foreach ($xml->xpath('//Powername') as $powername) { $return .= "<TR><TD>" . $powername . "</TD>"; $return .= "<TD>" . $powername->LStars . "</TD>"; $return .= "<TD>" . $powername->KSats . "</TD>"; $return .= "<TD>" . $powername->BlanketSlots . "</TD>"; $return .= "<TD>" . $powername->Hits . "</TD>"; } } $return .= "</TBODY></TABLE>"; return $return; // // L-Star attack report section // } else { if ($xml->getName() == 'LSTAR') { $return = "<h6>Satellite Offensive report</h6>"; $return .= "<TABLE class='table table-condensed table-bordered battleTable'><THEAD>"; $return .= "<TR><TH Rowspan='2' Valign='Bottom'>Round</TH><TH Colspan=3>" . $xml->AttPowername . "</TH>"; $return .= "<TH Colspan=3>" . $xml->DefPowername . "</TH></TR>"; $return .= "<TR><TH>L-Stars</TH><TH>K-Sats</TH><TH>Hits</TH><TH>L-Stars</TH><TH>K-Sats</TH><TH>Hits</TH></TR></THEAD>"; // Table footer if ($footer == 'YES') { $return .= "<TFOOT><TR><TD Colspan=7 Align='Center'>"; $return .= "<INPUT Type='button' class='btn btn-primary btn-medium' Id='battleAttack' Value='Attack again'/>"; $return .= "<INPUT Type='button' class='btn btn-warning btn-medium' Id='battleStop' Value='Stop attacking'/>"; $return .= "<INPUT Type='button' class='btn btn-medium' Id='refresh' onClick='location.reload();return false' value='Finished'/>"; $return .= "</TD></TR></TFOOT>"; } // Table body $return .= "<TBODY id='battleBody'>"; for ($ti = 1; $ti <= (int) $xml->Rounds; $ti++) { $r = $xml->xpath("/LSTAR/R[@Id='R{$ti}']"); $r = $r[0]; $return .= "<TR><TD>{$ti}</TD>"; $return .= "<TD>" . $r->att_lstars . "</TD>"; $return .= "<TD>" . $r->att_ksats . "</TD>"; $return .= "<TD>" . $r->att_hits . "</TD>"; $return .= "<TD>" . $r->def_lstars . "</TD>"; $return .= "<TD>" . $r->def_ksats . "</TD>"; $return .= "<TD>" . $r->def_hits . "</TD></TR>"; } // Table body - last row $return .= "<TR><TD>Final</TD>"; $return .= "<TD>" . $xml->RESULT->ala . "</TD>"; $return .= "<TD>" . $xml->RESULT->aka . "</TD>"; $return .= "<TD></TD>"; $return .= "<TD>" . $xml->RESULT->dla . "</TD>"; $return .= "<TD>" . $xml->RESULT->dka . "</TD>"; $return .= "<TD></TD></TR></TBODY></TABLE>"; return $return; // // Communication section // } else { if ($xml->getName() == 'COMMS') { // Get message header information $realfrom = $xml->From->RealPowername; $from = $xml->From->Powername; if ($realfrom != '') { $from = $realfrom . " seen as " . $from; } $to = ''; if (isset($xml->To->Powername)) { foreach ($xml->To->Powername as $to_powername) { $to .= '*' . $to_powername; } } $messageno = $xml->messageno; $return = "<TABLE Class='table table-bordered table-condensed'>"; //if ($messageno > 0) $return .= "<TFOOT><TR><TD Colspan=2 Align='center'><A HREF='messages.php?messageno=".$xml->messageno."'>Reply All</A></TD></TR></TFOOT>'"; $return .= "<TBODY><TR><TH Width='30%'>From</TH><TD>{$from}</TD></TR>"; $return .= "<TR><TH>To</TH><TD>" . strtr(substr($to, 1), array('*' => ', ')) . "</TD></TR>"; $return .= "<TR><TD Colspan='2'>" . html_entity_decode($xml->Text) . "</TD></TR>"; $return .= "</TBODY></TABLE>"; return $return; // // Build report section // } else { if ($xml->getName() == 'BUILDREPORT') { $return = '<h6>Build report</h6>'; if (isset($xml->Research) ? count($xml->Research->children()) > 0 : 0) { $return .= "<table class='table table-bordered table-compact'>"; $return .= "<thead><tr><th>Research</th><th>Spend</th><th>Target</th><th>Success</th><th>Now</th></tr></thead><tbody>"; foreach ($xml->Research->children() as $xxml) { $return .= "<tr><td>" . $xxml->getName() . "</td><td>" . $xxml->Spend . "</td><td>" . $xxml->Levels . "</td><td>" . $xxml->Success . "</td><td>" . $xxml->NewLevel . "</td></tr>"; } $return .= "</tbody></table>"; } if (isset($xml->Storage) ? Count($xml->Storage->children()) > 0 : 0) { $return .= "<table class='table table-bordered table-condensed'>"; $return .= "<thead><tr><th>Storage</th><th>Built</th><th>Now</th></tr></thead><tbody>"; foreach ($xml->Storage->children() as $xxml) { $return .= "<tr><td>" . $xxml->getName() . "</td><td>" . $xxml->Built . "</td><td>" . $xxml->Now . "</td></tr>"; } $return .= "</tbody></table>"; } if (isset($xml->Strategic) ? count($xml->Strategic->children()) > 0 : 0) { $return .= "<table class='table table-bordered table-condensed'>"; $return .= "<thead><tr><th>Strategic Weapons</th><th>Built</th><th>Now</th><th>Left</th></tr></thead><tbody>"; foreach ($xml->Strategic->children() as $xxml) { $return .= "<tr><td>" . $xxml->getName() . "</td><td>" . $xxml->Built . "</td><td>" . $xxml->Now . "</td><td>" . $xxml->Left . "</td></tr>"; } $return .= "</tbody></table>"; } if (isset($xml->BuildTroops) ? count($xml->BuildTroops->children()) > 0 : 0) { $return .= "<table class='table table-bordered table-condensed'>"; $return .= "<thead><tr><th>Territory</th><th>Troops</th><th>Built</th><th>Now</th></tr></thead><tbody>"; foreach ($xml->BuildTroops->children() as $xxml) { $i = 1; foreach ($xxml as $txml) { $return .= "<tr>"; if ($i == 1) { $return .= "<td rowspan='" . $xxml->count() . "'>" . $xxml . "</td>"; } $return .= "<td>" . $txml->getName() . "</td><td>" . $txml->Build . "</td><td>" . $txml->Now . "</td></tr>"; $i++; } } $return .= "</tbody></table>"; } $return .= "<table class='table table-bordered table-condensed'><thead><tr><th> </th><th>Spend</th><th>Remaining</th></tr></thead><tbody>"; $return .= "<tr><td>Cash</td><td>" . $xml->Cash->Spend . "</td><td>" . $xml->Cash->Remaining . "</td></tr>"; $return .= "<tr><td>Minerals</td><td>" . $xml->Minerals->Spend . "</td><td>" . $xml->Minerals->Remaining . "</td></tr>"; $return .= "<tr><td>Oil</td><td>" . $xml->Oil->Spend . "</td><td>" . $xml->Oil->Remaining . "</td></tr>"; $return .= "<tr><td>Grain</td><td>" . $xml->Grain->Spend . "</td><td>" . $xml->Grain->Remaining . "</td></tr>"; $return .= "</tbody></table>"; return $return; // // Waiting message // } else { if ($xml->getName() == 'WAIT') { $return = $xml; $return .= "<table width='100%' class='table table-bordered'>"; $return .= "<tr><td width='33%'>Game</td><td><strong>" . $xml->Game . "</strong></td></tr>"; $return .= "<tr><td>Turn</td><td><strong>" . $xml->Turn . "</strong></td></tr>"; $return .= "<tr><td>Phase</td><td><strong>" . $xml->Phase . "</strong></td></tr>"; $return .= "<tr><td>Deadline</td><td><strong>"; $return .= gmdate($xml->dt_format, $xml->UTS - $xml->offset * 60) . " (local)<br/>"; $return .= gmdate($xml->dt_format, (int) $xml->UTS) . " (GMT)"; $return .= "</strong></td></tr></table>"; return $return; // // Dead player message // } else { if ($xml->getName() == 'DEADPOWER') { $return = '<h6>Superpower defeat salvage report</h6>'; $return .= "<table width='100%' class='table table-bordered'>"; $return .= "<tr><th>Powername</th><td>" . $xml->DeadPower . "</td></tr>"; $return .= "<tr><th>Territories</th><td>" . ($xml->Territories - $xml->NukedTerritories) . "</td></tr>"; foreach ($xml->xpath('//Powername') as $power) { $return .= "<tr><td><strong>{$power}</strong></td><td>"; foreach ($power->children() as $bit) { if ($bit > 0) { $return .= $bit->attributes()->Label . " = " . $bit . "<br/>"; } } $return .= "</td></tr>"; } $return .= "</table>"; return $return; // // UN Report // } else { if ($xml->getName() == 'UNREPORT') { $return = '<h6>United Nations Resource Report</h6>'; $return .= "<table width='100%' class='table table-bordered'>"; $return .= "<tr>"; foreach ($xml->Powername[0]->children() as $bit) { $return .= "<th>" . $bit->getName() . "</th>"; } $return .= "</tr>"; foreach ($xml->Powername as $power) { $return .= '<tr>'; foreach ($power->children() as $bit) { $return .= "<td>{$bit}</td>"; } $return .= '</tr>'; } $return .= "</table>"; return $return; // // Corruption Report // } else { if ($xml->getName() == 'BRIBES') { $return = '<h6>United Nations Report on Corruption spending</h6>'; $return .= "<table width='100%' class='table table-bordered'>"; $return .= "<tr><th>Superpower</th><th>Phase</th><th>Spend</th></tr>"; foreach ($xml->Bribe as $bribe) { $return .= '<tr>'; $return .= '<td>' . $bribe->Powername . '</td><td>' . $bribe->Phasedesc . '</td><td>' . $bribe->Amount . '</td>'; $return .= '</tr>'; } $return .= "</table>"; return $return; // // Collapsible XML table // } else { $return = "<DIV class='expander'><DIV class='collHead'><i class='icon-plus-sign'></i> " . $xml->getName() . "</DIV>"; $return .= "<DIV class='collDetail' style='display:none'>"; $return .= "<TABLE Width='100%' Class='table table-bordered'>"; foreach ($xml->children() as $bit) { $return .= "<TR Class='odd'><TD Width='120px'>" . (isset($bit['Id']) ? $bit['Id'] : $bit->getName()) . "</TD><TD>"; if ($bit != '') { $return .= "<strong>{$bit}</strong><br/>"; } foreach ($bit->children() as $bit2) { $return .= $bit2->getName() . " = {$bit2}<BR>"; foreach ($bit2->children() as $bit3) { $return .= "->" . $bit3->getName() . " = {$bit3}<BR>"; } } $return .= "</TD></TR>"; } $return .= "</TABLE></DIV><DIV>"; return $return; } } } } } } } } } } } }
<?php // Process orders from phase 6 // $Id: process_phase6.php 107 2012-08-23 00:06:26Z paul $ //? Assume no bad submits // All info should be in the SR_ORDERXML $result = $mysqli->query("select order_code From sp_orders Where gameno={$gameno} and phaseno={$phaseno} and ordername='SR_ORDERXML'") or die("PROCESS_PHASE6:1:" + $mysqli->error); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); } $result->close(); libxml_use_internal_errors(true); $orderxml = SimpleXML_Load_String(isset($row['order_code']) ? $row['order_code'] : '<TRANSACTION></TRANSACTION>'); if ($_POST['transaction'] == 'Accept') { $ordersOK = 'Y'; // Check transaction foreach ($_POST as $key => $val) { if (!in_array($key, array('randgen', 'PROCESS', 'transaction', 'Accepted'))) { if ($val != $orderxml->{$key}) { $ordersOK = 'N'; } } } // Accept or reject $orderxml->Accepted = $_POST['Accepted']; $row['order_code'] = $orderxml->asXML(); $mysqli->query("Update sp_orders Set order_code = '{$row['order_code']}' Where gameno={$gameno} and phaseno={$phaseno} and ordername='SR_ORDERXML'") or die("PROCESS_PHASE6:2:" + $mysqli->error); } else { // Update ORDERXML foreach ($_POST as $key => $val) { if ($key != 'randgen' and $key != 'PROCESS') {