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