function fetchXML() { // is a player feed - take details from logged in user if (user::get('usr_pilot_id')) { $plt = new pilot(user::get('usr_pilot_id')); $usersname = $plt->getName(); $this->CharName_ = $usersname; // $this->CharName_ is used later for config key value for caching $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"'; $qry = DBFactory::getDBQuery(); $qry->execute($sql); $row = $qry->getRow(); $pilot_id = $row['plt_id']; $API_charID = $row['plt_externalid']; if ($pilot_id == 0) { return "Something went wrong with finiding pilots external ID<br>"; } $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"'; $qry->execute($newsql); $userrow = $qry->getRow(); $API_userID = $userrow['userID']; $API_apiKey = $userrow['apiKey']; $myKeyString = array(); $myKeyString["userID"] = $API_userID; $myKeyString["apiKey"] = $API_apiKey; $myKeyString["characterID"] = $API_charID; $data = $this->loaddata($myKeyString); } else { return "You are not logged in."; } $xml_parser = xml_parser_create(); xml_set_object($xml_parser, $this); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, 'characterData'); if (!xml_parse($xml_parser, $data, true)) { return "<i>Error getting XML data from " . API_SERVER . "/CharacterSheet.xml.aspx </i><br><br>"; } xml_parser_free($xml_parser); return $this->html; }
function fetchXML() { $myKeyString = array(); // is a player feed - take details from logged in user if ($this->API_corpID_ != "") { $myKeyString["corporationID"] = $this->API_corpID_; $this->CharName_ = $this->API_corpID_; } elseif (user::get('usr_pilot_id')) { $plt = new pilot(user::get('usr_pilot_id')); $usersname = $plt->getName(); $this->CharName_ = $usersname; $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $usersname . '"'; $qry = DBFactory::getDBQuery(); $qry->execute($sql); $row = $qry->getRow(); $pilot_id = $row['plt_id']; $API_charID = $row['plt_externalid']; if ($pilot_id == 0) { return "Something went wrong with finding pilots external ID<br>"; } $newsql = 'SELECT userID , apiKey FROM kb3_api_user WHERE charID = "' . $API_charID . '"'; $qry->execute($newsql); $userrow = $qry->getRow(); $API_userID = $userrow['userID']; $API_apiKey = $userrow['apiKey']; $myKeyString["userID"] = $API_userID; $myKeyString["apiKey"] = $API_apiKey; $myKeyString["characterID"] = $API_charID; } else { if ($this->API_userID_ != "" && $this->API_apiKey_ != "" && $this->API_charID_ != "") { $myKeyString["userID"] = $this->API_userID_; $myKeyString["apiKey"] = $this->API_apiKey_; $myKeyString["characterID"] = $this->API_charID_; $this->CharName_ = $this->API_charID_; } else { return "You are not logged in and have not set API details."; } } $this->_result = $this->CallAPI("corp", "CorporationSheet", array('corporationID' => $myKeyString['corporationID']), $this->API_userID_, $this->API_apiKey_); if ($this->_result == false) { return false; } $this->CurrentTime_ = $this->_result->request_time; $this->CachedUntil_ = $this->_result->cached_until; return true; }