Note: Сache for XmlAlliancesTag

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Note: Сache for XmlAlliancesTag

      Mission: modify - cache XML or save file XML

      Source Code

      1. function XmlAlliancesTag ($strName, $strUni, $strDomain){
      2. $url = 'http://s'.$strUni.'-'.$strDomain.'.ogame.gameforge.com/api/players.xml';
      3. $xml = simplexml_load_file($url);
      4. foreach ($xml->children() as $players) {
      5. if ($players['name'] == $strName){
      6. $allianceID = trim($players['alliance']);
      7. break;
      8. }
      9. }
      10. $url = 'http://s'.$strUni.'-'.$strDomain.'.ogame.gameforge.com/api/alliances.xml';
      11. $xml = simplexml_load_file($url);
      12. foreach ($xml->children() as $alliance) {
      13. if ($alliance['id'] == $allianceID)
      14. {
      15. $varResult = trim($alliance['tag']);
      16. break;
      17. }
      18. }
      19. return $varResult;
      20. }
      Display All


      Source Code

      1. $intTitle = split("vs.", $strReturn);
      2. $arrAttackers = split(",", $intTitle[0]);
      3. $arrDefenders = split(",", $intTitle[1]);
      4. foreach($arrAttackers as $arrPlayer) {
      5. $arrPlayer = trim($arrPlayer);
      6. $AllianceTag = XmlAlliancesTag ($arrPlayer, $intUni, $strDomain);
      7. if ($AllianceTag) $intTitle[0] = str_replace($arrPlayer, '['.$AllianceTag.'] '.$arrPlayer, $intTitle[0]);
      8. }
      9. foreach($arrDefenders as $arrPlayer) {
      10. $arrPlayer = trim($arrPlayer);
      11. $AllianceTag = XmlAlliancesTag ($arrPlayer, $intUni, $strDomain);
      12. if ($AllianceTag) $intTitle[1] = str_replace($arrPlayer, '['.$AllianceTag.'] '.$arrPlayer, $intTitle[1]);
      13. }
      14. $strReturn = $intTitle[0].' vs. '.$intTitle[1];
      Display All
    • Done

      Source Code

      1. function XmlAlliancesTag ($strName, $strUni, $strDomain){
      2. $url = 'http://s'.$strUni.'-'.$strDomain.'.ogame.gameforge.com/api/players.xml';
      3. $flashRAW = file_get_contents($url);
      4. $flashXML = simplexml_load_string($flashRAW);
      5. $xmlFile = 'xml/'.$strUni.'-'.$strDomain.'_players.xml';
      6. if ((time() - filectime($xmlFile)) >= 7 * 24 * 3600 || !file_exists($xmlFile)) {
      7. $xmlHandle = fopen($xmlFile, "w");
      8. $xmlString = $flashXML->asXML();
      9. fwrite($xmlHandle, $xmlString);
      10. fclose($xmlHandle);
      11. }
      12. $xml = simplexml_load_file($xmlFile);
      13. foreach ($xml->children() as $players) {
      14. if ($players['name'] == $strName){
      15. $allianceID = trim($players['alliance']);
      16. break;
      17. }
      18. }
      19. $url = 'http://s'.$strUni.'-'.$strDomain.'.ogame.gameforge.com/api/alliances.xml';
      20. $flashRAW = file_get_contents($url);
      21. $flashXML = simplexml_load_string($flashRAW);
      22. $xmlFile = 'xml/'.$strUni.'-'.$strDomain.'_alliances.xml';
      23. if ((time() - filectime($xmlFile)) >= 24 * 3600 || !file_exists($xmlFile)) {
      24. $xmlHandle = fopen($xmlFile, "w");
      25. $xmlString = $flashXML->asXML();
      26. fwrite($xmlHandle, $xmlString);
      27. fclose($xmlHandle);
      28. }
      29. $xml = simplexml_load_file($xmlFile);
      30. foreach ($xml->children() as $alliance) {
      31. if ($alliance['id'] == $allianceID)
      32. {
      33. $varResult = trim($alliance['tag']);
      34. break;
      35. }
      36. }
      37. return $varResult;
      38. }
      Display All