mirror of
https://github.com/voronius/NGE-resource-browser
synced 2026-01-16 23:04:42 -05:00
first commit
This commit is contained in:
14
README
Normal file
14
README
Normal file
@@ -0,0 +1,14 @@
|
||||
Disclaimer: use it at your own risk, unmaintained ...
|
||||
|
||||
Tested on Firefox
|
||||
|
||||
Purpose is to create a basic resource browser interface that doesn't require additional work (like filling values in GH or feeding xml in there every x days)
|
||||
|
||||
You're free to use/improve/redistribute, i don't care
|
||||
|
||||
Install steps:
|
||||
1.extracting the archive will create a "res" folder under htdocs on your web server
|
||||
2.check file permission/access settings for access via web
|
||||
3.configure db connection data at the top at the "res.php" file and the limit (!!! default 10 results per page !!!) same place
|
||||
4.access via some URL like https://127.0.0.1/res/res.php
|
||||
5.enjoy !
|
||||
21
attribute_def.php
Normal file
21
attribute_def.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
//just maps internal attribute name to user friendly name
|
||||
|
||||
$attributes=array
|
||||
(
|
||||
"res_decay_resist"=>"DR",
|
||||
"res_flavor"=>"FL",
|
||||
"res_potential_energy"=>"PE",
|
||||
"res_quality"=>"OQ",
|
||||
"res_malleability"=>"MA",
|
||||
"res_shock_resistance"=>"SR",
|
||||
"res_toughness"=>"UT",
|
||||
"res_cold_resist"=>"CR",
|
||||
"res_conductivity"=>"CD",
|
||||
"res_heat_resist"=>"HR",
|
||||
"entangle_resistance"=>"ER"
|
||||
);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
90
form.php
Normal file
90
form.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<div style="position:fixed;top:80px; left:10px">
|
||||
<form action="res.php" method="post">
|
||||
<!--
|
||||
<input type="radio" name="class_or_type" value="class" autocomplete="off" onchange="if(this.checked) { this.form.select_res_type.disabled=true;this.form.select_res_class.disabled=false;}" checked> From class:</input>
|
||||
|
||||
</br>
|
||||
|
||||
<select name="select_res_class" autocomplete="off">
|
||||
<option value="Inorganic">ALL</option>
|
||||
<option value="Inorganic">Inorganic</option>
|
||||
<option value="Organic">Organic</option>
|
||||
<option value="Mineral">Mineral</option>
|
||||
<option value="Ore">Metal</option>
|
||||
</select>
|
||||
|
||||
</br>
|
||||
<input type="radio" name="class_or_type" value="type" autocomplete="off" onchange="if(this.checked) {this.form.select_res_class.disabled=true; this.form.select_res_type.disabled=false;}"> Of type:</input>
|
||||
|
||||
</br>
|
||||
<select name="select_res_type" disabled="true" autocomplete="off">
|
||||
<option value="Inorganic">Duralloy Steel</option>
|
||||
<option value="Organic">Ditanium Steel</option>
|
||||
<option value="Mineral">Polysteel Copper</option>
|
||||
<option value="Ore">Titanium alluminum</option>
|
||||
</select>
|
||||
//-->
|
||||
<label for="">Comma separated
|
||||
</br> or leave empty
|
||||
</br>(ex.:must,intrusive):</label>
|
||||
</br>
|
||||
|
||||
<input type="text" name="search" value="<?php echo $search;?>">
|
||||
|
||||
</br>
|
||||
</br>
|
||||
<!--
|
||||
<label for="select_res_planet">Only on planet:</label>
|
||||
</br>
|
||||
<select name="select_res_planet" autocomplete="off">
|
||||
<option value="All">ALL</option>
|
||||
<option value="Inorganic">Corellia</option>
|
||||
<option value="Organic">Naboo</option>
|
||||
<option value="Mineral">Talus</option>
|
||||
<option value="Ore">Lok</option>
|
||||
</select>
|
||||
</br>
|
||||
</br>
|
||||
</br>
|
||||
//-->
|
||||
<label for="order_res_attribute">Order by attribute:</label>
|
||||
</br>
|
||||
<select name="order_res_attribute" >
|
||||
<option value="res_quality" >OQ</option>
|
||||
<option value="res_decay_resist"<?php if( strcmp($sort_attribute,"res_decay_resist")==0) echo " selected";?> >DR</option>
|
||||
<option value="res_flavor"<?php if( strcmp($sort_attribute,"res_flavor")==0) echo " selected";?> >FL</option>
|
||||
<option value="res_potential_energy"<?php if( strcmp($sort_attribute,"res_potential_energy")==0) echo " selected";?> >PE</option>
|
||||
<option value="res_malleability"<?php if( strcmp($sort_attribute,"res_malleability")==0) echo " selected";?> >MA</option>
|
||||
<option value="res_shock_resistance"<?php if( strcmp($sort_attribute,"res_shock_resistance")==0) echo " selected";?> >SR</option>
|
||||
<option value="res_toughness"<?php if( strcmp($sort_attribute,"res_toughness")==0) echo " selected";?> >UT</option>
|
||||
<option value="res_cold_resist"<?php if( strcmp($sort_attribute,"res_cold_resist")==0) echo " selected";?> >CR</option>
|
||||
<option value="res_conductivity"<?php if( strcmp($sort_attribute,"res_conductivity")==0) echo " selected";?> >CD</option>
|
||||
<option value="res_heat_resist"<?php if( strcmp($sort_attribute,"res_heat_resist")==0) echo " selected";?> >HR</option>
|
||||
<option value="entangle_resistance"<?php if( strcmp($sort_attribute,"entangle_resistance")==0) echo " selected";?> >ER</option>
|
||||
|
||||
</select>
|
||||
|
||||
</br>
|
||||
</br>
|
||||
<label for="current"> Only current
|
||||
</br>
|
||||
<input type="checkbox" name="current" <?php if($current==1) echo " checked"; ?>>
|
||||
</br>
|
||||
</br>
|
||||
</br>
|
||||
<input type="submit" value="Go" style="font-weight:bold;"/>
|
||||
<input type="hidden" name="offset" value="<?php echo $offset;?>">
|
||||
|
||||
<?php
|
||||
echo "<input type=\"submit\" name=\"next\" value=\" next >> \"></br>";
|
||||
if($offset>0) echo "<input type=\"submit\" name=\"prev\" value=\" <prev \">";
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
53
planets_def.php
Normal file
53
planets_def.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
$planets=array
|
||||
(
|
||||
"10000006"=>"corellia",
|
||||
"10000007"=>"dantooine",
|
||||
"10000008"=>"dathomir",
|
||||
"10000009"=>"endor",
|
||||
"10000010"=>"lok",
|
||||
"10000011"=>"naboo",
|
||||
"10000012"=>"rori",
|
||||
"10000013"=>"talus",
|
||||
"10000014"=>"tatooine",
|
||||
"10000015"=>"tutorial",
|
||||
"10000016"=>"yavin4",
|
||||
"10000017"=>"dungeon1",
|
||||
"10000018"=>"space_corellia",
|
||||
"10000019"=>"space_corellia_2",
|
||||
"10000020"=>"space_naboo",
|
||||
"10000021"=>"space_naboo_2",
|
||||
"10000022"=>"space_tatooine",
|
||||
"10000023"=>"space_tatooine_2",
|
||||
"10000024"=>"space_lok",
|
||||
"10000025"=>"space_dantooine",
|
||||
"10000026"=>"space_dathomir",
|
||||
"10000027"=>"space_yavin4",
|
||||
"10000028"=>"space_endor",
|
||||
"10000029"=>"space_heavy1",
|
||||
"10000030"=>"space_light1",
|
||||
"10000031"=>"kashyyyk_dead_forest",
|
||||
"10000032"=>"kashyyyk_hunting",
|
||||
"10000033"=>"kashyyyk_main",
|
||||
"10000034"=>"kashyyyk_north_dungeons",
|
||||
"10000035"=>"kashyyyk_pob_dungeons",
|
||||
"10000036"=>"kashyyyk_rryatt_trail",
|
||||
"10000037"=>"kashyyyk_south_dungeons",
|
||||
"10000038"=>"space_kashyyyk",
|
||||
"10000039"=>"mustafar",
|
||||
"10000040"=>"space_ord_mantell",
|
||||
"10000041"=>"space_ord_mantell_2",
|
||||
"10000042"=>"space_ord_mantell_3",
|
||||
"10000043"=>"space_ord_mantell_4",
|
||||
"10000044"=>"space_ord_mantell_5",
|
||||
"10000045"=>"space_ord_mantell_6",
|
||||
"10000046"=>"space_nova_orion",
|
||||
"10000047"=>"space_npe_falcon",
|
||||
"10000048"=>"space_npe_falcon_2",
|
||||
"10000049"=>"space_npe_falcon_3",
|
||||
"10000050"=>"adventure1",
|
||||
"10000051"=>"adventure2"
|
||||
);
|
||||
?>
|
||||
|
||||
346
res.php
Normal file
346
res.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/////Made by : bintodec/voronius/alexuspanait@yahoo.com (one and only)
|
||||
/////You're free to change and redistribute as long as you keep the above line
|
||||
/////I'm not reposnsible for any harm it might cause (like ddos ...)
|
||||
/////Purpose of this is to give you a base for your own resource browsing tool
|
||||
//
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////// CONFIG PART /////////////////////////////////
|
||||
//user
|
||||
$user="swg";
|
||||
//pass
|
||||
$pass="swg";
|
||||
//db_url
|
||||
$db_url="localhost/swg";
|
||||
//max rows returned, use it to limit traffic (?)
|
||||
$limit=10;
|
||||
|
||||
////////////////////////////////////// END CONFIG PART ///////////////////////////////
|
||||
|
||||
|
||||
require_once("planets_def.php");
|
||||
require_once("attribute_def.php");
|
||||
require_once("resource_class_tree.php");
|
||||
|
||||
|
||||
$conn = oci_connect($user, $pass, $db_url);
|
||||
if (!$conn)
|
||||
{
|
||||
$e = oci_error();
|
||||
echo "connect failed ".print_r($e);
|
||||
}
|
||||
|
||||
|
||||
$search="";
|
||||
$search_type_query="";
|
||||
$sort_attribute='res_quality';
|
||||
$only_current="";
|
||||
$current=0;
|
||||
|
||||
$offset=0;
|
||||
$prev_offset=0;
|
||||
$next_offset=0;
|
||||
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
if(isSet($_POST["order_res_attribute"]))
|
||||
{
|
||||
$sort_attribute=$_POST["order_res_attribute"];
|
||||
}
|
||||
|
||||
if(isSet($_POST["search"]))
|
||||
{
|
||||
$search=trim($_POST["search"]);
|
||||
|
||||
}
|
||||
if(strlen($search)>0)
|
||||
{
|
||||
$search_arr=explode(",",$_POST["search"]);
|
||||
$count=0;
|
||||
foreach ($search_arr as $item_type)
|
||||
{
|
||||
$item_type=str_replace("_","\\_",addslashes(trim($item_type)));
|
||||
$search_type_query.=" and ( RESOURCE_CLASS like '%".$item_type."%' )";
|
||||
|
||||
|
||||
|
||||
++$count;
|
||||
|
||||
//limit search on 3 keywords
|
||||
if($count>2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if no specific resources searched enable only_current
|
||||
else
|
||||
{
|
||||
$only_current="and depleted_timestamp >= (select last_save_time from clock)";
|
||||
$current=1;
|
||||
|
||||
}
|
||||
|
||||
if(isSet($_POST["current"]))
|
||||
{
|
||||
$only_current="and depleted_timestamp >= (select last_save_time from clock)";
|
||||
$current=1;
|
||||
|
||||
}
|
||||
|
||||
if(isSet($_POST["prev"]))
|
||||
{
|
||||
$offset=intval($_POST["offset"]);
|
||||
$offset-=$limit;
|
||||
}
|
||||
else if(isSet($_POST["next"]))
|
||||
{
|
||||
$offset=intval($_POST["offset"]);
|
||||
$offset+=$limit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$query_order="select RESOURCE_ID, RESOURCE_NAME, RESOURCE_CLASS, ATTRIBUTES, FRACTAL_SEEDS , (DEPLETED_TIMESTAMP - (SELECT last_save_time FROM clock)) as DEPLETED_TIMESTAMP, substr(ATTRIBUTES, TO_NUMBER(instr(ATTRIBUTES,'".$sort_attribute." ') ) +".(strlen($sort_attribute)+1).") as first_part from resource_types where ATTRIBUTES like '%".$sort_attribute." %' ".$search_type_query." ".$only_current." order by TO_NUMBER(substr(first_part,0,TO_NUMBER(instr(first_part,':'))-1)) desc";
|
||||
//." OFFSET ".$offset." ROWS FETCH NEXT ".$limit." ROWS ONLY";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$statement=oci_parse($conn,$query_order);
|
||||
|
||||
if(!$statement)
|
||||
{
|
||||
$e = oci_error();
|
||||
echo "ERROR: Invalid statement </br>".$e['message'];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
oci_execute($statement, OCI_DESCRIBE_ONLY);
|
||||
$ncols = oci_num_fields($statement);
|
||||
|
||||
echo "<table cellpadding=\"20px\"><tr><td valign=\"top\">Chose your options: ";
|
||||
include("form.php");
|
||||
echo "</td><td>";
|
||||
echo "<table border=\"1\" cellpadding=\"5px\" style=\"border-collapse: collapse; \">";
|
||||
echo "<tr>";
|
||||
echo "<th style=\"width:150px;background-color: #bde9ba;position: sticky;top: 0;\">Resource</th>";
|
||||
echo "<th style=\"width:835px;background-color: #bde9ba;position: sticky;top: 0;\">Attributes</th>";
|
||||
echo "<th style=\"width:150px;background-color: #bde9ba;position: sticky;top: 0;\">Planets</th>";
|
||||
echo "<th style=\"width:100px;background-color: #bde9ba;position: sticky;top: 0;\">Avail. until<br>(estimated)</th>";
|
||||
|
||||
|
||||
|
||||
echo "</tr>\n";
|
||||
|
||||
oci_execute($statement);
|
||||
//$nrows = oci_fetch_all($statement, $res, null, null, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
|
||||
$nrows = oci_fetch_all($statement, $res, $offset, $limit, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
|
||||
|
||||
|
||||
foreach ( $res as $row)
|
||||
{
|
||||
|
||||
//fix to ignore smelted/mixed whose name will mess up the table
|
||||
if(strpos($row['RESOURCE_NAME'],"@resource")===0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
echo "\n <tr>";
|
||||
|
||||
//echo "\n\t<td>".$row['RESOURCE_ID']."</td>";
|
||||
|
||||
|
||||
$resource_class=$resource_classes[strval($row['RESOURCE_CLASS'])];
|
||||
|
||||
echo "\n\t<td style=\"text-wrap:normal;word-wrap:break-word;\"><b>".$row['RESOURCE_NAME']."</b></br>(".$resource_class["names"][0].")</td>";
|
||||
|
||||
|
||||
//interpret encoded attribute data
|
||||
echo "\n\t";
|
||||
//echo $row['ATTRIBUTES'];
|
||||
|
||||
|
||||
$resource_stat_display=array
|
||||
(
|
||||
"res_decay_resist"=>array("DR"),
|
||||
"res_flavor"=>array("FL"),
|
||||
"res_potential_energy"=>array("PE"),
|
||||
"res_quality"=>array("OQ"),
|
||||
"res_malleability"=>array("MA"),
|
||||
"res_shock_resistance"=>array("SR"),
|
||||
"res_toughness"=>array("UT"),
|
||||
"res_cold_resist"=>array("CR"),
|
||||
"res_conductivity"=>array("CD"),
|
||||
"res_heat_resist"=>array("HR"),
|
||||
"entangle_resistance"=>array("ER")
|
||||
);
|
||||
|
||||
echo "<td style=\"width:835px\"><table cellspacing=0 cellpadding=0 style=\"table-layout: fixed; width: 825px\">";
|
||||
|
||||
$attr_header="<tr>";
|
||||
$attr_values="<tr>";
|
||||
$attr_percent="<tr>";
|
||||
|
||||
if($row['ATTRIBUTES']!=="")
|
||||
{
|
||||
$attr_set=explode(":",$row['ATTRIBUTES']);
|
||||
foreach($attr_set as $tmp_data)
|
||||
{
|
||||
if($tmp_data!=="")
|
||||
{
|
||||
|
||||
$tmp_arr=explode(" ",$tmp_data);
|
||||
if($tmp_arr[0]!=="")
|
||||
{
|
||||
$attr_internal=$tmp_arr[0];
|
||||
$attr_name=$attributes[$attr_internal];
|
||||
$attr_val=intval($tmp_arr[1]);
|
||||
$attr_max=intval($resource_class["Attributes"][strval($attr_internal)."_MAX"]);
|
||||
$attr_min=intval($resource_class["Attributes"][strval($attr_internal)."_MIN"]);
|
||||
$range=$attr_max-$attr_min;
|
||||
if($range<=0) $range=$attr_max;
|
||||
$percent=intval( floatval(($attr_val-$attr_min)/($range))*1000 )/10;
|
||||
|
||||
$resource_stat_display[$attr_internal][1]=$attr_val;
|
||||
$resource_stat_display[$attr_internal][2]=$percent;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($resource_stat_display as $attr_data)
|
||||
{
|
||||
$attr_header.="<td width=\"75px\" align=\"right\" >".$attr_data[0]."</td>";
|
||||
$attr_values.="<td align=\"right\" width=\"75px\" >";
|
||||
$attr_values.=(isset($attr_data[1]))?str_replace('~', ' ',str_pad($attr_data[1],4,'~',STR_PAD_LEFT)):" ";
|
||||
$attr_values.="</td>";
|
||||
if(isset($attr_data[2]))
|
||||
{
|
||||
$attr_percent.="<td align=\"right\" width=\"75px\" style=\"color:";
|
||||
$attr_percent.=(($attr_data[2]<=49)?"red":(($attr_data[2]<=85)?"blue":"green"));
|
||||
$attr_percent.=";\">(".$attr_data[2]."%)</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attr_percent.="<td></td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$attr_header.="</tr>";
|
||||
$attr_values.="</tr>";
|
||||
$attr_percent.="</tr>";
|
||||
|
||||
|
||||
|
||||
//end attr parsing
|
||||
echo $attr_header.$attr_values.$attr_percent."</table></td>";
|
||||
|
||||
|
||||
|
||||
$planet_str="";
|
||||
|
||||
//get planets from fractal data
|
||||
if (strlen($row['FRACTAL_SEEDS'])==0)
|
||||
{
|
||||
$planet_str="NONE";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$spawn=explode(':',$row['FRACTAL_SEEDS']);
|
||||
foreach ($spawn as $planet_data)
|
||||
{
|
||||
if( isset($planet_data) && $planet_data!=="")
|
||||
{
|
||||
$pdata=explode(' ',$planet_data);
|
||||
|
||||
if(count($pdata)!=2)
|
||||
{
|
||||
echo "Unable to parse planet data for input : \"".$planet_data."\", row was: \"".$row['FRACTAL_SEEDS']."\"</br>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$planet_id=$pdata[0];
|
||||
|
||||
//ignore multiple Kashyyyk entries, this should be ok, right ?
|
||||
if( intval($planet_id)>10000031 && intval($planet_id)<=10000037)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(strlen($planet_str)>0)
|
||||
{
|
||||
$planet_str.=", ";
|
||||
}
|
||||
|
||||
if(isset($planet_id) && $planet_id!=="")
|
||||
{
|
||||
if(!isset($planets[$planet_id]))
|
||||
{
|
||||
echo "Unable to find planet name for id : \"".$planet_id."\"</br>";
|
||||
echo "<pre>";
|
||||
print_r($pdata);
|
||||
echo "</pre>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$planet_str.=$planets["".$planet_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "\n\t<td width=\"150px\">".$planet_str."</td>";
|
||||
|
||||
|
||||
|
||||
//interpret depleted - aproximate based on the server clock and depleted timestamp
|
||||
//assuming server clock last_save_time is set very often and that the server won't shutdown
|
||||
$depleted=time()+$row['DEPLETED_TIMESTAMP'];
|
||||
|
||||
$depleted_date=date('Y-M-d, H:i:s',$depleted);
|
||||
echo "\n\t<td width=\"150px\">".$depleted_date."</td>";
|
||||
|
||||
//echo "\n\t<td>".$row['DEPLETED_TIMESTAMP']."</td>";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "\n </tr>";
|
||||
}
|
||||
|
||||
|
||||
echo "</table></td></tr><table>";
|
||||
echo "</br></br><center>Made by: <b>bintodec/voronius/alexuspanait@yahoo.com</b> (one and only)</center></br>";
|
||||
}
|
||||
|
||||
oci_free_statement($statement);
|
||||
oci_close($conn);
|
||||
|
||||
?>
|
||||
18765
resource_class_tree.php
Normal file
18765
resource_class_tree.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user