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