Changeset 254 for dev/common/includes/class.kill.php
- Timestamp:
- 12/05/07 20:53:40 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/includes/class.kill.php
r240 r254 15 15 $this->involvedparties_ = array(); 16 16 $this->destroyeditems_ = array(); 17 $this->droppeditems_ = array(); 18 } 19 20 function set($var, $value) 21 { 22 $this->$var = $value; 17 23 } 18 24 … … 202 208 $system = $this->getSystem(); 203 209 $mail .= "System: ".$system->getName()."\r\n"; 204 $mail .= "Security: ".$system->getSecurity(true)."\r\n\r\n"; 210 $mail .= "Security: ".$system->getSecurity(true)."\r\n"; 211 $mail .= "Damage Taken: ".$this->VictimDamageTaken."\r\n\r\n"; 205 212 $mail .= "Involved parties:\r\n\r\n"; 206 213 … … 236 243 $mail .= "Ship: ".$ship->getName()."\r\n"; 237 244 $mail .= "Weapon: ".$weapon->getName()."\r\n"; 245 $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; 246 } 247 else 248 { 249 $mail .= "Damage Done: ".$inv->dmgdone_."\r\n"; 238 250 } 239 251 $mail .= "\r\n"; … … 269 281 $mail .= " (Cargo)"; 270 282 if ($destroyed->getLocationID() == 6) // drone 283 $mail .= " (Drone Bay)"; 284 $mail .= "\r\n"; 285 } 286 } 287 288 if (count($this->droppeditems_) > 0) 289 { 290 $mail .= "\r\nDropped items:\r\n\r\n"; 291 292 foreach($this->droppeditems_ as $dropped) 293 { 294 $item = $dropped->getItem(); 295 $mail .= $item->getName(); 296 if ($dropped->getQuantity() > 1) 297 { 298 // if the option is enabled and the item is fitted then split it up 299 // this is aworkaround for the lazy parser of griefwatch 300 if (config::get('kill_splitfit') && $dropped->getQuantity() < 9 && ($dropped->getLocationID() == 1 301 || $dropped->getLocationID() == 2 || $dropped->getLocationID() == 3)) 302 { 303 for ($i = $dropped->getQuantity(); $i > 1; $i--) 304 { 305 $mail .= "\r\n".$item->getName(); 306 } 307 308 } 309 else 310 { 311 $mail .= ", Qty: ".$dropped->getQuantity(); 312 } 313 } 314 if ($dropped->getLocationID() == 4) // cargo 315 $mail .= " (Cargo)"; 316 if ($dropped->getLocationID() == 6) // drone 271 317 $mail .= " (Drone Bay)"; 272 318 $mail .= "\r\n"; … … 324 370 fbplt.plt_name as fbplt_name, 325 371 fbcrp.crp_name as fbcrp_name, 326 fbali.all_name as fbali_name 372 fbali.all_name as fbali_name, 373 kll_dmgtaken 327 374 from kb3_kills kll, kb3_pilots plt, kb3_corps crp, 328 375 kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, … … 366 413 $this->plt_ext_ = $row['plt_externalid']; 367 414 $this->fbplt_ext_ = $row['fbplt_externalid']; 415 $this->VictimDamageTaken = $row['kll_dmgtaken']; 368 416 369 417 // involved 370 418 $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, 371 ind_shp_id, ind_wep_id 419 ind_shp_id, ind_wep_id, ind_dmgdone 372 420 from kb3_inv_detail 373 421 where ind_kll_id = ".$this->getID()." … … 383 431 new Ship($row['ind_shp_id']), 384 432 new Item($row['ind_wep_id'])); 433 $involved->dmgdone_ = $row['ind_dmgdone']; 385 434 array_push($this->involvedparties_, $involved); 386 435 } 387 436 // 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 437 $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, 438 itd_itl_id, itl_location 439 from kb3_items_destroyed itd 440 left join kb3_items itm on itd.itd_itm_id = itm.itm_id 441 left join kb3_item_locations itl on (itd.itd_itl_id = itl.itl_id or (itd.itd_itl_id = 0 and itl.itl_id = 1)) 392 442 where itd.itd_kll_id = ".$this->getID()." 393 and itd.itd_itm_id = itm.itm_id394 and ( itd.itd_itl_id = itl.itl_id or (itd.itd_itl_id = 0 and itl.itl_id = 1))395 443 group by itd_itm_id, itd_itl_id 396 444 order by itd.itd_itl_id, itm.itm_type"; 397 445 446 if (DB_USE_CCP) 447 { 448 $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, 449 itd_itl_id, itl_location 450 from kb3_items_destroyed itd 451 left join kb3_item_locations itl on (itd.itd_itl_id = itl.itl_id or (itd.itd_itl_id = 0 and itl.itl_id = 1)) 452 where itd.itd_kll_id = ".$this->getID()." 453 group by itd_itm_id, itd_itl_id 454 order by itd.itd_itl_id"; 455 } 398 456 $qry->execute($sql); 399 457 while ($row = $qry->getRow()) … … 404 462 array_push($this->destroyeditems_, $destroyed); 405 463 } 464 465 if (DB_USE_CCP) 466 { 467 $sql = "select sum(itd.itd_quantity) as itd_quantity, itd_itm_id, 468 itd_itl_id, itl_location 469 from kb3_items_dropped itd 470 left join kb3_item_locations itl on (itd.itd_itl_id = itl.itl_id or (itd.itd_itl_id = 0 and itl.itl_id = 1)) 471 where itd.itd_kll_id = ".$this->getID()." 472 group by itd_itm_id, itd_itl_id 473 order by itd.itd_itl_id"; 474 $qry->execute($sql); 475 while ($row = $qry->getRow()) 476 { 477 $destroyed = new DroppedItem(new Item($row['itd_itm_id']), 478 $row['itd_quantity'], 479 $row['itl_location']); 480 array_push($this->droppeditems_, $destroyed); 481 } 482 } 406 483 } 407 484 } … … 417 494 418 495 $offset = config::get('kill_classified')*3600; 419 if (strtotime($this->timestamp_) > time()-$offset) 496 if (config::get('date_gmtime')) 497 { 498 $time = time()-date('Z'); 499 } 500 else 501 { 502 $time = time(); 503 } 504 if (strtotime($this->timestamp_) > $time-$offset) 420 505 { 421 506 return true; … … 430 515 { 431 516 $offset = config::get('kill_classified')*3600; 432 if (strtotime($this->timestamp_) > time()-$offset) 433 { 434 return ($offset-time()+strtotime($this->timestamp_)); 517 if (config::get('date_gmtime')) 518 { 519 $time = time()-date('Z'); 520 } 521 else 522 { 523 $time = time(); 524 } 525 if (strtotime($this->timestamp_) > $time-$offset) 526 { 527 return ($offset-$time+strtotime($this->timestamp_)); 435 528 } 436 529 } … … 667 760 { 668 761 $qid = $id; 762 } 763 if (!$this->dmgtaken) 764 { 765 $this->dmgtaken = 0; 669 766 } 670 767 … … 675 772 ".$this->victimcorpid_.", ".$this->victimship_->getID().", 676 773 ".$this->solarsystem_->getID().", ".$this->getFBAllianceID().", 677 ".$this->getFBCorpID().", ".$this->getFBPilotID().", ".$this->calculateKillPoints()." )";774 ".$this->getFBCorpID().", ".$this->getFBPilotID().", ".$this->calculateKillPoints().", ".$this->dmgtaken." )"; 678 775 $qry->execute($sql); 679 776 … … 702 799 } 703 800 801 if (!$inv->dmgdone_) 802 { 803 $inv->dmgdone_ = 0; 804 } 805 704 806 $sql = "insert into kb3_inv_detail 705 807 values ( ".$this->getID().", ".$inv->getPilotID().", '".$inv->getSecStatus()."', " 706 808 .$inv->getAllianceID().", ".$inv->getCorpID().", ".$ship->getID().", " 707 .$weapon->getID().", ".$order++." 809 .$weapon->getID().", ".$order++.", ".$inv->dmgdone_.")"; 708 810 $qry->execute($sql) or die($qry->getErrorMsg()); 709 811 … … 730 832 $item = $dest->getItem(); 731 833 $loc_id = $dest->getLocationID(); 732 if (!is_numeric($ item->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id))834 if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) 733 835 { 734 836 trigger_error('error with destroyed item.', E_USER_WARNING); … … 743 845 } 744 846 847 // dropped 848 foreach ($this->droppeditems_ as $dest) 849 { 850 $item = $dest->getItem(); 851 $loc_id = $dest->getLocationID(); 852 if (!is_numeric($this->getID()) || !is_numeric($item->getID()) || !is_numeric($dest->getQuantity()) || !is_numeric($loc_id)) 853 { 854 trigger_error('error with dropped item.', E_USER_WARNING); 855 var_dump($dest);exit; 856 continue; 857 } 858 859 $sql = "insert into kb3_items_dropped 860 values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " 861 .$loc_id." )"; 862 $qry->execute($sql); 863 } 864 745 865 // call the event that we added this mail 746 event::call('killmail_added', &$this);866 event::call('killmail_added', $this); 747 867 return $this->id_; 748 868 } … … 753 873 return; 754 874 755 event::call('killmail_delete', &$this);875 event::call('killmail_delete', $this); 756 876 757 877 $qry = new DBQuery(); … … 762 882 $qry->execute("delete from kb3_inv_plt where inp_kll_id = ".$this->id_); 763 883 $qry->execute("delete from kb3_items_destroyed where itd_kll_id = ".$this->id_); 884 $qry->execute("delete from kb3_items_dropped where itd_kll_id = ".$this->id_); 764 885 if ($delcomments) 765 886 { … … 776 897 { 777 898 array_push($this->destroyeditems_, $destroyed); 899 } 900 901 function addDroppedItem($dropped) 902 { 903 array_push($this->droppeditems_, $dropped); 778 904 } 779 905 } … … 842 968 } 843 969 970 function getFormatttedValue() 971 { 972 if (!isset($this->value)) 973 { 974 $this->getValue(); 975 } 976 if ($this->value > 0) 977 { 978 $value = $this->value * $this->getQuantity(); 979 // Value Manipulation for prettyness. 980 if (strlen($value) > 6) // Is this value in the millions? 981 { 982 $formatted = round($value / 1000000, 2); 983 $formatted = number_format($formatted, 2); 984 $formatted = $formatted." M"; 985 } 986 elseif (strlen($value) > 3) // 1000's ? 987 { 988 $formatted = round($value / 1000, 2); 989 990 $formatted = number_format($formatted, 2); 991 $formatted = $formatted." K"; 992 } 993 else 994 { 995 $formatted = number_format($value, 2); 996 $formatted = $formatted." isk"; 997 } 998 } 999 else 1000 { 1001 $formatted = "0 isk"; 1002 } 1003 return $formatted; 1004 } 1005 844 1006 function getValue() 845 //returns the value of an item846 1007 { 1008 if ($this->value) 1009 { 1010 return $this->value; 1011 } 1012 if (DB_USE_CCP) 1013 { 1014 $this->value = 0; 1015 $qry = new DBQuery(); 1016 $qry->execute("select basePrice, price from kb3_invtypes left join kb3_item_price using (typeID) where typeID='".$this->item_->getID()."'"); 1017 if ($row = $qry->getRow()) 1018 { 1019 if ($row['price']) 1020 { 1021 $this->value = $row['price']; 1022 } 1023 else 1024 { 1025 $this->value = $row['basePrice']; 1026 } 1027 } 1028 return $this->value; 1029 } 1030 1031 //returns the value of an item 847 1032 $value = 0; // Set 0 value incase nothing comes back 848 1033 $id = $this->item_->getID(); // get Item ID … … 875 1060 } 876 1061 } 1062 1063 class DroppedItem extends DestroyedItem 1064 { 1065 function DroppedItem($item, $quantity, $location) 1066 { 1067 $this->item_ = $item; 1068 $this->quantity_ = $quantity; 1069 $this->location_ = $location; 1070 } 1071 } 877 1072 ?>