PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/include/api/character_old.php

https://github.com/Dratone/EveBB
PHP | 244 lines | 184 code | 41 blank | 19 comment | 37 complexity | 1ac112fb174bf4e333d9a9acf0cf0418 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * 31/01/2011
  4. * character_old.php
  5. * Panda
  6. */
  7. class Character {
  8. //Single value types.
  9. var $characterID;
  10. var $name;
  11. var $corporationID;
  12. var $corporationName;
  13. var $allianceID;
  14. var $allianceName;
  15. var $DoB;
  16. var $race;
  17. var $bloodLine;
  18. var $ancestry;
  19. var $gender;
  20. var $cloneName;
  21. var $cloneSkillPoints;
  22. var $balance;
  23. //Array types.
  24. //var $implants = array();
  25. //var $attributes = array();
  26. //var $skills = array();
  27. //var $certs = array();
  28. var $corporationRoles;
  29. var $skillQueue;
  30. var $characterList;
  31. //var $corporationRolesAtHQ = array();
  32. //var $corporationRolesAtBase = array();
  33. //var $corporationRolesAtOther = array();
  34. //var $corporationTitles = array();
  35. //Parsing types...
  36. var $current_tag = '';
  37. var $in_rowsets = false;
  38. var $in_roles = false;
  39. var $in_characters = false;
  40. function load_character(&$cak) {
  41. global $db, $pun_request, $_LAST_ERROR;
  42. $_LAST_ERROR = 0;
  43. //Is our CAK valid?
  44. if ($cak->validate(true) != CAK_OK) {
  45. $_LAST_ERROR = API_BAD_AUTH;
  46. return false;
  47. } //End if.
  48. $url = "https://api.eveonline.com/char/CharacterSheet.xml.aspx";
  49. $char_sheet;
  50. if (!$xml = $pun_request->post($url, $cak->get_auth())) {
  51. $_LAST_ERROR = API_BAD_REQUEST;
  52. return false;
  53. } //End if.
  54. $this->corporationRoles = '0';
  55. $use_roles = @bscale(0);
  56. $xml_parser = xml_parser_create();
  57. xml_set_object($xml_parser, $this);
  58. xml_set_element_handler($xml_parser, "startElement", "endElement");
  59. xml_set_character_data_handler($xml_parser, "characterData");
  60. if (!xml_parse($xml_parser, $xml, true)) {
  61. error(sprintf("XML error: %s at line %d",
  62. xml_error_string(xml_get_error_code($xml_parser)),
  63. xml_get_current_line_number($xml_parser)), __FILE__, __LINE__);
  64. } //End if.
  65. xml_parser_free($xml_parser);
  66. $this->characterID = $this->CHARACTERID;
  67. $this->name = $db->escape($this->NAME);
  68. $this->corporationID = $this->CORPORATIONID;
  69. $this->corporationName = $db->escape($this->CORPORATIONNAME);
  70. $this->allianceID = $this->ALLIANCEID;
  71. $this->allianceName = $db->escape($this->ALLIANCENAME);
  72. $this->DoB = $db->escape($this->DOB);
  73. $this->race = $db->escape($this->RACE);
  74. $this->bloodLine = $db->escape($this->BLOODLINE);
  75. $this->ancestry = $db->escape($this->ANCESTRY);
  76. $this->gender = $db->escape($this->GENDER);
  77. $this->cloneName = $db->escape($this->CLONENAME);
  78. $this->cloneSkillPoints = $this->CLONESKILLPOINTS;
  79. $this->balance = $this->BALANCE;
  80. $_LAST_ERROR = 0;
  81. if (!$use_roles) {
  82. $this->corporationRoles = '0';
  83. } //End if.
  84. return $this->characterID;
  85. } //End load_character().
  86. function load_skill_queue(&$cak) {
  87. global $db, $pun_request, $_LAST_ERROR;
  88. $_LAST_ERROR = 0;
  89. //If any of them are not set and if sheet is false...
  90. if ($cak->validate(true) != CAK_OK) {
  91. $_LAST_ERROR = API_BAD_AUTH;
  92. return false;
  93. } //End if.
  94. $url = "https://api.eveonline.com/char/SkillQueue.xml.aspx";
  95. $queue;
  96. if (!$xml = $pun_request->post($url, $cak->get_auth())) {
  97. $_LAST_ERROR = API_BAD_REQUEST;
  98. return false;
  99. } //End if.
  100. $this->skillQueue = array();
  101. $xml_parser = xml_parser_create();
  102. xml_set_object($xml_parser, $this);
  103. xml_set_element_handler($xml_parser, "startElement", "endElement");
  104. xml_set_character_data_handler($xml_parser, "characterData");
  105. if (!xml_parse($xml_parser, $xml, true)) {
  106. error(sprintf("XML error: %s at line %d",
  107. xml_error_string(xml_get_error_code($xml_parser)),
  108. xml_get_current_line_number($xml_parser)), __FILE__, __LINE__);
  109. } //End if.
  110. xml_parser_free($xml_parser);
  111. $_LAST_ERROR = 0;
  112. return true;
  113. } //End load_skill_queue().
  114. function get_list(&$cak) {
  115. global $db, $pun_request, $_LAST_ERROR;
  116. $_LAST_ERROR = 0;
  117. //If any of them are not set and if sheet is false...
  118. if ($cak->validate() != CAK_OK) {
  119. $_LAST_ERROR = API_BAD_AUTH;
  120. return false;
  121. } //End if.
  122. $url = "https://api.eveonline.com/account/Characters.xml.aspx";
  123. $characters;
  124. if (!$xml = $pun_request->post($url, $cak->get_auth())) {
  125. $_LAST_ERROR = API_BAD_REQUEST;
  126. return false;
  127. } //End if.
  128. $this->characterList = array();
  129. $xml_parser = xml_parser_create();
  130. xml_set_object($xml_parser, $this);
  131. xml_set_element_handler($xml_parser, "startElement", "endElement");
  132. xml_set_character_data_handler($xml_parser, "characterData");
  133. if (!xml_parse($xml_parser, $xml, true)) {
  134. error(sprintf("XML error: %s at line %d",
  135. xml_error_string(xml_get_error_code($xml_parser)),
  136. xml_get_current_line_number($xml_parser)), __FILE__, __LINE__);
  137. } //End if.
  138. xml_parser_free($xml_parser);
  139. if ($_LAST_ERROR > 0) {
  140. return false;
  141. } //End if.
  142. $_LAST_ERROR = 0;
  143. return true;
  144. } //End load_skill_queue().
  145. function startElement($parser, $name, $attrs) {
  146. $this->current_tag = $name;
  147. if ($name == 'error') {
  148. global $_LAST_ERROR;
  149. $_LAST_ERROR = intval($attrs['CODE']);
  150. } //End if.
  151. if ($name == 'ROWSET') {
  152. $this->in_rowset = true;
  153. if ($attrs['NAME'] == 'corporationRoles') {
  154. $this->in_roles = true;
  155. } else if ($attrs['NAME'] == 'skillqueue') {
  156. $this->in_queue = true;
  157. } else if ($attrs['NAME'] == 'characters') {
  158. $this->in_characters = true;
  159. } //End if - else if.
  160. return;
  161. } //End if.
  162. if ($name == 'ROW') {
  163. if ($this->in_roles) {
  164. $this->corporationRoles = badd($this->corporationRoles, $attrs['ROLEID']);
  165. } else if ($this->in_queue) {
  166. $this->skillQueue[] = array(
  167. 'queuePosition' => $db->escape($attrs['QUEUEPOSITION']),
  168. 'typeID' => $db->escape($attrs['TYPEID']),
  169. 'level' => $db->escape($attrs['LEVEL']),
  170. 'startSP' => $db->escape($attrs['STARTSP']),
  171. 'endSP' => $db->escape($attrs['ENDSP']),
  172. 'startTime' => $db->escape($attrs['STARTTIME']),
  173. 'endTime' => $db->escape($attrs['ENDTIME'])
  174. );
  175. } else if ($this->in_characters) {
  176. $this->characterList[] = array(
  177. 'name' => $db->escape($attrs['NAME']),
  178. 'characterID' => $db->escape($attrs['CHARACTERID']),
  179. 'corporationName' => $db->escape($attrs['CORPORATIONNAME']),
  180. 'corporationID' => $db->escape($attrs['CORPORATIONID'])
  181. );
  182. } //End if - else if.
  183. } //End if.
  184. } //startElement
  185. function characterData($parser, $data) {
  186. if ($this->in_rowset) {
  187. return; //We don't care about the characterData while in a rowset.
  188. } //End if.
  189. if (preg_match('/^[a-zA-Z0-9\.\\\'\/\" \-\:]+$/', $data)) {
  190. eval('$this->'.$this->current_tag.'="'.addslashes($data).'";');
  191. } //End if.
  192. } //End characterData().
  193. function endElement($parser, $name) {
  194. $this->current_tag = '';
  195. if ($name == 'ROWSET') {
  196. $this->in_rowset = false;
  197. $this->in_roles = false;
  198. $this->in_queue = false;
  199. $this->in_characters = false;
  200. } //End if.
  201. } //End endElement.
  202. } //End Character Class.
  203. ?>