-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathparsedna.php
More file actions
102 lines (89 loc) · 2.86 KB
/
parsedna.php
File metadata and controls
102 lines (89 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
header('Access-Control-Allow-Origin: *');
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
require_once('db.inc.php');
$dna=$_GET['dna'];
$array=explode(":",$dna);
$high=array();
$med=array();
$low=array();
$subsystem=array();
$ammo=array();
$rig=array();
$drones=array();
$charge=array();
$innertypelist=array();
foreach ( $array as $value)
{
$types=explode(";",$value);
if ($types[0])
{
$innertypelist[]=filter_var($types[0],FILTER_SANITIZE_NUMBER_INT);
}
}
#$sql='select invTypes.typeid,typename,COALESCE(effectid,1) effectid from invTypes left join dgmTypeEffects on (dgmTypeEffects.typeid=invTypes.typeid and effectid in (11,12,13,2663,3772)) where invTypes.typeid=?';
$sql='select invTypes.typeid,typename,COALESCE(effectid,categoryID) effectid from invTypes left join dgmTypeEffects on (dgmTypeEffects.typeid=invTypes.typeid and effectid in (11,12,13,2663,3772)), invGroups where invTypes.typeid=? and invTypes.groupid=invGroups.groupid';
$stmt = $dbh->prepare($sql);
$typenames=array();
$typeslot=array();
foreach ($innertypelist as $value)
{
$stmt->execute(array($value));
if ($row = $stmt->fetchObject())
{
$typenames[$row->typeid]=htmlentities($row->typename, ENT_QUOTES);
$typeslot[$row->typeid]=$row->effectid;
}
}
$shiptype='';
$shipid='';
foreach ( $array as $value)
{
$types=explode(";",$value);
$types[0]=filter_var($types[0],FILTER_SANITIZE_NUMBER_INT);
$types[1]=filter_var($types[1],FILTER_SANITIZE_NUMBER_INT);
if ($types[0])
{
switch($typeslot[$types[0]])
{
case 6:
$shipid=$types[0];
$shiptype= $typenames[$shipid];
break;
case 11:
$low[]=array($typenames[$types[0]].":".$types[0]=>(int)$types[1]);
break;
case 12:
$high[]=array($typenames[$types[0]].":".$types[0]=>(int)$types[1]);
break;
case 13:
$med[]=array($typenames[$types[0]].":".$types[0]=>(int)$types[1]);
break;
case 2663:
$rig[]=array($typenames[$types[0]].":".$types[0]=>(int)$types[1]);
break;
case 3772:
$subsystem[]=array($typenames[$types[0]].":".$types[0]=>1);
break;
case 18:
$drones[]=array($typenames[$types[0]].":".$types[0]=>(int)$types[1]);
break;
case 8:
$charge[]=array($typenames[$types[0]].":".$types[0]=>(int)$types[1]);
break;
}
}
}
$json=array();
$json["ship"]=array("shipname"=>$shiptype,"shipid"=>$shipid,"dna"=>$dna);
$json["high"]=$high;
$json["medium"]=$med;
$json["low"]=$low;
$json["rig"]=$rig;
$json["subsystem"]=$subsystem;
$json["drones"]=$drones;
$json["charge"]=$charge;
echo json_encode($json);
?>