957 | | $this->currenttime_ = $data; // 'Y-m-d H:i:s' |
958 | | $this->timereturned_ = true; |
959 | | } |
960 | | } |
961 | | |
962 | | function loaddata() |
| 1181 | $this->CachedUntil_ = $tempvalue; |
| 1182 | config::set('API_eve_ConquerableStationList' , $tempvalue); |
| 1183 | } |
| 1184 | |
| 1185 | if ($name == "ROW") |
| 1186 | { |
| 1187 | $this->Stations_[] = $Station; |
| 1188 | $Station = array(); |
| 1189 | unset($Station); |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | function characterData($parser, $data) |
| 1194 | { |
| 1195 | global $tempvalue; |
| 1196 | |
| 1197 | $tempvalue = $data; |
| 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | // ********************************************************************************************************************************************** |
| 1202 | // **************** API Error list - /eve/ErrorList.xml.aspx **************** |
| 1203 | // ********************************************************************************************************************************************** |
| 1204 | |
| 1205 | class API_ErrorList |
| 1206 | { |
| 1207 | function getCachedUntil() |
| 1208 | { |
| 1209 | return $this->CachedUntil_; |
| 1210 | } |
| 1211 | |
| 1212 | function getCurrentTime() |
| 1213 | { |
| 1214 | return $this->CurrentTime_; |
| 1215 | } |
| 1216 | |
| 1217 | function getErrorList() |
| 1218 | { |
| 1219 | return $this->Error_; |
| 1220 | } |
| 1221 | |
| 1222 | function fetchXML() |
| 1223 | { |
| 1224 | $data = LoadGlobalData('/eve/ErrorList.xml.aspx'); |
| 1225 | |
| 1226 | $xml_parser = xml_parser_create(); |
| 1227 | xml_set_object ( $xml_parser, $this ); |
| 1228 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1229 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1230 | |
| 1231 | if (!xml_parse($xml_parser, $data, true)) |
| 1232 | return "<i>Error getting XML data from api.eve-online.com/eve/ErrorList.xml.aspx </i><br><br>"; |
| 1233 | |
| 1234 | xml_parser_free($xml_parser); |
| 1235 | |
| 1236 | return $this->html; |
| 1237 | } |
| 1238 | |
| 1239 | function startElement($parser, $name, $attribs) |
| 1240 | { |
| 1241 | global $ErrorData; |
| 1242 | |
| 1243 | if ($name == "ROW") |
| 1244 | { |
| 1245 | if (count($attribs)) |
| 1246 | { |
| 1247 | foreach ($attribs as $k => $v) |
| 1248 | { |
| 1249 | switch ($k) |
| 1250 | { |
| 1251 | case "ERRORCODE": |
| 1252 | $ErrorData['errorCode'] = $v; |
| 1253 | break; |
| 1254 | case "ERRORTEXT": |
| 1255 | $ErrorData['errorText'] = $v; |
| 1256 | break; |
| 1257 | } |
| 1258 | } |
| 1259 | } |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | function endElement($parser, $name) |
| 1264 | { |
| 1265 | global $ErrorData; |
| 1266 | global $tempvalue; |
| 1267 | |
| 1268 | if ($name == "CURRENTTIME") |
| 1269 | $this->CurrentTime_ = $tempvalue; |
| 1270 | if ($name == "CACHEDUNTIL") |
| 1271 | { |
| 1272 | $this->CachedUntil_ = $tempvalue; |
| 1273 | config::set('API_eve_ErrorList' , $tempvalue); |
| 1274 | } |
| 1275 | |
| 1276 | if ($name == "ROW") |
| 1277 | { |
| 1278 | $this->Error_[] = $ErrorData; |
| 1279 | $ErrorData = array(); |
| 1280 | unset($ErrorData); |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | function characterData($parser, $data) |
| 1285 | { |
| 1286 | global $tempvalue; |
| 1287 | |
| 1288 | $tempvalue = $data; |
| 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | // ********************************************************************************************************************************************** |
| 1293 | // **************** API Jumps list - /map/Jumps.xml.aspx **************** |
| 1294 | // ********************************************************************************************************************************************** |
| 1295 | |
| 1296 | class API_Jumps |
| 1297 | { |
| 1298 | function getCachedUntil() |
| 1299 | { |
| 1300 | return $this->CachedUntil_; |
| 1301 | } |
| 1302 | |
| 1303 | function getCurrentTime() |
| 1304 | { |
| 1305 | return $this->CurrentTime_; |
| 1306 | } |
| 1307 | |
| 1308 | function getDataTime() |
| 1309 | { |
| 1310 | return $this->DataTime_; |
| 1311 | } |
| 1312 | |
| 1313 | function getJumps() |
| 1314 | { |
| 1315 | return $this->Jumps_; |
| 1316 | } |
| 1317 | |
| 1318 | function fetchXML() |
| 1319 | { |
| 1320 | $data = LoadGlobalData('/map/Jumps.xml.aspx'); |
| 1321 | |
| 1322 | $xml_parser = xml_parser_create(); |
| 1323 | xml_set_object ( $xml_parser, $this ); |
| 1324 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1325 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1326 | |
| 1327 | if (!xml_parse($xml_parser, $data, true)) |
| 1328 | return "<i>Error getting XML data from api.eve-online.com/map/Jumps.xml.aspx </i><br><br>"; |
| 1329 | |
| 1330 | xml_parser_free($xml_parser); |
| 1331 | |
| 1332 | return $this->html; |
| 1333 | } |
| 1334 | |
| 1335 | function startElement($parser, $name, $attribs) |
| 1336 | { |
| 1337 | global $JumpData; |
| 1338 | |
| 1339 | if ($name == "ROW") |
| 1340 | { |
| 1341 | if (count($attribs)) |
| 1342 | { |
| 1343 | foreach ($attribs as $k => $v) |
| 1344 | { |
| 1345 | switch ($k) |
| 1346 | { |
| 1347 | case "SOLARSYSTEMID": |
| 1348 | $JumpData['solarSystemID'] = $v; |
| 1349 | break; |
| 1350 | case "SHIPJUMPS": |
| 1351 | $JumpData['shipJumps'] = $v; |
| 1352 | break; |
| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | function endElement($parser, $name) |
| 1360 | { |
| 1361 | global $JumpData; |
| 1362 | global $tempvalue; |
| 1363 | |
| 1364 | if ($name == "CURRENTTIME") |
| 1365 | $this->CurrentTime_ = $tempvalue; |
| 1366 | if ($name == "DATATIME") |
| 1367 | $this->DataTime_ = $tempvalue; |
| 1368 | if ($name == "CACHEDUNTIL") |
| 1369 | { |
| 1370 | $this->CachedUntil_ = $tempvalue; |
| 1371 | config::set('API_map_Jumps' , $tempvalue); |
| 1372 | } |
| 1373 | |
| 1374 | if ($name == "ROW") |
| 1375 | { |
| 1376 | $this->Jumps_[] = $JumpData; |
| 1377 | $JumpData = array(); |
| 1378 | unset($JumpData); |
| 1379 | } |
| 1380 | } |
| 1381 | |
| 1382 | function characterData($parser, $data) |
| 1383 | { |
| 1384 | global $tempvalue; |
| 1385 | |
| 1386 | $tempvalue = $data; |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | // ********************************************************************************************************************************************** |
| 1391 | // **************** API Kills list - /map/Kills.xml.aspx **************** |
| 1392 | // ********************************************************************************************************************************************** |
| 1393 | |
| 1394 | class API_Kills |
| 1395 | { |
| 1396 | function getCachedUntil() |
| 1397 | { |
| 1398 | return $this->CachedUntil_; |
| 1399 | } |
| 1400 | |
| 1401 | function getCurrentTime() |
| 1402 | { |
| 1403 | return $this->CurrentTime_; |
| 1404 | } |
| 1405 | |
| 1406 | function getDataTime() |
| 1407 | { |
| 1408 | return $this->DataTime_; |
| 1409 | } |
| 1410 | |
| 1411 | function getkills() |
| 1412 | { |
| 1413 | return $this->kills_; |
| 1414 | } |
| 1415 | |
| 1416 | function fetchXML() |
| 1417 | { |
| 1418 | $data = LoadGlobalData('/map/Kills.xml.aspx'); |
| 1419 | |
| 1420 | $xml_parser = xml_parser_create(); |
| 1421 | xml_set_object ( $xml_parser, $this ); |
| 1422 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1423 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1424 | |
| 1425 | if (!xml_parse($xml_parser, $data, true)) |
| 1426 | return "<i>Error getting XML data from api.eve-online.com/map/Kills.xml.aspx </i><br><br>"; |
| 1427 | |
| 1428 | xml_parser_free($xml_parser); |
| 1429 | |
| 1430 | return $this->html; |
| 1431 | } |
| 1432 | |
| 1433 | function startElement($parser, $name, $attribs) |
| 1434 | { |
| 1435 | global $KillsData; |
| 1436 | |
| 1437 | if ($name == "ROW") |
| 1438 | { |
| 1439 | if (count($attribs)) |
| 1440 | { |
| 1441 | foreach ($attribs as $k => $v) |
| 1442 | { |
| 1443 | switch ($k) |
| 1444 | { |
| 1445 | case "SOLARSYSTEMID": |
| 1446 | $KillsData['solarSystemID'] = $v; |
| 1447 | break; |
| 1448 | case "SHIPKILLS": |
| 1449 | $KillsData['shipKills'] = $v; |
| 1450 | break; |
| 1451 | case "FACTIONKILLS": |
| 1452 | $KillsData['factionKills'] = $v; |
| 1453 | break; |
| 1454 | case "PODKILLS": |
| 1455 | $KillsData['podKills'] = $v; |
| 1456 | break; |
| 1457 | } |
| 1458 | } |
| 1459 | } |
| 1460 | } |
| 1461 | } |
| 1462 | |
| 1463 | function endElement($parser, $name) |
| 1464 | { |
| 1465 | global $KillsData; |
| 1466 | global $tempvalue; |
| 1467 | |
| 1468 | if ($name == "CURRENTTIME") |
| 1469 | $this->CurrentTime_ = $tempvalue; |
| 1470 | if ($name == "DATATIME") |
| 1471 | $this->DataTime_ = $tempvalue; |
| 1472 | if ($name == "CACHEDUNTIL") |
| 1473 | { |
| 1474 | $this->CachedUntil_ = $tempvalue; |
| 1475 | config::set('API_map_Kills' , $tempvalue); |
| 1476 | } |
| 1477 | |
| 1478 | if ($name == "ROW") |
| 1479 | { |
| 1480 | $this->kills_[] = $KillsData; |
| 1481 | $KillsData = array(); |
| 1482 | unset($KillsData); |
| 1483 | } |
| 1484 | } |
| 1485 | |
| 1486 | function characterData($parser, $data) |
| 1487 | { |
| 1488 | global $tempvalue; |
| 1489 | |
| 1490 | $tempvalue = $data; |
| 1491 | } |
| 1492 | } |
| 1493 | |
| 1494 | // ********************************************************************************************************************************************** |
| 1495 | // **************** API Alliance Sovereignty - /map/Sovereignty.xml.aspx **************** |
| 1496 | // ********************************************************************************************************************************************** |
| 1497 | |
| 1498 | class API_Sovereignty |
| 1499 | { |
| 1500 | function getCachedUntil() |
| 1501 | { |
| 1502 | return $this->CachedUntil_; |
| 1503 | } |
| 1504 | |
| 1505 | function getCurrentTime() |
| 1506 | { |
| 1507 | return $this->CurrentTime_; |
| 1508 | } |
| 1509 | |
| 1510 | function getDataTime() |
| 1511 | { |
| 1512 | return $this->DataTime_; |
| 1513 | } |
| 1514 | |
| 1515 | function getSovereignty() |
| 1516 | { |
| 1517 | return $this->Sovereignty_; |
| 1518 | } |
| 1519 | |
| 1520 | function fetchXML() |
| 1521 | { |
| 1522 | $data = LoadGlobalData('/map/Sovereignty.xml.aspx'); |
| 1523 | |
| 1524 | $xml_parser = xml_parser_create(); |
| 1525 | xml_set_object ( $xml_parser, $this ); |
| 1526 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1527 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1528 | |
| 1529 | if (!xml_parse($xml_parser, $data, true)) |
| 1530 | return "<i>Error getting XML data from api.eve-online.com/map/Sovereignty.xml.aspx </i><br><br>"; |
| 1531 | |
| 1532 | xml_parser_free($xml_parser); |
| 1533 | |
| 1534 | return $this->html; |
| 1535 | } |
| 1536 | |
| 1537 | function startElement($parser, $name, $attribs) |
| 1538 | { |
| 1539 | global $SovereigntyData; |
| 1540 | |
| 1541 | if ($name == "ROW") |
| 1542 | { |
| 1543 | if (count($attribs)) |
| 1544 | { |
| 1545 | foreach ($attribs as $k => $v) |
| 1546 | { |
| 1547 | switch ($k) |
| 1548 | { |
| 1549 | case "SOLARSYSTEMID": |
| 1550 | $SovereigntyData['solarSystemID'] = $v; |
| 1551 | break; |
| 1552 | case "ALLIANCEID": |
| 1553 | $SovereigntyData['allianceID'] = $v; |
| 1554 | break; |
| 1555 | case "CONSTELLATIONSOVEREIGNTY": |
| 1556 | $SovereigntyData['constellationSovereignty'] = $v; |
| 1557 | break; |
| 1558 | case "SOVEREIGNTYLEVEL": |
| 1559 | $SovereigntyData['sovereigntyLevel'] = $v; |
| 1560 | break; |
| 1561 | case "FACTIONID": |
| 1562 | $SovereigntyData['factionID'] = $v; |
| 1563 | break; |
| 1564 | case "SOLARSYSTEMNAME": |
| 1565 | $SovereigntyData['solarSystemName'] = $v; |
| 1566 | break; |
| 1567 | } |
| 1568 | } |
| 1569 | } |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | function endElement($parser, $name) |
| 1574 | { |
| 1575 | global $SovereigntyData; |
| 1576 | global $tempvalue; |
| 1577 | |
| 1578 | if ($name == "CURRENTTIME") |
| 1579 | $this->CurrentTime_ = $tempvalue; |
| 1580 | if ($name == "DATATIME") |
| 1581 | $this->DataTime_ = $tempvalue; |
| 1582 | if ($name == "CACHEDUNTIL") |
| 1583 | { |
| 1584 | $this->CachedUntil_ = $tempvalue; |
| 1585 | config::set('API_map_Sovereignty' , $tempvalue); |
| 1586 | } |
| 1587 | |
| 1588 | if ($name == "ROW") |
| 1589 | { |
| 1590 | $this->Sovereignty_[] = $SovereigntyData; |
| 1591 | $SovereigntyData = array(); |
| 1592 | unset($SovereigntyData); |
| 1593 | } |
| 1594 | } |
| 1595 | |
| 1596 | function characterData($parser, $data) |
| 1597 | { |
| 1598 | global $tempvalue; |
| 1599 | |
| 1600 | $tempvalue = $data; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | // ********************************************************************************************************************************************** |
| 1605 | // **************** API Reference Types - /eve/RefTypes.xml.aspx **************** |
| 1606 | // ********************************************************************************************************************************************** |
| 1607 | |
| 1608 | class API_RefTypes |
| 1609 | { |
| 1610 | function getCachedUntil() |
| 1611 | { |
| 1612 | return $this->CachedUntil_; |
| 1613 | } |
| 1614 | |
| 1615 | function getCurrentTime() |
| 1616 | { |
| 1617 | return $this->CurrentTime_; |
| 1618 | } |
| 1619 | |
| 1620 | function getRefTypes() |
| 1621 | { |
| 1622 | return $this->RefTypes_; |
| 1623 | } |
| 1624 | |
| 1625 | function fetchXML() |
| 1626 | { |
| 1627 | $data = LoadGlobalData('/eve/RefTypes.xml.aspx'); |
| 1628 | |
| 1629 | $xml_parser = xml_parser_create(); |
| 1630 | xml_set_object ( $xml_parser, $this ); |
| 1631 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1632 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1633 | |
| 1634 | if (!xml_parse($xml_parser, $data, true)) |
| 1635 | return "<i>Error getting XML data from api.eve-online.com/eve/RefTypes.xml.aspx </i><br><br>"; |
| 1636 | |
| 1637 | xml_parser_free($xml_parser); |
| 1638 | |
| 1639 | return $this->html; |
| 1640 | } |
| 1641 | |
| 1642 | function startElement($parser, $name, $attribs) |
| 1643 | { |
| 1644 | global $RefTypeData; |
| 1645 | |
| 1646 | if ($name == "ROW") |
| 1647 | { |
| 1648 | if (count($attribs)) |
| 1649 | { |
| 1650 | foreach ($attribs as $k => $v) |
| 1651 | { |
| 1652 | switch ($k) |
| 1653 | { |
| 1654 | case "REFTYPEID": |
| 1655 | $RefTypeData['refTypeID'] = $v; |
| 1656 | break; |
| 1657 | case "REFTYPENAME": |
| 1658 | $RefTypeData['refTypeName'] = $v; |
| 1659 | break; |
| 1660 | } |
| 1661 | } |
| 1662 | } |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | function endElement($parser, $name) |
| 1667 | { |
| 1668 | global $RefTypeData; |
| 1669 | global $tempvalue; |
| 1670 | |
| 1671 | if ($name == "CURRENTTIME") |
| 1672 | $this->CurrentTime_ = $tempvalue; |
| 1673 | if ($name == "CACHEDUNTIL") |
| 1674 | { |
| 1675 | $this->CachedUntil_ = $tempvalue; |
| 1676 | config::set('API_eve_RefTypes' , $tempvalue); |
| 1677 | } |
| 1678 | |
| 1679 | if ($name == "ROW") |
| 1680 | { |
| 1681 | $this->RefTypes_[] = $RefTypeData; |
| 1682 | $RefTypeData = array(); |
| 1683 | unset($RefTypeData); |
| 1684 | } |
| 1685 | } |
| 1686 | |
| 1687 | function characterData($parser, $data) |
| 1688 | { |
| 1689 | global $tempvalue; |
| 1690 | |
| 1691 | $tempvalue = $data; |
| 1692 | } |
| 1693 | } |
| 1694 | |
| 1695 | // ********************************************************************************************************************************************** |
| 1696 | // **************** API Faction War Systems - /map/FacWarSystems.xml.aspx **************** |
| 1697 | // ********************************************************************************************************************************************** |
| 1698 | |
| 1699 | class API_FacWarSystems |
| 1700 | { |
| 1701 | function getCachedUntil() |
| 1702 | { |
| 1703 | return $this->CachedUntil_; |
| 1704 | } |
| 1705 | |
| 1706 | function getCurrentTime() |
| 1707 | { |
| 1708 | return $this->CurrentTime_; |
| 1709 | } |
| 1710 | |
| 1711 | function getFacWarSystems() |
| 1712 | { |
| 1713 | return $this->FacWarSystems_; |
| 1714 | } |
| 1715 | |
| 1716 | function fetchXML() |
| 1717 | { |
| 1718 | $data = LoadGlobalData('/map/FacWarSystems.xml.aspx'); |
| 1719 | |
| 1720 | $xml_parser = xml_parser_create(); |
| 1721 | xml_set_object ( $xml_parser, $this ); |
| 1722 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1723 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1724 | |
| 1725 | if (!xml_parse($xml_parser, $data, true)) |
| 1726 | return "<i>Error getting XML data from api.eve-online.com/map/FacWarSystems.xml.aspx </i><br><br>"; |
| 1727 | |
| 1728 | xml_parser_free($xml_parser); |
| 1729 | |
| 1730 | return $this->FacWarSystems_; |
| 1731 | } |
| 1732 | |
| 1733 | function startElement($parser, $name, $attribs) |
| 1734 | { |
| 1735 | global $FacWarSystem; |
| 1736 | |
| 1737 | if ($name == "ROW") |
| 1738 | { |
| 1739 | if (count($attribs)) |
| 1740 | { |
| 1741 | foreach ($attribs as $k => $v) |
| 1742 | { |
| 1743 | switch ($k) |
| 1744 | { |
| 1745 | case "SOLARSYSTEMID": |
| 1746 | $FacWarSystem['solarSystemID'] = $v; |
| 1747 | break; |
| 1748 | case "SOLARSYSTEMNAME": |
| 1749 | $FacWarSystem['solarSystemName'] = $v; |
| 1750 | break; |
| 1751 | case "OCCUPYINGFACTIONID": |
| 1752 | $FacWarSystem['occupyingFactionID'] = $v; |
| 1753 | break; |
| 1754 | case "OCCUPYINGFACTIONNAME": |
| 1755 | $FacWarSystem['occupyingFactionName'] = $v; |
| 1756 | break; |
| 1757 | case "CONTESTED": |
| 1758 | $FacWarSystem['contested'] = $v; |
| 1759 | break; |
| 1760 | } |
| 1761 | } |
| 1762 | } |
| 1763 | } |
| 1764 | } |
| 1765 | |
| 1766 | function endElement($parser, $name) |
| 1767 | { |
| 1768 | global $FacWarSystem; |
| 1769 | global $tempvalue; |
| 1770 | |
| 1771 | if ($name == "CURRENTTIME") |
| 1772 | $this->CurrentTime_ = $tempvalue; |
| 1773 | if ($name == "CACHEDUNTIL") |
| 1774 | { |
| 1775 | $this->CachedUntil_ = $tempvalue; |
| 1776 | config::set('API_map_FacWarSystems' , $tempvalue); |
| 1777 | } |
| 1778 | |
| 1779 | if ($name == "ROW") |
| 1780 | { |
| 1781 | $this->FacWarSystems_[] = $FacWarSystem; |
| 1782 | $FacWarSystem = array(); |
| 1783 | unset($FacWarSystem); |
| 1784 | } |
| 1785 | } |
| 1786 | |
| 1787 | function characterData($parser, $data) |
| 1788 | { |
| 1789 | global $tempvalue; |
| 1790 | |
| 1791 | $tempvalue = $data; |
| 1792 | } |
| 1793 | } |
| 1794 | |
| 1795 | // ********************************************************************************************************************************************** |
| 1796 | // **************** API Standings - /corp & char/Standings.xml.aspx **************** |
| 1797 | // ********************************************************************************************************************************************** |
| 1798 | class API_Standings |
| 1799 | { |
| 1800 | function getCachedUntil() |
| 1801 | { |
| 1802 | return $this->CachedUntil_; |
| 1803 | } |
| 1804 | |
| 1805 | function getCurrentTime() |
| 1806 | { |
| 1807 | return $this->CurrentTime_; |
| 1808 | } |
| 1809 | |
| 1810 | function isUser($value) // boolean value - sets between char/corp |
| 1811 | { |
| 1812 | $this->isUser_ = $value; |
| 1813 | } |
| 1814 | |
| 1815 | function setAPIKey($key) |
| 1816 | { |
| 1817 | $this->API_apiKey = $key; |
| 1818 | } |
| 1819 | |
| 1820 | function setUserID($uid) |
| 1821 | { |
| 1822 | $this->API_userID_ = $uid; |
| 1823 | } |
| 1824 | |
| 1825 | function setCharacterID($cid) |
| 1826 | { |
| 1827 | $this->API_characterID_ = $cid; |
| 1828 | } |
| 1829 | |
| 1830 | function getCharacters() |
| 1831 | { |
| 1832 | return $this->Characters_; |
| 1833 | } |
| 1834 | function getCorporations() |
| 1835 | { |
| 1836 | return $this->Corporations_; |
| 1837 | } |
| 1838 | function getAlliances() |
| 1839 | { |
| 1840 | return $this->Alliances_; |
| 1841 | } |
| 1842 | function getAgents() |
| 1843 | { |
| 1844 | return $this->Agents_; |
| 1845 | } |
| 1846 | function getNPCCorporations() |
| 1847 | { |
| 1848 | return $this->NPCCorporations_; |
| 1849 | } |
| 1850 | function getFactions() |
| 1851 | { |
| 1852 | return $this->Factions_; |
| 1853 | } |
| 1854 | function getAllianceCorporations() |
| 1855 | { |
| 1856 | return $this->AllianceCorporations_; |
| 1857 | } |
| 1858 | function getAliianceAlliances() |
| 1859 | { |
| 1860 | return $this->AliianceAlliances_; |
| 1861 | } |
| 1862 | |
| 1863 | function fetchXML() |
| 1864 | { |
| 1865 | $this->isAllianceStandings_ = false; |
| 1866 | $this->isCorporationStandings_ = false; |
| 1867 | |
| 1868 | if ($this->isUser_) |
| 1869 | { // is a player feed - take details from logged in user |
| 1870 | if (user::get('usr_pilot_id')) |
| 1871 | { |
| 1872 | $myEveCharAPI = new API_CharacterSheet(); |
| 1873 | $this->html .= $myEveCharAPI->fetchXML(); |
| 1874 | |
| 1875 | $skills = $myEveCharAPI->getSkills(); |
| 1876 | |
| 1877 | $this->connections_ = 0; |
| 1878 | $this->diplomacy_ = 0; |
| 1879 | |
| 1880 | foreach ((array)$skills as $myTempData) |
| 1881 | { |
| 1882 | if ($myTempData['typeID'] == "3359") |
| 1883 | $this->connections_ = $myTempData['Level']; |
| 1884 | if ($myTempData['typeID'] == "3357") |
| 1885 | $this->diplomacy_ = $myTempData['Level']; |
| 1886 | } |
| 1887 | |
| 1888 | $myKeyString = "userID=" . $this->API_userID_ . "&apiKey=" . $this->API_apiKey_ . "&characterID=" . $this->API_characterID_; |
| 1889 | |
| 1890 | $data = $this->loaddata($myKeyString, "char"); |
| 1891 | } else { |
| 1892 | return "You are not logged in."; |
| 1893 | } |
| 1894 | |
| 1895 | } else { // is a corp feed |
| 1896 | |
| 1897 | } |
| 1898 | |
| 1899 | $xml_parser = xml_parser_create(); |
| 1900 | xml_set_object ( $xml_parser, $this ); |
| 1901 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 1902 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 1903 | |
| 1904 | if (!xml_parse($xml_parser, $data, true)) |
| 1905 | return "<i>Error getting XML data from api.eve-online.com/Standings.xml.aspx </i><br><br>"; |
| 1906 | |
| 1907 | xml_parser_free($xml_parser); |
| 1908 | |
| 1909 | // sort the arrays (in descending order of standing) |
| 1910 | $this->Factions_ = $this->mysortarray($this->Factions_); |
| 1911 | $this->Characters_ = $this->mysortarray($this->Characters_); |
| 1912 | $this->Corporations_ = $this->mysortarray($this->Corporations_); |
| 1913 | $this->Alliances_ = $this->mysortarray($this->Alliances_); |
| 1914 | $this->Agents_ = $this->mysortarray($this->Agents_); |
| 1915 | $this->NPCCorporations_ = $this->mysortarray($this->NPCCorporations_); |
| 1916 | $this->AllianceCorporations_ = $this->mysortarray($this->AllianceCorporations_); |
| 1917 | $this->AllianceAlliances_ = $this->mysortarray($this->AliianceAlliances_); |
| 1918 | |
| 1919 | return $this->html; |
| 1920 | } |
| 1921 | |
| 1922 | function mysortarray($arraydata) |
| 1923 | { |
| 1924 | if (count($arraydata) != 0 ) |
| 1925 | { |
| 1926 | foreach ((array)$arraydata as $key => $row) { |
| 1927 | $standing[$key] = $row['Standing']; |
| 1928 | $name[$key] = $row['Name']; |
| 1929 | $id[$key] = $row['ID']; |
| 1930 | } |
| 1931 | |
| 1932 | array_multisort($standing, SORT_DESC, $name, SORT_ASC, $id, SORT_ASC, $arraydata); |
| 1933 | |
| 1934 | $standing = array(); |
| 1935 | unset($standing); |
| 1936 | $name = array(); |
| 1937 | unset($name); |
| 1938 | $id = array(); |
| 1939 | unset($id); |
| 1940 | |
| 1941 | return $arraydata; |
| 1942 | } |
| 1943 | } |
| 1944 | |
| 1945 | function startElement($parser, $name, $attribs) |
| 1946 | { |
| 1947 | |
| 1948 | if ($name == "CORPORATIONSTANDINGS") |
| 1949 | { |
| 1950 | $this->isAllianceStandings_ = false; |
| 1951 | $this->isCorporationStandings_ = true; |
| 1952 | } |
| 1953 | if ($name == "STANDINGSTO") |
| 1954 | { |
| 1955 | $this->StandingsTo_ = true; // used to determine if/when to apply diplomacy/connections bonus |
| 1956 | } |
| 1957 | if ($name == "STANDINGSFROM") |
| 1958 | { |
| 1959 | $this->StandingsTo_ = false; |
| 1960 | } |
| 1961 | if ($name == "ALLIANCESTANDINGS") |
| 1962 | { |
| 1963 | $this->isAllianceStandings_ = true; |
| 1964 | $this->isCorporationStandings_ = false; |
| 1965 | } |
| 1966 | |
| 1967 | if ($name == "ROWSET") // In this If statement we set booleans to ultimately determine where the data in the next If statement is stored |
| 1968 | { |
| 1969 | if (count($attribs)) |
| 1970 | { |
| 1971 | foreach ($attribs as $k => $v) |
| 1972 | { |
| 1973 | switch ($k) |
| 1974 | { |
| 1975 | case "NAME": |
| 1976 | switch ($v) |
| 1977 | { // bitwise or numeric flag would be better and more concise - but fuck it! |
| 1978 | case "characters": // can only be personal/corp |
| 1979 | $this->isCharacters_ = true; |
| 1980 | $this->isCorporations_ = false; |
| 1981 | $this->isAlliances_ = false; |
| 1982 | $this->isAgents_ = false; |
| 1983 | $this->isNPCCorporations_ = false; |
| 1984 | $this->isFactions_ = false; |
| 1985 | $this->isAllianceCorporations_ = false; |
| 1986 | $this->isAllianceAlliances_ = false; |
| 1987 | break; |
| 1988 | case "corporations": // can be either personal/corp or alliance |
| 1989 | $this->isCharacters_ = false; |
| 1990 | $this->isCorporations_ = false; |
| 1991 | $this->isAlliances_ = false; |
| 1992 | $this->isAgents_ = false; |
| 1993 | $this->isNPCCorporations_ = false; |
| 1994 | $this->isFactions_ = false; |
| 1995 | $this->isAllianceCorporations_ = false; |
| 1996 | $this->isAllianceAlliances_ = false; |
| 1997 | |
| 1998 | if (!$this->isAllianceStandings_) // then it is personal/corp |
| 1999 | { |
| 2000 | $this->isCorporations_ = true; |
| 2001 | } else { // then it is alliance |
| 2002 | $this->isAllianceCorporations_ = true; |
| 2003 | } |
| 2004 | break; |
| 2005 | case "alliances": // can be either personal/corp or alliance |
| 2006 | $this->isCharacters_ = false; |
| 2007 | $this->isCorporations_ = false; |
| 2008 | $this->isAlliances_ = false; |
| 2009 | $this->isAgents_ = false; |
| 2010 | $this->isNPCCorporations_ = false; |
| 2011 | $this->isFactions_ = false; |
| 2012 | $this->isAllianceCorporations_ = false; |
| 2013 | $this->isAllianceAlliances_ = false; |
| 2014 | |
| 2015 | if (!$this->isAllianceStandings_) // then it is personal/corp |
| 2016 | { |
| 2017 | $this->isAlliances_ = true; |
| 2018 | } else { // then it is alliance |
| 2019 | $this->isAllianceAlliances_ = true; |
| 2020 | } |
| 2021 | break; |
| 2022 | case "agents": // can only be personal/corp |
| 2023 | $this->isCharacters_ = false; |
| 2024 | $this->isCorporations_ = false; |
| 2025 | $this->isAlliances_ = false; |
| 2026 | $this->isAgents_ = true; |
| 2027 | $this->isNPCCorporations_ = false; |
| 2028 | $this->isFactions_ = false; |
| 2029 | $this->isAllianceCorporations_ = false; |
| 2030 | $this->isAllianceAlliances_ = false; |
| 2031 | break; |
| 2032 | case "NPCCorporations": // can only be personal/corp |
| 2033 | $this->isCharacters_ = false; |
| 2034 | $this->isCorporations_ = false; |
| 2035 | $this->isAlliances_ = false; |
| 2036 | $this->isAgents_ = false; |
| 2037 | $this->isNPCCorporations_ = true; |
| 2038 | $this->isFactions_ = false; |
| 2039 | $this->isAllianceCorporations_ = false; |
| 2040 | $this->isAllianceAlliances_ = false; |
| 2041 | break; |
| 2042 | case "factions": // can only be personal/corp |
| 2043 | $this->isCharacters_ = false; |
| 2044 | $this->isCorporations_ = false; |
| 2045 | $this->isAlliances_ = false; |
| 2046 | $this->isAgents_ = false; |
| 2047 | $this->isNPCCorporations_ = false; |
| 2048 | $this->isFactions_ = true; |
| 2049 | $this->isAllianceCorporations_ = false; |
| 2050 | $this->isAllianceAlliances_ = false; |
| 2051 | break; |
| 2052 | } |
| 2053 | break; |
| 2054 | } |
| 2055 | } |
| 2056 | } |
| 2057 | } |
| 2058 | |
| 2059 | if ($name == "ROW") |
| 2060 | { |
| 2061 | global $tempdata; |
| 2062 | |
| 2063 | if (count($attribs)) |
| 2064 | { |
| 2065 | foreach ($attribs as $k => $v) |
| 2066 | { |
| 2067 | switch ($k) |
| 2068 | { |
| 2069 | case "TOID": |
| 2070 | $tempdata['ID'] = $v; |
| 2071 | break; |
| 2072 | case "FROMID": |
| 2073 | $tempdata['ID'] = $v; |
| 2074 | break; |
| 2075 | case "TONAME": |
| 2076 | $tempdata['Name'] = $v; |
| 2077 | break; |
| 2078 | case "FROMNAME": |
| 2079 | $tempdata['Name'] = $v; |
| 2080 | break; |
| 2081 | case "STANDING": |
| 2082 | // use flags determined in previous If... to load the correct array[] |
| 2083 | if ($this->isUser_ && !$this->StandingsTo_) |
| 2084 | { // set standings bonus where applicable |
| 2085 | // calculate bonus |
| 2086 | if ($v >= 0) // Connections |
| 2087 | $tempdata['Standing'] = number_format($v + ((10 - $v) * (0.04 * $this->connections_)), 2, '.', ''); |
| 2088 | else // Diplomacy |
| 2089 | $tempdata['Standing'] = number_format($v + ((10 - $v) * (0.04 * $this->diplomacy_)), 2, '.', ''); |
| 2090 | } else { |
| 2091 | $tempdata['Standing'] = $v; |
| 2092 | } |
| 2093 | |
| 2094 | // check that 'Name' isn't empty as this means the value was reset |
| 2095 | if ($tempdata['Name'] != "") |
| 2096 | { |
| 2097 | if ($this->isCharacters_) { |
| 2098 | $this->Characters_[] = $tempdata; |
| 2099 | } elseif ($this->isCorporations_) { |
| 2100 | $this->Corporations_[] = $tempdata; |
| 2101 | } elseif ($this->isAlliances_ ) { |
| 2102 | $this->Alliances_[] = $tempdata; |
| 2103 | } elseif ($this->isAgents_) { |
| 2104 | $this->Agents_[] = $tempdata; |
| 2105 | } elseif ($this->isNPCCorporations_) { |
| 2106 | $this->NPCCorporations_[] = $tempdata; |
| 2107 | } elseif ($this->isFactions_) { |
| 2108 | $this->Factions_[] = $tempdata; |
| 2109 | } elseif ($this->isAllianceCorporations_) { |
| 2110 | $this->AllianceCorporations_[] = $tempdata; |
| 2111 | } elseif ($this->isAllianceAlliances_) { |
| 2112 | $this->AllianceAlliances_[] = $tempdata; |
| 2113 | } |
| 2114 | } |
| 2115 | |
| 2116 | $tempdata = array(); |
| 2117 | unset($tempdata); |
| 2118 | break; |
| 2119 | } |
| 2120 | } |
| 2121 | } |
| 2122 | } |
| 2123 | } |
| 2124 | |
| 2125 | function endElement($parser, $name) |
| 2126 | { |
| 2127 | |
| 2128 | if ($name == "CURRENTTIME") |
| 2129 | $this->CurrentTime_ = $this->characterDataValue; |
| 2130 | if ($name == "CACHEDUNTIL") |
| 2131 | { |
| 2132 | $this->CachedUntil_ = $this->characterDataValue; |
| 2133 | config::set( $this->API_characterID_ . '_Standings' , $this->characterDataValue); |
| 2134 | } |
| 2135 | } |
| 2136 | |
| 2137 | function characterData($parser, $data) |
| 2138 | { |
| 2139 | $this->characterDataValue = $data; |
| 2140 | } |
| 2141 | |
| 2142 | function loaddata($keystring, $typestring) |
| 2143 | { |
| 2144 | $configvalue = $this->API_characterID_ . '_Standings'; |
| 2145 | |
| 2146 | $CachedTime = config::get($configvalue); |
| 2147 | $UseCaching = config::get('API_UseCache'); |
| 2148 | |
| 2149 | $url = "http://api.eve-online.com/" . $typestring . "/Standings.xml.aspx" . $keystring; |
| 2150 | |
| 2151 | $path = '/' . $typestring . '/Standings.xml.aspx'; |
| 2152 | |
| 2153 | // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round. |
| 2154 | if ($CachedTime == "") |
| 2155 | { |
| 2156 | $CachedTime = "2005-01-01 00:00:00"; // fake date to ensure that it runs first time. |
| 2157 | } |
| 2158 | |
| 2159 | if (is_file('cache/api/'.$configvalue.'.xml')) |
| 2160 | $cacheexists = true; |
| 2161 | else |
| 2162 | $cacheexists = false; |
| 2163 | |
| 2164 | |
| 2165 | if ((strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0) || ($UseCaching == 1) || !$cacheexists )// if API_UseCache = 1 (off) then don't use cache |
| 2166 | { |
| 2167 | $fp = fsockopen("api.eve-online.com", 80); |
| 2168 | |
| 2169 | if (!$fp) |
| 2170 | { |
| 2171 | $this->Output_ .= "Could not connect to API URL"; |
| 2172 | } else { |
| 2173 | // request the xml |
| 2174 | fputs ($fp, "POST " . $path . " HTTP/1.0\r\n"); |
| 2175 | fputs ($fp, "Host: api.eve-online.com\r\n"); |
| 2176 | fputs ($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); |
| 2177 | fputs ($fp, "User-Agent: PHPApi\r\n"); |
| 2178 | fputs ($fp, "Content-Length: " . strlen($keystring) . "\r\n"); |
| 2179 | fputs ($fp, "Connection: close\r\n\r\n"); |
| 2180 | fputs ($fp, $keystring."\r\n"); |
| 2181 | |
| 2182 | // retrieve contents |
| 2183 | $contents = ""; |
| 2184 | while (!feof($fp)) |
| 2185 | { |
| 2186 | $contents .= fgets($fp); |
| 2187 | } |
| 2188 | |
| 2189 | // close connection |
| 2190 | fclose($fp); |
| 2191 | |
| 2192 | $start = strpos($contents, "?>"); |
| 2193 | if ($start !== FALSE) |
| 2194 | { |
| 2195 | $contents = substr($contents, $start + strlen("\r\n\r\n")); |
| 2196 | } |
| 2197 | |
| 2198 | if ($UseCaching == 0) // Save the file if we're caching (0 = true in Thunks world) |
| 2199 | { |
| 2200 | $file = fopen('cache/api/'.$configvalue.'.xml', 'w+'); |
| 2201 | fwrite($file, $contents); |
| 2202 | fclose($file); |
| 2203 | } |
| 2204 | } |
| 2205 | } else { |
| 2206 | // re-use cached XML |
| 2207 | if ($fp = @fopen('cache/api/'.$configvalue.'.xml', 'r')) { |
| 2208 | $contents = fread($fp, 1000000); |
| 2209 | fclose($fp); |
| 2210 | } else { |
| 2211 | return "<i>error loading cached file ".$configvalue.".xml</i><br><br>"; |
| 2212 | } |
| 2213 | } |
| 2214 | return $contents; |
| 2215 | } |
| 2216 | } |
| 2217 | |
| 2218 | // ********************************************************************************************************************************************** |
| 2219 | // **************** API Character Sheet - char/CharacterSheet.xml.aspx **************** |
| 2220 | // ********************************************************************************************************************************************** |
| 2221 | class API_CharacterSheet // Incomplete - Does not read Certificates or Roles |
| 2222 | { |
| 2223 | function getCachedUntil() |
| 2224 | { |
| 2225 | return $this->CachedUntil_; |
| 2226 | } |
| 2227 | |
| 2228 | function getCurrentTime() |
| 2229 | { |
| 2230 | return $this->CurrentTime_; |
| 2231 | } |
| 2232 | |
| 2233 | function getSkills() |
| 2234 | { |
| 2235 | return $this->Skills_; |
| 2236 | } |
| 2237 | |
| 2238 | function getImplants() // array 1-5 based on implant slot position. 6-10 don't seem to appear, presumably because Hardwirings do not affect skill training. |
| 2239 | { |
| 2240 | return $this->Implant_; |
| 2241 | } |
| 2242 | |
| 2243 | function getIntelligence() |
| 2244 | { |
| 2245 | return $this->Intelligence_; |
| 2246 | } |
| 2247 | |
| 2248 | function getMemory() |
| 2249 | { |
| 2250 | return $this->Memory_; |
| 2251 | } |
| 2252 | |
| 2253 | function getCharisma() |
| 2254 | { |
| 2255 | return $this->Charisma_; |
| 2256 | } |
| 2257 | |
| 2258 | function getPerception() |
| 2259 | { |
| 2260 | return $this->Perception_; |
| 2261 | } |
| 2262 | |
| 2263 | function getWillpower() |
| 2264 | { |
| 2265 | return $this->Willpower_; |
| 2266 | } |
| 2267 | function getCharacterID() |
| 2268 | { |
| 2269 | return $this->CharacterID_; |
| 2270 | } |
| 2271 | function getName() |
| 2272 | { |
| 2273 | return $this->Name_; |
| 2274 | } |
| 2275 | function getRace() |
| 2276 | { |
| 2277 | return $this->Race_; |
| 2278 | } |
| 2279 | function getBloodLine() |
| 2280 | { |
| 2281 | return $this->BloodLine_; |
| 2282 | } |
| 2283 | function getGender() |
| 2284 | { |
| 2285 | return $this->Gender_; |
| 2286 | } |
| 2287 | function getCorporationName() |
| 2288 | { |
| 2289 | return $this->CorporationName_; |
| 2290 | } |
| 2291 | function getCorporationID() |
| 2292 | { |
| 2293 | return $this->CorporationID_; |
| 2294 | } |
| 2295 | function getCloneName() |
| 2296 | { |
| 2297 | return $this->CloneName_; |
| 2298 | } |
| 2299 | function getCloneSkillPoints() |
| 2300 | { |
| 2301 | return $this->CloneSkillPoints_; |
| 2302 | } |
| 2303 | function getBalance() |
| 2304 | { |
| 2305 | return $this->Balance_; |
| 2306 | } |
| 2307 | function fetchXML() |
| 2308 | { |
| 2309 | // is a player feed - take details from logged in user |
| 2310 | if (user::get('usr_pilot_id')) |
| 2311 | { |
| 2312 | require_once('class.pilot.php'); |
| 2313 | $plt = new pilot(user::get('usr_pilot_id')); |
| 2314 | $usersname = $plt->getName(); |
| 2315 | |
| 2316 | $this->CharName_ = $usersname; // $this->CharName_ is used later for config key value for caching |
| 2317 | |
| 2318 | $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"'; |
| 2319 | |
| 2320 | $qry = new DBQuery(); |
| 2321 | $qry->execute($sql); |
| 2322 | $row = $qry->getRow(); |
| 2323 | |
| 2324 | $pilot_id = $row['plt_id']; |
| 2325 | $API_charID = $row['plt_externalid']; |
| 2326 | |
| 2327 | if ( $pilot_id == 0 ) |
| 2328 | { |
| 2329 | return "Something went wrong with finiding pilots external ID<br>"; |
| 2330 | } |
| 2331 | |
| 2332 | $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"'; |
| 2333 | $qry->execute($newsql); |
| 2334 | $userrow = $qry->getRow(); |
| 2335 | |
| 2336 | $API_userID = $userrow['userID']; |
| 2337 | $API_apiKey = $userrow['apiKey']; |
| 2338 | |
| 2339 | $myKeyString = "userID=" . $API_userID . "&apiKey=" . $API_apiKey . "&characterID=" . $API_charID; |
| 2340 | |
| 2341 | $data = $this->loaddata($myKeyString); |
| 2342 | } else { |
| 2343 | return "You are not logged in."; |
| 2344 | } |
| 2345 | |
| 2346 | $xml_parser = xml_parser_create(); |
| 2347 | xml_set_object ( $xml_parser, $this ); |
| 2348 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 2349 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 2350 | |
| 2351 | if (!xml_parse($xml_parser, $data, true)) |
| 2352 | return "<i>Error getting XML data from api.eve-online.com/Standings.xml.aspx </i><br><br>"; |
| 2353 | |
| 2354 | xml_parser_free($xml_parser); |
| 2355 | |
| 2356 | return $this->html; |
| 2357 | } |
| 2358 | |
| 2359 | function startElement($parser, $name, $attribs) |
| 2360 | { |
| 2361 | if ($name == "ROW") |
| 2362 | { |
| 2363 | global $tempdata; |
| 2364 | |
| 2365 | if (count($attribs)) |
| 2366 | { |
| 2367 | foreach ($attribs as $k => $v) |
| 2368 | { |
| 2369 | switch ($k) |
| 2370 | { |
| 2371 | case "TYPEID": |
| 2372 | $tempdata['typeID'] = $v; |
| 2373 | $tempdata['SkillName'] = gettypeIDname($v); |
| 2374 | $tempdata['GroupID'] = getgroupID($v); |
| 2375 | $tempdata['GroupName'] = getgroupIDname($tempdata['GroupID']); |
| 2376 | $tempdata['Rank'] = gettypeIDrank($v); |
| 2377 | break; |
| 2378 | case "SKILLPOINTS": |
| 2379 | $tempdata['SkillPoints'] = $v; |
| 2380 | break; |
| 2381 | case "LEVEL": |
| 2382 | $tempdata['Level'] = $v; |
| 2383 | |
| 2384 | $this->Skills_[] = $tempdata; |
| 2385 | |
| 2386 | $tempdata = array(); |
| 2387 | unset($tempdata); |
| 2388 | break; |
| 2389 | case "UNPUBLISHED": // unused skill eg. Black Market Trading |
| 2390 | $tempdata = array(); |
| 2391 | unset($tempdata); |
| 2392 | break; |
| 2393 | } |
| 2394 | } |
| 2395 | } |
| 2396 | } |
| 2397 | } |
| 2398 | |
| 2399 | function endElement($parser, $name) |
| 2400 | { |
| 2401 | // Player Details |
| 2402 | if ($name == "CHARACTERID") |
| 2403 | $this->CharacterID_ = $this->characterDataValue; |
| 2404 | if ($name == "NAME") |
| 2405 | $this->Name_ = $this->characterDataValue; |
| 2406 | if ($name == "RACE") |
| 2407 | $this->Race_ = $this->characterDataValue; |
| 2408 | if ($name == "BLOODLINE") |
| 2409 | $this->BloodLine_ = $this->characterDataValue; |
| 2410 | if ($name == "GENDER") |
| 2411 | $this->Gender_ = $this->characterDataValue; |
| 2412 | if ($name == "CORPORATIONNAME") |
| 2413 | $this->CorporationName_ = $this->characterDataValue; |
| 2414 | if ($name == "CORPORATIONID") |
| 2415 | $this->CorporationID_ = $this->characterDataValue; |
| 2416 | if ($name == "CLONENAME") |
| 2417 | $this->CloneName_ = $this->characterDataValue; |
| 2418 | if ($name == "CLONESKILLPOINTS") |
| 2419 | $this->CloneSkillPoints_ = $this->characterDataValue; |
| 2420 | if ($name == "BALANCE") |
| 2421 | $this->Balance_ = $this->characterDataValue; |
| 2422 | |
| 2423 | // Augmentations |
| 2424 | if ($name == "AUGMENTATORNAME") |
| 2425 | $tempaug['Name'] = $this->characterDataValue; |
| 2426 | if ($name == "AUGMENTATORVALUE") |
| 2427 | $tempaug['Value'] = $this->characterDataValue; |
| 2428 | |
| 2429 | if ($name == "PERCEPTIONBONUS") |
| 2430 | { |
| 2431 | $this->Implant_[1] = $tempaug; |
| 2432 | |
| 2433 | $tempaug = array(); |
| 2434 | unset($tempaug); |
| 2435 | } |
| 2436 | if ($name == "MEMORYBONUS") |
| 2437 | { |
| 2438 | $this->Implant_[2] = $tempaug; |
| 2439 | |
| 2440 | $tempaug = array(); |
| 2441 | unset($tempaug); |
| 2442 | } |
| 2443 | if ($name == "WILLPOWERBONUS") |
| 2444 | { |
| 2445 | $this->Implant_[3] = $tempaug; |
| 2446 | |
| 2447 | $tempaug = array(); |
| 2448 | unset($tempaug); |
| 2449 | } |
| 2450 | if ($name == "INTELLIGENCEBONUS") |
| 2451 | { |
| 2452 | $this->Implant_[4] = $tempaug; |
| 2453 | |
| 2454 | $tempaug = array(); |
| 2455 | unset($tempaug); |
| 2456 | } |
| 2457 | if ($name == "CHARISMABONUS") |
| 2458 | { |
| 2459 | $this->Implant_[5] = $tempaug; |
| 2460 | |
| 2461 | $tempaug = array(); |
| 2462 | unset($tempaug); |
| 2463 | } |
| 2464 | |
| 2465 | // Attributes |
| 2466 | if ($name == "INTELLIGENCE") |
| 2467 | $this->Intelligence_ = $this->characterDataValue; |
| 2468 | if ($name == "MEMORY") |
| 2469 | $this->Memory_ = $this->characterDataValue; |
| 2470 | if ($name == "CHARISMA") |
| 2471 | $this->Charisma_ = $this->characterDataValue; |
| 2472 | if ($name == "PERCEPTION") |
| 2473 | $this->Perception_ = $this->characterDataValue; |
| 2474 | if ($name == "WILLPOWER") |
| 2475 | $this->Willpower_ = $this->characterDataValue; |
| 2476 | |
| 2477 | if ($name == "CURRENTTIME") |
| 2478 | $this->CurrentTime_ = $this->characterDataValue; |
| 2479 | if ($name == "CACHEDUNTIL") |
| 2480 | { |
| 2481 | $this->CachedUntil_ = $this->characterDataValue; |
| 2482 | //config::set('API_eve_RefTypes' , $this->characterDataValue); |
| 2483 | config::set( $this->CharName_ . '_CharacterSheet' , $this->characterDataValue); |
| 2484 | } |
| 2485 | } |
| 2486 | |
| 2487 | function characterData($parser, $data) |
| 2488 | { |
| 2489 | $this->characterDataValue = $data; |
| 2490 | } |
| 2491 | |
| 2492 | function loaddata($keystring) |
| 2493 | { |
| 2494 | $configvalue = $this->CharName_ . '_CharacterSheet'; |
| 2495 | |
| 2496 | $CachedTime = config::get($configvalue); |
| 2497 | $UseCaching = config::get('API_UseCache'); |
| 2498 | |
| 2499 | $url = "http://api.eve-online.com/char/CharacterSheet.xml.aspx" . $keystring; |
| 2500 | |
| 2501 | $path = '/char/CharacterSheet.xml.aspx'; |
| 2502 | |
| 2503 | // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round. |
| 2504 | if ($CachedTime == "") |
| 2505 | { |
| 2506 | $CachedTime = "2005-01-01 00:00:00"; // fake date to ensure that it runs first time. |
| 2507 | } |
| 2508 | |
| 2509 | if (is_file('cache/api/'.$configvalue.'.xml')) |
| 2510 | $cacheexists = true; |
| 2511 | else |
| 2512 | $cacheexists = false; |
| 2513 | |
| 2514 | |
| 2515 | if ((strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0) || ($UseCaching == 1) || !$cacheexists )// if API_UseCache = 1 (off) then don't use cache |
| 2516 | { |
| 2517 | $fp = fsockopen("api.eve-online.com", 80); |
| 2518 | |
| 2519 | if (!$fp) |
| 2520 | { |
| 2521 | $this->Output_ .= "Could not connect to API URL"; |
| 2522 | } else { |
| 2523 | // request the xml |
| 2524 | fputs ($fp, "POST " . $path . " HTTP/1.0\r\n"); |
| 2525 | fputs ($fp, "Host: api.eve-online.com\r\n"); |
| 2526 | fputs ($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); |
| 2527 | fputs ($fp, "User-Agent: PHPApi\r\n"); |
| 2528 | fputs ($fp, "Content-Length: " . strlen($keystring) . "\r\n"); |
| 2529 | fputs ($fp, "Connection: close\r\n\r\n"); |
| 2530 | fputs ($fp, $keystring."\r\n"); |
| 2531 | |
| 2532 | // retrieve contents |
| 2533 | $contents = ""; |
| 2534 | while (!feof($fp)) |
| 2535 | { |
| 2536 | $contents .= fgets($fp); |
| 2537 | } |
| 2538 | |
| 2539 | // close connection |
| 2540 | fclose($fp); |
| 2541 | |
| 2542 | $start = strpos($contents, "?>"); |
| 2543 | if ($start !== FALSE) |
| 2544 | { |
| 2545 | $contents = substr($contents, $start + strlen("\r\n\r\n")); |
| 2546 | } |
| 2547 | |
| 2548 | if ($UseCaching == 0) // Save the file if we're caching (0 = true in Thunks world) |
| 2549 | { |
| 2550 | $file = fopen('cache/api/'.$configvalue.'.xml', 'w+'); |
| 2551 | fwrite($file, $contents); |
| 2552 | fclose($file); |
| 2553 | } |
| 2554 | } |
| 2555 | } else { |
| 2556 | // re-use cached XML |
| 2557 | if ($fp = @fopen('cache/api/'.$configvalue.'.xml', 'r')) { |
| 2558 | $contents = fread($fp, 1000000); |
| 2559 | fclose($fp); |
| 2560 | } else { |
| 2561 | return "<i>error loading cached file ".$configvalue.".xml</i><br><br>"; |
| 2562 | } |
| 2563 | } |
| 2564 | return $contents; |
| 2565 | } |
| 2566 | } |
| 2567 | |
| 2568 | // ********************************************************************************************************************************************** |
| 2569 | // **************** API Skill Training Sheet - char/SkillInTraining.xml.aspx **************** |
| 2570 | // ********************************************************************************************************************************************** |
| 2571 | class API_SkillInTraining |
| 2572 | { |
| 2573 | |
| 2574 | function getSkillInTraining() |
| 2575 | { |
| 2576 | return $this->SkillInTraining_; |
| 2577 | } |
| 2578 | |
| 2579 | function getCurrentTQTime() |
| 2580 | { |
| 2581 | return $this->CurrentTQTime_; |
| 2582 | } |
| 2583 | |
| 2584 | function getTrainingEndTime() |
| 2585 | { |
| 2586 | return $this->TrainingEndTime_; |
| 2587 | } |
| 2588 | |
| 2589 | function getTrainingStartTime() |
| 2590 | { |
| 2591 | return $this->TrainingStartTime_; |
| 2592 | } |
| 2593 | |
| 2594 | function getTrainingTypeID() |
| 2595 | { |
| 2596 | return $this->TrainingTypeID_; |
| 2597 | } |
| 2598 | |
| 2599 | function getTrainingStartSP() |
| 2600 | { |
| 2601 | return $this->TrainingStartSP_; |
| 2602 | } |
| 2603 | |
| 2604 | function getTrainingDestinationSP() |
| 2605 | { |
| 2606 | return $this->TrainingDestinationSP_; |
| 2607 | } |
| 2608 | |
| 2609 | function getTrainingToLevel() |
| 2610 | { |
| 2611 | return $this->TrainingToLevel_; |
| 2612 | } |
| 2613 | |
| 2614 | function getCachedUntil() |
| 2615 | { |
| 2616 | return $this->CachedUntil_; |
| 2617 | } |
| 2618 | |
| 2619 | function getCurrentTime() |
| 2620 | { |
| 2621 | return $this->CurrentTime_; |
| 2622 | } |
| 2623 | |
| 2624 | function getSPTrained() |
| 2625 | { |
| 2626 | return $this->SPTrained_; |
| 2627 | } |
| 2628 | |
| 2629 | function getTrainingTimeRemaining() |
| 2630 | { |
| 2631 | return $this->TrainingTimeRemaining_; |
| 2632 | } |
| 2633 | |
| 2634 | function fetchXML() |
| 2635 | { |
| 2636 | // is a player feed - take details from logged in user |
| 2637 | if (user::get('usr_pilot_id')) |
| 2638 | { |
| 2639 | require_once('class.pilot.php'); |
| 2640 | $plt = new pilot(user::get('usr_pilot_id')); |
| 2641 | $usersname = $plt->getName(); |
| 2642 | |
| 2643 | $this->CharName_ = $usersname; |
| 2644 | |
| 2645 | $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"'; |
| 2646 | |
| 2647 | $qry = new DBQuery(); |
| 2648 | $qry->execute($sql); |
| 2649 | $row = $qry->getRow(); |
| 2650 | |
| 2651 | $pilot_id = $row['plt_id']; |
| 2652 | $API_charID = $row['plt_externalid']; |
| 2653 | |
| 2654 | if ( $pilot_id == 0 ) |
| 2655 | { |
| 2656 | return "Something went wrong with finiding pilots external ID<br>"; |
| 2657 | } |
| 2658 | |
| 2659 | $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"'; |
| 2660 | $qry->execute($newsql); |
| 2661 | $userrow = $qry->getRow(); |
| 2662 | |
| 2663 | $API_userID = $userrow['userID']; |
| 2664 | $API_apiKey = $userrow['apiKey']; |
| 2665 | |
| 2666 | $myKeyString = "userID=" . $API_userID . "&apiKey=" . $API_apiKey . "&characterID=" . $API_charID; |
| 2667 | |
| 2668 | $data = $this->loaddata($myKeyString); |
| 2669 | } else { |
| 2670 | return "You are not logged in."; |
| 2671 | } |
| 2672 | |
| 2673 | $xml_parser = xml_parser_create(); |
| 2674 | xml_set_object ( $xml_parser, $this ); |
| 2675 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 2676 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 2677 | |
| 2678 | if (!xml_parse($xml_parser, $data, true)) |
| 2679 | return "<i>Error getting XML data from api.eve-online.com/Standings.xml.aspx </i><br><br>"; |
| 2680 | |
| 2681 | xml_parser_free($xml_parser); |
| 2682 | |
| 2683 | // Calculate Time Training remaining and amount of SP Done |
| 2684 | if ($this->SkillInTraining_ == 1) |
| 2685 | { |
| 2686 | $trainingleft = $this->TrainingEndTime_; |
| 2687 | |
| 2688 | $now = time(); |
| 2689 | $gmmktime = gmmktime(); |
| 2690 | $finaltime = $gmmktime - $now; |
| 2691 | |
| 2692 | $year = (int)substr($trainingleft, 0, 4); |
| 2693 | $month = (int)substr($trainingleft, 5, 2); |
| 2694 | $day = (int)substr($trainingleft, 8, 2); |
| 2695 | $hour = (int)substr($trainingleft, 11, 2) + (($finaltime > 0) ? floor($finaltime / 60 / 60) : 0); //2007-06-22 16:47:50 |
| 2696 | $minute = (int)substr($trainingleft, 14, 2); |
| 2697 | $second = (int)substr($trainingleft, 17, 2); |
| 2698 | |
| 2699 | $difference = gmmktime($hour, $minute, $second, $month, $day, $year) - $now; |
| 2700 | $timedone = $difference; |
| 2701 | if ($difference >= 1) |
| 2702 | { |
| 2703 | $days = floor($difference/86400); |
| 2704 | $difference = $difference - ($days*86400); |
| 2705 | $hours = floor($difference/3600); |
| 2706 | $difference = $difference - ($hours*3600); |
| 2707 | $minutes = floor($difference/60); |
| 2708 | $difference = $difference - ($minutes*60); |
| 2709 | $seconds = $difference; |
| 2710 | $this->TrainingTimeRemaining_ = "$days Days, $hours Hours, $minutes Minutes and $seconds Seconds."; |
| 2711 | } else { |
| 2712 | $this->TrainingTimeRemaining_ = "Done !"; |
| 2713 | } |
| 2714 | |
| 2715 | // Calculate SP done by using the ratio gained from Time spent training so far. |
| 2716 | $finaltime = strtotime($this->TrainingEndTime_) - strtotime($this->TrainingStartTime_); // in seconds |
| 2717 | $ratio = 1 - ($timedone / $finaltime); |
| 2718 | $this->SPTrained_ = ($this->TrainingDestinationSP_ - $this->TrainingStartSP_) * $ratio; |
| 2719 | } |
| 2720 | |
| 2721 | return $this->html; // should be empty, but keeping just incase - errors are returned by Text so worth looking anyway. |
| 2722 | } |
| 2723 | |
| 2724 | function startElement($parser, $name, $attribs) |
| 2725 | { |
| 2726 | // Nothing to do here |
| 2727 | } |
| 2728 | |
| 2729 | function endElement($parser, $name) |
| 2730 | { |
| 2731 | // Details |
| 2732 | if ($name == "SKILLINTRAINING") |
| 2733 | $this->SkillInTraining_ = $this->characterDataValue; |
| 2734 | if ($name == "CURRENTTQTIME") |
| 2735 | $this->CurrentTQTime_ = $this->characterDataValue; |
| 2736 | if ($name == "TRAININGENDTIME") |
| 2737 | $this->TrainingEndTime_ = $this->characterDataValue; |
| 2738 | if ($name == "TRAININGSTARTTIME") |
| 2739 | $this->TrainingStartTime_ = $this->characterDataValue; |
| 2740 | if ($name == "TRAININGTYPEID") |
| 2741 | $this->TrainingTypeID_ = $this->characterDataValue; |
| 2742 | if ($name == "TRAININGSTARTSP") |
| 2743 | $this->TrainingStartSP_ = $this->characterDataValue; |
| 2744 | if ($name == "TRAININGDESTINATIONSP") |
| 2745 | $this->TrainingDestinationSP_ = $this->characterDataValue; |
| 2746 | if ($name == "TRAININGTOLEVEL") |
| 2747 | $this->TrainingToLevel_ = $this->characterDataValue; |
| 2748 | |
| 2749 | if ($name == "CURRENTTIME") |
| 2750 | $this->CurrentTime_ = $this->characterDataValue; |
| 2751 | if ($name == "CACHEDUNTIL") |
| 2752 | { |
| 2753 | $this->CachedUntil_ = $this->characterDataValue; |
| 2754 | //config::set('API_eve_RefTypes' , $this->characterDataValue); |
| 2755 | config::set( $this->CharName_ . '_SkillInTraining' , $this->characterDataValue); |
| 2756 | } |
| 2757 | } |
| 2758 | |
| 2759 | function characterData($parser, $data) |
| 2760 | { |
| 2761 | $this->characterDataValue = $data; |
| 2762 | } |
| 2763 | |
| 2764 | function loaddata($keystring) |
| 2765 | { |
| 2766 | $configvalue = $this->CharName_ . '_SkillInTraining'; |
| 2767 | |
| 2768 | $CachedTime = config::get($configvalue); |
| 2769 | $UseCaching = config::get('API_UseCache'); |
| 2770 | |
| 2771 | $url = "http://api.eve-online.com/char/SkillInTraining.xml.aspx" . $keystring; |
| 2772 | |
| 2773 | $path = '/char/SkillInTraining.xml.aspx'; |
| 2774 | |
| 2775 | // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round. |
| 2776 | if ($CachedTime == "") |
| 2777 | { |
| 2778 | $CachedTime = "2005-01-01 00:00:00"; // fake date to ensure that it runs first time. |
| 2779 | } |
| 2780 | |
| 2781 | if (is_file('cache/api/'.$configvalue.'.xml')) |
| 2782 | $cacheexists = true; |
| 2783 | else |
| 2784 | $cacheexists = false; |
| 2785 | |
| 2786 | |
| 2787 | if ((strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0) || ($UseCaching == 1) || !$cacheexists )// if API_UseCache = 1 (off) then don't use cache |
| 2788 | { |
| 2789 | $fp = fsockopen("api.eve-online.com", 80); |
| 2790 | |
| 2791 | if (!$fp) |
| 2792 | { |
| 2793 | $this->Output_ .= "Could not connect to API URL"; |
| 2794 | } else { |
| 2795 | // request the xml |
| 2796 | fputs ($fp, "POST " . $path . " HTTP/1.0\r\n"); |
| 2797 | fputs ($fp, "Host: api.eve-online.com\r\n"); |
| 2798 | fputs ($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); |
| 2799 | fputs ($fp, "User-Agent: PHPApi\r\n"); |
| 2800 | fputs ($fp, "Content-Length: " . strlen($keystring) . "\r\n"); |
| 2801 | fputs ($fp, "Connection: close\r\n\r\n"); |
| 2802 | fputs ($fp, $keystring."\r\n"); |
| 2803 | |
| 2804 | // retrieve contents |
| 2805 | $contents = ""; |
| 2806 | while (!feof($fp)) |
| 2807 | { |
| 2808 | $contents .= fgets($fp); |
| 2809 | } |
| 2810 | |
| 2811 | // close connection |
| 2812 | fclose($fp); |
| 2813 | |
| 2814 | $start = strpos($contents, "?>"); |
| 2815 | if ($start !== FALSE) |
| 2816 | { |
| 2817 | $contents = substr($contents, $start + strlen("\r\n\r\n")); |
| 2818 | } |
| 2819 | |
| 2820 | if ($UseCaching == 0) // Save the file if we're caching (0 = true in Thunks world) |
| 2821 | { |
| 2822 | $file = fopen('cache/api/'.$configvalue.'.xml', 'w+'); |
| 2823 | fwrite($file, $contents); |
| 2824 | fclose($file); |
| 2825 | } |
| 2826 | } |
| 2827 | } else { |
| 2828 | // re-use cached XML |
| 2829 | if ($fp = @fopen('cache/api/'.$configvalue.'.xml', 'r')) { |
| 2830 | $contents = fread($fp, 1000000); |
| 2831 | fclose($fp); |
| 2832 | } else { |
| 2833 | return "<i>error loading cached file ".$configvalue.".xml</i><br><br>"; |
| 2834 | } |
| 2835 | } |
| 2836 | return $contents; |
| 2837 | } |
| 2838 | } |
| 2839 | |
| 2840 | // ********************************************************************************************************************************************** |
| 2841 | // **************** API StarbaseList - /corp/StarbaseList.xml.aspx **************** |
| 2842 | // ********************************************************************************************************************************************** |
| 2843 | class API_StarbaseList |
| 2844 | { |
| 2845 | function getCachedUntil() |
| 2846 | { |
| 2847 | return $this->CachedUntil_; |
| 2848 | } |
| 2849 | |
| 2850 | function getCurrentTime() |
| 2851 | { |
| 2852 | return $this->CurrentTime_; |
| 2853 | } |
| 2854 | |
| 2855 | function setAPIKey($key) |
| 2856 | { |
| 2857 | $this->API_apiKey_ = $key; |
| 2858 | } |
| 2859 | |
| 2860 | function setUserID($uid) |
| 2861 | { |
| 2862 | $this->API_userID_ = $uid; |
| 2863 | } |
| 2864 | |
| 2865 | function setCharacterID($cid) |
| 2866 | { |
| 2867 | $this->API_charID_ = $cid; |
| 2868 | } |
| 2869 | |
| 2870 | function getStarbases() |
| 2871 | { |
| 2872 | return $this->Starbase_; |
| 2873 | } |
| 2874 | |
| 2875 | function fetchXML() |
| 2876 | { |
| 2877 | // is a player feed - take details from logged in user |
| 2878 | if (user::get('usr_pilot_id')) |
| 2879 | { |
| 2880 | require_once('class.pilot.php'); |
| 2881 | $plt = new pilot(user::get('usr_pilot_id')); |
| 2882 | $usersname = $plt->getName(); |
| 2883 | |
| 2884 | $this->CharName_ = $usersname; |
| 2885 | |
| 2886 | $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"'; |
| 2887 | |
| 2888 | $qry = new DBQuery(); |
| 2889 | $qry->execute($sql); |
| 2890 | $row = $qry->getRow(); |
| 2891 | |
| 2892 | $pilot_id = $row['plt_id']; |
| 2893 | $API_charID = $row['plt_externalid']; |
| 2894 | |
| 2895 | if ( $pilot_id == 0 ) |
| 2896 | { |
| 2897 | return "Something went wrong with finiding pilots external ID<br>"; |
| 2898 | } |
| 2899 | |
| 2900 | $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"'; |
| 2901 | $qry->execute($newsql); |
| 2902 | $userrow = $qry->getRow(); |
| 2903 | |
| 2904 | $API_userID = $userrow['userID']; |
| 2905 | $API_apiKey = $userrow['apiKey']; |
| 2906 | |
| 2907 | $myKeyString = "userID=" . $API_userID . "&apiKey=" . $API_apiKey . "&characterID=" . $API_charID; |
| 2908 | |
| 2909 | $data = $this->loaddata($myKeyString); |
| 2910 | } else { |
| 2911 | if ($this->API_userID_ != "" && $this->API_apiKey_ != "" && $this->API_charID_ != "") |
| 2912 | { |
| 2913 | $myKeyString = "userID=" . $this->API_userID_ . "&apiKey=" . $this->API_apiKey_ . "&characterID=" . $this->API_charID_; |
| 2914 | $this->CharName_ = $this->API_charID_; |
| 2915 | $data = $this->loaddata($myKeyString); |
| 2916 | } else { |
| 2917 | return "You are not logged in and have not set API details."; |
| 2918 | } |
| 2919 | } |
| 2920 | |
| 2921 | $xml_parser = xml_parser_create(); |
| 2922 | xml_set_object ( $xml_parser, $this ); |
| 2923 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 2924 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 2925 | |
| 2926 | if (!xml_parse($xml_parser, $data, true)) |
| 2927 | return "<i>Error getting XML data from api.eve-online.com/Standings.xml.aspx </i><br><br>"; |
| 2928 | |
| 2929 | xml_parser_free($xml_parser); |
| 2930 | |
| 2931 | return $this->html; // should be empty, but keeping just incase - errors are returned by Text so worth looking anyway. |
| 2932 | } |
| 2933 | |
| 2934 | function startElement($parser, $name, $attribs) |
| 2935 | { |
| 2936 | if ($name == "ROW") |
| 2937 | { |
| 2938 | global $tempdata; |
| 2939 | |
| 2940 | if (count($attribs)) |
| 2941 | { |
| 2942 | foreach ($attribs as $k => $v) |
| 2943 | { |
| 2944 | switch ($k) |
| 2945 | { |
| 2946 | case "ITEMID": |
| 2947 | $tempdata['itemID'] = $v; |
| 2948 | break; |
| 2949 | case "TYPEID": |
| 2950 | $tempdata['typeID'] = $v; |
| 2951 | $tempdata['typeName'] = gettypeIDname($v); |
| 2952 | break; |
| 2953 | case "LOCATIONID": |
| 2954 | $tempdata['locationID'] = $v; |
| 2955 | $sql = 'select sys.sys_name, sys.sys_sec from kb3_systems sys where sys.sys_eve_id = '.$v; |
| 2956 | |
| 2957 | $qry = new DBQuery(); |
| 2958 | $qry->execute($sql); |
| 2959 | $row = $qry->getRow(); |
| 2960 | |
| 2961 | $tempdata['locationName'] = $row['sys_name']; |
| 2962 | $mysec = $row['sys_sec']; |
| 2963 | if ($mysec <= 0) |
| 2964 | $tempdata['locationSec'] = number_format(0.0, 1); |
| 2965 | else |
| 2966 | $tempdata['locationSec'] = number_format(round($mysec, 1), 1); |
| 2967 | break; |
| 2968 | case "MOONID": |
| 2969 | $tempdata['moonID'] = $v; |
| 2970 | $tempdata['moonName'] = getMoonName($v); |
| 2971 | break; |
| 2972 | case "STATE": |
| 2973 | $tempdata['state'] = $v; |
| 2974 | break; |
| 2975 | case "STATETIMESTAMP": |
| 2976 | $tempdata['stateTimestamp'] = $v; |
| 2977 | break; |
| 2978 | case "ONLINETIMESTAMP": |
| 2979 | $tempdata['onlineTimestamp'] = $v; |
| 2980 | $this->Starbase_[] = $tempdata; |
| 2981 | |
| 2982 | $tempdata = array(); |
| 2983 | unset($tempdata); |
| 2984 | break; |
| 2985 | } |
| 2986 | } |
| 2987 | } |
| 2988 | } |
| 2989 | } |
| 2990 | |
| 2991 | function endElement($parser, $name) |
| 2992 | { |
| 2993 | // Details |
| 2994 | if ($name == "ERROR") |
| 2995 | $this->html .= $this->characterDataValue; |
| 2996 | if ($name == "CURRENTTIME") |
| 2997 | $this->CurrentTime_ = $this->characterDataValue; |
| 2998 | if ($name == "CACHEDUNTIL") |
| 2999 | { |
| 3000 | $this->CachedUntil_ = $this->characterDataValue; |
| 3001 | //config::set('API_eve_RefTypes' , $this->characterDataValue); |
| 3002 | config::set( $this->CharName_ . '_StarbaseList' , $this->characterDataValue); |
| 3003 | } |
| 3004 | } |
| 3005 | |
| 3006 | function characterData($parser, $data) |
| 3007 | { |
| 3008 | $this->characterDataValue = $data; |
| 3009 | } |
| 3010 | |
| 3011 | function loaddata($keystring) |
| 3012 | { |
| 3013 | $configvalue = $this->CharName_ . '_StarbaseList'; |
| 3014 | |
| 3015 | $CachedTime = config::get($configvalue); |
| 3016 | $UseCaching = config::get('API_UseCache'); |
| 3017 | |
| 3018 | $url = "http://api.eve-online.com/corp/StarbaseList.xml.aspx" . $keystring; |
| 3019 | |
| 3020 | $path = '/corp/StarbaseList.xml.aspx'; |
| 3021 | |
| 3022 | // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round. |
| 3023 | if ($CachedTime == "") |
| 3024 | { |
| 3025 | $CachedTime = "2005-01-01 00:00:00"; // fake date to ensure that it runs first time. |
| 3026 | } |
| 3027 | |
| 3028 | if (is_file('cache/api/'.$configvalue.'.xml')) |
| 3029 | $cacheexists = true; |
| 3030 | else |
| 3031 | $cacheexists = false; |
| 3032 | |
| 3033 | |
| 3034 | if ((strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0) || ($UseCaching == 1) || !$cacheexists )// if API_UseCache = 1 (off) then don't use cache |
| 3035 | { |
| 3036 | $fp = fsockopen("api.eve-online.com", 80); |
| 3037 | |
| 3038 | if (!$fp) |
| 3039 | { |
| 3040 | $this->Output_ .= "Could not connect to API URL"; |
| 3041 | } else { |
| 3042 | // request the xml |
| 3043 | fputs ($fp, "POST " . $path . " HTTP/1.0\r\n"); |
| 3044 | fputs ($fp, "Host: api.eve-online.com\r\n"); |
| 3045 | fputs ($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); |
| 3046 | fputs ($fp, "User-Agent: PHPApi\r\n"); |
| 3047 | fputs ($fp, "Content-Length: " . strlen($keystring) . "\r\n"); |
| 3048 | fputs ($fp, "Connection: close\r\n\r\n"); |
| 3049 | fputs ($fp, $keystring."\r\n"); |
| 3050 | |
| 3051 | // retrieve contents |
| 3052 | $contents = ""; |
| 3053 | while (!feof($fp)) |
| 3054 | { |
| 3055 | $contents .= fgets($fp); |
| 3056 | } |
| 3057 | |
| 3058 | // close connection |
| 3059 | fclose($fp); |
| 3060 | |
| 3061 | $start = strpos($contents, "?>"); |
| 3062 | if ($start !== FALSE) |
| 3063 | { |
| 3064 | $contents = substr($contents, $start + strlen("\r\n\r\n")); |
| 3065 | } |
| 3066 | |
| 3067 | if ($UseCaching == 0) // Save the file if we're caching (0 = true in Thunks world) |
| 3068 | { |
| 3069 | $file = fopen('cache/api/'.$configvalue.'.xml', 'w+'); |
| 3070 | fwrite($file, $contents); |
| 3071 | fclose($file); |
| 3072 | } |
| 3073 | } |
| 3074 | } else { |
| 3075 | // re-use cached XML |
| 3076 | if ($fp = @fopen('cache/api/'.$configvalue.'.xml', 'r')) { |
| 3077 | $contents = fread($fp, 1000000); |
| 3078 | fclose($fp); |
| 3079 | } else { |
| 3080 | return "<i>error loading cached file ".$configvalue.".xml</i><br><br>"; |
| 3081 | } |
| 3082 | } |
| 3083 | return $contents; |
| 3084 | } |
| 3085 | } |
| 3086 | |
| 3087 | // ********************************************************************************************************************************************** |
| 3088 | // **************** API StarbaseDetail - /corp/StarbaseDetail.xml.aspx **************** |
| 3089 | // ********************************************************************************************************************************************** |
| 3090 | class API_StarbaseDetail |
| 3091 | { |
| 3092 | function getCachedUntil() |
| 3093 | { |
| 3094 | return $this->CachedUntil_; |
| 3095 | } |
| 3096 | |
| 3097 | function getCurrentTime() |
| 3098 | { |
| 3099 | return $this->CurrentTime_; |
| 3100 | } |
| 3101 | |
| 3102 | function setAPIKey($key) |
| 3103 | { |
| 3104 | $this->API_apiKey_ = $key; |
| 3105 | } |
| 3106 | |
| 3107 | function setUserID($uid) |
| 3108 | { |
| 3109 | $this->API_userID_ = $uid; |
| 3110 | } |
| 3111 | |
| 3112 | function setCharacterID($cid) |
| 3113 | { |
| 3114 | $this->API_charID_ = $cid; |
| 3115 | } |
| 3116 | |
| 3117 | function setitemID($itemID) |
| 3118 | { |
| 3119 | $this->API_itemID_ = $itemID; |
| 3120 | } |
| 3121 | function getFuel() |
| 3122 | { |
| 3123 | return $this->Fuel_; |
| 3124 | } |
| 3125 | function getState() |
| 3126 | { |
| 3127 | return $this->State_; |
| 3128 | } |
| 3129 | function getstateTimestamp() |
| 3130 | { |
| 3131 | return $this->stateTimestamp_; |
| 3132 | } |
| 3133 | function getonlineTimestamp() |
| 3134 | { |
| 3135 | return $this->onlineTimestamp_; |
| 3136 | } |
| 3137 | function getusageFlags() |
| 3138 | { |
| 3139 | return $this->usageFlags_; |
| 3140 | } |
| 3141 | function getdeployFlags() |
| 3142 | { |
| 3143 | return $this->deployFlags_; |
| 3144 | } |
| 3145 | function getallowCorporationMembers() |
| 3146 | { |
| 3147 | return $this->allowCorporationMembers_; |
| 3148 | } |
| 3149 | function getallowAllianceMembers() |
| 3150 | { |
| 3151 | return $this->allowAllianceMembers_; |
| 3152 | } |
| 3153 | function getclaimSovereignty() |
| 3154 | { |
| 3155 | return $this->claimSovereignty_; |
| 3156 | } |
| 3157 | function getonStandingDrop() |
| 3158 | { |
| 3159 | return $this->onStandingDrop_; |
| 3160 | } |
| 3161 | function getonStatusDrop() |
| 3162 | { |
| 3163 | return $this->onStatusDrop_; |
| 3164 | } |
| 3165 | function getonAggression() |
| 3166 | { |
| 3167 | return $this->onAggression_; |
| 3168 | } |
| 3169 | function getonCorporationWar() |
| 3170 | { |
| 3171 | return $this->onCorporationWar_; |
| 3172 | } |
| 3173 | |
| 3174 | |
| 3175 | function fetchXML() |
| 3176 | { |
| 3177 | // is a player feed - take details from logged in user |
| 3178 | if (user::get('usr_pilot_id')) |
| 3179 | { |
| 3180 | require_once('class.pilot.php'); |
| 3181 | $plt = new pilot(user::get('usr_pilot_id')); |
| 3182 | $usersname = $plt->getName(); |
| 3183 | |
| 3184 | $this->CharName_ = $usersname; |
| 3185 | |
| 3186 | $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"'; |
| 3187 | |
| 3188 | $qry = new DBQuery(); |
| 3189 | $qry->execute($sql); |
| 3190 | $row = $qry->getRow(); |
| 3191 | |
| 3192 | $pilot_id = $row['plt_id']; |
| 3193 | $API_charID = $row['plt_externalid']; |
| 3194 | |
| 3195 | if ( $pilot_id == 0 ) |
| 3196 | { |
| 3197 | return "Something went wrong with finding pilots external ID<br>"; |
| 3198 | } |
| 3199 | |
| 3200 | $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"'; |
| 3201 | $qry->execute($newsql); |
| 3202 | $userrow = $qry->getRow(); |
| 3203 | |
| 3204 | $API_userID = $userrow['userID']; |
| 3205 | $API_apiKey = $userrow['apiKey']; |
| 3206 | |
| 3207 | $myKeyString = "userID=" . $API_userID . "&apiKey=" . $API_apiKey . "&characterID=" . $API_charID . "&itemID=" . $this->API_itemID_; |
| 3208 | |
| 3209 | $data = $this->loaddata($myKeyString); |
| 3210 | } else { |
| 3211 | if (($this->API_userID_ != "") && ($this->API_apiKey_ != "") && ($this->API_charID_ != "") && ($this->API_itemID_ != "")) |
| 3212 | { |
| 3213 | $myKeyString = "userID=" . $this->API_userID_ . "&apiKey=" . $this->API_apiKey_ . "&characterID=" . $this->API_charID_ . "&itemID=" . $this->API_itemID_; |
| 3214 | $this->CharName_ = $this->API_charID_; |
| 3215 | $data = $this->loaddata($myKeyString); |
| 3216 | } else { |
| 3217 | return "You are not logged in and have not set API details."; |
| 3218 | } |
| 3219 | } |
| 3220 | |
| 3221 | $xml_parser = xml_parser_create(); |
| 3222 | xml_set_object ( $xml_parser, $this ); |
| 3223 | xml_set_element_handler($xml_parser, "startElement", "endElement"); |
| 3224 | xml_set_character_data_handler ( $xml_parser, 'characterData' ); |
| 3225 | |
| 3226 | if (!xml_parse($xml_parser, $data, true)) |
| 3227 | return "<i>Error getting XML data from api.eve-online.com/Standings.xml.aspx </i><br><br>"; |
| 3228 | |
| 3229 | xml_parser_free($xml_parser); |
| 3230 | |
| 3231 | return $this->html; // should be empty, but keeping just incase - errors are returned by Text so worth looking anyway. |
| 3232 | } |
| 3233 | |
| 3234 | function startElement($parser, $name, $attribs) |
| 3235 | { |
| 3236 | if ($name == "ROW") |
| 3237 | { |
| 3238 | global $tempdata; |
| 3239 | |
| 3240 | if (count($attribs)) |
| 3241 | { |
| 3242 | foreach ($attribs as $k => $v) |
| 3243 | { |
| 3244 | switch ($k) |
| 3245 | { |
| 3246 | case "TYPEID": |
| 3247 | $fueldata['typeID'] = $v; |
| 3248 | $fueldata['typeName'] = gettypeIDname($v); |
| 3249 | break; |
| 3250 | case "QUANTITY": |
| 3251 | $fueldata['quantity'] = $v; |
| 3252 | $this->Fuel_[] = $fueldata; |
| 3253 | |
| 3254 | $fueldata = array(); |
| 3255 | unset($fueldata); |
| 3256 | break; |
| 3257 | } |
| 3258 | } |
| 3259 | } |
| 3260 | } |
| 3261 | |
| 3262 | if ($name == "ONSTANDINGDROP") |
| 3263 | { |
| 3264 | if (count($attribs)) |
| 3265 | { |
| 3266 | foreach ($attribs as $k => $v) |
| 3267 | { |
| 3268 | switch ($k) |
| 3269 | { |
| 3270 | case "ENABLED": |
| 3271 | $this->onStandingDrop_['enabled'] = $v; |
| 3272 | break; |
| 3273 | case "STANDING": |
| 3274 | $this->onStandingDrop_['standing'] = $v; |
| 3275 | break; |
| 3276 | } |
| 3277 | } |
| 3278 | } |
| 3279 | } |
| 3280 | |
| 3281 | if ($name == "ONSTATUSDROP") |
| 3282 | { |
| 3283 | if (count($attribs)) |
| 3284 | { |
| 3285 | foreach ($attribs as $k => $v) |
| 3286 | { |
| 3287 | switch ($k) |
| 3288 | { |
| 3289 | case "ENABLED": |
| 3290 | $this->onStatusDrop_['enabled'] = $v; |
| 3291 | break; |
| 3292 | case "STANDING": |
| 3293 | $this->onStatusDrop_['standing'] = $v; |
| 3294 | break; |
| 3295 | } |
| 3296 | } |
| 3297 | } |
| 3298 | } |
| 3299 | |
| 3300 | if ($name == "ONAGGRESSION") |
| 3301 | { |
| 3302 | if (count($attribs)) |
| 3303 | { |
| 3304 | foreach ($attribs as $k => $v) |
| 3305 | { |
| 3306 | switch ($k) |
| 3307 | { |
| 3308 | case "ENABLED": |
| 3309 | $this->onAggression_['enabled'] = $v; |
| 3310 | break; |
| 3311 | } |
| 3312 | } |
| 3313 | } |
| 3314 | } |
| 3315 | |
| 3316 | if ($name == "ONCORPORATIONWAR") |
| 3317 | { |
| 3318 | if (count($attribs)) |
| 3319 | { |
| 3320 | foreach ($attribs as $k => $v) |
| 3321 | { |
| 3322 | switch ($k) |
| 3323 | { |
| 3324 | case "ENABLED": |
| 3325 | $this->onCorporationWar_['enabled'] = $v; |
| 3326 | break; |
| 3327 | } |
| 3328 | } |
| 3329 | } |
| 3330 | } |
| 3331 | } |
| 3332 | |
| 3333 | function endElement($parser, $name) |
| 3334 | { |
| 3335 | // Details |
| 3336 | if ($name == "ERROR") |
| 3337 | $this->html .= $this->characterDataValue; |
| 3338 | |
| 3339 | if ($name == "STATE") |
| 3340 | $this->State_ .= $this->characterDataValue; |
| 3341 | if ($name == "STATETIMESTAMP") |
| 3342 | $this->stateTimestamp_ .= $this->characterDataValue; |
| 3343 | if ($name == "ONLINETIMESTAMP") |
| 3344 | $this->onlineTimestamp_ .= $this->characterDataValue; |
| 3345 | |
| 3346 | // General Settings |
| 3347 | if ($name == "USAGEFLAGS") |
| 3348 | $this->usageFlags_ .= $this->characterDataValue; |
| 3349 | if ($name == "DEPLOYFLAGS") |
| 3350 | $this->deployFlags_ .= $this->characterDataValue; |
| 3351 | if ($name == "ALLOWCORPORATIONMEMBERS") |
| 3352 | $this->allowCorporationMembers_ .= $this->characterDataValue; |
| 3353 | if ($name == "ALLOWALLIANCEMEMBERS") |
| 3354 | $this->allowAllianceMembers_ .= $this->characterDataValue; |
| 3355 | if ($name == "CLAIMSOVEREIGNTY") |
| 3356 | $this->claimSovereignty_ .= $this->characterDataValue; |
| 3357 | |
| 3358 | if ($name == "CURRENTTIME") |
| 3359 | $this->CurrentTime_ = $this->characterDataValue; |
| 3360 | if ($name == "CACHEDUNTIL") |
| 3361 | { |
| 3362 | $this->CachedUntil_ = $this->characterDataValue; |
| 3363 | //config::set('API_eve_RefTypes' , $this->characterDataValue); |
| 3364 | config::set( $this->API_itemID_ . '_StarbaseDetail' , $this->characterDataValue); |
| 3365 | } |
| 3366 | } |
| 3367 | |
| 3368 | function characterData($parser, $data) |
| 3369 | { |
| 3370 | $this->characterDataValue = $data; |
| 3371 | } |
| 3372 | |
| 3373 | function loaddata($keystring) |
| 3374 | { |
| 3375 | $configvalue = $this->API_itemID_ . '_StarbaseDetail'; |
| 3376 | |
| 3377 | $CachedTime = config::get($configvalue); |
| 3378 | $UseCaching = config::get('API_UseCache'); |
| 3379 | |
| 3380 | $url = "http://api.eve-online.com/corp/StarbaseDetail.xml.aspx" . $keystring; |
| 3381 | |
| 3382 | $path = '/corp/StarbaseDetail.xml.aspx'; |
| 3383 | |
| 3384 | // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round. |
| 3385 | if ($CachedTime == "") |
| 3386 | { |
| 3387 | $CachedTime = "2005-01-01 00:00:00"; // fake date to ensure that it runs first time. |
| 3388 | } |
| 3389 | |
| 3390 | if (is_file('cache/api/'.$configvalue.'.xml')) |
| 3391 | $cacheexists = true; |
| 3392 | else |
| 3393 | $cacheexists = false; |
| 3394 | |
| 3395 | |
| 3396 | if ((strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0) || ($UseCaching == 1) || !$cacheexists )// if API_UseCache = 1 (off) then don't use cache |
| 3397 | { |
| 3398 | $fp = fsockopen("api.eve-online.com", 80); |
| 3399 | |
| 3400 | if (!$fp) |
| 3401 | { |
| 3402 | $this->Output_ .= "Could not connect to API URL"; |
| 3403 | } else { |
| 3404 | // request the xml |
| 3405 | fputs ($fp, "POST " . $path . " HTTP/1.0\r\n"); |
| 3406 | fputs ($fp, "Host: api.eve-online.com\r\n"); |
| 3407 | fputs ($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); |
| 3408 | fputs ($fp, "User-Agent: PHPApi\r\n"); |
| 3409 | fputs ($fp, "Content-Length: " . strlen($keystring) . "\r\n"); |
| 3410 | fputs ($fp, "Connection: close\r\n\r\n"); |
| 3411 | fputs ($fp, $keystring."\r\n"); |
| 3412 | |
| 3413 | // retrieve contents |
| 3414 | $contents = ""; |
| 3415 | while (!feof($fp)) |
| 3416 | { |
| 3417 | $contents .= fgets($fp); |
| 3418 | } |
| 3419 | |
| 3420 | // close connection |
| 3421 | fclose($fp); |
| 3422 | |
| 3423 | $start = strpos($contents, "?>"); |
| 3424 | if ($start !== FALSE) |
| 3425 | { |
| 3426 | $contents = substr($contents, $start + strlen("\r\n\r\n")); |
| 3427 | } |
| 3428 | |
| 3429 | if ($UseCaching == 0) // Save the file if we're caching (0 = true in Thunks world) |
| 3430 | { |
| 3431 | $file = fopen('cache/api/'.$configvalue.'.xml', 'w+'); |
| 3432 | fwrite($file, $contents); |
| 3433 | fclose($file); |
| 3434 | } |
| 3435 | } |
| 3436 | } else { |
| 3437 | // re-use cached XML |
| 3438 | if ($fp = @fopen('cache/api/'.$configvalue.'.xml', 'r')) { |
| 3439 | $contents = fread($fp, 1000000); |
| 3440 | fclose($fp); |
| 3441 | } else { |
| 3442 | return "<i>error loading cached file ".$configvalue.".xml</i><br><br>"; |
| 3443 | } |
| 3444 | } |
| 3445 | return $contents; |
| 3446 | } |
| 3447 | } |
| 3448 | // ********************************************************************************************************************************************** |
| 3449 | // ********************************************************************************************************************************************** |
| 3450 | // **************** GENERIC FUNCTIONS **************** |
| 3451 | // ********************************************************************************************************************************************** |
| 3452 | // ********************************************************************************************************************************************** |
| 3453 | |
| 3454 | // ********************************************************************************************************************************************** |
| 3455 | // **************** Load Generic XML **************** |
| 3456 | // ********************************************************************************************************************************************** |
| 3457 | |
| 3458 | function LoadGlobalData($path, $cacheoveride=false) // loads a generic XML sheet that requires no API Login as such |
| 3459 | { |
| 3460 | $temppath = substr($path, 0, strlen(£path) - 14); |
| 3461 | $configvalue = "API" . str_replace("/", "_", $temppath); |
| 3462 | |
| 3463 | $CachedTime = config::get($configvalue); |
| 3464 | $UseCaching = config::get('API_UseCache'); |
| 3465 | |
| 3466 | // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round. |
| 3467 | if ($CachedTime == "") |
| 3468 | { |
| 3469 | $CachedTime = "2005-01-01 00:00:00"; // fake date to ensure that it runs first time. |
| 3470 | } |
| 3471 | |
| 3472 | if (is_file('cache/api/'.$configvalue.'.xml')) |
| 3473 | $cacheexists = true; |
| 3474 | else |
| 3475 | $cacheexists = false; |
| 3476 | |
| 3477 | |
| 3478 | if ((strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0) || ($UseCaching == 1) || !$cacheexists )// if API_UseCache = 1 (off) then don't use cache |