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