1 | <?php |
---|
2 | require_once('common/includes/class.item.php'); |
---|
3 | require_once('common/includes/class.corp.php'); |
---|
4 | require_once('common/includes/class.alliance.php'); |
---|
5 | require_once('common/includes/class.ship.php'); |
---|
6 | require_once('common/includes/class.system.php'); |
---|
7 | require_once('common/includes/class.pilot.php'); |
---|
8 | require_once('common/includes/class.killlist.php'); |
---|
9 | |
---|
10 | class Kill |
---|
11 | { |
---|
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 | $this->execQuery(); |
---|
197 | if ($this->isClassified()) |
---|
198 | { |
---|
199 | return 'Killmail not yet available, try again in '.round($this->getClassifiedTime()/3600, 2).' hrs.'; |
---|
200 | } |
---|
201 | |
---|
202 | $mail .= substr(str_replace('-', '.' , $this->getTimeStamp()), 0, 16)."\r\n\r\n"; |
---|
203 | $mail .= "Victim: ".$this->getVictimName()."\r\n"; |
---|
204 | $mail .= "Corp: ".$this->getVictimCorpName()."\r\n"; |
---|
205 | $mail .= "Alliance: ".$this->getVictimAllianceName()."\r\n"; |
---|
206 | $mail .= "Faction: NONE\r\n"; |
---|
207 | $ship = $this->getVictimShip(); |
---|
208 | $mail .= "Destroyed: ".$ship->getName()."\r\n"; |
---|
209 | $system = $this->getSystem(); |
---|
210 | $mail .= "System: ".$system->getName()."\r\n"; |
---|
211 | $mail .= "Security: ".$system->getSecurity(true)."\r\n"; |
---|
212 | $mail .= "Damage Taken: ".$this->VictimDamageTaken."\r\n\r\n"; |
---|
213 | $mail .= "Involved parties:\r\n\r\n"; |
---|
214 | |
---|
215 | foreach ($this->involvedparties_ as $inv) |
---|
216 | { |
---|
217 | $pilot = new Pilot($inv->getPilotID()); |
---|
218 | $corp = new Corporation($inv->getCorpID()); |
---|
219 | $alliance = new Alliance($inv->getAllianceID()); |
---|
220 | |
---|
221 | $weapon = $inv->getWeapon(); |
---|
222 | $ship = $inv->getShip(); |
---|
223 | if ($pilot->getName() == $weapon->getName()) |
---|
224 | { |
---|
225 | $name = $pilot->getName()." / ".$corp->getName(); |
---|
226 | } |
---|
227 | else |
---|
228 | { |
---|
229 | $name = $pilot->getName(); |
---|
230 | } |
---|
231 | |
---|
232 | $mail .= "Name: ".$name; |
---|
233 | if ($pilot->getID() == $this->getFBPilotID()) |
---|
234 | { |
---|
235 | $mail .= " (laid the final blow)"; |
---|
236 | } |
---|
237 | $mail .= "\r\n"; |
---|
238 | |
---|
239 | if ($pilot->getName() != $weapon->getName()) |
---|
240 | { |
---|
241 | $mail .= "Security: ".$inv->getSecStatus()."\r\n"; |
---|
242 | $mail .= "Corp: ".$corp->getName()."\r\n"; |
---|
243 | $mail .= "Alliance: ".$alliance->getName()."\r\n"; |
---|
244 | $mail .= "Faction: NONE\r\n"; |
---|
245 | $mail .= "Ship: ".$ship->getName()."\r\n"; |
---|
246 | $mail .= "Weapon: ".$weapon->getName()."\r\n"; |
---|
247 | $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; |
---|
248 | } |
---|
249 | else |
---|
250 | { |
---|
251 | $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; |
---|
252 | } |
---|
253 | $mail .= "\r\n"; |
---|
254 | } |
---|
255 | |
---|
256 | if (count($this->destroyeditems_) > 0) |
---|
257 | { |
---|
258 | $mail .= "\r\nDestroyed items:\r\n\r\n"; |
---|
259 | |
---|
260 | foreach($this->destroyeditems_ as $destroyed) |
---|
261 | { |
---|
262 | $item = $destroyed->getItem(); |
---|
263 | $mail .= $item->getName(); |
---|
264 | if ($destroyed->getQuantity() > 1) |
---|
265 | { |
---|
266 | // if the option is enabled and the item is fitted then split it up |
---|
267 | // this is aworkaround for the lazy parser of griefwatch |
---|
268 | if (config::get('kill_splitfit') && $destroyed->getQuantity() < 9 && ($destroyed->getLocationID() == 1 |
---|
269 | || $destroyed->getLocationID() == 2 || $destroyed->getLocationID() == 3)) |
---|
270 | { |
---|
271 | for ($i = $destroyed->getQuantity(); $i > 1; $i--) |
---|
272 | { |
---|
273 | $mail .= "\r\n".$item->getName(); |
---|
274 | } |
---|
275 | |
---|
276 | } |
---|
277 | else |
---|
278 | { |
---|
279 | $mail .= ", Qty: ".$destroyed->getQuantity(); |
---|
280 | } |
---|
281 | } |
---|
282 | if ($destroyed->getLocationID() == 4) // cargo |
---|
283 | $mail .= " (Cargo)"; |
---|
284 | if ($destroyed->getLocationID() == 6) // drone |
---|
285 | $mail .= " (Drone Bay)"; |
---|
286 | $mail .= "\r\n"; |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | if (count($this->droppeditems_) > 0) |
---|
291 | { |
---|
292 | $mail .= "\r\nDropped items:\r\n\r\n"; |
---|
293 | |
---|
294 | foreach($this->droppeditems_ as $dropped) |
---|
295 | { |
---|
296 | $item = $dropped->getItem(); |
---|
297 | $mail .= $item->getName(); |
---|
298 | if ($dropped->getQuantity() > 1) |
---|
299 | { |
---|
300 | // if the option is enabled and the item is fitted then split it up |
---|
301 | // this is aworkaround for the lazy parser of griefwatch |
---|
302 | if (config::get('kill_splitfit') && $dropped->getQuantity() < 9 && ($dropped->getLocationID() == 1 |
---|
303 | || $dropped->getLocationID() == 2 || $dropped->getLocationID() == 3)) |
---|
304 | { |
---|
305 | for ($i = $dropped->getQuantity(); $i > 1; $i--) |
---|
306 | { |
---|
307 | $mail .= "\r\n".$item->getName(); |
---|
308 | } |
---|
309 | |
---|
310 | } |
---|
311 | else |
---|
312 | { |
---|
313 | $mail .= ", Qty: ".$dropped->getQuantity(); |
---|
314 | } |
---|
315 | } |
---|
316 | if ($dropped->getLocationID() == 4) // cargo |
---|
317 | $mail .= " (Cargo)"; |
---|
318 | if ($dropped->getLocationID() == 6) // drone |
---|
319 | $mail .= " (Drone Bay)"; |
---|
320 | $mail .= "\r\n"; |
---|
321 | } |
---|
322 | } |
---|
323 | |
---|
324 | return $mail; |
---|
325 | } |
---|
326 | |
---|
327 | function getDupe($checkonly = false) |
---|
328 | { |
---|
329 | if (!$checkonly) |
---|
330 | { |
---|
331 | $this->execQuery(); |
---|
332 | } |
---|
333 | $dupe = 0; |
---|
334 | $qry = new DBQuery(); |
---|
335 | if (!$this->getFBPilotID() || !$this->victimid_) |
---|
336 | return 0; |
---|
337 | $qry->execute("select kll_id |
---|
338 | from kb3_kills |
---|
339 | where kll_timestamp <= |
---|
340 | date_add( '".$this->timestamp_."', INTERVAL '5:0' MINUTE_SECOND ) |
---|
341 | and kll_timestamp >= |
---|
342 | date_sub( '".$this->timestamp_."', INTERVAL '5:0' MINUTE_SECOND ) |
---|
343 | and kll_victim_id = ".$this->victimid_." |
---|
344 | and kll_ship_id = ".$this->victimship_->getID()." |
---|
345 | and kll_system_id = ".$this->solarsystem_->getID()." |
---|
346 | and kll_fb_plt_id = ".$this->getFBPilotID()." |
---|
347 | and kll_id != ".$this->id_); |
---|
348 | |
---|
349 | $row = $qry->getRow(); |
---|
350 | if ($row) |
---|
351 | return $row['kll_id']; |
---|
352 | else |
---|
353 | return 0; |
---|
354 | } |
---|
355 | |
---|
356 | function execQuery() |
---|
357 | { |
---|
358 | if (!$this->timestamp_) |
---|
359 | { |
---|
360 | $qry = new DBQuery(); |
---|
361 | |
---|
362 | $this->qry_ = new DBQuery(); |
---|
363 | $this->sql_ = "select kll.kll_id, kll.kll_timestamp, plt.plt_name, |
---|
364 | crp.crp_name, ali.all_name, ali.all_id, kll.kll_ship_id, |
---|
365 | kll.kll_system_id, kll.kll_ship_id, |
---|
366 | kll.kll_victim_id, plt.plt_externalid, |
---|
367 | kll.kll_crp_id, kll.kll_points, |
---|
368 | fbplt.plt_id as fbplt_id, |
---|
369 | fbplt.plt_externalid as fbplt_externalid, |
---|
370 | fbcrp.crp_id as fbcrp_id, |
---|
371 | fbali.all_id as fbali_id, |
---|
372 | fbplt.plt_name as fbplt_name, |
---|
373 | fbcrp.crp_name as fbcrp_name, |
---|
374 | fbali.all_name as fbali_name, |
---|
375 | kll_dmgtaken |
---|
376 | from kb3_kills kll, kb3_pilots plt, kb3_corps crp, |
---|
377 | kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, |
---|
378 | kb3_pilots fbplt |
---|
379 | where kll.kll_id = '".$this->id_."' |
---|
380 | and plt.plt_id = kll.kll_victim_id |
---|
381 | and crp.crp_id = kll.kll_crp_id |
---|
382 | and ali.all_id = kll.kll_all_id |
---|
383 | and fbali.all_id = kll.kll_fb_all_id |
---|
384 | and fbcrp.crp_id = kll.kll_fb_crp_id |
---|
385 | and fbplt.plt_id = kll.kll_fb_plt_id"; |
---|
386 | |
---|
387 | $this->qry_->execute($this->sql_); |
---|
388 | $row = $this->qry_->getRow(); |
---|
389 | if (!$row) |
---|
390 | { |
---|
391 | $this->valid_ = false; |
---|
392 | return false; |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | $this->valid_ = true; |
---|
397 | } |
---|
398 | |
---|
399 | $this->setTimeStamp($row['kll_timestamp']); |
---|
400 | $this->setSolarSystem(new SolarSystem($row['kll_system_id'])); |
---|
401 | $this->setVictimID($row['kll_victim_id']); |
---|
402 | $this->setVictimName($row['plt_name']); |
---|
403 | $this->setVictimCorpID($row['kll_crp_id']); |
---|
404 | $this->setVictimCorpName($row['crp_name']); |
---|
405 | $this->setVictimAllianceID($row['all_id']); |
---|
406 | $this->setVictimAllianceName($row['all_name']); |
---|
407 | $this->setVictimShip(new Ship($row['kll_ship_id'])); |
---|
408 | $this->setFBPilotID($row['fbplt_id']); |
---|
409 | $this->setFBPilotName($row['fbplt_name']); |
---|
410 | $this->setFBCorpID($row['fbcrp_id']); |
---|
411 | $this->setFBCorpName($row['fbcrp_name']); |
---|
412 | $this->setFBAllianceID($row['fbali_id']); |
---|
413 | $this->setFBAllianceName($row['fbali_name']); |
---|
414 | $this->setKillPoints($row['kll_points']); |
---|
415 | $this->plt_ext_ = $row['plt_externalid']; |
---|
416 | $this->fbplt_ext_ = $row['fbplt_externalid']; |
---|
417 | $this->VictimDamageTaken = $row['kll_dmgtaken']; |
---|
418 | |
---|
419 | // involved |
---|
420 | $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, |
---|
421 | ind_shp_id, ind_wep_id, ind_dmgdone |
---|
422 | from kb3_inv_detail |
---|
423 | where ind_kll_id = ".$this->getID()." |
---|
424 | order by ind_order"; |
---|
425 | |
---|
426 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
427 | while ($row = $qry->getRow()) |
---|
428 | { |
---|
429 | $involved = new InvolvedParty($row['ind_plt_id'], |
---|
430 | $row['ind_crp_id'], |
---|
431 | $row['ind_all_id'], |
---|
432 | $row['ind_sec_status'], |
---|
433 | new Ship($row['ind_shp_id']), |
---|
434 | new Item($row['ind_wep_id'])); |
---|
435 | $involved->dmgdone_ = $row['ind_dmgdone']; |
---|
436 | array_push($this->involvedparties_, $involved); |
---|
437 | } |
---|
438 | // destroyed items |
---|
439 | $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, |
---|
440 | itd_itl_id, itl_location |
---|
441 | from kb3_items_destroyed itd |
---|
442 | 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)) |
---|
443 | where itd.itd_kll_id = ".$this->getID()." |
---|
444 | group by itd_itm_id, itd_itl_id |
---|
445 | order by itd.itd_itl_id"; |
---|
446 | $qry->execute($sql); |
---|
447 | while ($row = $qry->getRow()) |
---|
448 | { |
---|
449 | $destroyed = new DestroyedItem(new Item($row['itd_itm_id']), |
---|
450 | $row['itd_quantity'], |
---|
451 | $row['itl_location']); |
---|
452 | array_push($this->destroyeditems_, $destroyed); |
---|
453 | } |
---|
454 | |
---|
455 | // dropped items |
---|
456 | $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, |
---|
457 | itd_itl_id, itl_location |
---|
458 | from kb3_items_dropped itd |
---|
459 | 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)) |
---|
460 | where itd.itd_kll_id = ".$this->getID()." |
---|
461 | group by itd_itm_id, itd_itl_id |
---|
462 | order by itd.itd_itl_id"; |
---|
463 | $qry->execute($sql); |
---|
464 | while ($row = $qry->getRow()) |
---|
465 | { |
---|
466 | $destroyed = new DroppedItem(new Item($row['itd_itm_id']), |
---|
467 | $row['itd_quantity'], |
---|
468 | $row['itl_location']); |
---|
469 | array_push($this->droppeditems_, $destroyed); |
---|
470 | } |
---|
471 | } |
---|
472 | } |
---|
473 | |
---|
474 | function isClassified() |
---|
475 | { |
---|
476 | if (config::get('kill_classified')) |
---|
477 | { |
---|
478 | if (user::role('classified_see')) |
---|
479 | { |
---|
480 | return false; |
---|
481 | } |
---|
482 | |
---|
483 | $offset = config::get('kill_classified')*3600; |
---|
484 | if (config::get('date_gmtime')) |
---|
485 | { |
---|
486 | $time = time()-date('Z'); |
---|
487 | } |
---|
488 | else |
---|
489 | { |
---|
490 | $time = time(); |
---|
491 | } |
---|
492 | if (strtotime($this->timestamp_) > $time-$offset) |
---|
493 | { |
---|
494 | return true; |
---|
495 | } |
---|
496 | } |
---|
497 | return false; |
---|
498 | } |
---|
499 | |
---|
500 | function getClassifiedTime() |
---|
501 | { |
---|
502 | if (config::get('kill_classified')) |
---|
503 | { |
---|
504 | $offset = config::get('kill_classified')*3600; |
---|
505 | if (config::get('date_gmtime')) |
---|
506 | { |
---|
507 | $time = time()-date('Z'); |
---|
508 | } |
---|
509 | else |
---|
510 | { |
---|
511 | $time = time(); |
---|
512 | } |
---|
513 | if (strtotime($this->timestamp_) > $time-$offset) |
---|
514 | { |
---|
515 | return ($offset-$time+strtotime($this->timestamp_)); |
---|
516 | } |
---|
517 | } |
---|
518 | return 0; |
---|
519 | } |
---|
520 | |
---|
521 | function getInvolvedPartyCount() |
---|
522 | { |
---|
523 | $qry = new DBQuery(); |
---|
524 | $qry->execute("select count(inp_kll_id) inv from kb3_inv_plt where inp_kll_id = ". $this->id_); |
---|
525 | $result = $qry->getRow(); |
---|
526 | return $result['inv']; |
---|
527 | } |
---|
528 | |
---|
529 | function exists() |
---|
530 | { |
---|
531 | $this->execQuery(); |
---|
532 | return $this->valid_; |
---|
533 | } |
---|
534 | |
---|
535 | function relatedKillCount() |
---|
536 | { |
---|
537 | $kslist = new KillList(); |
---|
538 | $kslist->setRelated($this->id_); |
---|
539 | involved::load($kslist,'kill'); |
---|
540 | |
---|
541 | return $kslist->getCount(); |
---|
542 | } |
---|
543 | |
---|
544 | function relatedLossCount() |
---|
545 | { |
---|
546 | $lslist = new KillList(); |
---|
547 | $lslist->setRelated($this->id_); |
---|
548 | involved::load($lslist,'loss'); |
---|
549 | |
---|
550 | return $lslist->getCount(); |
---|
551 | } |
---|
552 | |
---|
553 | function countComment($kll_id) |
---|
554 | { |
---|
555 | $qry = new DBQuery(); |
---|
556 | $sql = "SELECT * FROM kb3_comments WHERE kll_id = '$kll_id'"; |
---|
557 | $count = $qry->execute($sql); |
---|
558 | $count = $qry->recordCount(); |
---|
559 | return $count; |
---|
560 | } |
---|
561 | |
---|
562 | function setID($id) |
---|
563 | { |
---|
564 | $this->id_ = $id; |
---|
565 | } |
---|
566 | |
---|
567 | function setTimeStamp($timestamp) |
---|
568 | { |
---|
569 | $this->timestamp_ = $timestamp; |
---|
570 | } |
---|
571 | |
---|
572 | function setSolarSystem($solarsystem) |
---|
573 | { |
---|
574 | $this->solarsystem_ = $solarsystem; |
---|
575 | } |
---|
576 | |
---|
577 | function setSolarSystemName($solarsystemname) |
---|
578 | { |
---|
579 | $this->solarsystemname_ = $solarsystemname; |
---|
580 | } |
---|
581 | |
---|
582 | function setSolarSystemSecurity($solarsystemsecurity) |
---|
583 | { |
---|
584 | $this->solarsystemsecurity_ = $solarsystemsecurity; |
---|
585 | } |
---|
586 | |
---|
587 | function setVictim($victim) |
---|
588 | { |
---|
589 | $this->victim_ = $victim; |
---|
590 | } |
---|
591 | |
---|
592 | function setVictimID($victimid) |
---|
593 | { |
---|
594 | $this->victimid_ = $victimid; |
---|
595 | } |
---|
596 | |
---|
597 | function setVictimName($victimname) |
---|
598 | { |
---|
599 | $this->victimname_ = $victimname; |
---|
600 | } |
---|
601 | |
---|
602 | function setVictimCorpID($victimcorpid) |
---|
603 | { |
---|
604 | $this->victimcorpid_ = $victimcorpid; |
---|
605 | } |
---|
606 | |
---|
607 | function setVictimCorpName($victimcorpname) |
---|
608 | { |
---|
609 | $this->victimcorpname_ = $victimcorpname; |
---|
610 | } |
---|
611 | |
---|
612 | function setVictimAllianceID($victimallianceid) |
---|
613 | { |
---|
614 | $this->victimallianceid_ = $victimallianceid; |
---|
615 | } |
---|
616 | |
---|
617 | function setVictimAllianceName($victimalliancename) |
---|
618 | { |
---|
619 | $this->victimalliancename_ = $victimalliancename; |
---|
620 | } |
---|
621 | |
---|
622 | function setVictimShip($victimship) |
---|
623 | { |
---|
624 | $this->victimship_ = $victimship; |
---|
625 | } |
---|
626 | |
---|
627 | function setVictimShipName($victimshipname) |
---|
628 | { |
---|
629 | $this->victimshipname_ = $victimshipname; |
---|
630 | } |
---|
631 | |
---|
632 | function setVictimShipExternalID($victimshipexternalid) |
---|
633 | { |
---|
634 | $this->victimshipexternalid_ = $victimshipexternalid; |
---|
635 | } |
---|
636 | |
---|
637 | function setVictimShipClassName($victimshipclassname) |
---|
638 | { |
---|
639 | $this->victimshipclassname_ = $victimshipclassname; |
---|
640 | } |
---|
641 | |
---|
642 | function setVictimShipValue($victimshipvalue) |
---|
643 | { |
---|
644 | $this->victimshipvalue_ = $victimshipvalue; |
---|
645 | } |
---|
646 | |
---|
647 | function setFBPilotID($fbpilotid) |
---|
648 | { |
---|
649 | $this->fbpilotid_ = $fbpilotid; |
---|
650 | } |
---|
651 | |
---|
652 | function setFBPilotName($fbpilotname) |
---|
653 | { |
---|
654 | $npc = strpos($fbpilotname, "#"); |
---|
655 | if ($npc === false) |
---|
656 | { |
---|
657 | $this->fbpilotname_ = $fbpilotname; |
---|
658 | } |
---|
659 | else |
---|
660 | { |
---|
661 | $name = explode("#", $fbpilotname); |
---|
662 | $plt = new Item($name[2]); |
---|
663 | $this->fbpilotname_ = $plt->getName(); |
---|
664 | } |
---|
665 | } |
---|
666 | |
---|
667 | function setFBCorpID($fbcorpid) |
---|
668 | { |
---|
669 | $this->fbcorpid_ = $fbcorpid; |
---|
670 | } |
---|
671 | |
---|
672 | function setFBCorpName($fbcorpname) |
---|
673 | { |
---|
674 | $this->fbcorpname_ = $fbcorpname; |
---|
675 | } |
---|
676 | |
---|
677 | function setFBAllianceID($fballianceid) |
---|
678 | { |
---|
679 | $this->fballianceid_ = $fballianceid; |
---|
680 | } |
---|
681 | |
---|
682 | function setFBAllianceName($fballiancename) |
---|
683 | { |
---|
684 | $this->fballiancename_ = $fballiancename; |
---|
685 | } |
---|
686 | function setKillPoints($killpoints) |
---|
687 | { |
---|
688 | $this->killpoints_ = $killpoints; |
---|
689 | } |
---|
690 | |
---|
691 | function calculateKillPoints() |
---|
692 | { |
---|
693 | $ship = $this->getVictimShip(); |
---|
694 | $shipclass = $ship->getClass(); |
---|
695 | $vicpoints = $shipclass->getPoints(); |
---|
696 | $maxpoints = round($vicpoints * 1.2); |
---|
697 | |
---|
698 | foreach ($this->involvedparties_ as $inv) |
---|
699 | { |
---|
700 | $shipinv = $inv->getShip(); |
---|
701 | $shipclassinv = $shipinv->getClass(); |
---|
702 | $invpoints += $shipclassinv->getPoints(); |
---|
703 | } |
---|
704 | |
---|
705 | $gankfactor = $vicpoints / ($vicpoints + $invpoints); |
---|
706 | $points = ceil($vicpoints * ($gankfactor / 0.75)); |
---|
707 | |
---|
708 | if ($points > $maxpoints) $points = $maxpoints; |
---|
709 | |
---|
710 | $points = round($points, 0); |
---|
711 | return $points; |
---|
712 | } |
---|
713 | |
---|
714 | function add($id = null) |
---|
715 | { |
---|
716 | if (!$this->solarsystem_->getID()) |
---|
717 | { |
---|
718 | echo 'INTERNAL ERROR; SOLARSYSTEM NOT FOUND; PLEASE CONTACT A DEV WITH THIS MESSAGE<br/>'; |
---|
719 | var_dump($this->solarsystem_); |
---|
720 | var_dump($this->solarsystemname_); |
---|
721 | return 0; |
---|
722 | } |
---|
723 | |
---|
724 | $dupe = $this->getDupe(true); |
---|
725 | if ($dupe == 0) |
---|
726 | { |
---|
727 | $this->realadd(); |
---|
728 | } |
---|
729 | elseif (config::get('readd_dupes')) |
---|
730 | { |
---|
731 | $this->dupeid_ = $dupe; |
---|
732 | $this->id_ = $dupe; |
---|
733 | $this->remove(false); |
---|
734 | $this->realadd($dupe); |
---|
735 | $this->id_ = -1; |
---|
736 | } |
---|
737 | else |
---|
738 | { |
---|
739 | $this->dupeid_ = $dupe; |
---|
740 | $this->id_ = -1; |
---|
741 | } |
---|
742 | return $this->id_; |
---|
743 | } |
---|
744 | |
---|
745 | function realadd($id = null) |
---|
746 | { |
---|
747 | // if ( $this->timestamp_ == "" || !$this->victimid_ || !$this->victimship_->getID() || !$this->solarsystem_->getID() || |
---|
748 | // !$this->victimallianceid_ || !$this->victimcorpid_ || !$this->getFBAllianceID() || !$this->getFBCorpID() || |
---|
749 | // !$this->getFBPilotID() ) |
---|
750 | // return 0; |
---|
751 | if ($id == null) |
---|
752 | { |
---|
753 | $qid = 'null'; |
---|
754 | } |
---|
755 | else |
---|
756 | { |
---|
757 | $qid = $id; |
---|
758 | } |
---|
759 | if (!$this->dmgtaken) |
---|
760 | { |
---|
761 | $this->dmgtaken = 0; |
---|
762 | } |
---|
763 | |
---|
764 | $qry = new DBQuery(); |
---|
765 | $sql = "insert into kb3_kills values (".$qid.", |
---|
766 | date_format('".$this->timestamp_."', '%Y.%m.%d %H:%i:%s'), |
---|
767 | ".$this->victimid_.", ".$this->victimallianceid_.", |
---|
768 | ".$this->victimcorpid_.", ".$this->victimship_->getID().", |
---|
769 | ".$this->solarsystem_->getID().", ".$this->getFBAllianceID().", |
---|
770 | ".$this->getFBCorpID().", ".$this->getFBPilotID().", ".$this->calculateKillPoints().", ".$this->dmgtaken." )"; |
---|
771 | $qry->execute($sql); |
---|
772 | |
---|
773 | if ($id) |
---|
774 | { |
---|
775 | $this->id_ = $id; |
---|
776 | } |
---|
777 | else |
---|
778 | { |
---|
779 | $this->id_ = $qry->getInsertID(); |
---|
780 | } |
---|
781 | |
---|
782 | // involved |
---|
783 | $order = 0; |
---|
784 | $invall = array(); |
---|
785 | $invcrp = array(); |
---|
786 | $invplt = array(); |
---|
787 | foreach ($this->involvedparties_ as $inv) |
---|
788 | { |
---|
789 | $ship = $inv->getShip(); |
---|
790 | $weapon = $inv->getWeapon(); |
---|
791 | if (!$inv->getPilotID() || $inv->getSecStatus() == "" || !$inv->getAllianceID() || !$inv->getCorpID() || !$ship->getID() || !$weapon->getID()) |
---|
792 | { |
---|
793 | $this->remove(); |
---|
794 | return 0; |
---|
795 | } |
---|
796 | |
---|
797 | if (!$inv->dmgdone_) |
---|
798 | { |
---|
799 | $inv->dmgdone_ = 0; |
---|
800 | } |
---|
801 | |
---|
802 | $sql = "insert into kb3_inv_detail |
---|
803 | values ( ".$this->getID().", ".$inv->getPilotID().", '".$inv->getSecStatus()."', " |
---|
804 | .$inv->getAllianceID().", ".$inv->getCorpID().", ".$ship->getID().", " |
---|
805 | .$weapon->getID().", ".$order++.", ".$inv->dmgdone_.")"; |
---|
806 | $qry->execute($sql) or die($qry->getErrorMsg()); |
---|
807 | |
---|
808 | if (!in_array($inv->getAllianceID(), $invall) && $inv->getAllianceID() != 14) |
---|
809 | { |
---|
810 | array_push($invall, $inv->getAllianceID()); |
---|
811 | $qry->execute("insert into kb3_inv_all values ( ".$this->getID().", ".$inv->getAllianceID()." )") or die($qry->getErrorMsg()); |
---|
812 | } |
---|
813 | if (!in_array($inv->getCorpID(), $invcrp)) |
---|
814 | { |
---|
815 | array_push($invcrp, $inv->getCorpID()); |
---|
816 | $qry->execute("insert into kb3_inv_crp values ( ".$this->getID().", ".$inv->getCorpID()." )") or die($qry->getErrorMsg()); |
---|
817 | } |
---|
818 | if (!in_array($inv->getPilotID(), $invplt)) |
---|
819 | { |
---|
820 | array_push($invplt, $inv->getPilotID()); |
---|
821 | $qry->execute("insert into kb3_inv_plt values ( ".$this->getID().", ".$inv->getPilotID()." )") or die($qry->getErrorMsg()); |
---|
822 | } |
---|
823 | } |
---|
824 | |
---|
825 | // destroyed |
---|
826 | foreach ($this->destroyeditems_ as $dest) |
---|
827 | { |
---|
828 | $item = $dest->getItem(); |
---|
829 | $loc_id = $dest->getLocationID(); |
---|
830 | if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) |
---|
831 | { |
---|
832 | trigger_error('error with destroyed item.', E_USER_WARNING); |
---|
833 | var_dump($dest);exit; |
---|
834 | continue; |
---|
835 | } |
---|
836 | |
---|
837 | $sql = "insert into kb3_items_destroyed |
---|
838 | values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " |
---|
839 | .$loc_id." )"; |
---|
840 | $qry->execute($sql); |
---|
841 | } |
---|
842 | |
---|
843 | // dropped |
---|
844 | foreach ($this->droppeditems_ as $dest) |
---|
845 | { |
---|
846 | $item = $dest->getItem(); |
---|
847 | $loc_id = $dest->getLocationID(); |
---|
848 | if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) |
---|
849 | { |
---|
850 | trigger_error('error with dropped item.', E_USER_WARNING); |
---|
851 | var_dump($dest);exit; |
---|
852 | continue; |
---|
853 | } |
---|
854 | |
---|
855 | $sql = "insert into kb3_items_dropped |
---|
856 | values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " |
---|
857 | .$loc_id." )"; |
---|
858 | $qry->execute($sql); |
---|
859 | } |
---|
860 | |
---|
861 | // call the event that we added this mail |
---|
862 | event::call('killmail_added', $this); |
---|
863 | return $this->id_; |
---|
864 | } |
---|
865 | |
---|
866 | function remove($delcomments = true) |
---|
867 | { |
---|
868 | if (!$this->id_) |
---|
869 | return; |
---|
870 | |
---|
871 | event::call('killmail_delete', $this); |
---|
872 | |
---|
873 | $qry = new DBQuery(); |
---|
874 | $qry->execute("delete from kb3_kills where kll_id = ".$this->id_); |
---|
875 | $qry->execute("delete from kb3_inv_detail where ind_kll_id = ".$this->id_); |
---|
876 | $qry->execute("delete from kb3_inv_all where ina_kll_id = ".$this->id_); |
---|
877 | $qry->execute("delete from kb3_inv_crp where inc_kll_id = ".$this->id_); |
---|
878 | $qry->execute("delete from kb3_inv_plt where inp_kll_id = ".$this->id_); |
---|
879 | $qry->execute("delete from kb3_items_destroyed where itd_kll_id = ".$this->id_); |
---|
880 | $qry->execute("delete from kb3_items_dropped where itd_kll_id = ".$this->id_); |
---|
881 | if ($delcomments) |
---|
882 | { |
---|
883 | $qry->execute("delete from kb3_comments where kll_id = ".$this->id_); |
---|
884 | } |
---|
885 | } |
---|
886 | |
---|
887 | function addInvolvedParty($involved) |
---|
888 | { |
---|
889 | array_push($this->involvedparties_, $involved); |
---|
890 | } |
---|
891 | |
---|
892 | function addDestroyedItem($destroyed) |
---|
893 | { |
---|
894 | array_push($this->destroyeditems_, $destroyed); |
---|
895 | } |
---|
896 | |
---|
897 | function addDroppedItem($dropped) |
---|
898 | { |
---|
899 | array_push($this->droppeditems_, $dropped); |
---|
900 | } |
---|
901 | } |
---|
902 | |
---|
903 | class InvolvedParty |
---|
904 | { |
---|
905 | function InvolvedParty($pilotid, $corpid, $allianceid, $secstatus, $ship, $weapon) |
---|
906 | { |
---|
907 | $this->pilotid_ = $pilotid; |
---|
908 | $this->corpid_ = $corpid; |
---|
909 | $this->allianceid_ = $allianceid; |
---|
910 | $this->secstatus_ = $secstatus; |
---|
911 | $this->ship_ = $ship; |
---|
912 | $this->weapon_ = $weapon; |
---|
913 | } |
---|
914 | |
---|
915 | function getPilotID() |
---|
916 | { |
---|
917 | return $this->pilotid_; |
---|
918 | } |
---|
919 | |
---|
920 | function getCorpID() |
---|
921 | { |
---|
922 | return $this->corpid_; |
---|
923 | } |
---|
924 | |
---|
925 | function getAllianceID() |
---|
926 | { |
---|
927 | return $this->allianceid_; |
---|
928 | } |
---|
929 | |
---|
930 | function getSecStatus() |
---|
931 | { |
---|
932 | return $this->secstatus_; |
---|
933 | } |
---|
934 | |
---|
935 | function getShip() |
---|
936 | { |
---|
937 | return $this->ship_; |
---|
938 | } |
---|
939 | |
---|
940 | function getWeapon() |
---|
941 | { |
---|
942 | return $this->weapon_; |
---|
943 | } |
---|
944 | } |
---|
945 | |
---|
946 | class DestroyedItem |
---|
947 | { |
---|
948 | function DestroyedItem($item, $quantity, $location) |
---|
949 | { |
---|
950 | $this->item_ = $item; |
---|
951 | $this->quantity_ = $quantity; |
---|
952 | $this->location_ = $location; |
---|
953 | } |
---|
954 | |
---|
955 | function getItem() |
---|
956 | { |
---|
957 | return $this->item_; |
---|
958 | } |
---|
959 | |
---|
960 | function getQuantity() |
---|
961 | { |
---|
962 | if ($this->quantity_ == "") $this->quantity = 1; |
---|
963 | return $this->quantity_; |
---|
964 | } |
---|
965 | |
---|
966 | function getFormatttedValue() |
---|
967 | { |
---|
968 | if (!isset($this->value)) |
---|
969 | { |
---|
970 | $this->getValue(); |
---|
971 | } |
---|
972 | if ($this->value > 0) |
---|
973 | { |
---|
974 | $value = $this->value * $this->getQuantity(); |
---|
975 | // Value Manipulation for prettyness. |
---|
976 | if (strlen($value) > 6) // Is this value in the millions? |
---|
977 | { |
---|
978 | $formatted = round($value / 1000000, 2); |
---|
979 | $formatted = number_format($formatted, 2); |
---|
980 | $formatted = $formatted." M"; |
---|
981 | } |
---|
982 | elseif (strlen($value) > 3) // 1000's ? |
---|
983 | { |
---|
984 | $formatted = round($value / 1000, 2); |
---|
985 | |
---|
986 | $formatted = number_format($formatted, 2); |
---|
987 | $formatted = $formatted." K"; |
---|
988 | } |
---|
989 | else |
---|
990 | { |
---|
991 | $formatted = number_format($value, 2); |
---|
992 | $formatted = $formatted." isk"; |
---|
993 | } |
---|
994 | } |
---|
995 | else |
---|
996 | { |
---|
997 | $formatted = "0 isk"; |
---|
998 | } |
---|
999 | return $formatted; |
---|
1000 | } |
---|
1001 | |
---|
1002 | function getValue() |
---|
1003 | { |
---|
1004 | if ($this->value) |
---|
1005 | { |
---|
1006 | return $this->value; |
---|
1007 | } |
---|
1008 | if (DB_USE_CCP) |
---|
1009 | { |
---|
1010 | $this->value = 0; |
---|
1011 | $qry = new DBQuery(); |
---|
1012 | $qry->execute("select basePrice, price |
---|
1013 | from kb3_invtypes |
---|
1014 | left join kb3_item_price on kb3_invtypes.typeID=kb3_item_price.typeID |
---|
1015 | where kb3_invtypes.typeID='".$this->item_->getID()."'"); |
---|
1016 | if ($row = $qry->getRow()) |
---|
1017 | { |
---|
1018 | if ($row['price']) |
---|
1019 | { |
---|
1020 | $this->value = $row['price']; |
---|
1021 | } |
---|
1022 | else |
---|
1023 | { |
---|
1024 | $this->value = $row['basePrice']; |
---|
1025 | } |
---|
1026 | } |
---|
1027 | return $this->value; |
---|
1028 | } |
---|
1029 | |
---|
1030 | //returns the value of an item |
---|
1031 | $value = 0; // Set 0 value incase nothing comes back |
---|
1032 | $id = $this->item_->getID(); // get Item ID |
---|
1033 | $qry = new DBQuery(); |
---|
1034 | $qry->execute("select itm_value from kb3_items where itm_id= '".$id."'"); |
---|
1035 | $row = $qry->getRow(); |
---|
1036 | $value = $row['itm_value']; |
---|
1037 | if ($value == '') |
---|
1038 | { |
---|
1039 | $value = 0; |
---|
1040 | } |
---|
1041 | return $value; |
---|
1042 | } |
---|
1043 | |
---|
1044 | function getLocationID() |
---|
1045 | { |
---|
1046 | $id = false; |
---|
1047 | if (strlen($this->location_) < 2) |
---|
1048 | { |
---|
1049 | $id = $this->item_->getSlot(); |
---|
1050 | } |
---|
1051 | else |
---|
1052 | { |
---|
1053 | $qry = new DBQuery(); |
---|
1054 | $qry->execute("select itl_id from kb3_item_locations where itl_location = '".$this->location_."'"); |
---|
1055 | $row = $qry->getRow(); |
---|
1056 | $id = $row['itl_id']; |
---|
1057 | } |
---|
1058 | return $id; |
---|
1059 | } |
---|
1060 | } |
---|
1061 | |
---|
1062 | class DroppedItem extends DestroyedItem |
---|
1063 | { |
---|
1064 | function DroppedItem($item, $quantity, $location) |
---|
1065 | { |
---|
1066 | $this->item_ = $item; |
---|
1067 | $this->quantity_ = $quantity; |
---|
1068 | $this->location_ = $location; |
---|
1069 | } |
---|
1070 | } |
---|
1071 | ?> |
---|