Ore price calculator using EVE-Centrals Mineral Index for EVE-Online


/ Published in: PHP
Save to your folder(s)

Ore price calculator using EVE-Centrals Mineral Index for EVE-Online
Improvement on Mattdathor's code.

Instructions for use:
-Save as .php
-Upload to any PHP-enabled host
-Use it


Copy this code and paste it in your HTML
  1. <?
  2. if ($f = @fopen('http://eve-central.com/home/marketstat_xml.html?evemon=1', 'r'))
  3. {
  4. $content = '';
  5. while (!feof($f)) {
  6. $content .= fgets($f, 4096);
  7. }
  8. }
  9. fclose($f);
  10.  
  11. preg_match_all("'<mineral>(.*?)</mineral>'si", $content, $items);
  12. //print_r($items[1]);
  13. foreach($items[1] as $item)
  14. {
  15. preg_match("'<name.*?>(.*?)</name>'si", $item, $name);
  16. preg_match("'<price.*?>(.*?)</price>'si", $item, $price);
  17. $result[$name[1]] = $price[1]; // Set only if not empty
  18. }
  19. ?>
  20. <html>
  21. <head>
  22. <title>ORE</title>
  23.  
  24. <style>
  25. body { background-color: #dddddd; font-family: Verdana;}
  26. .TblHeader {font-size:20px; font-weight:bold; text-align:center;}
  27. .TblHeader2 {font-size:14px; text-align:center; font-weight:bold;}
  28. .TblData {font-size:14px; padding:2px;}
  29. </style>
  30.  
  31. <script Language="JavaScript">
  32. var Materials = new Array('Tritanium', 'Pyerite', 'Mexallon', 'Isogen', 'Nocxium', 'Zydrine', 'Megacyte', 'Morphite');
  33.  
  34. var Asteroids = new Array();
  35. Asteroids['Veldspar'] = new Array();
  36. Asteroids['Veldspar']['Batchsize'] = 333;
  37. Asteroids['Veldspar']['m3'] = 0.1;
  38. Asteroids['Veldspar']['Materials'] = new Array();
  39. Asteroids['Veldspar']['Materials']['Tritanium'] = 1000;
  40.  
  41. Asteroids['Scordite'] = new Array();
  42. Asteroids['Scordite']['Batchsize'] = 333;
  43. Asteroids['Scordite']['m3'] = 0.15;
  44. Asteroids['Scordite']['Materials'] = new Array();
  45. Asteroids['Scordite']['Materials']['Tritanium'] = 833;
  46. Asteroids['Scordite']['Materials']['Pyerite'] = 416;
  47.  
  48. Asteroids['Pyroxeres'] = new Array();
  49. Asteroids['Pyroxeres']['Batchsize'] = 333;
  50. Asteroids['Pyroxeres']['m3'] = 0.3;
  51. Asteroids['Pyroxeres']['Materials'] = new Array();
  52. Asteroids['Pyroxeres']['Materials']['Tritanium'] = 844;
  53. Asteroids['Pyroxeres']['Materials']['Pyerite'] = 59;
  54. Asteroids['Pyroxeres']['Materials']['Mexallon'] = 120;
  55. Asteroids['Pyroxeres']['Materials']['Nocxium'] = 11;
  56.  
  57. Asteroids['Plagioclase'] = new Array();
  58. Asteroids['Plagioclase']['Batchsize'] = 333;
  59. Asteroids['Plagioclase']['m3'] = 0.35;
  60. Asteroids['Plagioclase']['Materials'] = new Array();
  61. Asteroids['Plagioclase']['Materials']['Tritanium'] = 256;
  62. Asteroids['Plagioclase']['Materials']['Pyerite'] = 512;
  63. Asteroids['Plagioclase']['Materials']['Mexallon'] = 256;
  64.  
  65. Asteroids['Kernite'] = new Array();
  66. Asteroids['Kernite']['Batchsize'] = 400;
  67. Asteroids['Kernite']['m3'] = 1.2;
  68. Asteroids['Kernite']['Materials'] = new Array();
  69. Asteroids['Kernite']['Materials']['Tritanium'] = 386;
  70. Asteroids['Kernite']['Materials']['Mexallon'] = 773;
  71. Asteroids['Kernite']['Materials']['Isogen'] = 386;
  72.  
  73. Asteroids['Omber'] = new Array();
  74. Asteroids['Omber']['Batchsize'] = 500;
  75. Asteroids['Omber']['m3'] = 0.6;
  76. Asteroids['Omber']['Materials'] = new Array();
  77. Asteroids['Omber']['Materials']['Tritanium'] = 307;
  78. Asteroids['Omber']['Materials']['Pyerite'] = 123;
  79. Asteroids['Omber']['Materials']['Isogen'] = 307;
  80.  
  81. Asteroids['Jaspet'] = new Array();
  82. Asteroids['Jaspet']['Batchsize'] = 500;
  83. Asteroids['Jaspet']['m3'] = 2;
  84. Asteroids['Jaspet']['Materials'] = new Array();
  85. Asteroids['Jaspet']['Materials']['Tritanium'] = 259;
  86. Asteroids['Jaspet']['Materials']['Pyerite'] = 259;
  87. Asteroids['Jaspet']['Materials']['Mexallon'] = 518;
  88. Asteroids['Jaspet']['Materials']['Nocxium'] = 259;
  89. Asteroids['Jaspet']['Materials']['Zydrine'] = 8;
  90.  
  91. Asteroids['Hemorphite'] = new Array();
  92. Asteroids['Hemorphite']['Batchsize'] = 500;
  93. Asteroids['Hemorphite']['m3'] = 3;
  94. Asteroids['Hemorphite']['Materials'] = new Array();
  95. Asteroids['Hemorphite']['Materials']['Tritanium'] = 212;
  96. Asteroids['Hemorphite']['Materials']['Isogen'] = 212;
  97. Asteroids['Hemorphite']['Materials']['Nocxium'] = 424;
  98. Asteroids['Hemorphite']['Materials']['Zydrine'] = 28;
  99.  
  100. Asteroids['Hedbergite'] = new Array();
  101. Asteroids['Hedbergite']['Batchsize'] = 500;
  102. Asteroids['Hedbergite']['m3'] = 3;
  103. Asteroids['Hedbergite']['Materials'] = new Array();
  104. Asteroids['Hedbergite']['Materials']['Isogen'] = 708;
  105. Asteroids['Hedbergite']['Materials']['Nocxium'] = 354;
  106. Asteroids['Hedbergite']['Materials']['Zydrine'] = 32;
  107.  
  108. Asteroids['Spodumain'] = new Array();
  109. Asteroids['Spodumain']['Batchsize'] = 250;
  110. Asteroids['Spodumain']['m3'] = 16;
  111. Asteroids['Spodumain']['Materials'] = new Array();
  112. Asteroids['Spodumain']['Materials']['Tritanium'] = 700;
  113. Asteroids['Spodumain']['Materials']['Pyerite'] = 140;
  114. Asteroids['Spodumain']['Materials']['Megacyte'] = 140;
  115.  
  116. Asteroids['Gneiss'] = new Array();
  117. Asteroids['Gneiss']['Batchsize'] = 400;
  118. Asteroids['Gneiss']['m3'] = 5;
  119. Asteroids['Gneiss']['Materials'] = new Array();
  120. Asteroids['Gneiss']['Materials']['Tritanium'] = 171;
  121. Asteroids['Gneiss']['Materials']['Mexallon'] = 171;
  122. Asteroids['Gneiss']['Materials']['Isogen'] = 343;
  123. Asteroids['Gneiss']['Materials']['Zydrine'] = 171;
  124.  
  125. Asteroids['DarkOchre'] = new Array();
  126. Asteroids['DarkOchre']['Batchsize'] = 400;
  127. Asteroids['DarkOchre']['m3'] = 8;
  128. Asteroids['DarkOchre']['Materials'] = new Array();
  129. Asteroids['DarkOchre']['Materials']['Tritanium'] = 250;
  130. Asteroids['DarkOchre']['Materials']['Nocxium'] = 500;
  131. Asteroids['DarkOchre']['Materials']['Zydrine'] = 250;
  132.  
  133. Asteroids['Crokite'] = new Array();
  134. Asteroids['Crokite']['Batchsize'] = 250;
  135. Asteroids['Crokite']['m3'] = 16;
  136. Asteroids['Crokite']['Materials'] = new Array();
  137. Asteroids['Crokite']['Materials']['Tritanium'] = 331;
  138. Asteroids['Crokite']['Materials']['Isogen'] = 331;
  139. Asteroids['Crokite']['Materials']['Zydrine'] = 663;
  140.  
  141. Asteroids['Bistot'] = new Array();
  142. Asteroids['Bistot']['Batchsize'] = 200;
  143. Asteroids['Bistot']['m3'] = 16;
  144. Asteroids['Bistot']['Materials'] = new Array();
  145. Asteroids['Bistot']['Materials']['Pyerite'] = 170;
  146. Asteroids['Bistot']['Materials']['Zydrine'] = 341;
  147. Asteroids['Bistot']['Materials']['Megacyte'] = 170;
  148.  
  149. Asteroids['Arkonor'] = new Array();
  150. Asteroids['Arkonor']['Batchsize'] = 200;
  151. Asteroids['Arkonor']['m3'] = 16;
  152. Asteroids['Arkonor']['Materials'] = new Array();
  153. Asteroids['Arkonor']['Materials']['Tritanium'] = 300;
  154. Asteroids['Arkonor']['Materials']['Zydrine'] = 166;
  155. Asteroids['Arkonor']['Materials']['Megacyte'] = 333;
  156.  
  157. Asteroids['Mercoxit'] = new Array();
  158. Asteroids['Mercoxit']['Batchsize'] = 250;
  159. Asteroids['Mercoxit']['m3'] = 40;
  160. Asteroids['Mercoxit']['Materials'] = new Array();
  161. Asteroids['Mercoxit']['Materials']['Morphite'] = 530;
  162.  
  163.  
  164. function UpdateList ()
  165. {
  166. for (var i in Materials)
  167. {
  168. var Material = Materials[i];
  169. eval ("var "+Material+"Price = parseFloat(document.getElementById(\""+Material+"Price\").value);");
  170. }
  171.  
  172. for (var i in Asteroids)
  173. {
  174. var Asteroid = Asteroids[i];
  175. var Price = 0;
  176.  
  177. for (var j in Asteroid['Materials'])
  178. {
  179. eval ("var MaterialPrice = "+j+"Price;");
  180. if (MaterialPrice > 0 && Price >= 0)
  181. {
  182. Price += MaterialPrice * Asteroid['Materials'][j];
  183. }
  184. else
  185. {
  186. Price = -1;
  187. break;
  188. }
  189. }
  190.  
  191. if (Price >= 0)
  192. {
  193. var PricePerUnit = Math.round(Price / Asteroid['Batchsize']*100)/100;
  194. var PricePerM3 = Math.round(((Price / Asteroid['Batchsize']) / Asteroid['m3'])*100)/100;
  195. if ((PricePerUnit*100)%10 == 0)
  196. {
  197. PricePerUnit = String.concat(PricePerUnit+"0");
  198. }
  199. if ((PricePerM3*100)%10 == 0)
  200. {
  201. PricePerM3 = String.concat(PricePerM3+"0");
  202. }
  203. }
  204. else
  205. {
  206. PricePerUnit = 0.00;
  207. PricePerM3 = 0.00;
  208. }
  209.  
  210. document.getElementById(i+"_Unit").innerHTML = PricePerUnit;
  211. document.getElementById(i+"_m3").innerHTML = PricePerM3;
  212. }
  213. }
  214. </script>
  215. </head>
  216.  
  217. <body onLoad="javascript:UpdateList();">
  218.  
  219. <table border="0" cellpadding="0" cellspacing="0" width="1000">
  220. <tr>
  221. <td width="45%" valign="top">
  222. <table border="0" cellpadding="0" cellspacing="0" width="400">
  223. <tr>
  224. <td class="TblHeader" colspan="2">Material Prices</td>
  225. </tr>
  226.  
  227. <tr>
  228.  
  229. <td class="TblData">Tritanium:</td>
  230. <td class="TblData"><input class="TxtField" id="TritaniumPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Tritanium'].'"'; ?>></td>
  231. </tr>
  232. <tr>
  233. <td class="TblData">Pyerite:</td>
  234. <td class="TblData"><input class="TxtField" id="PyeritePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Pyerite'].'"'; ?>></td>
  235. </tr>
  236. <tr>
  237.  
  238. <td class="TblData">Mexallon:</td>
  239. <td class="TblData"><input class="TxtField" id="MexallonPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Mexallon'].'"'; ?>></td>
  240. </tr>
  241. <tr>
  242. <td class="TblData">Isogen:</td>
  243. <td class="TblData"><input class="TxtField" id="IsogenPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Isogen'].'"'; ?>></td>
  244. </tr>
  245. <tr>
  246.  
  247. <td class="TblData">Nocxium:</td>
  248. <td class="TblData"><input class="TxtField" id="NocxiumPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Nocxium'].'"'; ?>></td>
  249. </tr>
  250. <tr>
  251. <td class="TblData">Zydrine:</td>
  252. <td class="TblData"><input class="TxtField" id="ZydrinePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Zydrine'].'"'; ?>></td>
  253. </tr>
  254. <tr>
  255.  
  256. <td class="TblData">Megacyte:</td>
  257. <td class="TblData"><input class="TxtField" id="MegacytePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Megacyte'].'"'; ?>></td>
  258. </tr>
  259. <tr>
  260. <td class="TblData">Morphite:</td>
  261. <td class="TblData"><input class="TxtField" id="MorphitePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Morphite'].'"'; ?>></td>
  262. </tr>
  263. </table>
  264.  
  265. </td>
  266.  
  267. <td width="10%">&nbsp;</td>
  268.  
  269. <td width="45%" valign="top">
  270. <table border="0" cellpadding="0" cellspacing="0" width="400">
  271. <tr>
  272. <td class="TblHeader" colspan="3">Asteroids</td>
  273. </tr>
  274. <tr>
  275.  
  276. <td class="TblHeader2">Name</td>
  277. <td class="TblHeader2">ISK/m3</td>
  278. <td class="TblHeader2">ISK/Unit</td>
  279. </tr>
  280.  
  281. <tr>
  282. <td class="TblData">Veldspar:</td>
  283. <td class="TblData" align="right"><span id="Veldspar_m3">---</span></td>
  284.  
  285. <td class="TblData" align="right"><span id="Veldspar_Unit">---</span></td>
  286. </tr>
  287. <tr>
  288. <td class="TblData">Scordite:</td>
  289. <td class="TblData" align="right"><span id="Scordite_m3">---</span></td>
  290. <td class="TblData" align="right"><span id="Scordite_Unit">---</span></td>
  291. </tr>
  292.  
  293. <tr>
  294. <td class="TblData">Plagioclase:</td>
  295. <td class="TblData" align="right"><span id="Plagioclase_m3">---</span></td>
  296. <td class="TblData" align="right"><span id="Plagioclase_Unit">---</span></td>
  297. </tr>
  298. <tr>
  299. <td class="TblData">Pyroxeres:</td>
  300.  
  301. <td class="TblData" align="right"><span id="Pyroxeres_m3">---</span></td>
  302. <td class="TblData" align="right"><span id="Pyroxeres_Unit">---</span></td>
  303. </tr>
  304. <tr>
  305. <td class="TblData">Kernite:</td>
  306. <td class="TblData" align="right"><span id="Kernite_m3">---</span></td>
  307. <td class="TblData" align="right"><span id="Kernite_Unit">---</span></td>
  308.  
  309. </tr>
  310. <tr>
  311. <td class="TblData">Omber:</td>
  312. <td class="TblData" align="right"><span id="Omber_m3">---</span></td>
  313. <td class="TblData" align="right"><span id="Omber_Unit">---</span></td>
  314. </tr>
  315. <tr>
  316.  
  317. <td class="TblData">Jaspet:</td>
  318. <td class="TblData" align="right"><span id="Jaspet_m3">---</span></td>
  319. <td class="TblData" align="right"><span id="Jaspet_Unit">---</span></td>
  320. </tr>
  321. <tr>
  322. <td class="TblData">Hemorphite:</td>
  323. <td class="TblData" align="right"><span id="Hemorphite_m3">---</span></td>
  324.  
  325. <td class="TblData" align="right"><span id="Hemorphite_Unit">---</span></td>
  326. </tr>
  327. <tr>
  328. <td class="TblData">Hedbergite:</td>
  329. <td class="TblData" align="right"><span id="Hedbergite_m3">---</span></td>
  330. <td class="TblData" align="right"><span id="Hedbergite_Unit">---</span></td>
  331. </tr>
  332.  
  333. <tr>
  334. <td class="TblData">Spodumain:</td>
  335. <td class="TblData" align="right"><span id="Spodumain_m3">---</span></td>
  336. <td class="TblData" align="right"><span id="Spodumain_Unit">---</span></td>
  337. </tr>
  338. <tr>
  339. <td class="TblData">Gneiss:</td>
  340.  
  341. <td class="TblData" align="right"><span id="Gneiss_m3">---</span></td>
  342. <td class="TblData" align="right"><span id="Gneiss_Unit">---</span></td>
  343. </tr>
  344. <tr>
  345. <td class="TblData">Dark Ochre:</td>
  346. <td class="TblData" align="right"><span id="DarkOchre_m3">---</span></td>
  347. <td class="TblData" align="right"><span id="DarkOchre_Unit">---</span></td>
  348.  
  349. </tr>
  350. <tr>
  351. <td class="TblData">Crokite:</td>
  352. <td class="TblData" align="right"><span id="Crokite_m3">---</span></td>
  353. <td class="TblData" align="right"><span id="Crokite_Unit">---</span></td>
  354. </tr>
  355. <tr>
  356.  
  357. <td class="TblData">Bistot:</td>
  358. <td class="TblData" align="right"><span id="Bistot_m3">---</span></td>
  359. <td class="TblData" align="right"><span id="Bistot_Unit">---</span></td>
  360. </tr>
  361. <tr>
  362. <td class="TblData">Arkonor:</td>
  363. <td class="TblData" align="right"><span id="Arkonor_m3">---</span></td>
  364.  
  365. <td class="TblData" align="right"><span id="Arkonor_Unit">---</span></td>
  366. </tr>
  367. <tr>
  368. <td class="TblData">Mercoxit:</td>
  369. <td class="TblData" align="right"><span id="Mercoxit_m3">---</span></td>
  370. <td class="TblData" align="right"><span id="Mercoxit_Unit">---</span></td>
  371. </tr>
  372.  
  373.  
  374. </table>
  375. </td>
  376. </tr>
  377. </table>
  378. </body>
  379. </html>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.