1 | <?php |
---|
2 | |
---|
3 | defined('SYSPATH') or die('No direct script access.'); |
---|
4 | |
---|
5 | /** |
---|
6 | * Note to self: |
---|
7 | * The database tables that use the EVE-Online typeID field have |
---|
8 | * an id field that is used within the killboard. This is done |
---|
9 | * to maintain relationships between tables when an update is |
---|
10 | * deployed that changes the typeID of a row. |
---|
11 | * This logic has also been applied to other EVE datadump related |
---|
12 | * tables such as solar_systems, regions etc. |
---|
13 | * |
---|
14 | * Why should typeID be kept? I have no idea really, it could be needed |
---|
15 | * later on though. |
---|
16 | */ |
---|
17 | |
---|
18 | class Killboard_Kill_Model extends Model |
---|
19 | { |
---|
20 | // Raw mail |
---|
21 | public $rawMail = ""; |
---|
22 | |
---|
23 | // Kill time as a unix timestamp |
---|
24 | public $killTime = 0; |
---|
25 | |
---|
26 | // Victim as a Killboard_pilot_Model |
---|
27 | public $victim = null; |
---|
28 | |
---|
29 | public $corp = null; |
---|
30 | |
---|
31 | public $alliance = null; |
---|
32 | |
---|
33 | public $faction = null; |
---|
34 | |
---|
35 | public $destroyed = null; |
---|
36 | |
---|
37 | public $solarSystem = null; |
---|
38 | |
---|
39 | public $constellation = null; |
---|
40 | |
---|
41 | public $region = null; |
---|
42 | |
---|
43 | public $security = 0; |
---|
44 | |
---|
45 | public $damageTaken = 0; |
---|
46 | |
---|
47 | public $type = ""; |
---|
48 | |
---|
49 | public function ParseMail($mail, $autosave=false) |
---|
50 | { |
---|
51 | $this->rawMail = $mail; |
---|
52 | |
---|
53 | // Parse the killmail |
---|
54 | // Yes I could have used regex here but I really don't think it's required |
---|
55 | // This parser works on stepping through stages of the killmail looking for |
---|
56 | // all the components. |
---|
57 | |
---|
58 | $victimName = ""; |
---|
59 | $corpName = ""; |
---|
60 | $allianceName = ""; |
---|
61 | $factionName = ""; |
---|
62 | $destroyedName = ""; |
---|
63 | $solarSystemName = ""; |
---|
64 | $security = null; |
---|
65 | $moon = ""; |
---|
66 | $damageTaken = null; |
---|
67 | $killtime = 0; |
---|
68 | $involvedParties = array(); |
---|
69 | $destroyedItems = array(); |
---|
70 | $droppedItems = array(); |
---|
71 | $type = ""; |
---|
72 | |
---|
73 | $lines = explode("\n", $this->rawMail); |
---|
74 | list($year,$month,$day,$hour,$min,$sec) = |
---|
75 | sscanf(trim($lines[0]), "%d.%d.%d %d:%d:%d"); |
---|
76 | $killtime = mktime($hour,$min,$sec,$month,$day,$year); |
---|
77 | $state = "victim"; |
---|
78 | $items = array(); |
---|
79 | foreach($lines as $line) |
---|
80 | { |
---|
81 | if (trim($line)=="") continue; |
---|
82 | |
---|
83 | $pos = strpos($line, ":"); |
---|
84 | $id = substr($line,0,$pos); |
---|
85 | if ($pos+1 == strlen(trim($line))) |
---|
86 | $value = ""; |
---|
87 | else |
---|
88 | $value = substr(trim($line),$pos+2); |
---|
89 | |
---|
90 | switch($state) |
---|
91 | { |
---|
92 | case "victim": |
---|
93 | switch (strtolower($id)) |
---|
94 | { |
---|
95 | case "victim": |
---|
96 | $victimName= $value; |
---|
97 | $type = "ship"; |
---|
98 | break; |
---|
99 | case "corp": |
---|
100 | $corpName = $value; |
---|
101 | break; |
---|
102 | case "alliance": |
---|
103 | $alianceName = $value; |
---|
104 | break; |
---|
105 | case "faction": |
---|
106 | $factionName = $value; |
---|
107 | break; |
---|
108 | case "destroyed": |
---|
109 | $destroyedName = $value; |
---|
110 | break; |
---|
111 | case "system": |
---|
112 | $solarSystemName = $value; |
---|
113 | break; |
---|
114 | case "security": |
---|
115 | $security = (float)$value; |
---|
116 | break; |
---|
117 | case "damage taken": |
---|
118 | $damageTaken = (int)$value; |
---|
119 | break; |
---|
120 | case "moon": |
---|
121 | $moon = $value; |
---|
122 | $type = "tower"; |
---|
123 | break; |
---|
124 | case "involved parties": |
---|
125 | $state = "involved"; |
---|
126 | break; |
---|
127 | } |
---|
128 | break; |
---|
129 | case "involved": |
---|
130 | switch (strtolower($id)) |
---|
131 | { |
---|
132 | case "name": |
---|
133 | $involvedParties[] = array('charID'=>0,'corpID'=>0,'allianceID'=>0, |
---|
134 | 'factionID'=>0); |
---|
135 | if (strpos($value, "(laid the final blow)") !== false) |
---|
136 | { |
---|
137 | $value = substr($value,0,strlen($value)-22); |
---|
138 | $involvedParties[sizeof($involvedParties)-1] |
---|
139 | ['FinalBlow'] = true; |
---|
140 | } else |
---|
141 | $involvedParties[sizeof($involvedParties)-1] |
---|
142 | ['FinalBlow'] = false; |
---|
143 | $involvedParties[sizeof($involvedParties)-1] |
---|
144 | ['Name'] = $value; |
---|
145 | break; |
---|
146 | case "destroyed items": |
---|
147 | $state = "destroyed"; |
---|
148 | break; |
---|
149 | case "dropped items": |
---|
150 | $state = "dropped"; |
---|
151 | break; |
---|
152 | default: |
---|
153 | if (strtolower($id)=='ship') |
---|
154 | { |
---|
155 | $items[] = $value; |
---|
156 | $involvedParties[sizeof($involvedParties)-1] |
---|
157 | ['shipID'] = 0; |
---|
158 | $involvedParties[sizeof($involvedParties)-1] |
---|
159 | ['shipGraphicID'] = 0; |
---|
160 | } else if (strtolower($id)=='weapon') { |
---|
161 | $items[] = $value; |
---|
162 | $involvedParties[sizeof($involvedParties)-1] |
---|
163 | ['weaponID'] = 0; |
---|
164 | $involvedParties[sizeof($involvedParties)-1] |
---|
165 | ['weaponGraphicID'] = 0; |
---|
166 | } |
---|
167 | $involvedParties[sizeof($involvedParties)-1] |
---|
168 | [$id] = $value; |
---|
169 | break; |
---|
170 | } |
---|
171 | break; |
---|
172 | case "destroyed": |
---|
173 | // Take off (Cargo) and (Drone Bay) |
---|
174 | if (strtolower($id)=="dropped items") |
---|
175 | { |
---|
176 | $state = "dropped"; |
---|
177 | } else { |
---|
178 | $value = trim($line); |
---|
179 | $itemName = ""; |
---|
180 | $qty = 0; |
---|
181 | $cargo = false; |
---|
182 | $dronebay = false; |
---|
183 | |
---|
184 | if (($pos = strpos($value, "(Cargo)")) !== false) |
---|
185 | { |
---|
186 | $cargo = true; |
---|
187 | $value = substr($value, 0, strlen($value)-8); |
---|
188 | } |
---|
189 | if (($pos = strpos($value, "(Drone Bay)")) !== false) |
---|
190 | { |
---|
191 | $dronebay = true; |
---|
192 | $value = substr($value, 0, strlen($value)-12); |
---|
193 | } |
---|
194 | |
---|
195 | if (($pos = strpos($value, ", Qty: ")) !== false) |
---|
196 | { |
---|
197 | $itemName = substr($value, 0, $pos); |
---|
198 | $qty = (int)substr($value, $pos+7); |
---|
199 | } else { |
---|
200 | $itemName = $value; |
---|
201 | $qty = 1; |
---|
202 | } |
---|
203 | $items[] = $itemName; |
---|
204 | $destroyedItems[] = array('typeName'=>$itemName, 'qty'=>$qty, |
---|
205 | 'cargo'=>$cargo, 'dronebay'=>$dronebay, 'id'=>0, 'graphicID'=>0); |
---|
206 | } |
---|
207 | break; |
---|
208 | case "dropped": |
---|
209 | if (strtolower($id)=="destroyed items") |
---|
210 | { |
---|
211 | $state = "destroyed"; |
---|
212 | } else { |
---|
213 | $value = trim($line); |
---|
214 | $itemName = ""; |
---|
215 | $qty = 0; |
---|
216 | $cargo = false; |
---|
217 | $dronebay = false; |
---|
218 | |
---|
219 | if (($pos = strpos($value, "(Cargo)")) !== false) |
---|
220 | { |
---|
221 | $cargo = true; |
---|
222 | $value = substr($value, 0, strlen($value)-8); |
---|
223 | } |
---|
224 | if (($pos = strpos($value, "(Drone Bay)")) !== false) |
---|
225 | { |
---|
226 | $dronebay = true; |
---|
227 | $value = substr($value, 0, strlen($value)-12); |
---|
228 | } |
---|
229 | |
---|
230 | if (($pos = strpos($value, ", Qty: ")) !== false) |
---|
231 | { |
---|
232 | $itemName = substr($value, 0, $pos); |
---|
233 | $qty = (int)substr($value, $pos+7); |
---|
234 | } else { |
---|
235 | $itemName = $value; |
---|
236 | $qty = 1; |
---|
237 | } |
---|
238 | $items[] = $itemName; |
---|
239 | $droppedItems[] = array('typeName'=>$itemName, 'qty'=>$qty, |
---|
240 | 'cargo'=>$cargo, 'dronebay'=>$dronebay, 'id'=>0, 'graphicID'=>0); |
---|
241 | } |
---|
242 | break; |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | // Sanity checks |
---|
247 | if ($state == "victim") |
---|
248 | throw new Exception("Malformed killmail"); |
---|
249 | if ($type == "") |
---|
250 | throw new Exception("No victim or moon found"); |
---|
251 | if (sizeof($involvedParties) < 1) |
---|
252 | throw new Exception("No involved parties found"); |
---|
253 | if ($victimName == "") |
---|
254 | throw new Exception("No victim found"); |
---|
255 | if ($destroyedName == "") |
---|
256 | throw new Exception("No destroyed found"); |
---|
257 | if ($corpName == "") |
---|
258 | throw new Exception("No corporation found"); |
---|
259 | if ($solarSystemName == "") |
---|
260 | throw new Exception("No solar system found"); |
---|
261 | if ($killtime == 0) |
---|
262 | throw new Exception("Couldn't read kill time"); |
---|
263 | if ($security === null) |
---|
264 | throw new Exception("No security found"); |
---|
265 | if ($damageTaken === null) |
---|
266 | throw new Exception("No damage taken found"); |
---|
267 | |
---|
268 | // Create the object |
---|
269 | $this->victim = new Killboard_Pilot_Model($victimName); |
---|
270 | $this->corp = new Killboard_Corp_Model($corpName); |
---|
271 | if ($allianceName != "NONE" && $allianceName != "") |
---|
272 | $this->alliance = new Killboard_Alliance_Model($allianceName); |
---|
273 | if ($factionName != "NONE" && $factionName != "") |
---|
274 | $this->faction = new Killboard_Faction_Model($factionName); |
---|
275 | if ($type == "ship") |
---|
276 | $this->destroyed = new Killboard_Ship_Model($destroyedName); |
---|
277 | else if ($type == "tower") |
---|
278 | $this->destroyed = new Killboard_Tower_Model($destroyedName); |
---|
279 | $this->solarSystem = new SolarSystem_Model($solarSystemName); |
---|
280 | $this->constellation = $this->solarSystem->constellation; |
---|
281 | $this->region = $this->solarSystem->region; |
---|
282 | $this->security = $security; |
---|
283 | $this->damageTaken = $damageTaken; |
---|
284 | $this->killtime = $killtime; |
---|
285 | $this->type = $type; |
---|
286 | |
---|
287 | if ($autosave) return $this->Save(); |
---|
288 | return $this; |
---|
289 | |
---|
290 | // Assign some of the EDK properties |
---|
291 | /* |
---|
292 | $db = Database::instance(); |
---|
293 | |
---|
294 | $query = $db->from('solar_systems')->join( |
---|
295 | 'constellations', 'solar_systems.constellationID=constellations.constellationID' |
---|
296 | )->join( |
---|
297 | 'regions', 'solar_systems.regionID=regions.regionID' |
---|
298 | )->where('solarSystemName="'.$this->system.'"')->get(); |
---|
299 | |
---|
300 | if ($query->count() < 1) |
---|
301 | throw new Exception("Solar system not found"); |
---|
302 | $row = $query->current(); |
---|
303 | |
---|
304 | $this->region = $row->regionName; |
---|
305 | $this->regionID = $row->regionID; |
---|
306 | $this->constellation = $row->constellationName; |
---|
307 | $this->constellationID = $row->constellationID; |
---|
308 | $this->solarSystemID = $row->solarSystemID; |
---|
309 | |
---|
310 | $query = $db->from('ships')->where('ship_name="'.$this->destroyed.'"')->get(); |
---|
311 | if ($query->count() < 1) |
---|
312 | throw new Exception("Item not found"); |
---|
313 | $row = $query->current(); |
---|
314 | |
---|
315 | $this->typeID = $row->id; |
---|
316 | $this->graphicID = $row->graphicID; |
---|
317 | |
---|
318 | $query = $db->from('items')->in('typeName',array_unique($items))->get(); |
---|
319 | foreach($query as $row) |
---|
320 | { |
---|
321 | for($i=0;$i<sizeof($this->destroyedItems);$i++) |
---|
322 | { |
---|
323 | if ($this->destroyedItems[$i]['typeName']==$row->typeName) |
---|
324 | { |
---|
325 | $this->destroyedItems[$i]['id'] = $row->id; |
---|
326 | $this->destroyedItems[$i]['graphicID'] = $row->graphicID; |
---|
327 | } |
---|
328 | } |
---|
329 | for($i=0;$i<sizeof($this->droppedItems);$i++) |
---|
330 | { |
---|
331 | if ($this->droppedItems[$i]['typeName']==$row->typeName) |
---|
332 | { |
---|
333 | $this->droppedItems[$i]['id'] = $row->id; |
---|
334 | $this->droppedItems[$i]['graphicID'] = $row->graphicID; |
---|
335 | } |
---|
336 | } |
---|
337 | for($i=0;$i<sizeof($this->involvedParties);$i++) |
---|
338 | { |
---|
339 | if ($this->involvedParties[$i]['Ship']==$row->typeName) |
---|
340 | { |
---|
341 | $this->involvedParties[$i]['shipID'] = $row->id; |
---|
342 | $this->involvedParties[$i] |
---|
343 | ['shipGraphicID'] = $row->graphicID; |
---|
344 | } |
---|
345 | if ($this->involvedParties[$i]['Weapon']==$row->typeName) |
---|
346 | { |
---|
347 | $this->involvedParties[$i]['weaponID'] = $row->id; |
---|
348 | $this->involvedParties[$i] |
---|
349 | ['weaponGraphicID'] = $row->graphicID; |
---|
350 | } |
---|
351 | } |
---|
352 | }*/ |
---|
353 | } |
---|
354 | |
---|
355 | public function Save() |
---|
356 | { |
---|
357 | } |
---|
358 | } |
---|
359 | |
---|
360 | class Killboard_kill_Model_Test extends Model |
---|
361 | { |
---|
362 | // Raw mail |
---|
363 | public $rawMail = ""; |
---|
364 | |
---|
365 | // Raw killmail fields |
---|
366 | public $killTime = 0; |
---|
367 | public $victim = ""; |
---|
368 | public $corp = ""; |
---|
369 | public $alliance = ""; |
---|
370 | public $faction = ""; |
---|
371 | public $destroyed = ""; |
---|
372 | public $system = ""; |
---|
373 | public $security = ""; |
---|
374 | public $damageTaken = 0; |
---|
375 | public $moon = ""; |
---|
376 | public $involvedParties = array(); |
---|
377 | public $destroyedItems = array(); |
---|
378 | public $droppedItems = array(); |
---|
379 | |
---|
380 | // EDK properties |
---|
381 | public $type = ""; |
---|
382 | public $region = ""; |
---|
383 | public $constellation = ""; |
---|
384 | public $regionID = 0; |
---|
385 | public $constellationID = 0; |
---|
386 | public $solarSystemID = 0; |
---|
387 | public $allianceID = 0; |
---|
388 | public $corpID = 0; |
---|
389 | public $factionID = 0; |
---|
390 | public $typeID = 0; |
---|
391 | public $graphicID = 0; |
---|
392 | |
---|
393 | public function Save() |
---|
394 | { |
---|
395 | // If alliance isn't "NONE" look for it in the database |
---|
396 | // If nothing found, create a record and set $this->allianceID |
---|
397 | // If something found, set $this->allianceID |
---|
398 | |
---|
399 | // Look for corp in the database |
---|
400 | // If nothing found, create a record and set $this->corpID |
---|
401 | // If something found, set $this->corpID |
---|
402 | // If allianceID doesn't match, update the corp record |
---|
403 | |
---|
404 | // For each involved party: |
---|
405 | // Look for character record |
---|
406 | // If nothing found, create a character record and set the charID |
---|
407 | // If somethig found, set the charID |
---|
408 | // Update the character record |
---|
409 | } |
---|
410 | |
---|
411 | public function ParseMail($mail) |
---|
412 | { |
---|
413 | $this->rawMail = $mail; |
---|
414 | |
---|
415 | // Parse the killmail |
---|
416 | // Yes I could have used regex here but I really don't think it's required |
---|
417 | // This parser works on stepping through stages of the killmail looking for |
---|
418 | // all the components. |
---|
419 | $lines = explode("\n", $this->rawMail); |
---|
420 | list($year,$month,$day,$hour,$min,$sec) = |
---|
421 | sscanf(trim($lines[0]), "%d.%d.%d %d:%d:%d"); |
---|
422 | $this->killTime = mktime($hour,$min,$sec,$month,$day,$year); |
---|
423 | $state = "victim"; |
---|
424 | $items = array(); |
---|
425 | foreach($lines as $line) |
---|
426 | { |
---|
427 | if (trim($line)=="") continue; |
---|
428 | $pos = strpos($line, ":"); |
---|
429 | $id = substr($line,0,$pos); |
---|
430 | if ($pos+1 == strlen(trim($line))) |
---|
431 | $value = ""; |
---|
432 | else |
---|
433 | $value = substr(trim($line),$pos+2); |
---|
434 | switch($state) |
---|
435 | { |
---|
436 | case "victim": |
---|
437 | switch (strtolower($id)) |
---|
438 | { |
---|
439 | case "victim": |
---|
440 | $this->victim = $value; |
---|
441 | $this->type = "ship"; |
---|
442 | break; |
---|
443 | case "corp": |
---|
444 | $this->corp = $value; |
---|
445 | break; |
---|
446 | case "alliance": |
---|
447 | $this->alliance = $value; |
---|
448 | break; |
---|
449 | case "faction": |
---|
450 | $this->faction = $value; |
---|
451 | break; |
---|
452 | case "destroyed": |
---|
453 | $this->destroyed = $value; |
---|
454 | break; |
---|
455 | case "system": |
---|
456 | $this->system = $value; |
---|
457 | break; |
---|
458 | case "security": |
---|
459 | $this->security = (float)$value; |
---|
460 | break; |
---|
461 | case "damage taken": |
---|
462 | $this->damageTaken = (int)$value; |
---|
463 | break; |
---|
464 | case "moon": |
---|
465 | $this->moon = $value; |
---|
466 | $this->type = "tower"; |
---|
467 | break; |
---|
468 | case "involved parties": |
---|
469 | $state = "involved"; |
---|
470 | break; |
---|
471 | } |
---|
472 | break; |
---|
473 | case "involved": |
---|
474 | switch (strtolower($id)) |
---|
475 | { |
---|
476 | case "name": |
---|
477 | $this->involvedParties[] = array('charID'=>0,'corpID'=>0,'allianceID'=>0, |
---|
478 | 'factionID'=>0); |
---|
479 | if (strpos($value, "(laid the final blow)") !== false) |
---|
480 | { |
---|
481 | $value = substr($value,0,strlen($value)-22); |
---|
482 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
483 | ['FinalBlow'] = true; |
---|
484 | } else |
---|
485 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
486 | ['FinalBlow'] = false; |
---|
487 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
488 | ['Name'] = $value; |
---|
489 | break; |
---|
490 | case "destroyed items": |
---|
491 | $state = "destroyed"; |
---|
492 | break; |
---|
493 | case "dropped items": |
---|
494 | $state = "dropped"; |
---|
495 | break; |
---|
496 | default: |
---|
497 | if (strtolower($id)=='ship') |
---|
498 | { |
---|
499 | $items[] = $value; |
---|
500 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
501 | ['shipID'] = 0; |
---|
502 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
503 | ['shipGraphicID'] = 0; |
---|
504 | } else if (strtolower($id)=='weapon') { |
---|
505 | $items[] = $value; |
---|
506 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
507 | ['weaponID'] = 0; |
---|
508 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
509 | ['weaponGraphicID'] = 0; |
---|
510 | } |
---|
511 | $this->involvedParties[sizeof($this->involvedParties)-1] |
---|
512 | [$id] = $value; |
---|
513 | break; |
---|
514 | } |
---|
515 | break; |
---|
516 | case "destroyed": |
---|
517 | // Take off (Cargo) and (Drone Bay) |
---|
518 | if (strtolower($id)=="dropped items") |
---|
519 | { |
---|
520 | $state = "dropped"; |
---|
521 | } else { |
---|
522 | $value = trim($line); |
---|
523 | $itemName = ""; |
---|
524 | $qty = 0; |
---|
525 | $cargo = false; |
---|
526 | $dronebay = false; |
---|
527 | |
---|
528 | if (($pos = strpos($value, "(Cargo)")) !== false) |
---|
529 | { |
---|
530 | $cargo = true; |
---|
531 | $value = substr($value, 0, strlen($value)-8); |
---|
532 | } |
---|
533 | if (($pos = strpos($value, "(Drone Bay)")) !== false) |
---|
534 | { |
---|
535 | $dronebay = true; |
---|
536 | $value = substr($value, 0, strlen($value)-12); |
---|
537 | } |
---|
538 | |
---|
539 | if (($pos = strpos($value, ", Qty: ")) !== false) |
---|
540 | { |
---|
541 | $itemName = substr($value, 0, $pos); |
---|
542 | $qty = (int)substr($value, $pos+7); |
---|
543 | } else { |
---|
544 | $itemName = $value; |
---|
545 | $qty = 1; |
---|
546 | } |
---|
547 | $items[] = $itemName; |
---|
548 | $this->destroyedItems[] = array('typeName'=>$itemName, 'qty'=>$qty, |
---|
549 | 'cargo'=>$cargo, 'dronebay'=>$dronebay, 'id'=>0, 'graphicID'=>0); |
---|
550 | } |
---|
551 | break; |
---|
552 | case "dropped": |
---|
553 | if (strtolower($id)=="destroyed items") |
---|
554 | { |
---|
555 | $state = "destroyed"; |
---|
556 | } else { |
---|
557 | $value = trim($line); |
---|
558 | $itemName = ""; |
---|
559 | $qty = 0; |
---|
560 | $cargo = false; |
---|
561 | $dronebay = false; |
---|
562 | |
---|
563 | if (($pos = strpos($value, "(Cargo)")) !== false) |
---|
564 | { |
---|
565 | $cargo = true; |
---|
566 | $value = substr($value, 0, strlen($value)-8); |
---|
567 | } |
---|
568 | if (($pos = strpos($value, "(Drone Bay)")) !== false) |
---|
569 | { |
---|
570 | $dronebay = true; |
---|
571 | $value = substr($value, 0, strlen($value)-12); |
---|
572 | } |
---|
573 | |
---|
574 | if (($pos = strpos($value, ", Qty: ")) !== false) |
---|
575 | { |
---|
576 | $itemName = substr($value, 0, $pos); |
---|
577 | $qty = (int)substr($value, $pos+7); |
---|
578 | } else { |
---|
579 | $itemName = $value; |
---|
580 | $qty = 1; |
---|
581 | } |
---|
582 | $items[] = $itemName; |
---|
583 | $this->droppedItems[] = array('typeName'=>$itemName, 'qty'=>$qty, |
---|
584 | 'cargo'=>$cargo, 'dronebay'=>$dronebay, 'id'=>0, 'graphicID'=>0); |
---|
585 | } |
---|
586 | break; |
---|
587 | } |
---|
588 | } |
---|
589 | |
---|
590 | // Sanity checks |
---|
591 | if ($state == "victim") |
---|
592 | throw new Exception("Malformed killmail"); |
---|
593 | if ($this->type == "") |
---|
594 | throw new Exception("No victim or moon found"); |
---|
595 | if (sizeof($this->involvedParties) < 1) |
---|
596 | throw new Exception("No \"involved parties\" found"); |
---|
597 | |
---|
598 | // Assign some of the EDK properties |
---|
599 | $db = Database::instance(); |
---|
600 | |
---|
601 | $query = $db->from('solar_systems')->join( |
---|
602 | 'constellations', 'solar_systems.constellationID=constellations.constellationID' |
---|
603 | )->join( |
---|
604 | 'regions', 'solar_systems.regionID=regions.regionID' |
---|
605 | )->where('solarSystemName="'.$this->system.'"')->get(); |
---|
606 | |
---|
607 | if ($query->count() < 1) |
---|
608 | throw new Exception("Solar system not found"); |
---|
609 | $row = $query->current(); |
---|
610 | |
---|
611 | $this->region = $row->regionName; |
---|
612 | $this->regionID = $row->regionID; |
---|
613 | $this->constellation = $row->constellationName; |
---|
614 | $this->constellationID = $row->constellationID; |
---|
615 | $this->solarSystemID = $row->solarSystemID; |
---|
616 | |
---|
617 | $query = $db->from('ships')->where('ship_name="'.$this->destroyed.'"')->get(); |
---|
618 | if ($query->count() < 1) |
---|
619 | throw new Exception("Item not found"); |
---|
620 | $row = $query->current(); |
---|
621 | |
---|
622 | $this->typeID = $row->id; |
---|
623 | $this->graphicID = $row->graphicID; |
---|
624 | |
---|
625 | $query = $db->from('items')->in('typeName',array_unique($items))->get(); |
---|
626 | foreach($query as $row) |
---|
627 | { |
---|
628 | for($i=0;$i<sizeof($this->destroyedItems);$i++) |
---|
629 | { |
---|
630 | if ($this->destroyedItems[$i]['typeName']==$row->typeName) |
---|
631 | { |
---|
632 | $this->destroyedItems[$i]['id'] = $row->id; |
---|
633 | $this->destroyedItems[$i]['graphicID'] = $row->graphicID; |
---|
634 | } |
---|
635 | } |
---|
636 | for($i=0;$i<sizeof($this->droppedItems);$i++) |
---|
637 | { |
---|
638 | if ($this->droppedItems[$i]['typeName']==$row->typeName) |
---|
639 | { |
---|
640 | $this->droppedItems[$i]['id'] = $row->id; |
---|
641 | $this->droppedItems[$i]['graphicID'] = $row->graphicID; |
---|
642 | } |
---|
643 | } |
---|
644 | for($i=0;$i<sizeof($this->involvedParties);$i++) |
---|
645 | { |
---|
646 | if ($this->involvedParties[$i]['Ship']==$row->typeName) |
---|
647 | { |
---|
648 | $this->involvedParties[$i]['shipID'] = $row->id; |
---|
649 | $this->involvedParties[$i] |
---|
650 | ['shipGraphicID'] = $row->graphicID; |
---|
651 | } |
---|
652 | if ($this->involvedParties[$i]['Weapon']==$row->typeName) |
---|
653 | { |
---|
654 | $this->involvedParties[$i]['weaponID'] = $row->id; |
---|
655 | $this->involvedParties[$i] |
---|
656 | ['weaponGraphicID'] = $row->graphicID; |
---|
657 | } |
---|
658 | } |
---|
659 | } |
---|
660 | |
---|
661 | /* |
---|
662 | 2008.09.06 22:24:00 |
---|
663 | |
---|
664 | Victim: SirKnyghtMare |
---|
665 | Corp: Orion Industry and Business |
---|
666 | Alliance: Quantum Star Alliance |
---|
667 | Faction: NONE |
---|
668 | Destroyed: Helios |
---|
669 | System: YI-GV6 |
---|
670 | Security: 0.0 |
---|
671 | Damage Taken: 1428 |
---|
672 | |
---|
673 | Involved parties: |
---|
674 | |
---|
675 | Name: Zyer |
---|
676 | Security: -2.1 |
---|
677 | Corp: The Priory |
---|
678 | Alliance: NONE |
---|
679 | Faction: NONE |
---|
680 | Ship: Zealot |
---|
681 | Weapon: Heavy Pulse Laser II |
---|
682 | Damage Done: 660 |
---|
683 | |
---|
684 | Name: Dray (laid the final blow) |
---|
685 | Security: -1.6 |
---|
686 | Corp: The Priory |
---|
687 | Alliance: NONE |
---|
688 | Faction: NONE |
---|
689 | Ship: Zealot |
---|
690 | Weapon: Heavy Pulse Laser II |
---|
691 | Damage Done: 388 |
---|
692 | |
---|
693 | Name: Szaman |
---|
694 | Security: -1.6 |
---|
695 | Corp: The Priory |
---|
696 | Alliance: NONE |
---|
697 | Faction: NONE |
---|
698 | Ship: Zealot |
---|
699 | Weapon: Heavy Pulse Laser II |
---|
700 | Damage Done: 380 |
---|
701 | |
---|
702 | Name: JC Weyland |
---|
703 | Security: -2.1 |
---|
704 | Corp: Endgame. |
---|
705 | Alliance: NONE |
---|
706 | Faction: NONE |
---|
707 | Ship: Kitsune |
---|
708 | Weapon: 75mm Gatling Rail II |
---|
709 | Damage Done: 0 |
---|
710 | |
---|
711 | Name: Parad iseLost |
---|
712 | Security: 1.8 |
---|
713 | Corp: The Priory |
---|
714 | Alliance: NONE |
---|
715 | Faction: NONE |
---|
716 | Ship: Ishtar |
---|
717 | Weapon: Warp Disruptor II |
---|
718 | Damage Done: 0 |
---|
719 | |
---|
720 | Name: Gus Preston |
---|
721 | Security: -2.2 |
---|
722 | Corp: The Priory |
---|
723 | Alliance: NONE |
---|
724 | Faction: NONE |
---|
725 | Ship: Scimitar |
---|
726 | Weapon: Warp Disruptor II |
---|
727 | Damage Done: 0 |
---|
728 | |
---|
729 | Destroyed items: |
---|
730 | |
---|
731 | Covert Ops Cloaking Device II |
---|
732 | Cynosural Field Generator I |
---|
733 | Expanded Cargohold II |
---|
734 | 1MN MicroWarpdrive II |
---|
735 | |
---|
736 | Dropped items: |
---|
737 | |
---|
738 | Expanded Cargohold II, Qty: 2 |
---|
739 | Liquid Ozone, Qty: 450 (Cargo) |
---|
740 | */ |
---|
741 | } |
---|
742 | } |
---|
743 | ?> |
---|