Changeset 73
- Timestamp:
- 11/16/06 23:20:05 (16 years ago)
- Location:
- dev/common
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/class.kill.php
r69 r73 161 161 function getVictimShipImage($size) 162 162 { 163 return IMG_URL . "/ships/" . $size . "_" . $size . "/" 164 . $this->victimshipexternalid_ . ".png"; 163 return IMG_URL."/ships/".$size."_".$size."/".$this->victimshipexternalid_.".png"; 165 164 } 166 165 … … 184 183 $color = "purple"; 185 184 186 return IMG_URL . "/ships/ship-" . $color .".gif";185 return IMG_URL."/ships/ship-".$color.".gif"; 187 186 } 188 187 … … 191 190 $this->execQuery(); 192 191 193 $mail .= substr(str_replace('-', '.' , $this->getTimeStamp()), 0, 16) ."\r\n\r\n";194 $mail .= "Victim: " . $this->getVictimName() ."\r\n";195 $mail .= "Alliance: " . $this->getVictimAllianceName() ."\r\n";196 $mail .= "Corp: " . $this->getVictimCorpName() ."\r\n";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"; 197 196 $ship = $this->getVictimShip(); 198 $mail .= "Destroyed: " . $ship->getName() ."\r\n";197 $mail .= "Destroyed: ".$ship->getName()."\r\n"; 199 198 $system = $this->getSystem(); 200 $mail .= "System: " . $system->getName() ."\r\n";201 $mail .= "Security: " . $system->getSecurity(true) ."\r\n\r\n";199 $mail .= "System: ".$system->getName()."\r\n"; 200 $mail .= "Security: ".$system->getSecurity(true)."\r\n\r\n"; 202 201 $mail .= "Involved parties:\r\n\r\n"; 203 202 … … 211 210 $ship = $inv->getShip(); 212 211 if ($pilot->getName() == $weapon->getName()) 213 $name = $pilot->getName() . " / " . $corp->getName(); 212 { 213 $name = $pilot->getName()." / ".$corp->getName(); 214 } 214 215 else 216 { 215 217 $name = $pilot->getName(); 216 217 $mail .= "Name: " . $name; 218 } 219 220 $mail .= "Name: ".$name; 218 221 if ($pilot->getID() == $this->getFBPilotID()) 222 { 219 223 $mail .= " (laid the final blow)"; 224 } 220 225 $mail .= "\r\n"; 221 226 222 227 if ($pilot->getName() != $weapon->getName()) 223 228 { 224 $mail .= "Security: " . $inv->getSecStatus() ."\r\n";225 $mail .= "Alliance: " . $alliance->getName() ."\r\n";226 $mail .= "Corp: " . $corp->getName() ."\r\n";227 $mail .= "Ship: " . $ship->getName() ."\r\n";228 $mail .= "Weapon: " . $weapon->getName() ."\r\n";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"; 229 234 } 230 235 $mail .= "\r\n"; … … 240 245 $mail .= $item->getName(); 241 246 if ($destroyed->getQuantity() > 1) 242 $mail .= ", Qty: " .$destroyed->getQuantity();247 $mail .= ", Qty: ".$destroyed->getQuantity(); 243 248 if ($destroyed->getLocationID() == 4) // cargo 244 249 $mail .= " (Cargo)"; … … 252 257 } 253 258 254 function getDupe() 255 { 256 $this->execQuery(); 259 function getDupe($checkonly = false) 260 { 261 if (!$checkonly) 262 { 263 $this->execQuery(); 264 } 257 265 $dupe = 0; 258 266 $qry = new DBQuery(); … … 261 269 $qry->execute("select kll_id 262 270 from kb3_kills 263 264 date_add( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND )265 266 date_sub( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND )267 and kll_victim_id = " . $this->victimid_ ."268 and kll_ship_id = " . $this->victimship_->getID() ."269 and kll_system_id = " . $this->solarsystem_->getID() ."270 and kll_fb_plt_id = " . $this->getFBPilotID() ."271 and kll_id != " .$this->id_);271 where kll_timestamp <= 272 date_add( '".$this->timestamp_."', INTERVAL '3:0' MINUTE_SECOND ) 273 and kll_timestamp >= 274 date_sub( '".$this->timestamp_."', INTERVAL '3: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_); 272 280 273 281 $row = $qry->getRow(); … … 288 296 crp.crp_name, ali.all_name, ali.all_id, kll.kll_ship_id, 289 297 kll.kll_system_id, kll.kll_ship_id, 290 kll.kll_victim_id, plt.plt_externalid,291 kll.kll_crp_id, kll.kll_points,292 fbplt.plt_id as fbplt_id,293 fbcrp.crp_id as fbcrp_id,294 fbali.all_id as fbali_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 fbcrp.crp_id as fbcrp_id, 302 fbali.all_id as fbali_id, 295 303 fbplt.plt_name as fbplt_name, 296 304 fbcrp.crp_name as fbcrp_name, … … 299 307 kb3_alliances ali, kb3_alliances fbali, kb3_corps fbcrp, 300 308 kb3_pilots fbplt 301 where kll.kll_id = " . $this->id_ ."309 where kll.kll_id = ".$this->id_." 302 310 and plt.plt_id = kll.kll_victim_id 303 311 and crp.crp_id = kll.kll_crp_id … … 332 340 // involved 333 341 $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, 334 335 336 where ind_kll_id = " . $this->getID() ."337 342 ind_shp_id, ind_wep_id 343 from kb3_inv_detail 344 where ind_kll_id = ".$this->getID()." 345 order by ind_order"; 338 346 339 347 $qry->execute($sql) or die($qry->getErrorMsg()); … … 350 358 // destroyed items 351 359 $sql = "select sum( itd.itd_quantity ) as itd_quantity, itd_itm_id, 352 353 354 355 where itd.itd_kll_id = " . $this->getID() ."356 357 358 359 360 itd_itl_id, itl_location 361 from kb3_items_destroyed itd, kb3_items itm, 362 kb3_item_locations itl 363 where itd.itd_kll_id = ".$this->getID()." 364 and itd.itd_itm_id = itm.itm_id 365 and ( itd.itd_itl_id = itl.itl_id or itd.itd_itl_id = 0 ) 366 group by itd_itm_id, itd_itl_id 367 order by itd.itd_itl_id, itm.itm_type"; 360 368 361 369 $qry->execute($sql) or die($qry->getErrorMsg()); … … 502 510 { 503 511 $npc = strpos($fbpilotname, "#"); 504 if($npc === false) { 505 $this->fbpilotname_ = $fbpilotname; 512 if ($npc === false) 513 { 514 $this->fbpilotname_ = $fbpilotname; 506 515 } 507 else { 508 $name = explode("#",$fbpilotname); 509 $plt = new Item(); 510 $name = $plt->lookup($name[2]); 511 $this->fbpilotname_ = $name; 516 else 517 { 518 $name = explode("#", $fbpilotname); 519 $plt = new Item(); 520 $name = $plt->lookup($name[2]); 521 $this->fbpilotname_ = $name; 512 522 } 513 523 } … … 560 570 } 561 571 562 function add( )572 function add($id = null) 563 573 { 564 574 // if ( $this->timestamp_ == "" || !$this->victimid_ || !$this->victimship_->getID() || !$this->solarsystem_->getID() || … … 566 576 // !$this->getFBPilotID() ) 567 577 // return 0; 568 $qry = new DBQuery(); 569 $qry->execute("select kll_id 570 from kb3_kills 571 where kll_timestamp <= 572 date_add( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND ) 573 and kll_timestamp >= 574 date_sub( '" . $this->timestamp_ . "', INTERVAL '15:0' MINUTE_SECOND ) 575 and kll_victim_id = " . $this->victimid_ . " 576 and kll_ship_id = " . $this->victimship_->getID() . " 577 and kll_system_id = " . $this->solarsystem_->getID() . " 578 and kll_fb_plt_id = " . $this->getFBPilotID()) or die($qry->getErrorMsg()); 579 580 if ($qry->recordCount() == 0) 578 if (!$this->solarsystem_->getID()) 579 { 580 echo 'INTERNAL ERROR; SOLARSYSTEM NOT FOUND; PLEASE CONTACT A DEV WITH THIS MESSAGE<br/>'; 581 var_dump($this->solarsystem_); 582 var_dump($this->solarsystemname_); 583 return 0; 584 } 585 $dupe = $this->getDupe(true); 586 587 if ($dupe == 0) 581 588 { 582 589 $sql = "insert into kb3_kills 583 590 values ( null, 584 date_format('" . $this->timestamp_ . "', '%Y.%m.%d %H:%i:%s'), 585 " . $this->victimid_ . ", " . $this->victimallianceid_ . ", 586 " . $this->victimcorpid_ . ", " . $this->victimship_->getID() . ", 587 " . $this->solarsystem_->getID() . ", " . $this->getFBAllianceID() . ", 588 " . $this->getFBCorpID() . ", " . $this->getFBPilotID() . ", " . $this->calculateKillPoints() . " )"; 589 $qry->execute($sql) or die($qry->getErrorMsg()); 590 $this->id_ = $qry->getInsertID(); 591 date_format('".$this->timestamp_."', '%Y.%m.%d %H:%i:%s'), 592 ".$this->victimid_.", ".$this->victimallianceid_.", 593 ".$this->victimcorpid_.", ".$this->victimship_->getID().", 594 ".$this->solarsystem_->getID().", ".$this->getFBAllianceID().", 595 ".$this->getFBCorpID().", ".$this->getFBPilotID().", ".$this->calculateKillPoints()." )"; 596 $qry->execute($sql); 597 if ($id) 598 { 599 $this->id_ = $id; 600 } 601 else 602 { 603 $this->id_ = $qry->getInsertID(); 604 } 591 605 // involved 592 606 $order = 0; … … 605 619 606 620 $sql = "insert into kb3_inv_detail 607 values ( " . $this->getID() . ", " . $inv->getPilotID() . ", '" . $inv->getSecStatus() ."', "608 . $inv->getAllianceID() . ", " . $inv->getCorpID() . ", " . $ship->getID() .", "609 . $weapon->getID() . ", " . $order++ ." )";621 values ( ".$this->getID().", ".$inv->getPilotID().", '".$inv->getSecStatus()."', " 622 .$inv->getAllianceID().", ".$inv->getCorpID().", ".$ship->getID().", " 623 .$weapon->getID().", ".$order++." )"; 610 624 $qry->execute($sql) or die($qry->getErrorMsg()); 611 625 … … 613 627 { 614 628 array_push($invall, $inv->getAllianceID()); 615 $qry->execute("insert into kb3_inv_all values ( " . $this->getID() . ", " . $inv->getAllianceID() ." )") or die($qry->getErrorMsg());629 $qry->execute("insert into kb3_inv_all values ( ".$this->getID().", ".$inv->getAllianceID()." )") or die($qry->getErrorMsg()); 616 630 } 617 631 if (!in_array($inv->getCorpID(), $invcrp)) 618 632 { 619 633 array_push($invcrp, $inv->getCorpID()); 620 $qry->execute("insert into kb3_inv_crp values ( " . $this->getID() . ", " . $inv->getCorpID() ." )") or die($qry->getErrorMsg());634 $qry->execute("insert into kb3_inv_crp values ( ".$this->getID().", ".$inv->getCorpID()." )") or die($qry->getErrorMsg()); 621 635 } 622 636 if (!in_array($inv->getPilotID(), $invplt)) 623 637 { 624 638 array_push($invplt, $inv->getPilotID()); 625 $qry->execute("insert into kb3_inv_plt values ( " . $this->getID() . ", " . $inv->getPilotID() ." )") or die($qry->getErrorMsg());639 $qry->execute("insert into kb3_inv_plt values ( ".$this->getID().", ".$inv->getPilotID()." )") or die($qry->getErrorMsg()); 626 640 } 627 641 } … … 634 648 635 649 $sql = "insert into kb3_items_destroyed 636 values ( " . $this->getID() . ", " . $item->getID() . ", " . $dest->getQuantity() .", "637 . $dest->getLocationID() ." )";638 $qry->execute($sql) or die($qry->getErrorMsg());650 values ( ".$this->getID().", ".$item->getID().", ".$dest->getQuantity().", " 651 .$dest->getLocationID()." )"; 652 $qry->execute($sql); 639 653 } 640 654 } … … 654 668 655 669 $qry = new DBQuery(); 656 $qry->execute("delete from kb3_kills 657 where kll_id = " . $this->id_); 658 $qry->execute("delete from kb3_inv_detail 659 where ind_kll_id = " . $this->id_); 660 $qry->execute("delete from kb3_inv_all 661 where ina_kll_id = " . $this->id_); 662 $qry->execute("delete from kb3_inv_crp 663 where inc_kll_id = " . $this->id_); 664 $qry->execute("delete from kb3_inv_plt 665 where inp_kll_id = " . $this->id_); 666 $qry->execute("delete from kb3_items_destroyed 667 where itd_kll_id = " . $this->id_); 670 $qry->execute("delete from kb3_kills where kll_id = ".$this->id_); 671 $qry->execute("delete from kb3_inv_detail where ind_kll_id = ".$this->id_); 672 $qry->execute("delete from kb3_inv_all where ina_kll_id = ".$this->id_); 673 $qry->execute("delete from kb3_inv_crp where inc_kll_id = ".$this->id_); 674 $qry->execute("delete from kb3_inv_plt where inp_kll_id = ".$this->id_); 675 $qry->execute("delete from kb3_items_destroyed where itd_kll_id = ".$this->id_); 676 $qry->execute("delete from kb3_comments where kll_id = ".$this->id_); 668 677 } 669 678 … … 749 758 $id= $this->item_->getID(); // get Item ID 750 759 $qry = new DBQuery(); 751 $qry->execute("select Value from kb3_items where itm_id= '" . $id ."'") or die($qry->getErrorMsg());760 $qry->execute("select Value from kb3_items where itm_id= '".$id."'") or die($qry->getErrorMsg()); 752 761 $row = $qry->getRow(); 753 762 $value = $row['Value']; 754 763 if ($value == "") { 755 764 $value = 0; 756 } 765 } 757 766 return $value; 758 767 } 759 768 760 769 function getLocationID() 761 770 { … … 768 777 { 769 778 $qry = new DBQuery(); 770 $qry->execute("select itl_id from kb3_item_locations where itl_location = '" . $this->location_ ."'") or die($qry->getErrorMsg());779 $qry->execute("select itl_id from kb3_item_locations where itl_location = '".$this->location_."'") or die($qry->getErrorMsg()); 771 780 $row = $qry->getRow(); 772 781 $id = $row['itl_id']; -
dev/common/class.system.php
r2 r73 1 <? 2 require_once( "db.php");1 <?php 2 require_once("db.php"); 3 3 4 class SolarSystem { 4 class SolarSystem 5 { 6 function SolarSystem($id = 0) 7 { 8 $this->id_ = $id; 9 $this->qry_ = new DBQuery(); 5 10 6 function SolarSystem( $id = 0 ) 7 { 8 $this->id_ = $id; 9 $this->qry_ = new DBQuery(); 10 11 $this->sql_ = "select * 11 $this->sql_ = "select * 12 12 from kb3_systems sys, kb3_constellations con, 13 13 kb3_regions reg 14 where sys.sys_id = " .$this->id_."14 where sys.sys_id = " . $this->id_ . " 15 15 and con.con_id = sys.sys_con_id 16 16 and reg.reg_id = con.con_reg_id"; … … 19 19 function getID() 20 20 { 21 return $this->id_;21 return $this->id_; 22 22 } 23 23 24 24 function getName() 25 25 { 26 $this->execQuery();27 return $this->row_['sys_name'];26 $this->execQuery(); 27 return $this->row_['sys_name']; 28 28 } 29 29 30 function getSecurity( $rounded = false)30 function getSecurity($rounded = false) 31 31 { 32 $this->execQuery();33 $sec = $this->row_['sys_sec'];32 $this->execQuery(); 33 $sec = $this->row_['sys_sec']; 34 34 35 if ( $rounded ) { 36 if ( $sec <= 0 ) 37 return number_format( 0.0, 1 ); 38 else 39 return number_format( round( $sec, 1 ), 1 ); 40 } else return $sec; 35 if ($rounded) 36 { 37 if ($sec <= 0) 38 return number_format(0.0, 1); 39 else 40 return number_format(round($sec, 1), 1); 41 } 42 else return $sec; 41 43 } 42 44 43 45 function getConstellationName() 44 46 { 45 $this->execQuery();46 return $this->row_['con_name'];47 $this->execQuery(); 48 return $this->row_['con_name']; 47 49 } 48 50 49 51 function getRegionName() 50 52 { 51 $this->execQuery();52 return $this->row_['reg_name'];53 $this->execQuery(); 54 return $this->row_['reg_name']; 53 55 } 54 56 55 57 function execQuery() 56 58 { 57 if ( !$this->qry_->executed_ ) { 58 $this->qry_->execute( $this->sql_ ); 59 $this->row_ = $this->qry_->getRow(); 60 } 59 if (!$this->qry_->executed_) 60 { 61 $this->qry_->execute($this->sql_); 62 $this->row_ = $this->qry_->getRow(); 63 } 61 64 } 62 65 63 function lookup( $name)66 function lookup($name) 64 67 { 65 $qry = new DBQuery();66 $qry->execute("select *68 $qry = new DBQuery(); 69 $qry->execute("select * 67 70 from kb3_systems 68 where sys_name = '".slashfix( $name )."'" ); 69 70 $row = $qry->getRow(); 71 $this->id_ = $row['sys_id']; 71 where sys_name = '" . slashfix($name) . "'"); 72 73 $row = $qry->getRow(); 74 if (!$row['sys_id']) 75 { 76 echo 'INTERNAL ERROR: SYSTEM NOT FOUND: "'.$name.'"<br/>'; 77 } 78 $this->id_ = $row['sys_id']; 72 79 } 73 80 } 74 81 75 76 77 function Region( $id = 0)82 class Region 83 { 84 function Region($id = 0) 78 85 { 79 $this->id_ = $id;86 $this->id_ = $id; 80 87 } 81 88 82 89 function getID() 83 90 { 84 return $this->id_;91 return $this->id_; 85 92 } 86 93 87 94 function getName() 88 95 { 89 $this->execQuery();90 return $this->row_['reg_name'];96 $this->execQuery(); 97 return $this->row_['reg_name']; 91 98 } 92 99 93 100 function execQuery() 94 101 { 95 if ( !$this->qry_ ) { 96 $this->qry_ = new DBQuery(); 97 $this->qry_->execute( "select * from kb3_regions 98 where reg_id = ".$this->id_ ); 99 $this->row_ = $this->qry_->getRow(); 100 } 102 if (!$this->qry_) 103 { 104 $this->qry_ = new DBQuery(); 105 $this->qry_->execute("select * from kb3_regions 106 where reg_id = " . $this->id_); 107 $this->row_ = $this->qry_->getRow(); 108 } 101 109 } 102 110 } 103 111 ?>