12 | | function Kill($id = 0) |
13 | | { |
14 | | $this->id_ = $id; |
15 | | $this->involvedparties_ = array(); |
16 | | $this->destroyeditems_ = array(); |
17 | | $this->droppeditems_ = array(); |
18 | | } |
19 | | |
20 | | function set($var, $value) |
21 | | { |
22 | | $this->$var = $value; |
23 | | } |
24 | | |
25 | | function getID() |
26 | | { |
27 | | return $this->id_; |
28 | | } |
29 | | |
30 | | function getTimeStamp() |
31 | | { |
32 | | $this->execQuery(); |
33 | | return $this->timestamp_; |
34 | | } |
35 | | |
36 | | function getVictimName() |
37 | | { |
38 | | $this->execQuery(); |
39 | | return $this->victimname_; |
40 | | } |
41 | | |
42 | | function getVictimID() |
43 | | { |
44 | | $this->execQuery(); |
45 | | return $this->victimid_; |
46 | | } |
47 | | |
48 | | function getVictimPortrait($size = 32) |
49 | | { |
50 | | $this->execQuery(); |
51 | | $plt = new Pilot($this->victimid_); |
52 | | return $plt->getPortraitURL($size); |
53 | | } |
54 | | |
55 | | function getVictimCorpID() |
56 | | { |
57 | | $this->execQuery(); |
58 | | return $this->victimcorpid_; |
59 | | } |
60 | | |
61 | | function getVictimCorpName() |
62 | | { |
63 | | $this->execQuery(); |
64 | | return $this->victimcorpname_; |
65 | | } |
66 | | |
67 | | function getVictimAllianceName() |
68 | | { |
69 | | $this->execQuery(); |
70 | | return $this->victimalliancename_; |
71 | | } |
72 | | |
73 | | function getVictimAllianceID() |
74 | | { |
75 | | $this->execQuery(); |
76 | | return $this->victimallianceid_; |
77 | | } |
78 | | |
79 | | function getVictimShip() |
80 | | { |
81 | | $this->execQuery(); |
82 | | return $this->victimship_; |
83 | | } |
84 | | |
85 | | function getSystem() |
86 | | { |
87 | | $this->execQuery(); |
88 | | return $this->solarsystem_; |
89 | | } |
90 | | |
91 | | function getFBPilotID() |
92 | | { |
93 | | $this->execQuery(); |
94 | | if (!$this->fbpilotid_) return "null"; |
95 | | else return $this->fbpilotid_; |
96 | | } |
97 | | |
98 | | function getFBPilotName() |
99 | | { |
100 | | $this->execQuery(); |
101 | | return $this->fbpilotname_; |
102 | | } |
103 | | |
104 | | function getFBCorpID() |
105 | | { |
106 | | $this->execQuery(); |
107 | | if (!$this->fbcorpid_) return "null"; |
108 | | else return $this->fbcorpid_; |
109 | | } |
110 | | |
111 | | function getFBCorpName() |
112 | | { |
113 | | $this->execQuery(); |
114 | | return $this->fbcorpname_; |
115 | | } |
116 | | |
117 | | function getFBAllianceID() |
118 | | { |
119 | | $this->execQuery(); |
120 | | if (!$this->fballianceid_) return "null"; |
121 | | else return $this->fballianceid_; |
122 | | } |
123 | | |
124 | | function getFBAllianceName() |
125 | | { |
126 | | $this->execQuery(); |
127 | | return $this->fballiancename_; |
128 | | } |
129 | | |
130 | | function getKillPoints() |
131 | | { |
132 | | $this->execQuery(); |
133 | | return $this->killpoints_; |
134 | | } |
135 | | |
136 | | function getSolarSystemName() |
137 | | { |
138 | | return $this->solarsystemname_; |
139 | | } |
140 | | |
141 | | function getSolarSystemSecurity() |
142 | | { |
143 | | return $this->solarsystemsecurity_; |
144 | | } |
145 | | |
146 | | function getVictimShipName() |
147 | | { |
148 | | return $this->victimshipname_; |
149 | | } |
150 | | |
151 | | function getVictimShipExternalID() |
152 | | { |
153 | | return $this->victimshipexternalid_; |
154 | | } |
155 | | |
156 | | function getVictimShipClassName() |
157 | | { |
158 | | return $this->victimshipclassname_; |
159 | | } |
160 | | |
161 | | function getVictimShipValue() |
162 | | { |
163 | | return $this->victimshipvalue_; |
164 | | } |
165 | | |
166 | | function getVictimShipImage($size) |
167 | | { |
168 | | return IMG_URL."/ships/".$size."_".$size."/".$this->victimshipexternalid_.".png"; |
169 | | } |
170 | | |
171 | | function getVictimShipValueIndicator() |
172 | | { |
173 | | // value is now raw |
174 | | $value = $this->getVictimShipValue()/1000000; |
175 | | |
176 | | if ($value >= 0 && $value <= 1) |
177 | | $color = 'gray'; |
178 | | elseif ($value > 1 && $value <= 15) |
179 | | $color = 'blue'; |
180 | | elseif ($value > 15 && $value <= 25) |
181 | | $color = 'green'; |
182 | | elseif ($value > 25 && $value <= 40) |
183 | | $color = 'yellow'; |
184 | | elseif ($value > 40 && $value <= 80) |
185 | | $color = 'red'; |
186 | | elseif ($value > 80 && $value <= 250) |
187 | | $color = 'orange'; |
188 | | elseif ($value > 250) |
189 | | $color = 'purple'; |
190 | | |
191 | | return IMG_URL.'/ships/ship-'.$color.'.gif'; |
192 | | } |
193 | | |
194 | | function getRawMail() |
195 | | { |
196 | | if (config::get('km_cache_enabled') && file_exists(config::get('km_cache_dir')."/".$this->getID().".txt")) |
197 | | { |
198 | | return file_get_contents(config::get('km_cache_dir')."/".$this->getID().".txt"); |
199 | | } |
200 | | |
201 | | $this->execQuery(); |
202 | | if ($this->isClassified()) |
203 | | { |
204 | | return 'Killmail not yet available, try again in '.round($this->getClassifiedTime()/3600, 2).' hrs.'; |
205 | | } |
206 | | |
207 | | $mail .= substr(str_replace('-', '.' , $this->getTimeStamp()), 0, 16)."\r\n\r\n"; |
208 | | $mail .= "Victim: ".$this->getVictimName()."\r\n"; |
209 | | $mail .= "Corp: ".$this->getVictimCorpName()."\r\n"; |
210 | | $mail .= "Alliance: ".$this->getVictimAllianceName()."\r\n"; |
211 | | $mail .= "Faction: NONE\r\n"; |
212 | | $ship = $this->getVictimShip(); |
213 | | $mail .= "Destroyed: ".$ship->getName()."\r\n"; |
214 | | $system = $this->getSystem(); |
215 | | $mail .= "System: ".$system->getName()."\r\n"; |
216 | | $mail .= "Security: ".$system->getSecurity(true)."\r\n"; |
217 | | $mail .= "Damage Taken: ".$this->VictimDamageTaken."\r\n\r\n"; |
218 | | $mail .= "Involved parties:\r\n\r\n"; |
219 | | |
220 | | foreach ($this->involvedparties_ as $inv) |
221 | | { |
222 | | $pilot = new Pilot($inv->getPilotID()); |
223 | | $corp = new Corporation($inv->getCorpID()); |
224 | | $alliance = new Alliance($inv->getAllianceID()); |
225 | | |
226 | | $weapon = $inv->getWeapon(); |
227 | | $ship = $inv->getShip(); |
228 | | if ($pilot->getName() == $weapon->getName()) |
229 | | { |
230 | | $name = $pilot->getName()." / ".$corp->getName(); |
231 | | } |
232 | | else |
233 | | { |
234 | | $name = $pilot->getName(); |
235 | | } |
236 | | |
237 | | $mail .= "Name: ".$name; |
238 | | if ($pilot->getID() == $this->getFBPilotID()) |
239 | | { |
240 | | $mail .= " (laid the final blow)"; |
241 | | } |
242 | | $mail .= "\r\n"; |
243 | | |
244 | | if ($pilot->getName() != $weapon->getName()) |
245 | | { |
246 | | $mail .= "Security: ".$inv->getSecStatus()."\r\n"; |
247 | | $mail .= "Corp: ".$corp->getName()."\r\n"; |
248 | | $mail .= "Alliance: ".$alliance->getName()."\r\n"; |
249 | | $mail .= "Faction: NONE\r\n"; |
250 | | $mail .= "Ship: ".$ship->getName()."\r\n"; |
251 | | $mail .= "Weapon: ".$weapon->getName()."\r\n"; |
252 | | $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; |
253 | | } |
254 | | else |
255 | | { |
256 | | $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; |
257 | | } |
258 | | $mail .= "\r\n"; |
259 | | } |
260 | | |
261 | | if (count($this->destroyeditems_) > 0) |
262 | | { |
263 | | $mail .= "\r\nDestroyed items:\r\n\r\n"; |
264 | | |
265 | | foreach($this->destroyeditems_ as $destroyed) |
266 | | { |
267 | | $item = $destroyed->getItem(); |
268 | | $mail .= $item->getName(); |
269 | | if ($destroyed->getQuantity() > 1) |
270 | | { |
271 | | // if the option is enabled and the item is fitted then split it up |
272 | | // this is aworkaround for the lazy parser of griefwatch |
273 | | if (config::get('kill_splitfit') && $destroyed->getQuantity() < 9 && ($destroyed->getLocationID() == 1 |
274 | | || $destroyed->getLocationID() == 2 || $destroyed->getLocationID() == 3)) |
275 | | { |
276 | | for ($i = $destroyed->getQuantity(); $i > 1; $i--) |
277 | | { |
278 | | $mail .= "\r\n".$item->getName(); |
279 | | } |
280 | | |
281 | | } |
282 | | else |
283 | | { |
284 | | $mail .= ", Qty: ".$destroyed->getQuantity(); |
285 | | } |
286 | | } |
287 | | if ($destroyed->getLocationID() == 4) // cargo |
288 | | $mail .= " (Cargo)"; |
289 | | if ($destroyed->getLocationID() == 6) // drone |
290 | | $mail .= " (Drone Bay)"; |
291 | | $mail .= "\r\n"; |
292 | | } |
293 | | } |
294 | | |
295 | | if (count($this->droppeditems_) > 0) |
296 | | { |
297 | | $mail .= "\r\nDropped items:\r\n\r\n"; |
298 | | |
299 | | foreach($this->droppeditems_ as $dropped) |
300 | | { |
301 | | $item = $dropped->getItem(); |
302 | | $mail .= $item->getName(); |
303 | | if ($dropped->getQuantity() > 1) |
304 | | { |
305 | | // if the option is enabled and the item is fitted then split it up |
306 | | // this is aworkaround for the lazy parser of griefwatch |
307 | | if (config::get('kill_splitfit') && $dropped->getQuantity() < 9 && ($dropped->getLocationID() == 1 |
308 | | || $dropped->getLocationID() == 2 || $dropped->getLocationID() == 3)) |
309 | | { |
310 | | for ($i = $dropped->getQuantity(); $i > 1; $i--) |
311 | | { |
312 | | $mail .= "\r\n".$item->getName(); |
313 | | } |
314 | | |
315 | | } |
316 | | else |
317 | | { |
318 | | $mail .= ", Qty: ".$dropped->getQuantity(); |
319 | | } |
320 | | } |
321 | | if ($dropped->getLocationID() == 4) // cargo |
322 | | $mail .= " (Cargo)"; |
323 | | if ($dropped->getLocationID() == 6) // drone |
324 | | $mail .= " (Drone Bay)"; |
325 | | $mail .= "\r\n"; |
326 | | } |
327 | | } |
328 | | |
329 | | if (config::get('km_cache_enabled')) file_put_contents(config::get('km_cache_dir')."/".$this->getID().".txt", $mail); |
330 | | |
331 | | return $mail; |
332 | | } |
333 | | |
334 | | function getDupe($checkonly = false) |
335 | | { |
336 | | if (!$checkonly) |
337 | | { |
338 | | $this->execQuery(); |
339 | | } |
340 | | $dupe = 0; |
341 | | $qry = new DBQuery(); |
342 | | if (!$this->getFBPilotID() || !$this->victimid_) |
343 | | return 0; |
344 | | $qry->execute("select kll_id |
345 | | from kb3_kills |
346 | | where kll_timestamp <= |
347 | | date_add( '".$this->timestamp_."', INTERVAL '5:0' MINUTE_SECOND ) |
348 | | and kll_timestamp >= |
349 | | date_sub( '".$this->timestamp_."', INTERVAL '5:0' MINUTE_SECOND ) |
350 | | and kll_victim_id = ".$this->victimid_." |
351 | | and kll_ship_id = ".$this->victimship_->getID()." |
352 | | and kll_system_id = ".$this->solarsystem_->getID()." |
353 | | and kll_fb_plt_id = ".$this->getFBPilotID()." |
354 | | and kll_id != ".$this->id_); |
355 | | |
356 | | $row = $qry->getRow(); |
357 | | if ($row) |
358 | | return $row['kll_id']; |
359 | | else |
360 | | return 0; |
361 | | } |
362 | | |
363 | | function execQuery() |
364 | | { |
365 | | if (!$this->timestamp_) |
366 | | { |
367 | | $qry = new DBQuery(); |
368 | | |
369 | | $this->qry_ = new DBQuery(); |
370 | | $this->sql_ = "select kll.kll_id, kll.kll_timestamp, plt.plt_name, |
371 | | crp.crp_name, ali.all_name, ali.all_id, kll.kll_ship_id, |
372 | | kll.kll_system_id, kll.kll_ship_id, |
373 | | kll.kll_victim_id, plt.plt_externalid, |
374 | | kll.kll_crp_id, kll.kll_points, |
375 | | fbplt.plt_id as fbplt_id, |
376 | | fbplt.plt_externalid as fbplt_externalid, |
377 | | fbcrp.crp_id as fbcrp_id, |
378 | | fbali.all_id as fbali_id, |
379 | | fbplt.plt_name as fbplt_name, |
380 | | fbcrp.crp_name as fbcrp_name, |
381 | | fbali.all_name as fbali_name, |
382 | | kll_dmgtaken |
383 | | from kb3_kills kll, kb3_pilots plt, kb3_corps crp, |
384 | | kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, |
385 | | kb3_pilots fbplt |
386 | | where kll.kll_id = '".$this->id_."' |
387 | | and plt.plt_id = kll.kll_victim_id |
388 | | and crp.crp_id = kll.kll_crp_id |
389 | | and ali.all_id = kll.kll_all_id |
390 | | and fbali.all_id = kll.kll_fb_all_id |
391 | | and fbcrp.crp_id = kll.kll_fb_crp_id |
392 | | and fbplt.plt_id = kll.kll_fb_plt_id"; |
393 | | |
394 | | $this->qry_->execute($this->sql_); |
395 | | $row = $this->qry_->getRow(); |
396 | | if (!$row) |
397 | | { |
398 | | $this->valid_ = false; |
399 | | return false; |
400 | | } |
401 | | else |
402 | | { |
403 | | $this->valid_ = true; |
404 | | } |
405 | | |
406 | | $this->setTimeStamp($row['kll_timestamp']); |
407 | | $this->setSolarSystem(new SolarSystem($row['kll_system_id'])); |
408 | | $this->setVictimID($row['kll_victim_id']); |
409 | | $this->setVictimName($row['plt_name']); |
410 | | $this->setVictimCorpID($row['kll_crp_id']); |
411 | | $this->setVictimCorpName($row['crp_name']); |
412 | | $this->setVictimAllianceID($row['all_id']); |
413 | | $this->setVictimAllianceName($row['all_name']); |
414 | | $this->setVictimShip(new Ship($row['kll_ship_id'])); |
415 | | $this->setFBPilotID($row['fbplt_id']); |
416 | | $this->setFBPilotName($row['fbplt_name']); |
417 | | $this->setFBCorpID($row['fbcrp_id']); |
418 | | $this->setFBCorpName($row['fbcrp_name']); |
419 | | $this->setFBAllianceID($row['fbali_id']); |
420 | | $this->setFBAllianceName($row['fbali_name']); |
421 | | $this->setKillPoints($row['kll_points']); |
422 | | $this->plt_ext_ = $row['plt_externalid']; |
423 | | $this->fbplt_ext_ = $row['fbplt_externalid']; |
424 | | $this->VictimDamageTaken = $row['kll_dmgtaken']; |
425 | | |
426 | | // involved |
427 | | $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, |
428 | | ind_shp_id, ind_wep_id, ind_dmgdone |
429 | | from kb3_inv_detail |
430 | | where ind_kll_id = ".$this->getID()." |
431 | | order by ind_order"; |
432 | | |
433 | | $qry->execute($sql) or die($qry->getErrorMsg()); |
434 | | while ($row = $qry->getRow()) |
435 | | { |
436 | | $involved = new InvolvedParty($row['ind_plt_id'], |
437 | | $row['ind_crp_id'], |
438 | | $row['ind_all_id'], |
439 | | $row['ind_sec_status'], |
440 | | new Ship($row['ind_shp_id']), |
441 | | new Item($row['ind_wep_id'])); |
442 | | $involved->dmgdone_ = $row['ind_dmgdone']; |
443 | | array_push($this->involvedparties_, $involved); |
444 | | } |
445 | | // destroyed items |
446 | | $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, |
447 | | itd_itl_id, itl_location |
448 | | from kb3_items_destroyed itd |
449 | | left join kb3_item_locations itl on (itd.itd_itl_id = itl.itl_id or (itd.itd_itl_id = 0 and itl.itl_id = 1)) |
450 | | where itd.itd_kll_id = ".$this->getID()." |
451 | | group by itd_itm_id, itd_itl_id |
452 | | order by itd.itd_itl_id"; |
453 | | $qry->execute($sql); |
454 | | while ($row = $qry->getRow()) |
455 | | { |
456 | | $destroyed = new DestroyedItem(new Item($row['itd_itm_id']), |
457 | | $row['itd_quantity'], |
458 | | $row['itl_location']); |
459 | | array_push($this->destroyeditems_, $destroyed); |
460 | | } |
461 | | |
462 | | // dropped items |
463 | | $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, |
464 | | itd_itl_id, itl_location |
465 | | from kb3_items_dropped itd |
466 | | left join kb3_item_locations itl on (itd.itd_itl_id = itl.itl_id or (itd.itd_itl_id = 0 and itl.itl_id = 1)) |
467 | | where itd.itd_kll_id = ".$this->getID()." |
468 | | group by itd_itm_id, itd_itl_id |
469 | | order by itd.itd_itl_id"; |
470 | | $qry->execute($sql); |
471 | | while ($row = $qry->getRow()) |
472 | | { |
473 | | $destroyed = new DroppedItem(new Item($row['itd_itm_id']), |
474 | | $row['itd_quantity'], |
475 | | $row['itl_location']); |
476 | | array_push($this->droppeditems_, $destroyed); |
477 | | } |
478 | | } |
479 | | } |
480 | | |
481 | | function isClassified() |
482 | | { |
483 | | if (config::get('kill_classified')) |
484 | | { |
485 | | if (user::role('classified_see')) |
486 | | { |
487 | | return false; |
488 | | } |
489 | | |
490 | | $offset = config::get('kill_classified')*3600; |
491 | | if (config::get('date_gmtime')) |
492 | | { |
493 | | $time = time()-date('Z'); |
494 | | } |
495 | | else |
496 | | { |
497 | | $time = time(); |
498 | | } |
499 | | if (strtotime($this->timestamp_) > $time-$offset) |
500 | | { |
501 | | return true; |
502 | | } |
503 | | } |
504 | | return false; |
505 | | } |
506 | | |
507 | | function getClassifiedTime() |
508 | | { |
509 | | if (config::get('kill_classified')) |
510 | | { |
511 | | $offset = config::get('kill_classified')*3600; |
512 | | if (config::get('date_gmtime')) |
513 | | { |
514 | | $time = time()-date('Z'); |
515 | | } |
516 | | else |
517 | | { |
518 | | $time = time(); |
519 | | } |
520 | | if (strtotime($this->timestamp_) > $time-$offset) |
521 | | { |
522 | | return ($offset-$time+strtotime($this->timestamp_)); |
523 | | } |
524 | | } |
525 | | return 0; |
526 | | } |
| 13 | function Kill($id = 0) |
| 14 | { |
| 15 | $this->id_ = $id; |
| 16 | $this->involvedparties_ = array(); |
| 17 | $this->destroyeditems_ = array(); |
| 18 | $this->droppeditems_ = array(); |
| 19 | } |
| 20 | |
| 21 | function set($var, $value) |
| 22 | { |
| 23 | $this->$var = $value; |
| 24 | } |
| 25 | |
| 26 | function getID() |
| 27 | { |
| 28 | return $this->id_; |
| 29 | } |
| 30 | |
| 31 | function getTimeStamp() |
| 32 | { |
| 33 | $this->execQuery(); |
| 34 | return $this->timestamp_; |
| 35 | } |
| 36 | |
| 37 | function getVictimName() |
| 38 | { |
| 39 | $this->execQuery(); |
| 40 | return $this->victimname_; |
| 41 | } |
| 42 | |
| 43 | function getVictimID() |
| 44 | { |
| 45 | $this->execQuery(); |
| 46 | return $this->victimid_; |
| 47 | } |
| 48 | |
| 49 | function getVictimPortrait($size = 32) |
| 50 | { |
| 51 | $this->execQuery(); |
| 52 | $plt = new Pilot($this->victimid_); |
| 53 | return $plt->getPortraitURL($size); |
| 54 | } |
| 55 | |
| 56 | function getVictimCorpID() |
| 57 | { |
| 58 | $this->execQuery(); |
| 59 | return $this->victimcorpid_; |
| 60 | } |
| 61 | |
| 62 | function getVictimCorpName() |
| 63 | { |
| 64 | $this->execQuery(); |
| 65 | return $this->victimcorpname_; |
| 66 | } |
| 67 | |
| 68 | function getVictimAllianceName() |
| 69 | { |
| 70 | $this->execQuery(); |
| 71 | return $this->victimalliancename_; |
| 72 | } |
| 73 | |
| 74 | function getVictimAllianceID() |
| 75 | { |
| 76 | $this->execQuery(); |
| 77 | return $this->victimallianceid_; |
| 78 | } |
| 79 | |
| 80 | function getVictimShip() |
| 81 | { |
| 82 | $this->execQuery(); |
| 83 | return $this->victimship_; |
| 84 | } |
| 85 | |
| 86 | function getSystem() |
| 87 | { |
| 88 | $this->execQuery(); |
| 89 | return $this->solarsystem_; |
| 90 | } |
| 91 | |
| 92 | function getFBPilotID() |
| 93 | { |
| 94 | $this->execQuery(); |
| 95 | if (!$this->fbpilotid_) return "null"; |
| 96 | else return $this->fbpilotid_; |
| 97 | } |
| 98 | |
| 99 | function getFBPilotName() |
| 100 | { |
| 101 | $this->execQuery(); |
| 102 | return $this->fbpilotname_; |
| 103 | } |
| 104 | |
| 105 | function getFBCorpID() |
| 106 | { |
| 107 | $this->execQuery(); |
| 108 | if (!$this->fbcorpid_) return "null"; |
| 109 | else return $this->fbcorpid_; |
| 110 | } |
| 111 | |
| 112 | function getFBCorpName() |
| 113 | { |
| 114 | $this->execQuery(); |
| 115 | return $this->fbcorpname_; |
| 116 | } |
| 117 | |
| 118 | function getFBAllianceID() |
| 119 | { |
| 120 | $this->execQuery(); |
| 121 | if (!$this->fballianceid_) return "null"; |
| 122 | else return $this->fballianceid_; |
| 123 | } |
| 124 | |
| 125 | function getFBAllianceName() |
| 126 | { |
| 127 | $this->execQuery(); |
| 128 | return $this->fballiancename_; |
| 129 | } |
| 130 | |
| 131 | function getISKLoss() |
| 132 | { |
| 133 | $this->execQuery(); |
| 134 | return $this->iskloss_; |
| 135 | } |
| 136 | function getKillPoints() |
| 137 | { |
| 138 | $this->execQuery(); |
| 139 | return $this->killpoints_; |
| 140 | } |
| 141 | |
| 142 | function getSolarSystemName() |
| 143 | { |
| 144 | return $this->solarsystemname_; |
| 145 | } |
| 146 | |
| 147 | function getSolarSystemSecurity() |
| 148 | { |
| 149 | return $this->solarsystemsecurity_; |
| 150 | } |
| 151 | |
| 152 | function getVictimShipName() |
| 153 | { |
| 154 | return $this->victimshipname_; |
| 155 | } |
| 156 | |
| 157 | function getVictimShipExternalID() |
| 158 | { |
| 159 | return $this->victimshipexternalid_; |
| 160 | } |
| 161 | |
| 162 | function getVictimShipClassName() |
| 163 | { |
| 164 | return $this->victimshipclassname_; |
| 165 | } |
| 166 | |
| 167 | function getVictimShipValue() |
| 168 | { |
| 169 | return $this->victimshipvalue_; |
| 170 | } |
| 171 | |
| 172 | function getVictimShipImage($size) |
| 173 | { |
| 174 | return IMG_URL."/ships/".$size."_".$size."/".$this->victimshipexternalid_.".png"; |
| 175 | } |
| 176 | |
| 177 | function getVictimShipValueIndicator() |
| 178 | { |
| 179 | // value is now raw |
| 180 | $value = $this->getVictimShipValue()/1000000; |
| 181 | |
| 182 | if ($value >= 0 && $value <= 1) |
| 183 | $color = 'gray'; |
| 184 | elseif ($value > 1 && $value <= 15) |
| 185 | $color = 'blue'; |
| 186 | elseif ($value > 15 && $value <= 25) |
| 187 | $color = 'green'; |
| 188 | elseif ($value > 25 && $value <= 40) |
| 189 | $color = 'yellow'; |
| 190 | elseif ($value > 40 && $value <= 80) |
| 191 | $color = 'red'; |
| 192 | elseif ($value > 80 && $value <= 250) |
| 193 | $color = 'orange'; |
| 194 | elseif ($value > 250) |
| 195 | $color = 'purple'; |
| 196 | |
| 197 | return IMG_URL.'/ships/ship-'.$color.'.gif'; |
| 198 | } |
| 199 | |
| 200 | function getRawMail() |
| 201 | { |
| 202 | if (config::get('km_cache_enabled') && file_exists(config::get('km_cache_dir')."/".$this->getID().".txt")) |
| 203 | { |
| 204 | return file_get_contents(config::get('km_cache_dir')."/".$this->getID().".txt"); |
| 205 | } |
| 206 | |
| 207 | $this->execQuery(); |
| 208 | if ($this->isClassified()) |
| 209 | { |
| 210 | return 'Killmail not yet available, try again in '.round($this->getClassifiedTime()/3600, 2).' hrs.'; |
| 211 | } |
| 212 | |
| 213 | $ship = $this->getVictimShip(); |
| 214 | $shipclass = $ship->getClass(); |
| 215 | |
| 216 | $mail .= substr(str_replace('-', '.' , $this->getTimeStamp()), 0, 16)."\r\n\r\n"; |
| 217 | if ( $shipclass->getID() == 35 ) // Starbase (so this is a POS mail) |
| 218 | { |
| 219 | $mail .= "Corp: ".$this->getVictimCorpName()."\r\n"; |
| 220 | $mail .= "Alliance: ".$this->getVictimAllianceName()."\r\n"; |
| 221 | $mail .= "Faction: NONE\r\n"; |
| 222 | //$ship = $this->getVictimShip(); |
| 223 | $mail .= "Destroyed: ".$ship->getName()."\r\n"; |
| 224 | $mail .= "Moon: ".$this->getVictimName()."\r\n"; |
| 225 | $system = $this->getSystem(); |
| 226 | $mail .= "System: ".$system->getName()."\r\n"; |
| 227 | $mail .= "Security: ".$system->getSecurity(true)."\r\n"; |
| 228 | $mail .= "Damage Taken: ".$this->VictimDamageTaken."\r\n\r\n"; |
| 229 | $mail .= "Involved parties:\r\n\r\n"; |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | $mail .= "Victim: ".$this->getVictimName()."\r\n"; |
| 234 | $mail .= "Corp: ".$this->getVictimCorpName()."\r\n"; |
| 235 | $mail .= "Alliance: ".$this->getVictimAllianceName()."\r\n"; |
| 236 | $mail .= "Faction: NONE\r\n"; |
| 237 | //$ship = $this->getVictimShip(); |
| 238 | $mail .= "Destroyed: ".$ship->getName()."\r\n"; |
| 239 | $system = $this->getSystem(); |
| 240 | $mail .= "System: ".$system->getName()."\r\n"; |
| 241 | $mail .= "Security: ".$system->getSecurity(true)."\r\n"; |
| 242 | $mail .= "Damage Taken: ".$this->VictimDamageTaken."\r\n\r\n"; |
| 243 | $mail .= "Involved parties:\r\n\r\n"; |
| 244 | } |
| 245 | |
| 246 | foreach ($this->involvedparties_ as $inv) |
| 247 | { |
| 248 | $pilot = new Pilot($inv->getPilotID()); |
| 249 | $corp = new Corporation($inv->getCorpID()); |
| 250 | $alliance = new Alliance($inv->getAllianceID()); |
| 251 | |
| 252 | $weapon = $inv->getWeapon(); |
| 253 | $ship = $inv->getShip(); |
| 254 | if ($pilot->getName() == $weapon->getName()) |
| 255 | { |
| 256 | $name = $pilot->getName()." / ".$corp->getName(); |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | $name = $pilot->getName(); |
| 261 | } |
| 262 | |
| 263 | $mail .= "Name: ".$name; |
| 264 | if ($pilot->getID() == $this->getFBPilotID()) |
| 265 | { |
| 266 | $mail .= " (laid the final blow)"; |
| 267 | } |
| 268 | $mail .= "\r\n"; |
| 269 | |
| 270 | if ($pilot->getName() != $weapon->getName()) |
| 271 | { |
| 272 | $mail .= "Security: ".$inv->getSecStatus()."\r\n"; |
| 273 | $mail .= "Corp: ".$corp->getName()."\r\n"; |
| 274 | $mail .= "Alliance: ".$alliance->getName()."\r\n"; |
| 275 | $mail .= "Faction: NONE\r\n"; |
| 276 | $mail .= "Ship: ".$ship->getName()."\r\n"; |
| 277 | $mail .= "Weapon: ".$weapon->getName()."\r\n"; |
| 278 | $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; |
| 283 | } |
| 284 | $mail .= "\r\n"; |
| 285 | } |
| 286 | |
| 287 | if (count($this->destroyeditems_) > 0) |
| 288 | { |
| 289 | $mail .= "\r\nDestroyed items:\r\n\r\n"; |
| 290 | |
| 291 | foreach($this->destroyeditems_ as $destroyed) |
| 292 | { |
| 293 | $item = $destroyed->getItem(); |
| 294 | $mail .= $item->getName(); |
| 295 | if ($destroyed->getQuantity() > 1) |
| 296 | { |
| 297 | // if the option is enabled and the item is fitted then split it up |
| 298 | // this is aworkaround for the lazy parser of griefwatch |
| 299 | if (config::get('kill_splitfit') && $destroyed->getQuantity() < 9 && ($destroyed->getLocationID() == 1 |
| 300 | || $destroyed->getLocationID() == 2 || $destroyed->getLocationID() == 3)) |
| 301 | { |
| 302 | for ($i = $destroyed->getQuantity(); $i > 1; $i--) |
| 303 | { |
| 304 | $mail .= "\r\n".$item->getName(); |
| 305 | } |
| 306 | |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | $mail .= ", Qty: ".$destroyed->getQuantity(); |
| 311 | } |
| 312 | } |
| 313 | if ($destroyed->getLocationID() == 4) // cargo |
| 314 | $mail .= " (Cargo)"; |
| 315 | if ($destroyed->getLocationID() == 6) // drone |
| 316 | $mail .= " (Drone Bay)"; |
| 317 | $mail .= "\r\n"; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | if (count($this->droppeditems_) > 0) |
| 322 | { |
| 323 | $mail .= "\r\nDropped items:\r\n\r\n"; |
| 324 | |
| 325 | foreach($this->droppeditems_ as $dropped) |
| 326 | { |
| 327 | $item = $dropped->getItem(); |
| 328 | $mail .= $item->getName(); |
| 329 | if ($dropped->getQuantity() > 1) |
| 330 | { |
| 331 | // if the option is enabled and the item is fitted then split it up |
| 332 | // this is aworkaround for the lazy parser of griefwatch |
| 333 | if (config::get('kill_splitfit') && $dropped->getQuantity() < 9 && ($dropped->getLocationID() == 1 |
| 334 | || $dropped->getLocationID() == 2 || $dropped->getLocationID() == 3)) |
| 335 | { |
| 336 | for ($i = $dropped->getQuantity(); $i > 1; $i--) |
| 337 | { |
| 338 | $mail .= "\r\n".$item->getName(); |
| 339 | } |
| 340 | |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | $mail .= ", Qty: ".$dropped->getQuantity(); |
| 345 | } |
| 346 | } |
| 347 | if ($dropped->getLocationID() == 4) // cargo |
| 348 | $mail .= " (Cargo)"; |
| 349 | if ($dropped->getLocationID() == 6) // drone |
| 350 | $mail .= " (Drone Bay)"; |
| 351 | $mail .= "\r\n"; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | if (config::get('km_cache_enabled')) file_put_contents(config::get('km_cache_dir')."/".$this->getID().".txt", $mail); |
| 356 | |
| 357 | return $mail; |
| 358 | } |
| 359 | |
| 360 | function getDupe($checkonly = false) |
| 361 | { |
| 362 | if (!$checkonly) |
| 363 | { |
| 364 | $this->execQuery(); |
| 365 | } |
| 366 | $dupe = 0; |
| 367 | $qry = new DBQuery(true); |
| 368 | if (!$this->getFBPilotID() || !$this->victimid_) |
| 369 | return 0; |
| 370 | $qry->execute("select kll_id |
| 371 | from kb3_kills |
| 372 | where kll_timestamp ='".$this->timestamp_."' |
| 373 | and kll_victim_id = ".$this->victimid_." |
| 374 | and kll_ship_id = ".$this->victimship_->getID()." |
| 375 | and kll_system_id = ".$this->solarsystem_->getID()." |
| 376 | and kll_fb_plt_id = ".$this->getFBPilotID()." |
| 377 | and kll_id != ".$this->id_); |
| 378 | |
| 379 | $row = $qry->getRow(); |
| 380 | if ($row) |
| 381 | return $row['kll_id']; |
| 382 | else |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | function execQuery() |
| 387 | { |
| 388 | if (!$this->timestamp_) |
| 389 | { |
| 390 | $qry = new DBQuery(); |
| 391 | |
| 392 | $this->qry_ = new DBQuery(); |
| 393 | $this->sql_ = "select kll.kll_id, kll.kll_timestamp, plt.plt_name, |
| 394 | crp.crp_name, ali.all_name, ali.all_id, kll.kll_ship_id, |
| 395 | kll.kll_system_id, kll.kll_ship_id, |
| 396 | kll.kll_victim_id, plt.plt_externalid, |
| 397 | kll.kll_crp_id, kll.kll_points, kll.kll_isk_loss, |
| 398 | fbplt.plt_id as fbplt_id, |
| 399 | fbplt.plt_externalid as fbplt_externalid, |
| 400 | fbcrp.crp_id as fbcrp_id, |
| 401 | fbali.all_id as fbali_id, |
| 402 | fbplt.plt_name as fbplt_name, |
| 403 | fbcrp.crp_name as fbcrp_name, |
| 404 | fbali.all_name as fbali_name, |
| 405 | kll_dmgtaken |
| 406 | from kb3_kills kll, kb3_pilots plt, kb3_corps crp, |
| 407 | kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, |
| 408 | kb3_pilots fbplt, kb3_inv_detail fb |
| 409 | where kll.kll_id = '".$this->id_."' |
| 410 | and plt.plt_id = kll.kll_victim_id |
| 411 | and crp.crp_id = kll.kll_crp_id |
| 412 | and ali.all_id = kll.kll_all_id |
| 413 | and fb.ind_kll_id = kll.kll_id |
| 414 | and fb.ind_plt_id = kll.kll_fb_plt_id |
| 415 | and fbali.all_id = fb.ind_all_id |
| 416 | and fbcrp.crp_id = fb.ind_crp_id |
| 417 | and fbplt.plt_id = kll.kll_fb_plt_id"; |
| 418 | |
| 419 | $this->qry_->execute($this->sql_); |
| 420 | $row = $this->qry_->getRow(); |
| 421 | if (!$row) |
| 422 | { |
| 423 | $this->valid_ = false; |
| 424 | return false; |
| 425 | } |
| 426 | else |
| 427 | { |
| 428 | $this->valid_ = true; |
| 429 | } |
| 430 | |
| 431 | $this->setTimeStamp($row['kll_timestamp']); |
| 432 | $this->setSolarSystem(new SolarSystem($row['kll_system_id'])); |
| 433 | $this->setVictimID($row['kll_victim_id']); |
| 434 | $this->setVictimName($row['plt_name']); |
| 435 | $this->setVictimCorpID($row['kll_crp_id']); |
| 436 | $this->setVictimCorpName($row['crp_name']); |
| 437 | $this->setVictimAllianceID($row['all_id']); |
| 438 | $this->setVictimAllianceName($row['all_name']); |
| 439 | $this->setVictimShip(new Ship($row['kll_ship_id'])); |
| 440 | $this->setFBPilotID($row['fbplt_id']); |
| 441 | $this->setFBPilotName($row['fbplt_name']); |
| 442 | $this->setFBCorpID($row['fbcrp_id']); |
| 443 | $this->setFBCorpName($row['fbcrp_name']); |
| 444 | $this->setFBAllianceID($row['fbali_id']); |
| 445 | $this->setFBAllianceName($row['fbali_name']); |
| 446 | $this->setKillPoints($row['kll_points']); |
| 447 | $this->iskloss_ = $row['kll_isk_loss']; |
| 448 | $this->plt_ext_ = $row['plt_externalid']; |
| 449 | $this->fbplt_ext_ = $row['fbplt_externalid']; |
| 450 | $this->VictimDamageTaken = $row['kll_dmgtaken']; |
| 451 | |
| 452 | // involved |
| 453 | $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, |
| 454 | ind_shp_id, ind_wep_id, ind_dmgdone |
| 455 | from kb3_inv_detail |
| 456 | where ind_kll_id = ".$this->getID()." |
| 457 | order by ind_order"; |
| 458 | |
| 459 | $qry->execute($sql) or die($qry->getErrorMsg()); |
| 460 | while ($row = $qry->getRow()) |
| 461 | { |
| 462 | $involved = new InvolvedParty($row['ind_plt_id'], |
| 463 | $row['ind_crp_id'], |
| 464 | $row['ind_all_id'], |
| 465 | $row['ind_sec_status'], |
| 466 | new Ship($row['ind_shp_id']), |
| 467 | new Item($row['ind_wep_id'])); |
| 468 | $involved->dmgdone_ = $row['ind_dmgdone']; |
| 469 | array_push($this->involvedparties_, $involved); |
| 470 | } |
| 471 | $destroyedlist = new ItemList(null, true); |
| 472 | $destroyedlist->addKillDestroyed($this->id_); |
| 473 | while($item = $destroyedlist->getItem()) |
| 474 | { |
| 475 | $destroyed = new DestroyedItem($item, |
| 476 | $item->row_['itd_quantity'], |
| 477 | $item->row_['itl_location'], |
| 478 | $item->row_['itd_itl_id']); |
| 479 | array_push($this->destroyeditems_, $destroyed); |
| 480 | } |
| 481 | $droppedlist = new ItemList(null, true); |
| 482 | $droppedlist->addKillDropped($this->id_); |
| 483 | while($item = $droppedlist->getItem()) |
| 484 | { |
| 485 | $dropped = new DroppedItem($item, |
| 486 | $item->row_['itd_quantity'], |
| 487 | $item->row_['itl_location'], |
| 488 | $item->row_['itd_itl_id']); |
| 489 | array_push($this->droppeditems_, $dropped); |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | function isClassified() |
| 495 | { |
| 496 | if (config::get('kill_classified')) |
| 497 | { |
| 498 | if (user::role('classified_see')) |
| 499 | { |
| 500 | return false; |
| 501 | } |
| 502 | |
| 503 | $offset = config::get('kill_classified')*3600; |
| 504 | if (config::get('date_gmtime')) |
| 505 | { |
| 506 | $time = time()-date('Z'); |
| 507 | } |
| 508 | else |
| 509 | { |
| 510 | $time = time(); |
| 511 | } |
| 512 | if (strtotime($this->timestamp_) > $time-$offset) |
| 513 | { |
| 514 | return true; |
| 515 | } |
| 516 | } |
| 517 | return false; |
| 518 | } |
| 519 | |
| 520 | function getClassifiedTime() |
| 521 | { |
| 522 | if (config::get('kill_classified')) |
| 523 | { |
| 524 | $offset = config::get('kill_classified')*3600; |
| 525 | if (config::get('date_gmtime')) |
| 526 | { |
| 527 | $time = time()-date('Z'); |
| 528 | } |
| 529 | else |
| 530 | { |
| 531 | $time = time(); |
| 532 | } |
| 533 | if (strtotime($this->timestamp_) > $time-$offset) |
| 534 | { |
| 535 | return ($offset-$time+strtotime($this->timestamp_)); |
| 536 | } |
| 537 | } |
| 538 | return 0; |
| 539 | } |
535 | | |
536 | | function exists() |
537 | | { |
538 | | $this->execQuery(); |
539 | | return $this->valid_; |
540 | | } |
541 | | |
542 | | function relatedKillCount() |
543 | | { |
544 | | $kslist = new KillList(); |
545 | | $kslist->setRelated($this->id_); |
546 | | involved::load($kslist,'kill'); |
547 | | |
548 | | return $kslist->getCount(); |
549 | | } |
550 | | |
551 | | function relatedLossCount() |
552 | | { |
553 | | $lslist = new KillList(); |
554 | | $lslist->setRelated($this->id_); |
555 | | involved::load($lslist,'loss'); |
556 | | |
557 | | return $lslist->getCount(); |
558 | | } |
559 | | |
560 | | function countComment($kll_id) |
561 | | { |
562 | | $qry = new DBQuery(); |
563 | | $sql = "SELECT * FROM kb3_comments WHERE kll_id = '$kll_id'"; |
564 | | $count = $qry->execute($sql); |
565 | | $count = $qry->recordCount(); |
566 | | return $count; |
567 | | } |
568 | | |
569 | | function setID($id) |
570 | | { |
571 | | $this->id_ = $id; |
572 | | } |
573 | | |
574 | | function setTimeStamp($timestamp) |
575 | | { |
576 | | $this->timestamp_ = $timestamp; |
577 | | } |
578 | | |
579 | | function setSolarSystem($solarsystem) |
580 | | { |
581 | | $this->solarsystem_ = $solarsystem; |
582 | | } |
583 | | |
584 | | function setSolarSystemName($solarsystemname) |
585 | | { |
586 | | $this->solarsystemname_ = $solarsystemname; |
587 | | } |
588 | | |
589 | | function setSolarSystemSecurity($solarsystemsecurity) |
590 | | { |
591 | | $this->solarsystemsecurity_ = $solarsystemsecurity; |
592 | | } |
593 | | |
594 | | function setVictim($victim) |
595 | | { |
596 | | $this->victim_ = $victim; |
597 | | } |
598 | | |
599 | | function setVictimID($victimid) |
600 | | { |
601 | | $this->victimid_ = $victimid; |
602 | | } |
603 | | |
604 | | function setVictimName($victimname) |
605 | | { |
606 | | $this->victimname_ = $victimname; |
607 | | } |
608 | | |
609 | | function setVictimCorpID($victimcorpid) |
610 | | { |
611 | | $this->victimcorpid_ = $victimcorpid; |
612 | | } |
613 | | |
614 | | function setVictimCorpName($victimcorpname) |
615 | | { |
616 | | $this->victimcorpname_ = $victimcorpname; |
617 | | } |
618 | | |
619 | | function setVictimAllianceID($victimallianceid) |
620 | | { |
621 | | $this->victimallianceid_ = $victimallianceid; |
622 | | } |
623 | | |
624 | | function setVictimAllianceName($victimalliancename) |
625 | | { |
626 | | $this->victimalliancename_ = $victimalliancename; |
627 | | } |
628 | | |
629 | | function setVictimShip($victimship) |
630 | | { |
631 | | $this->victimship_ = $victimship; |
632 | | } |
633 | | |
634 | | function setVictimShipName($victimshipname) |
635 | | { |
636 | | $this->victimshipname_ = $victimshipname; |
637 | | } |
638 | | |
639 | | function setVictimShipExternalID($victimshipexternalid) |
640 | | { |
641 | | $this->victimshipexternalid_ = $victimshipexternalid; |
642 | | } |
643 | | |
644 | | function setVictimShipClassName($victimshipclassname) |
645 | | { |
646 | | $this->victimshipclassname_ = $victimshipclassname; |
647 | | } |
648 | | |
649 | | function setVictimShipValue($victimshipvalue) |
650 | | { |
651 | | $this->victimshipvalue_ = $victimshipvalue; |
652 | | } |
653 | | |
654 | | function setFBPilotID($fbpilotid) |
655 | | { |
656 | | $this->fbpilotid_ = $fbpilotid; |
657 | | } |
658 | | |
659 | | function setFBPilotName($fbpilotname) |
660 | | { |
661 | | $npc = strpos($fbpilotname, "#"); |
| 550 | |
| 551 | // Set the number of involved parties - used by killlist |
| 552 | function setInvolvedPartyCount($invcount = 0) |
| 553 | { |
| 554 | $this->involvedcount_ = $invcount; |
| 555 | } |
| 556 | |
| 557 | function exists() |
| 558 | { |
| 559 | $this->execQuery(); |
| 560 | return $this->valid_; |
| 561 | } |
| 562 | |
| 563 | //Count all kills by board owner related to this kill |
| 564 | function relatedKillCount() |
| 565 | { |
| 566 | if($this->relatedkillcount_) return $this->relatedkillcount_; |
| 567 | $sql="SELECT COUNT(kll.kll_id) AS kills FROM kb3_kills kll WHERE "; |
| 568 | $sql.="kll.kll_timestamp <= '".(date('Y-m-d H:i:s',strtotime($this->timestamp_) + 60 * 60))."' |
| 569 | AND kll.kll_timestamp >= |
| 570 | '".(date('Y-m-d H:i:s',strtotime($this->timestamp_) - 60 * 60))."' |
| 571 | AND kll.kll_system_id = ".$this->solarsystem_->getID(); |
| 572 | if(ALLIANCE_ID <>0) |
| 573 | { |
| 574 | $sql .=" AND EXISTS (SELECT 1 FROM kb3_inv_detail ind". |
| 575 | " WHERE ( ind.ind_all_id = ".ALLIANCE_ID." AND kll.kll_id = ind.ind_kll_id". |
| 576 | " AND ind.ind_all_id != kll.kll_all_id ) )"; |
| 577 | } |
| 578 | else if(CORP_ID <>0) |
| 579 | { |
| 580 | $sql .=" AND EXISTS (SELECT 1 FROM kb3_inv_detail". |
| 581 | " WHERE ( ind_crp_id = ".CORP_ID." AND kll.kll_id = ind_kll_id". |
| 582 | " AND ind_crp_id != kll.kll_crp_id ) ) "; |
| 583 | } |
| 584 | else if(PILOT_ID <>0) |
| 585 | { |
| 586 | $sql .=" AND EXISTS (SELECT 1 FROM kb3_inv_detail". |
| 587 | " WHERE ( ind_plt_id = ".PILOT_ID." AND kll.kll_id = ind_kll_id". |
| 588 | " AND ind_plt_id != kll.kll_victim_id ) ) "; |
| 589 | } |
| 590 | $sql .= "-- related kill count"; |
| 591 | $qry = new DBQuery(); |
| 592 | if(!$qry->execute($sql)) return 0; |
| 593 | $res=$qry->getRow(); |
| 594 | $this->relatedkillcount_ = $res['kills']; |
| 595 | return $this->relatedkillcount_; |
| 596 | } |
| 597 | |
| 598 | //Count all losses by board owner related to this kill |
| 599 | function relatedLossCount() |
| 600 | { |
| 601 | if($this->relatedlosscount_) return $this->relatedlosscount_; |
| 602 | $sql="SELECT count(kll.kll_id) as losses FROM kb3_kills kll "; |
| 603 | $sql.="WHERE kll.kll_system_id = ".$this->solarsystem_->getID(). |
| 604 | " AND kll.kll_timestamp <= '". |
| 605 | (date('Y-m-d H:i:s',strtotime($this->timestamp_) + 60 * 60)). |
| 606 | "' AND kll.kll_timestamp >= '". |
| 607 | (date('Y-m-d H:i:s',strtotime($this->timestamp_) - 60 * 60))."'"; |
| 608 | if(ALLIANCE_ID <>0) |
| 609 | { |
| 610 | $sql .="AND kll.kll_all_id = ".ALLIANCE_ID. |
| 611 | " AND EXISTS (SELECT 1 FROM kb3_inv_detail ind". |
| 612 | " WHERE ( kll.kll_id = ind.ind_kll_id". |
| 613 | " AND ind.ind_all_id != ".ALLIANCE_ID." ) ) "; |
| 614 | } |
| 615 | else if(CORP_ID <>0) |
| 616 | { |
| 617 | $sql .="AND kll_crp_id = ".CORP_ID." AND". |
| 618 | " EXISTS (SELECT 1 FROM kb3_inv_detail". |
| 619 | " WHERE ( kll.kll_id = ind_kll_id". |
| 620 | " AND ind_crp_id != ".CORP_ID." ) ) "; |
| 621 | } |
| 622 | else if(PILOT_ID <>0) |
| 623 | { |
| 624 | $sql .="AND kll_victim_id = ".PILOT_ID." AND". |
| 625 | " EXISTS (SELECT 1 FROM kb3_inv_detail". |
| 626 | " WHERE ( kll.kll_id = ind_kll_id". |
| 627 | " AND ind_plt_id != ".PILOT_ID." ) ) "; |
| 628 | } |
| 629 | $sql .= "-- related loss count"; |
| 630 | $qry = new DBQuery(); |
| 631 | if(!$qry->execute($sql)) return 0; |
| 632 | $res=$qry->getRow(); |
| 633 | $this->relatedlosscount_ = $res['losses']; |
| 634 | return $this->relatedlosscount_; |
| 635 | } |
| 636 | |
| 637 | function countComment($kll_id) |
| 638 | { |
| 639 | if(isset($this->commentcount_)) return $this->commentcount_; |
| 640 | $qry = new DBQuery(); |
| 641 | $sql = "SELECT count(id) as comments FROM kb3_comments WHERE kll_id = '$kll_id'"; |
| 642 | // return 0 if query fails. May be incorrect but is harmless here |
| 643 | if(!$qry->execute($sql)) return 0; |
| 644 | $result = $qry->getRow(); |
| 645 | $this->commentcount_ = $result['comments']; |
| 646 | return $result['comments']; |
| 647 | } |
| 648 | |
| 649 | // Set the number of comments - used by killlist |
| 650 | function setCommentCount($comcount = 0) |
| 651 | { |
| 652 | $this->commentcount_ = $comcount; |
| 653 | } |
| 654 | |
| 655 | function setID($id) |
| 656 | { |
| 657 | $this->id_ = $id; |
| 658 | } |
| 659 | |
| 660 | function setTimeStamp($timestamp) |
| 661 | { |
| 662 | $this->timestamp_ = $timestamp; |
| 663 | } |
| 664 | |
| 665 | function setSolarSystem($solarsystem) |
| 666 | { |
| 667 | $this->solarsystem_ = $solarsystem; |
| 668 | } |
| 669 | |
| 670 | function setSolarSystemName($solarsystemname) |
| 671 | { |
| 672 | $this->solarsystemname_ = $solarsystemname; |
| 673 | } |
| 674 | |
| 675 | function setSolarSystemSecurity($solarsystemsecurity) |
| 676 | { |
| 677 | $this->solarsystemsecurity_ = $solarsystemsecurity; |
| 678 | } |
| 679 | |
| 680 | function setVictim($victim) |
| 681 | { |
| 682 | $this->victim_ = $victim; |
| 683 | } |
| 684 | |
| 685 | function setVictimID($victimid) |
| 686 | { |
| 687 | $this->victimid_ = $victimid; |
| 688 | } |
| 689 | |
| 690 | function setVictimName($victimname) |
| 691 | { |
| 692 | $this->victimname_ = $victimname; |
| 693 | } |
| 694 | |
| 695 | function setVictimCorpID($victimcorpid) |
| 696 | { |
| 697 | $this->victimcorpid_ = $victimcorpid; |
| 698 | } |
| 699 | |
| 700 | function setVictimCorpName($victimcorpname) |
| 701 | { |
| 702 | $this->victimcorpname_ = $victimcorpname; |
| 703 | } |
| 704 | |
| 705 | function setVictimAllianceID($victimallianceid) |
| 706 | { |
| 707 | $this->victimallianceid_ = $victimallianceid; |
| 708 | } |
| 709 | |
| 710 | function setVictimAllianceName($victimalliancename) |
| 711 | { |
| 712 | $this->victimalliancename_ = $victimalliancename; |
| 713 | } |
| 714 | |
| 715 | function setVictimShip($victimship) |
| 716 | { |
| 717 | $this->victimship_ = $victimship; |
| 718 | } |
| 719 | |
| 720 | function setVictimShipName($victimshipname) |
| 721 | { |
| 722 | $this->victimshipname_ = $victimshipname; |
| 723 | } |
| 724 | |
| 725 | function setVictimShipExternalID($victimshipexternalid) |
| 726 | { |
| 727 | $this->victimshipexternalid_ = $victimshipexternalid; |
| 728 | } |
| 729 | |
| 730 | function setVictimShipClassName($victimshipclassname) |
| 731 | { |
| 732 | $this->victimshipclassname_ = $victimshipclassname; |
| 733 | } |
| 734 | |
| 735 | function setVictimShipValue($victimshipvalue) |
| 736 | { |
| 737 | $this->victimshipvalue_ = $victimshipvalue; |
| 738 | } |
| 739 | |
| 740 | function setFBPilotID($fbpilotid) |
| 741 | { |
| 742 | $this->fbpilotid_ = $fbpilotid; |
| 743 | } |
| 744 | |
| 745 | function setFBPilotName($fbpilotname) |
| 746 | { |
| 747 | $npc = strpos($fbpilotname, "#"); |
667 | | { |
668 | | $name = explode("#", $fbpilotname); |
669 | | $plt = new Item($name[2]); |
670 | | $this->fbpilotname_ = $plt->getName(); |
671 | | } |
672 | | } |
673 | | |
674 | | function setFBCorpID($fbcorpid) |
675 | | { |
676 | | $this->fbcorpid_ = $fbcorpid; |
677 | | } |
678 | | |
679 | | function setFBCorpName($fbcorpname) |
680 | | { |
681 | | $this->fbcorpname_ = $fbcorpname; |
682 | | } |
683 | | |
684 | | function setFBAllianceID($fballianceid) |
685 | | { |
686 | | $this->fballianceid_ = $fballianceid; |
687 | | } |
688 | | |
689 | | function setFBAllianceName($fballiancename) |
690 | | { |
691 | | $this->fballiancename_ = $fballiancename; |
692 | | } |
693 | | function setKillPoints($killpoints) |
694 | | { |
695 | | $this->killpoints_ = $killpoints; |
696 | | } |
697 | | |
698 | | function calculateKillPoints() |
699 | | { |
700 | | $ship = $this->getVictimShip(); |
701 | | $shipclass = $ship->getClass(); |
702 | | $vicpoints = $shipclass->getPoints(); |
703 | | $maxpoints = round($vicpoints * 1.2); |
704 | | |
705 | | foreach ($this->involvedparties_ as $inv) |
706 | | { |
707 | | $shipinv = $inv->getShip(); |
708 | | $shipclassinv = $shipinv->getClass(); |
709 | | $invpoints += $shipclassinv->getPoints(); |
710 | | } |
711 | | |
712 | | $gankfactor = $vicpoints / ($vicpoints + $invpoints); |
713 | | $points = ceil($vicpoints * ($gankfactor / 0.75)); |
714 | | |
715 | | if ($points > $maxpoints) $points = $maxpoints; |
716 | | |
717 | | $points = round($points, 0); |
718 | | return $points; |
719 | | } |
720 | | |
721 | | function add($id = null) |
722 | | { |
723 | | if (!$this->solarsystem_->getID()) |
724 | | { |
725 | | echo 'INTERNAL ERROR; SOLARSYSTEM NOT FOUND; PLEASE CONTACT A DEV WITH THIS MESSAGE<br/>'; |
726 | | var_dump($this->solarsystem_); |
727 | | var_dump($this->solarsystemname_); |
728 | | return 0; |
729 | | } |
730 | | |
731 | | $dupe = $this->getDupe(true); |
732 | | if ($dupe == 0) |
733 | | { |
734 | | $this->realadd(); |
735 | | } |
736 | | elseif (config::get('readd_dupes')) |
737 | | { |
738 | | $this->dupeid_ = $dupe; |
739 | | $this->id_ = $dupe; |
740 | | $this->remove(false); |
741 | | $this->realadd($dupe); |
742 | | $this->id_ = -1; |
743 | | } |
744 | | else |
745 | | { |
746 | | $this->dupeid_ = $dupe; |
747 | | $this->id_ = -1; |
748 | | } |
749 | | return $this->id_; |
750 | | } |
751 | | |
752 | | function realadd($id = null) |
753 | | { |
754 | | // if ( $this->timestamp_ == "" || !$this->victimid_ || !$this->victimship_->getID() || !$this->solarsystem_->getID() || |
755 | | // !$this->victimallianceid_ || !$this->victimcorpid_ || !$this->getFBAllianceID() || !$this->getFBCorpID() || |
756 | | // !$this->getFBPilotID() ) |
757 | | // return 0; |
758 | | if ($id == null) |
759 | | { |
760 | | $qid = 'null'; |
761 | | } |
762 | | else |
763 | | { |
764 | | $qid = $id; |
765 | | } |
766 | | if (!$this->dmgtaken) |
767 | | { |
768 | | $this->dmgtaken = 0; |
769 | | } |
770 | | |
771 | | $qry = new DBQuery(); |
772 | | $sql = "INSERT INTO kb3_kills |
773 | | (kll_id , kll_timestamp , kll_victim_id , kll_all_id , kll_crp_id , kll_ship_id , kll_system_id , kll_fb_all_id , kll_fb_crp_id , kll_fb_plt_id , kll_points , kll_dmgtaken) |
774 | | VALUES (".$qid.", |
775 | | date_format('".$this->timestamp_."', '%Y.%m.%d %H:%i:%s'), |
776 | | ".$this->victimid_.", |
777 | | ".$this->victimallianceid_.", |
778 | | ".$this->victimcorpid_.", |
779 | | ".$this->victimship_->getID().", |
780 | | ".$this->solarsystem_->getID().", |
781 | | ".$this->getFBAllianceID().", |
782 | | ".$this->getFBCorpID().", |
783 | | ".$this->getFBPilotID().", |
784 | | ".$this->calculateKillPoints().", |
785 | | ".$this->dmgtaken." )"; |
786 | | $qry->execute($sql); |
787 | | |
788 | | if ($id) |
789 | | { |
790 | | $this->id_ = $id; |
791 | | } |
792 | | else |
793 | | { |
794 | | $this->id_ = $qry->getInsertID(); |
795 | | } |
796 | | |
797 | | // involved |
798 | | $order = 0; |
799 | | $invall = array(); |
800 | | $invcrp = array(); |
801 | | $invplt = array(); |
802 | | foreach ($this->involvedparties_ as $inv) |
803 | | { |
804 | | $ship = $inv->getShip(); |
805 | | $weapon = $inv->getWeapon(); |
806 | | if (!$inv->getPilotID() || $inv->getSecStatus() == "" || !$inv->getAllianceID() || !$inv->getCorpID() || !$ship->getID() || !$weapon->getID()) |
807 | | { |
808 | | $this->remove(); |
809 | | return 0; |
810 | | } |
811 | | |
812 | | if (!$inv->dmgdone_) |
813 | | { |
814 | | $inv->dmgdone_ = 0; |
815 | | } |
816 | | |
817 | | $sql = "insert into kb3_inv_detail |
818 | | (ind_kll_id, ind_plt_id, ind_sec_status, ind_all_id, ind_crp_id, ind_shp_id, ind_wep_id, ind_order, ind_dmgdone ) |
819 | | values ( ".$this->getID().", ".$inv->getPilotID().", '".$inv->getSecStatus()."', " |
820 | | .$inv->getAllianceID().", ".$inv->getCorpID().", ".$ship->getID().", " |
821 | | .$weapon->getID().", ".$order++.", ".$inv->dmgdone_.")"; |
822 | | $qry->execute($sql) or die($qry->getErrorMsg()); |
823 | | |
824 | | if (!in_array($inv->getAllianceID(), $invall) && $inv->getAllianceID() != 14) |
825 | | { |
826 | | array_push($invall, $inv->getAllianceID()); |
827 | | $qry->execute("insert into kb3_inv_all (ina_kll_id, ina_all_id) values ( ".$this->getID().", ".$inv->getAllianceID()." )") or die($qry->getErrorMsg()); |
828 | | } |
829 | | if (!in_array($inv->getCorpID(), $invcrp)) |
830 | | { |
831 | | array_push($invcrp, $inv->getCorpID()); |
832 | | $qry->execute("insert into kb3_inv_crp (inc_kll_id, inc_crp_id) values ( ".$this->getID().", ".$inv->getCorpID()." )") or die($qry->getErrorMsg()); |
833 | | } |
834 | | if (!in_array($inv->getPilotID(), $invplt)) |
835 | | { |
836 | | array_push($invplt, $inv->getPilotID()); |
837 | | $qry->execute("insert into kb3_inv_plt (inp_kll_id, inp_plt_id) values ( ".$this->getID().", ".$inv->getPilotID()." )") or die($qry->getErrorMsg()); |
838 | | } |
839 | | } |
840 | | |
841 | | // destroyed |
842 | | foreach ($this->destroyeditems_ as $dest) |
843 | | { |
844 | | $item = $dest->getItem(); |
845 | | $loc_id = $dest->getLocationID(); |
846 | | if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) |
847 | | { |
848 | | trigger_error('error with destroyed item.', E_USER_WARNING); |
849 | | var_dump($dest);exit; |
850 | | continue; |
851 | | } |
852 | | |
853 | | $sql = "insert into kb3_items_destroyed (itd_kll_id, itd_itm_id, itd_quantity, itd_itl_id) |
854 | | values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " |
855 | | .$loc_id." )"; |
856 | | $qry->execute($sql); |
857 | | } |
858 | | |
859 | | // dropped |
860 | | foreach ($this->droppeditems_ as $dest) |
861 | | { |
862 | | $item = $dest->getItem(); |
863 | | $loc_id = $dest->getLocationID(); |
864 | | if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) |
865 | | { |
866 | | trigger_error('error with dropped item.', E_USER_WARNING); |
867 | | var_dump($dest);exit; |
868 | | continue; |
869 | | } |
870 | | |
871 | | $sql = "insert into kb3_items_dropped (itd_kll_id, itd_itm_id, itd_quantity, itd_itl_id) |
872 | | values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " |
873 | | .$loc_id." )"; |
874 | | $qry->execute($sql); |
875 | | } |
876 | | |
877 | | // call the event that we added this mail |
878 | | event::call('killmail_added', $this); |
879 | | return $this->id_; |
880 | | } |
881 | | |
882 | | function remove($delcomments = true) |
883 | | { |
884 | | if (!$this->id_) |
885 | | return; |
886 | | |
887 | | event::call('killmail_delete', $this); |
888 | | |
889 | | $qry = new DBQuery(); |
890 | | $qry->execute("delete from kb3_kills where kll_id = ".$this->id_); |
891 | | $qry->execute("delete from kb3_inv_detail where ind_kll_id = ".$this->id_); |
892 | | $qry->execute("delete from kb3_inv_all where ina_kll_id = ".$this->id_); |
893 | | $qry->execute("delete from kb3_inv_crp where inc_kll_id = ".$this->id_); |
894 | | $qry->execute("delete from kb3_inv_plt where inp_kll_id = ".$this->id_); |
895 | | $qry->execute("delete from kb3_items_destroyed where itd_kll_id = ".$this->id_); |
896 | | $qry->execute("delete from kb3_items_dropped where itd_kll_id = ".$this->id_); |
897 | | if ($delcomments) |
898 | | { |
899 | | $qry->execute("delete from kb3_comments where kll_id = ".$this->id_); |
900 | | } |
901 | | } |
902 | | |
903 | | function addInvolvedParty($involved) |
904 | | { |
905 | | array_push($this->involvedparties_, $involved); |
906 | | } |
907 | | |
908 | | function addDestroyedItem($destroyed) |
909 | | { |
910 | | array_push($this->destroyeditems_, $destroyed); |
911 | | } |
912 | | |
913 | | function addDroppedItem($dropped) |
914 | | { |
915 | | array_push($this->droppeditems_, $dropped); |
916 | | } |
| 753 | { |
| 754 | $name = explode("#", $fbpilotname); |
| 755 | $plt = new Item($name[2]); |
| 756 | $this->fbpilotname_ = $plt->getName(); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | function setFBCorpID($fbcorpid) |
| 761 | { |
| 762 | $this->fbcorpid_ = $fbcorpid; |
| 763 | } |
| 764 | |
| 765 | function setFBCorpName($fbcorpname) |
| 766 | { |
| 767 | $this->fbcorpname_ = $fbcorpname; |
| 768 | } |
| 769 | |
| 770 | function setFBAllianceID($fballianceid) |
| 771 | { |
| 772 | $this->fballianceid_ = $fballianceid; |
| 773 | } |
| 774 | |
| 775 | function setFBAllianceName($fballiancename) |
| 776 | { |
| 777 | $this->fballiancename_ = $fballiancename; |
| 778 | } |
| 779 | function setKillPoints($killpoints) |
| 780 | { |
| 781 | $this->killpoints_ = $killpoints; |
| 782 | } |
| 783 | |
| 784 | function calculateISKLoss() |
| 785 | { |
| 786 | $value = 0; |
| 787 | foreach($this->destroyeditems_ as $itd) |
| 788 | { |
| 789 | $value += $itd->getValue() * $itd->getQuantity(); |
| 790 | } |
| 791 | $value += $this->getVictimShip()->getPrice(); |
| 792 | $this->iskloss_ = $value; |
| 793 | return $value; |
| 794 | } |
| 795 | function calculateKillPoints() |
| 796 | { |
| 797 | $ship = $this->getVictimShip(); |
| 798 | $shipclass = $ship->getClass(); |
| 799 | $vicpoints = $shipclass->getPoints(); |
| 800 | $maxpoints = round($vicpoints * 1.2); |
| 801 | |
| 802 | foreach ($this->involvedparties_ as $inv) |
| 803 | { |
| 804 | $shipinv = $inv->getShip(); |
| 805 | $shipclassinv = $shipinv->getClass(); |
| 806 | $invpoints += $shipclassinv->getPoints(); |
| 807 | } |
| 808 | |
| 809 | $gankfactor = $vicpoints / ($vicpoints + $invpoints); |
| 810 | $points = ceil($vicpoints * ($gankfactor / 0.75)); |
| 811 | |
| 812 | if ($points > $maxpoints) $points = $maxpoints; |
| 813 | |
| 814 | $points = round($points, 0); |
| 815 | return $points; |
| 816 | } |
| 817 | |
| 818 | function add($id = null) |
| 819 | { |
| 820 | if (!$this->solarsystem_->getID()) |
| 821 | { |
| 822 | echo 'INTERNAL ERROR; SOLARSYSTEM NOT FOUND; PLEASE CONTACT A DEV WITH THIS MESSAGE<br/>'; |
| 823 | var_dump($this->solarsystem_); |
| 824 | var_dump($this->solarsystemname_); |
| 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | $dupe = $this->getDupe(true); |
| 829 | if ($dupe == 0) |
| 830 | { |
| 831 | $this->realadd(); |
| 832 | } |
| 833 | elseif (config::get('readd_dupes')) |
| 834 | { |
| 835 | $this->dupeid_ = $dupe; |
| 836 | $this->id_ = $dupe; |
| 837 | $this->remove(false); |
| 838 | $this->realadd($dupe); |
| 839 | $this->id_ = -1; |
| 840 | } |
| 841 | else |
| 842 | { |
| 843 | $this->dupeid_ = $dupe; |
| 844 | $this->id_ = -1; |
| 845 | } |
| 846 | return $this->id_; |
| 847 | } |
| 848 | |
| 849 | function realadd($id = null) |
| 850 | { |
| 851 | if ( $this->timestamp_ == "" || !$this->victimid_ || !$this->victimship_->getID() || !$this->solarsystem_->getID() || |
| 852 | !$this->victimallianceid_ || !$this->victimcorpid_ || !$this->getFBAllianceID() || !$this->getFBCorpID() || |
| 853 | !$this->getFBPilotID() ) |
| 854 | return 0; |
| 855 | if ($id == null) |
| 856 | { |
| 857 | $qid = 'null'; |
| 858 | } |
| 859 | else |
| 860 | { |
| 861 | $qid = $id; |
| 862 | } |
| 863 | if (!$this->dmgtaken) |
| 864 | { |
| 865 | $this->dmgtaken = 0; |
| 866 | } |
| 867 | |
| 868 | $qry = new DBQuery(); |
| 869 | $sql = "INSERT INTO kb3_kills |
| 870 | (kll_id , kll_timestamp , kll_victim_id , kll_all_id , kll_crp_id , kll_ship_id , kll_system_id , kll_fb_plt_id , kll_points , kll_dmgtaken, kll_isk_loss) |
| 871 | VALUES (".$qid.", |
| 872 | date_format('".$this->timestamp_."', '%Y.%m.%d %H:%i:%s'), |
| 873 | ".$this->victimid_.", |
| 874 | ".$this->victimallianceid_.", |
| 875 | ".$this->victimcorpid_.", |
| 876 | ".$this->victimship_->getID().", |
| 877 | ".$this->solarsystem_->getID().", |
| 878 | ".$this->getFBPilotID().", |
| 879 | ".$this->calculateKillPoints().", |
| 880 | ".$this->dmgtaken.", |
| 881 | ".$this->calculateISKLoss()." )"; |
| 882 | $qry->autocommit(false); |
| 883 | if(!$qry->execute($sql)) |
| 884 | { |
| 885 | $qry->rollback(); |
| 886 | $qry->autocommit(true); |
| 887 | //If the query is causing errors here there's no point going on |
| 888 | return false; |
| 889 | } |
| 890 | |
| 891 | if ($id) |
| 892 | { |
| 893 | $this->id_ = $id; |
| 894 | } |
| 895 | else |
| 896 | { |
| 897 | $this->id_ = $qry->getInsertID(); |
| 898 | } |
| 899 | if(!$this->id_) |
| 900 | { |
| 901 | $qry->rollback(); |
| 902 | $qry->autocommit(true); |
| 903 | return false; |
| 904 | } |
| 905 | // involved |
| 906 | $order = 0; |
| 907 | $invall = array(); |
| 908 | $invcrp = array(); |
| 909 | $invplt = array(); |
| 910 | $involveddsql = 'insert into kb3_inv_detail |
| 911 | (ind_kll_id, ind_plt_id, ind_sec_status, ind_all_id, ind_crp_id, ind_shp_id, ind_wep_id, ind_order, ind_dmgdone ) |
| 912 | values '; |
| 913 | $notfirstd = false; |
| 914 | foreach ($this->involvedparties_ as $inv) |
| 915 | { |
| 916 | $ship = $inv->getShip(); |
| 917 | $weapon = $inv->getWeapon(); |
| 918 | if (!$inv->getPilotID() || $inv->getSecStatus() == "" || !$inv->getAllianceID() || !$inv->getCorpID() || !$ship->getID() || !$weapon->getID()) |
| 919 | { |
| 920 | $this->remove(); |
| 921 | return 0; |
| 922 | } |
| 923 | |
| 924 | if (!$inv->dmgdone_) |
| 925 | { |
| 926 | $inv->dmgdone_ = 0; |
| 927 | } |
| 928 | if($notfirstd) $involveddsql .= ", "; |
| 929 | $involveddsql .= "( ".$this->getID().", ".$inv->getPilotID().", '".$inv->getSecStatus()."', " |
| 930 | .$inv->getAllianceID().", ".$inv->getCorpID().", ".$ship->getID().", " |
| 931 | .$weapon->getID().", ".$order++.", ".$inv->dmgdone_.")"; |
| 932 | $notfirstd = true; |
| 933 | |
| 934 | } |
| 935 | if($notfirstd && !$qry->execute($involveddsql)) |
| 936 | { |
| 937 | $qry->rollback(); |
| 938 | $qry->autocommit(true); |
| 939 | return false; |
| 940 | } |
| 941 | |
| 942 | // destroyed |
| 943 | $notfirstitd=false; |
| 944 | $itdsql = "insert into kb3_items_destroyed (itd_kll_id, itd_itm_id, itd_quantity, itd_itl_id) values "; |
| 945 | foreach ($this->destroyeditems_ as $dest) |
| 946 | { |
| 947 | $item = $dest->getItem(); |
| 948 | $loc_id = $dest->getLocationID(); |
| 949 | if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) |
| 950 | { |
| 951 | trigger_error('error with destroyed item.', E_USER_WARNING); |
| 952 | var_dump($dest);exit; |
| 953 | continue; |
| 954 | } |
| 955 | |
| 956 | if($notfirstitd) $itdsql .= ", "; |
| 957 | $itdsql .= "( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", ".$loc_id." )"; |
| 958 | $notfirstitd = true; |
| 959 | } |
| 960 | if($notfirstitd &&!$qry->execute($itdsql)) |
| 961 | { |
| 962 | $qry->rollback(); |
| 963 | $qry->autocommit(true); |
| 964 | return false; |
| 965 | } |
| 966 | |
| 967 | // dropped |
| 968 | $notfirstitd=false; |
| 969 | $itdsql = "insert into kb3_items_dropped (itd_kll_id, itd_itm_id, itd_quantity, itd_itl_id) values "; |
| 970 | foreach ($this->droppeditems_ as $dest) |
| 971 | { |
| 972 | $item = $dest->getItem(); |
| 973 | $loc_id = $dest->getLocationID(); |
| 974 | if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) |
| 975 | { |
| 976 | trigger_error('error with dropped item.', E_USER_WARNING); |
| 977 | var_dump($dest);exit; |
| 978 | continue; |
| 979 | } |
| 980 | |
| 981 | if($notfirstitd) $itdsql .= ", "; |
| 982 | $itdsql .= "( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", ".$loc_id." )"; |
| 983 | $notfirstitd = true; |
| 984 | } |
| 985 | if($notfirstitd &&!$qry->execute($itdsql)) |
| 986 | { |
| 987 | $qry->rollback(); |
| 988 | $qry->autocommit(true); |
| 989 | return false; |
| 990 | } |
| 991 | $qry->autocommit(true); |
| 992 | // call the event that we added this mail |
| 993 | event::call('killmail_added', $this); |
| 994 | return $this->id_; |
| 995 | } |
| 996 | |
| 997 | function remove($delcomments = true) |
| 998 | { |
| 999 | if (!$this->id_) |
| 1000 | return; |
| 1001 | |
| 1002 | event::call('killmail_delete', $this); |
| 1003 | |
| 1004 | $qry = new DBQuery(); |
| 1005 | $qry->execute("delete from kb3_kills where kll_id = ".$this->id_); |
| 1006 | $qry->execute("delete from kb3_inv_detail where ind_kll_id = ".$this->id_); |
| 1007 | // $qry->execute("delete from kb3_inv_all where ina_kll_id = ".$this->id_); |
| 1008 | // $qry->execute("delete from kb3_inv_crp where inc_kll_id = ".$this->id_); |
| 1009 | // $qry->execute("delete from kb3_inv_plt where inp_kll_id = ".$this->id_); |
| 1010 | $qry->execute("delete from kb3_items_destroyed where itd_kll_id = ".$this->id_); |
| 1011 | $qry->execute("delete from kb3_items_dropped where itd_kll_id = ".$this->id_); |
| 1012 | // Don't remove comments when readding a kill |
| 1013 | if ($delcomments) |
| 1014 | { |
| 1015 | $qry->execute("delete from kb3_comments where kll_id = ".$this->id_); |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | function addInvolvedParty($involved) |
| 1020 | { |
| 1021 | array_push($this->involvedparties_, $involved); |
| 1022 | } |
| 1023 | |
| 1024 | function addDestroyedItem($destroyed) |
| 1025 | { |
| 1026 | array_push($this->destroyeditems_, $destroyed); |
| 1027 | } |
| 1028 | |
| 1029 | function addDroppedItem($dropped) |
| 1030 | { |
| 1031 | array_push($this->droppeditems_, $dropped); |
| 1032 | } |