Return to Snippet

Revision: 3650
at August 29, 2007 02:40 by Shinhan


Initial Code
<?
	if ($f = @fopen('http://eve-central.com/home/marketstat_xml.html?evemon=1', 'r')) 
		{
		$content = '';
		while (!feof($f)) {
			$content .= fgets($f, 4096);
			}
		}
	fclose($f);
	
	preg_match_all("'<mineral>(.*?)</mineral>'si", $content, $items);
	//print_r($items[1]);
	foreach($items[1] as $item)
	{
		preg_match("'<name.*?>(.*?)</name>'si", $item, $name);
		preg_match("'<price.*?>(.*?)</price>'si", $item, $price);
		$result[$name[1]] = $price[1]; // Set only if not empty
	}	
	?>
<html>
	<head>
		<title>ORE</title>

		<style>
			body { background-color: #dddddd; font-family: Verdana;}
			.TblHeader {font-size:20px; font-weight:bold; text-align:center;}
			.TblHeader2 {font-size:14px; text-align:center; font-weight:bold;}
			.TblData {font-size:14px; padding:2px;}
		</style>
		
		<script Language="JavaScript">
			var Materials = new Array('Tritanium', 'Pyerite', 'Mexallon', 'Isogen', 'Nocxium', 'Zydrine', 'Megacyte', 'Morphite');
			
			var Asteroids = new Array();
			Asteroids['Veldspar'] = new Array();
			Asteroids['Veldspar']['Batchsize'] = 333;
			Asteroids['Veldspar']['m3'] = 0.1;
			Asteroids['Veldspar']['Materials'] = new Array();
			Asteroids['Veldspar']['Materials']['Tritanium'] = 1000;
			
			Asteroids['Scordite'] = new Array();
			Asteroids['Scordite']['Batchsize'] = 333;
			Asteroids['Scordite']['m3'] = 0.15;
			Asteroids['Scordite']['Materials'] = new Array();
			Asteroids['Scordite']['Materials']['Tritanium'] = 833;
			Asteroids['Scordite']['Materials']['Pyerite'] = 416;
			
			Asteroids['Pyroxeres'] = new Array();
			Asteroids['Pyroxeres']['Batchsize'] = 333;
			Asteroids['Pyroxeres']['m3'] = 0.3;
			Asteroids['Pyroxeres']['Materials'] = new Array();
			Asteroids['Pyroxeres']['Materials']['Tritanium'] = 844;
			Asteroids['Pyroxeres']['Materials']['Pyerite'] = 59;
			Asteroids['Pyroxeres']['Materials']['Mexallon'] = 120;
			Asteroids['Pyroxeres']['Materials']['Nocxium'] = 11;
			
			Asteroids['Plagioclase'] = new Array();
			Asteroids['Plagioclase']['Batchsize'] = 333;
			Asteroids['Plagioclase']['m3'] = 0.35;
			Asteroids['Plagioclase']['Materials'] = new Array();
			Asteroids['Plagioclase']['Materials']['Tritanium'] = 256;
			Asteroids['Plagioclase']['Materials']['Pyerite'] = 512;
			Asteroids['Plagioclase']['Materials']['Mexallon'] = 256;
			
			Asteroids['Kernite'] = new Array();
			Asteroids['Kernite']['Batchsize'] = 400;
			Asteroids['Kernite']['m3'] = 1.2;
			Asteroids['Kernite']['Materials'] = new Array();
			Asteroids['Kernite']['Materials']['Tritanium'] = 386;
			Asteroids['Kernite']['Materials']['Mexallon'] = 773;
			Asteroids['Kernite']['Materials']['Isogen'] = 386;

			Asteroids['Omber'] = new Array();
			Asteroids['Omber']['Batchsize'] = 500;
			Asteroids['Omber']['m3'] = 0.6;
			Asteroids['Omber']['Materials'] = new Array();
			Asteroids['Omber']['Materials']['Tritanium'] = 307;
			Asteroids['Omber']['Materials']['Pyerite'] = 123;
			Asteroids['Omber']['Materials']['Isogen'] = 307;

			Asteroids['Jaspet'] = new Array();
			Asteroids['Jaspet']['Batchsize'] = 500;
			Asteroids['Jaspet']['m3'] = 2;
			Asteroids['Jaspet']['Materials'] = new Array();
			Asteroids['Jaspet']['Materials']['Tritanium'] = 259;
			Asteroids['Jaspet']['Materials']['Pyerite'] = 259;
			Asteroids['Jaspet']['Materials']['Mexallon'] = 518;
			Asteroids['Jaspet']['Materials']['Nocxium'] = 259;
			Asteroids['Jaspet']['Materials']['Zydrine'] = 8;

			Asteroids['Hemorphite'] = new Array();
			Asteroids['Hemorphite']['Batchsize'] = 500;
			Asteroids['Hemorphite']['m3'] = 3;
			Asteroids['Hemorphite']['Materials'] = new Array();
			Asteroids['Hemorphite']['Materials']['Tritanium'] = 212;
			Asteroids['Hemorphite']['Materials']['Isogen'] = 212;
			Asteroids['Hemorphite']['Materials']['Nocxium'] = 424;
			Asteroids['Hemorphite']['Materials']['Zydrine'] = 28;

			Asteroids['Hedbergite'] = new Array();
			Asteroids['Hedbergite']['Batchsize'] = 500;
			Asteroids['Hedbergite']['m3'] = 3;
			Asteroids['Hedbergite']['Materials'] = new Array();
			Asteroids['Hedbergite']['Materials']['Isogen'] = 708;
			Asteroids['Hedbergite']['Materials']['Nocxium'] = 354;
			Asteroids['Hedbergite']['Materials']['Zydrine'] = 32;
            
			Asteroids['Spodumain'] = new Array();
			Asteroids['Spodumain']['Batchsize'] = 250;
			Asteroids['Spodumain']['m3'] = 16;
			Asteroids['Spodumain']['Materials'] = new Array();
			Asteroids['Spodumain']['Materials']['Tritanium'] = 700;
			Asteroids['Spodumain']['Materials']['Pyerite'] = 140;
			Asteroids['Spodumain']['Materials']['Megacyte'] = 140;
			
			Asteroids['Gneiss'] = new Array();
			Asteroids['Gneiss']['Batchsize'] = 400;
			Asteroids['Gneiss']['m3'] = 5;
			Asteroids['Gneiss']['Materials'] = new Array();
			Asteroids['Gneiss']['Materials']['Tritanium'] = 171;
			Asteroids['Gneiss']['Materials']['Mexallon'] = 171;
			Asteroids['Gneiss']['Materials']['Isogen'] = 343;
			Asteroids['Gneiss']['Materials']['Zydrine'] = 171;

			Asteroids['DarkOchre'] = new Array();
			Asteroids['DarkOchre']['Batchsize'] = 400;
			Asteroids['DarkOchre']['m3'] = 8;
			Asteroids['DarkOchre']['Materials'] = new Array();
			Asteroids['DarkOchre']['Materials']['Tritanium'] = 250;
			Asteroids['DarkOchre']['Materials']['Nocxium'] = 500;
			Asteroids['DarkOchre']['Materials']['Zydrine'] = 250;

			Asteroids['Crokite'] = new Array();
			Asteroids['Crokite']['Batchsize'] = 250;
			Asteroids['Crokite']['m3'] = 16;
			Asteroids['Crokite']['Materials'] = new Array();
			Asteroids['Crokite']['Materials']['Tritanium'] = 331;
			Asteroids['Crokite']['Materials']['Isogen'] = 331;
			Asteroids['Crokite']['Materials']['Zydrine'] = 663;

			Asteroids['Bistot'] = new Array();
			Asteroids['Bistot']['Batchsize'] = 200;
			Asteroids['Bistot']['m3'] = 16;
			Asteroids['Bistot']['Materials'] = new Array();
			Asteroids['Bistot']['Materials']['Pyerite'] = 170;
			Asteroids['Bistot']['Materials']['Zydrine'] = 341;
			Asteroids['Bistot']['Materials']['Megacyte'] = 170;
			
			Asteroids['Arkonor'] = new Array();
			Asteroids['Arkonor']['Batchsize'] = 200;
			Asteroids['Arkonor']['m3'] = 16;
			Asteroids['Arkonor']['Materials'] = new Array();
			Asteroids['Arkonor']['Materials']['Tritanium'] = 300;
			Asteroids['Arkonor']['Materials']['Zydrine'] = 166;
			Asteroids['Arkonor']['Materials']['Megacyte'] = 333;

			Asteroids['Mercoxit'] = new Array();
			Asteroids['Mercoxit']['Batchsize'] = 250;
			Asteroids['Mercoxit']['m3'] = 40;
			Asteroids['Mercoxit']['Materials'] = new Array();
			Asteroids['Mercoxit']['Materials']['Morphite'] = 530;

			
			function UpdateList ()
			{
				for (var i in Materials)
				{
					var Material = Materials[i];
					eval ("var "+Material+"Price = parseFloat(document.getElementById(\""+Material+"Price\").value);");
				}
				
				for (var i in Asteroids)
				{
					var Asteroid = Asteroids[i];
					var Price = 0;
					
					for (var j in Asteroid['Materials'])
					{
						eval ("var MaterialPrice = "+j+"Price;");
						if (MaterialPrice > 0 && Price >= 0)
						{
							Price += MaterialPrice * Asteroid['Materials'][j];
						}
						else
						{
							Price = -1;
							break;
						}
					}
					
					if (Price >= 0)
					{
						var PricePerUnit = Math.round(Price / Asteroid['Batchsize']*100)/100;
						var PricePerM3 = Math.round(((Price / Asteroid['Batchsize']) / Asteroid['m3'])*100)/100;
						if ((PricePerUnit*100)%10 == 0)
							{
							PricePerUnit = String.concat(PricePerUnit+"0");
							}
						if ((PricePerM3*100)%10 == 0)
							{
							PricePerM3 = String.concat(PricePerM3+"0");
							}
					}
					else
					{
						PricePerUnit = 0.00;
						PricePerM3 = 0.00;
					}
					
					document.getElementById(i+"_Unit").innerHTML = PricePerUnit;
					document.getElementById(i+"_m3").innerHTML = PricePerM3;
				}
			}
		</script>
	</head>
	
	<body onLoad="javascript:UpdateList();">

		<table border="0" cellpadding="0" cellspacing="0" width="1000">
			<tr>
				<td width="45%" valign="top">
					<table border="0" cellpadding="0" cellspacing="0" width="400">
						<tr>
							<td class="TblHeader" colspan="2">Material Prices</td>
						</tr>
						
						<tr>

							<td class="TblData">Tritanium:</td>
							<td class="TblData"><input class="TxtField" id="TritaniumPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Tritanium'].'"'; ?>></td>
						</tr>
						<tr>
							<td class="TblData">Pyerite:</td>
							<td class="TblData"><input class="TxtField" id="PyeritePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Pyerite'].'"'; ?>></td>
						</tr>
						<tr>

							<td class="TblData">Mexallon:</td>
							<td class="TblData"><input class="TxtField" id="MexallonPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Mexallon'].'"'; ?>></td>
						</tr>
						<tr>
							<td class="TblData">Isogen:</td>
							<td class="TblData"><input class="TxtField" id="IsogenPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Isogen'].'"'; ?>></td>
						</tr>
						<tr>

							<td class="TblData">Nocxium:</td>
							<td class="TblData"><input class="TxtField" id="NocxiumPrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Nocxium'].'"'; ?>></td>
						</tr>
						<tr>
							<td class="TblData">Zydrine:</td>
							<td class="TblData"><input class="TxtField" id="ZydrinePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Zydrine'].'"'; ?>></td>
						</tr>
						<tr>

							<td class="TblData">Megacyte:</td>
							<td class="TblData"><input class="TxtField" id="MegacytePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Megacyte'].'"'; ?>></td>
						</tr>
						<tr>
							<td class="TblData">Morphite:</td>
							<td class="TblData"><input class="TxtField" id="MorphitePrice" onKeyUp="javascript:UpdateList();" onChange="javascript:UpdateList();"<? if (isset($result)) echo ' value="'.$result['Morphite'].'"'; ?>></td>
						</tr>
					</table>

				</td>
				
				<td width="10%">&nbsp;</td>
				
				<td width="45%" valign="top">
					<table border="0" cellpadding="0" cellspacing="0" width="400">
						<tr>
							<td class="TblHeader" colspan="3">Asteroids</td>
						</tr>
						<tr>

							<td class="TblHeader2">Name</td>
							<td class="TblHeader2">ISK/m3</td>
							<td class="TblHeader2">ISK/Unit</td>
						</tr>
						
						<tr>
							<td class="TblData">Veldspar:</td>
							<td class="TblData" align="right"><span id="Veldspar_m3">---</span></td>

							<td class="TblData" align="right"><span id="Veldspar_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Scordite:</td>
							<td class="TblData" align="right"><span id="Scordite_m3">---</span></td>
							<td class="TblData" align="right"><span id="Scordite_Unit">---</span></td>
						</tr>

						<tr>
							<td class="TblData">Plagioclase:</td>
							<td class="TblData" align="right"><span id="Plagioclase_m3">---</span></td>
							<td class="TblData" align="right"><span id="Plagioclase_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Pyroxeres:</td>

							<td class="TblData" align="right"><span id="Pyroxeres_m3">---</span></td>
							<td class="TblData" align="right"><span id="Pyroxeres_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Kernite:</td>
							<td class="TblData" align="right"><span id="Kernite_m3">---</span></td>
							<td class="TblData" align="right"><span id="Kernite_Unit">---</span></td>

						</tr>
						<tr>
							<td class="TblData">Omber:</td>
							<td class="TblData" align="right"><span id="Omber_m3">---</span></td>
							<td class="TblData" align="right"><span id="Omber_Unit">---</span></td>
						</tr>
						<tr>

							<td class="TblData">Jaspet:</td>
							<td class="TblData" align="right"><span id="Jaspet_m3">---</span></td>
							<td class="TblData" align="right"><span id="Jaspet_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Hemorphite:</td>
							<td class="TblData" align="right"><span id="Hemorphite_m3">---</span></td>

							<td class="TblData" align="right"><span id="Hemorphite_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Hedbergite:</td>
							<td class="TblData" align="right"><span id="Hedbergite_m3">---</span></td>
							<td class="TblData" align="right"><span id="Hedbergite_Unit">---</span></td>
						</tr>

						<tr>
							<td class="TblData">Spodumain:</td>
							<td class="TblData" align="right"><span id="Spodumain_m3">---</span></td>
							<td class="TblData" align="right"><span id="Spodumain_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Gneiss:</td>

							<td class="TblData" align="right"><span id="Gneiss_m3">---</span></td>
							<td class="TblData" align="right"><span id="Gneiss_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Dark Ochre:</td>
							<td class="TblData" align="right"><span id="DarkOchre_m3">---</span></td>
							<td class="TblData" align="right"><span id="DarkOchre_Unit">---</span></td>

						</tr>
						<tr>
							<td class="TblData">Crokite:</td>
							<td class="TblData" align="right"><span id="Crokite_m3">---</span></td>
							<td class="TblData" align="right"><span id="Crokite_Unit">---</span></td>
						</tr>
						<tr>

							<td class="TblData">Bistot:</td>
							<td class="TblData" align="right"><span id="Bistot_m3">---</span></td>
							<td class="TblData" align="right"><span id="Bistot_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Arkonor:</td>
							<td class="TblData" align="right"><span id="Arkonor_m3">---</span></td>

							<td class="TblData" align="right"><span id="Arkonor_Unit">---</span></td>
						</tr>
						<tr>
							<td class="TblData">Mercoxit:</td>
							<td class="TblData" align="right"><span id="Mercoxit_m3">---</span></td>
							<td class="TblData" align="right"><span id="Mercoxit_Unit">---</span></td>
						</tr>

						
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>

Initial URL

                                

Initial Description
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

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

Initial Tags

                                

Initial Language
PHP