Changeset 392
- Timestamp:
- 06/26/09 13:08:41 (13 years ago)
- Location:
- dev
- Files:
-
- 13 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/includes/class.config.php
r370 r392 57 57 // no config supplied, generate standard one 58 58 config::set('style_name', 'default'); 59 config::set('style_banner', 'default ');59 config::set('style_banner', 'default.jpg'); 60 60 config::set('post_password', 'CHANGEME'); 61 61 config::set('comment_password', 'CHANGEME'); -
dev/common/includes/class.item.php
r379 r392 183 183 $name = trim($name); 184 184 $qry = new DBQuery(); 185 $query = "select *,typeID as itm_id from kb3_invtypes itm185 $query = "select typeID as itm_id from kb3_invtypes itm 186 186 where typeName = '".slashfix($name)."'"; 187 187 $qry->execute($query); … … 192 192 } 193 193 $this->id_ = $row['itm_id']; 194 unset($this->row); 195 $this->executed_ = false; 196 return true; 194 197 } 195 198 … … 198 201 { 199 202 $qry = new DBQuery(); 200 $query = "select *,typeID as itm_id201 from kb3_i tems203 $query = "select typeID as itm_id 204 from kb3_invtypes 202 205 where typeName = '".slashfix($name)."'"; 203 206 $qry->execute($query); -
dev/common/includes/class.kill.php
r381 r392 1271 1271 return $this->item_->row_['baseprice']; 1272 1272 } 1273 if (DB_USE_CCP) 1274 { 1275 $this->value = 0; 1276 $qry = new DBQuery(); 1277 $qry->execute("select basePrice, price 1278 from kb3_invtypes 1279 left join kb3_item_price on kb3_invtypes.typeID=kb3_item_price.typeID 1280 where kb3_invtypes.typeID='".$this->item_->getID()."'"); 1281 if ($row = $qry->getRow()) 1282 { 1283 if ($row['price']) 1284 { 1285 $this->value = $row['price']; 1286 } 1287 else 1288 { 1289 $this->value = $row['basePrice']; 1290 } 1291 } 1292 return $this->value; 1293 } 1273 $this->value = 0; 1274 $qry = new DBQuery(); 1275 $qry->execute("select basePrice, price 1276 from kb3_invtypes 1277 left join kb3_item_price on kb3_invtypes.typeID=kb3_item_price.typeID 1278 where kb3_invtypes.typeID='".$this->item_->getID()."'"); 1279 if ($row = $qry->getRow()) 1280 { 1281 if ($row['price']) 1282 { 1283 $this->value = $row['price']; 1284 } 1285 else 1286 { 1287 $this->value = $row['basePrice']; 1288 } 1289 } 1290 return $this->value; 1294 1291 1295 1292 //returns the value of an item -
dev/common/includes/class.killlist.php
r380 r392 45 45 */ 46 46 $timeindex='kll_timestamp'; 47 $datefilter=$this->getDateFilter();48 47 if (!$this->qry_->executed_) 49 48 { 49 $datefilter=$this->getDateFilter(); 50 50 $this->sql_ = ''; 51 51 if (!count($this->groupby_) && ($this->comments_ || $this->involved_)) … … 82 82 fbplt.plt_name as fbplt_name, 83 83 fbplt.plt_externalid as fbplt_externalid, 84 fbcrp.crp_name as fbcrp_name'; 84 fbcrp.crp_name as fbcrp_name, 85 fbali.all_name as fball_name'; 85 86 } 86 87 } … … 110 111 111 112 if (!$this->summary_) $this->sql_ .= "INNER JOIN kb3_pilots plt 112 ON ( plt.plt_id = kll.kll_victim_id ) 113 INNER JOIN kb3_corps crp 114 ON ( crp.crp_id = kll.kll_crp_id ) 115 INNER JOIN kb3_alliances ali 116 ON ( ali.all_id = kll.kll_all_id ) 117 INNER JOIN kb3_pilots fbplt 118 ON ( fbplt.plt_id = kll.kll_fb_plt_id ) 119 INNER JOIN kb3_inv_detail fb 120 ON ( fb.ind_kll_id = kll.kll_id AND fb.ind_plt_id = kll.kll_fb_plt_id ) 121 INNER JOIN kb3_corps fbcrp 122 ON ( fbcrp.crp_id = fb.ind_crp_id )"; 113 ON ( plt.plt_id = kll.kll_victim_id ) 114 INNER JOIN kb3_corps crp 115 ON ( crp.crp_id = kll.kll_crp_id ) 116 INNER JOIN kb3_alliances ali 117 ON ( ali.all_id = kll.kll_all_id ) 118 INNER JOIN kb3_pilots fbplt 119 ON ( fbplt.plt_id = kll.kll_fb_plt_id ) 120 INNER JOIN kb3_inv_detail fb 121 ON ( fb.ind_kll_id = kll.kll_id AND fb.ind_plt_id = kll.kll_fb_plt_id ) 122 INNER JOIN kb3_corps fbcrp 123 ON ( fbcrp.crp_id = fb.ind_crp_id ) 124 INNER JOIN kb3_alliances fbali 125 ON ( fbali.all_id = fb.ind_all_id ) 126 "; 123 127 if(!$this->summary_ || count($this->systems_)) 124 128 $this->sql_ .= " INNER JOIN kb3_systems sys … … 397 401 $kill->setFBPilotName($row['fbplt_name']); 398 402 $kill->setFBCorpName($row['fbcrp_name']); 403 $kill->setFBAllianceName($row['fbcrp_name']); 399 404 $kill->setKillPoints($row['kll_points']); 400 405 $kill->setExternalID($row['kll_external_id']); … … 529 534 $this->plimit_ = $pagesplitter->getSplit(); 530 535 $this->poffset_ = ($page * $this->plimit_) - $this->plimit_; 531 // echo $this->offset_; 532 // echo $this->limit_; 533 } 534 535 // Filter results by week. Requires the year to also be set. 536 } 537 538 //! Filter results by week. Requires the year to also be set. 536 539 function setWeek($weekno) 537 540 { … … 542 545 } 543 546 544 // Filter results by year.547 //! Filter results by year. 545 548 function setYear($yearno) 546 549 { … … 553 556 } 554 557 555 // Filter results by starting week. Requires the year to also be set.558 //! Filter results by starting week. Requires the year to also be set. 556 559 function setStartWeek($weekno) 557 560 { … … 562 565 } 563 566 564 // Filter results by starting date/time.567 //! Filter results by starting date/time. 565 568 function setStartDate($timestamp) 566 569 { … … 569 572 } 570 573 571 // Filter results by ending date/time.574 //! Filter results by ending date/time. 572 575 function setEndDate($timestamp) 573 576 { … … 576 579 } 577 580 578 // Return SQL for date filter using currently set date limits 581 //! Convert given date ranges to SQL date range. 582 583 //! \return string containing SQL date filter. 579 584 function getDateFilter() 580 585 { 581 // timestamp filter 582 $qstartdate = 0; 583 $qenddate = 2147483647; 584 $sql = ''; 585 586 /* Priority order of date filters: 587 * weekno > startWeek > yearno 588 * weekno > yearno 589 * startDate and endDate are used if they restrict the date range further 590 * weekno and startweek are not used if no year is set 591 */ 592 if($this->yearno_ && $this->weekno_) 593 { 594 if ($this->weekno_ == 1) 595 { 596 $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 597 $qenddate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_).' weeks - 1 minute UTC'); 598 } 599 else if ($this->weekno_ == 53) 600 { 601 $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 602 $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 603 } 604 else 605 { 606 $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 607 $qenddate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_).' weeks - 1 minute UTC'); 608 } 609 } 610 else if($this->yearno_ && $this->startweekno_) 611 { 612 if ($this->startweekno_ == 1) $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 613 else $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 614 } 615 else if($this->yearno_) 616 { 617 $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 618 $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 619 } 620 //If set use the latest startdate and earliest enddate set. 621 if($this->startDate_ && $qstartdate < strtotime($this->startDate_." UTC")) $qstartdate = strtotime($this->startDate_." UTC"); 622 if($this->endDate_ && $qenddate > strtotime($this->endDate_." UTC")) $qenddate = strtotime($this->endDate_." UTC"); 623 624 if($qstartdate > 0) $sql .= " kll.kll_timestamp >= '".gmdate('Y-m-d H:i',$qstartdate)."' "; 625 if($qstartdate > 0 && $qenddate < 2147483647) $sql .= " AND "; 626 if($qenddate < 2147483647) $sql .= " kll.kll_timestamp <= '".gmdate('Y-m-d H:i',$qenddate)."' "; 627 return $sql; 586 $qstartdate = makeStartDate($this->weekno_, $this->yearno_, $this->monthno_, $this->startweekno_, $this->startDate_); 587 $qenddate = makeEndDate($this->weekno_, $this->yearno_, $this->monthno_, $this->endDate_); 588 if($qstartdate) $sql .= " kll.kll_timestamp >= '".gmdate('Y-m-d H:i',$qstartdate)."' "; 589 if($qstartdate && $qenddate) $sql .= " AND "; 590 if($qenddate) $sql .= " kll.kll_timestamp <= '".gmdate('Y-m-d H:i',$qenddate)."' "; 591 return $sql; 628 592 } 629 593 -
dev/common/includes/class.killsummarytable.php
r377 r392 4 4 class KillSummaryTable 5 5 { 6 function KillSummaryTable($klist = null, $llist = null) 7 { 8 $this->klist_ = $klist; 9 $this->llist_ = $llist; 10 $this->verbose_ = false; 11 $this->filter_ = true; 12 $this->inv_plt_ = array(); 13 $this->inv_crp_ = array(); 14 $this->inv_all_ = array(); 15 } 16 17 function setBreak($break) 18 { 19 $this->break_ = $break; 20 } 21 22 function setVerbose($verbose) 23 { 24 $this->verbose_ = $verbose; 25 } 26 27 function setFilter($filter) 28 { 29 $this->filter_ = $filter; 30 } 31 32 function setWeek($weekno) 33 { 34 $weekno=intval($weekno); 35 if($weekno <1) $this->weekno_ = 1; 36 if($weekno >53) $this->weekno_ = 53; 37 else $this->weekno_ = $weekno; 38 } 39 40 function setMonth($monthno) 41 { 42 $monthno = intval($monthno); 43 if($monthno < 1) $this->monthno_ = 1; 44 if($monthno > 12) $this->monthno_ = 12; 45 else $this->monthno_ = $monthno; 46 } 47 48 function setYear($yearno) 49 { 50 // 1970-2038 is the allowable range for the timestamp code used 51 // Needs to be revisited in the next 30 years 52 $yearno = intval($yearno); 53 if($yearno < 1970) $this->yearno_ = 1970; 54 if($yearno > 2038) $this->yearno_ = 2038; 55 else $this->yearno_ = $yearno; 56 } 57 58 function setStartWeek($weekno) 59 { 60 $weekno=intval($weekno); 61 if($weekno <1) $this->startweekno_ = 1; 62 if($weekno >53) $this->startweekno_ = 53; 63 else $this->startweekno_ = $weekno; 64 } 65 66 function setStartDate($timestamp) 67 { 68 // Check timestamp is valid before adding 69 if(strtotime($timestamp)) $this->startDate_ = $timestamp; 70 } 71 72 function setEndDate($timestamp) 73 { 74 // Check timestamp is valid before adding 75 if(strtotime($timestamp)) $this->endDate_ = $timestamp; 76 } 77 78 // Return SQL for date filter using currently set date limits 79 function setDateFilter() 80 { 81 $qstartdate = 0; 82 $qenddate = 2147483647; 83 $sql = ''; 84 85 /* Priority order of date filters: 86 * weekno > monthno > startWeek > yearno 87 * weekno > monthno > yearno 88 * startDate and endDate are used if they restrict the date range further 89 * monthno, weekno and startweek are not used if no year is set 90 */ 91 if($this->yearno_ && $this->weekno_) 92 { 93 if ($this->weekno_ == 1) 94 { 95 $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 96 $qenddate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_).' weeks - 1 minute UTC'); 97 } 98 else if ($this->weekno_ == 53) 99 { 100 $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 101 $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 102 } 103 else 104 { 105 $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 106 $qenddate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_).' weeks - 1 minute UTC'); 107 } 108 } 109 else if($this->yearno_ && $this->monthno_) 110 { 111 $qstartdate = strtotime($this->yearno_.'-'.$this->monthno_.'-1 00:00 UTC'); 112 if($this->monthno_ == 12) $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 113 else $qenddate = strtotime(($this->yearno_).'-'.($this->monthno_ + 1).'-1 00:00 - 1 minute UTC'); 114 } 115 else if($this->yearno_ && $this->startweekno_) 116 { 117 if ($this->startweekno_ == 1) $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 118 else $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 119 } 120 else if($this->yearno_) 121 { 122 $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 123 $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 124 } 125 //If set use the latest startdate and earliest enddate set. 126 if($this->startDate_ && $qstartdate < strtotime($this->startDate_." UTC")) $qstartdate = strtotime($this->startDate_." UTC"); 127 if($this->endDate_ && $qenddate > strtotime($this->endDate_." UTC")) $qenddate = strtotime($this->endDate_." UTC"); 128 129 if($qstartdate > 0) $sql .= " kll.kll_timestamp >= '".gmdate('Y-m-d H:i',$qstartdate)."' "; 130 if($qenddate < 2147483647) $sql .= " and kll.kll_timestamp <= '".gmdate('Y-m-d H:i',$qenddate)."' "; 131 return $sql; 132 } 133 134 function getTotalKills() 135 { 136 return $this->tkcount_; 137 } 138 139 function getTotalLosses() 140 { 141 return $this->tlcount_; 142 } 143 144 function getTotalKillPoints() 145 { 146 return $this->tkpoints_; 147 } 148 149 function getTotalLossPoints() 150 { 151 return $this->tlpoints_; 152 } 153 154 function getTotalKillISK() 155 { 156 return $this->tkisk_; 157 } 158 159 function getTotalLossISK() 160 { 161 return $this->tlisk_; 162 } 163 164 function setView($string) 165 { 166 $this->view_ = $string; 167 } 168 169 function addInvolvedPilot($pilot) 170 { 171 $this->inv_plt_[] = $pilot->getID(); 172 if ($this->inv_crp_ || $this->inv_all_) 173 { 174 $this->mixedinvolved_ = true; 175 } 176 } 177 178 function addInvolvedCorp($corp) 179 { 180 $this->inv_crp_[] = $corp->getID(); 181 if ($this->inv_plt_ || $this->inv_all_) 182 { 183 $this->mixedinvolved_ = true; 184 } 185 } 186 187 function addInvolvedAlliance($alliance) 188 { 189 $this->inv_all_[] = $alliance->getID(); 190 if ($this->inv_plt_ || $this->inv_crp_) 191 { 192 $this->mixedinvolved_ = true; 193 } 194 } 195 196 // do it faster, baby! 197 function getkills() 198 { 199 if ($this->mixedinvolved_) 200 { 201 echo 'mode not supported<br>'; 202 exit; 203 } 204 205 $this->entry_ = array(); 206 // as there is no way to do this elegantly in sql 207 // i'll keep it in php 208 $sql = "select scl_id, scl_class from kb3_ship_classes 6 function KillSummaryTable($klist = null, $llist = null) 7 { 8 $this->klist_ = $klist; 9 $this->llist_ = $llist; 10 $this->verbose_ = false; 11 $this->filter_ = true; 12 $this->inv_plt_ = array(); 13 $this->inv_crp_ = array(); 14 $this->inv_all_ = array(); 15 } 16 17 function setBreak($break) 18 { 19 $this->break_ = $break; 20 } 21 22 function setVerbose($verbose) 23 { 24 $this->verbose_ = $verbose; 25 } 26 27 function setFilter($filter) 28 { 29 $this->filter_ = $filter; 30 } 31 32 function setWeek($weekno) 33 { 34 $weekno=intval($weekno); 35 if($weekno <1) $this->weekno_ = 1; 36 if($weekno >53) $this->weekno_ = 53; 37 else $this->weekno_ = $weekno; 38 } 39 40 function setMonth($monthno) 41 { 42 $monthno = intval($monthno); 43 if($monthno < 1) $this->monthno_ = 1; 44 if($monthno > 12) $this->monthno_ = 12; 45 else $this->monthno_ = $monthno; 46 } 47 48 function setYear($yearno) 49 { 50 // 1970-2038 is the allowable range for the timestamp code used 51 // Needs to be revisited in the next 30 years 52 $yearno = intval($yearno); 53 if($yearno < 1970) $this->yearno_ = 1970; 54 if($yearno > 2038) $this->yearno_ = 2038; 55 else $this->yearno_ = $yearno; 56 } 57 58 function setStartWeek($weekno) 59 { 60 $weekno=intval($weekno); 61 if($weekno <1) $this->startweekno_ = 1; 62 if($weekno >53) $this->startweekno_ = 53; 63 else $this->startweekno_ = $weekno; 64 } 65 66 function setStartDate($timestamp) 67 { 68 // Check timestamp is valid before adding 69 if(strtotime($timestamp)) $this->startDate_ = $timestamp; 70 } 71 72 function setEndDate($timestamp) 73 { 74 // Check timestamp is valid before adding 75 if(strtotime($timestamp)) $this->endDate_ = $timestamp; 76 } 77 78 // Return SQL for date filter using currently set date limits 79 function setDateFilter() 80 { 81 $qstartdate = makeStartDate($this->weekno_, $this->yearno_, $this->monthno_, $this->startweekno_, $this->startDate_); 82 $qenddate = makeEndDate($this->weekno_, $this->yearno_, $this->monthno_, $this->endDate_); 83 if($qstartdate) $sql .= " kll.kll_timestamp >= '".gmdate('Y-m-d H:i',$qstartdate)."' "; 84 if($qstartdate && $qenddate) $sql .= " AND "; 85 if($qenddate) $sql .= " kll.kll_timestamp <= '".gmdate('Y-m-d H:i',$qenddate)."' "; 86 return $sql; 87 } 88 89 function getTotalKills() 90 { 91 return $this->tkcount_; 92 } 93 94 function getTotalLosses() 95 { 96 return $this->tlcount_; 97 } 98 99 function getTotalKillPoints() 100 { 101 return $this->tkpoints_; 102 } 103 104 function getTotalLossPoints() 105 { 106 return $this->tlpoints_; 107 } 108 109 function getTotalKillISK() 110 { 111 return $this->tkisk_; 112 } 113 114 function getTotalLossISK() 115 { 116 return $this->tlisk_; 117 } 118 119 function setView($string) 120 { 121 $this->view_ = $string; 122 } 123 124 function addInvolvedPilot($pilot) 125 { 126 $this->inv_plt_[] = $pilot->getID(); 127 if ($this->inv_crp_ || $this->inv_all_) 128 { 129 $this->mixedinvolved_ = true; 130 } 131 } 132 133 function addInvolvedCorp($corp) 134 { 135 $this->inv_crp_[] = $corp->getID(); 136 if ($this->inv_plt_ || $this->inv_all_) 137 { 138 $this->mixedinvolved_ = true; 139 } 140 } 141 142 function addInvolvedAlliance($alliance) 143 { 144 $this->inv_all_[] = $alliance->getID(); 145 if ($this->inv_plt_ || $this->inv_crp_) 146 { 147 $this->mixedinvolved_ = true; 148 } 149 } 150 151 // do it faster, baby! 152 function getkills() 153 { 154 if ($this->mixedinvolved_) 155 { 156 echo 'mode not supported<br>'; 157 exit; 158 } 159 160 $this->entry_ = array(); 161 // as there is no way to do this elegantly in sql 162 // i'll keep it in php 163 $sql = "select scl_id, scl_class from kb3_ship_classes 209 164 where scl_class not in ('Drone','Unknown') order by scl_class"; 210 165 211 212 213 214 215 216 217 218 219 220 221 166 $qry = new DBQuery(); 167 $qry->execute($sql); 168 while ($row = $qry->getRow()) 169 { 170 $this->entry_[$row['scl_class']] = array('id' => $row['scl_id'], 171 'kills' => 0, 'kills_isk' => 0, 172 'losses' => 0, 'losses_isk' => 0); 173 } 174 175 $sql = 'SELECT count(distinct kll.kll_id) AS knb, scl_id, scl_class,'; 176 $sql .= ' sum(kll_isk_loss) AS kisk FROM kb3_kills kll 222 177 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )'; 223 224 225 226 178 $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class )'; 179 180 // Force MySQL to first filter by date if a date range is given. 181 if($this->setDateFilter()) 227 182 { 228 183 $sql.= 'WHERE '.$this->setDateFilter(); … … 240 195 } 241 196 } 242 197 else 243 198 { 244 199 if ($this->inv_plt_) … … 256 211 } 257 212 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 213 $sql .= 'GROUP BY scl_class order by scl_class'; 214 215 $qry = new DBQuery(); 216 $qry->execute($sql); 217 while ($row = $qry->getRow()) 218 { 219 $this->entry_[$row['scl_class']]['kills'] = $row['knb']; 220 $this->entry_[$row['scl_class']]['kills_isk'] = $row['kisk']; 221 $this->tkcount_ += $row['knb']; 222 $this->tkisk_ += $row['kisk']; 223 } 224 225 226 $sql = 'SELECT count(distinct kll_id) AS lnb, scl_id, scl_class,'; 227 $sql .= ' sum(kll_isk_loss) AS lisk FROM kb3_kills kll 273 228 INNER JOIN kb3_ships shp ON ( shp.shp_id = kll.kll_ship_id )'; 274 275 276 277 229 $sql .= ' INNER JOIN kb3_ship_classes scl ON ( scl.scl_id = shp.shp_class )'; 230 231 $sqlop = ' WHERE '; 232 if($this->setDateFilter()) 278 233 { 279 234 $sql.= $sqlop.$this->setDateFilter(); … … 281 236 } 282 237 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 238 if ($this->inv_plt_) 239 { 240 $sql .= $sqlop.' kll.kll_victim_id IN ( '.implode(',', $this->inv_plt_).' ) '; 241 $sql .= ' AND EXISTS (SELECT 1 FROM kb3_inv_detail ind WHERE kll.kll_id = ind_kll_id AND ind.ind_plt_id NOT IN ( '.implode(',', $this->inv_plt_).' ) limit 0,1) '; 242 } 243 elseif ($this->inv_crp_) 244 { 245 $sql .= $sqlop.' kll.kll_crp_id IN ( '.implode(',', $this->inv_crp_).' ) '; 246 $sql .= 'AND EXISTS (SELECT 1 FROM kb3_inv_detail ind WHERE kll.kll_id = ind_kll_id AND ind.ind_crp_id NOT IN ( '.implode(',', $this->inv_crp_).' ) limit 0,1) '; 247 } 248 elseif ($this->inv_all_) 249 { 250 $sql .= $sqlop.' kll.kll_all_id IN ( '.implode(',', $this->inv_all_).' ) '; 251 $sql .= 'AND EXISTS (SELECT 1 FROM kb3_inv_detail ind WHERE kll.kll_id = ind_kll_id AND ind.ind_all_id NOT IN ( '.implode(',', $this->inv_all_).' ) limit 0,1) '; 252 } 253 $sql .= 'GROUP BY scl_class order by scl_class'; 254 255 $qry = new DBQuery(); 256 $qry->execute($sql); 257 while ($row = $qry->getRow()) 258 { 259 $this->entry_[$row['scl_class']]['losses'] = $row['lnb']; 260 $this->entry_[$row['scl_class']]['losses_isk'] = $row['lisk']; 261 262 $this->tlcount_ += $row['lnb']; 263 $this->tlisk_ += $row['lisk']; 264 } 265 } 266 267 function generate() 268 { 269 if ($this->klist_) 270 { 271 $entry = array(); 272 // build array 273 $sql = "select scl_id, scl_class 319 274 from kb3_ship_classes 320 275 where scl_class not in ( 'Drone', 'Unknown' ) 321 276 order by scl_class"; 322 277 323 $qry = new DBQuery(); 324 $qry->execute($sql) or die($qry->getErrorMsg()); 325 while ($row = $qry->getRow()) 326 { 327 if (!$row['scl_id']) 328 continue; 329 330 $shipclass = new ShipClass($row['scl_id']); 331 $shipclass->setName($row['scl_class']); 332 333 $entry[$shipclass->getName()]['id'] = $row['scl_id']; 334 $entry[$shipclass->getName()]['kills'] = 0; 335 $entry[$shipclass->getName()]['kills_isk'] = 0; 336 $entry[$shipclass->getName()]['losses'] = 0; 337 $entry[$shipclass->getName()]['losses_isk'] = 0; 338 } 339 // kills 340 while ($kill = $this->klist_->getKill()) 341 { 342 $classname = $kill->getVictimShipClassName(); 343 $entry[$classname]['kills']++; 344 $entry[$classname]['kills_isk'] += $kill->getISKLoss(); 345 $this->tkcount_++; 346 $this->tkisk_ += $kill->getISKLoss(); 347 } 348 // losses 349 while ($kill = $this->llist_->getKill()) 350 { 351 $classname = $kill->getVictimShipClassName(); 352 $entry[$classname]['losses']++; 353 $entry[$classname]['losses_isk'] += $kill->getISKLoss(); 354 $this->tlcount_++; 355 $this->tlisk_ += $kill->getISKLoss(); 356 } 357 } 358 else 359 { 360 $this->getkills(); 361 $entry = &$this->entry_; 362 } 363 364 $odd = false; 365 $prevdate = ""; 366 $num = count($entry); 367 $width_mod = $this->break_/$num; 278 $qry = new DBQuery(); 279 $qry->execute($sql) or die($qry->getErrorMsg()); 280 while ($row = $qry->getRow()) 281 { 282 if (!$row['scl_id']) 283 continue; 284 285 $shipclass = new ShipClass($row['scl_id']); 286 $shipclass->setName($row['scl_class']); 287 288 $entry[$shipclass->getName()]['id'] = $row['scl_id']; 289 $entry[$shipclass->getName()]['kills'] = 0; 290 $entry[$shipclass->getName()]['kills_isk'] = 0; 291 $entry[$shipclass->getName()]['losses'] = 0; 292 $entry[$shipclass->getName()]['losses_isk'] = 0; 293 } 294 // kills 295 while ($kill = $this->klist_->getKill()) 296 { 297 $classname = $kill->getVictimShipClassName(); 298 $entry[$classname]['kills']++; 299 $entry[$classname]['kills_isk'] += $kill->getISKLoss(); 300 $this->tkcount_++; 301 $this->tkisk_ += $kill->getISKLoss(); 302 } 303 // losses 304 while ($kill = $this->llist_->getKill()) 305 { 306 $classname = $kill->getVictimShipClassName(); 307 $entry[$classname]['losses']++; 308 $entry[$classname]['losses_isk'] += $kill->getISKLoss(); 309 $this->tlcount_++; 310 $this->tlisk_ += $kill->getISKLoss(); 311 } 312 } 313 else 314 { 315 $this->getkills(); 316 $entry = &$this->entry_; 317 } 318 319 $odd = false; 320 $prevdate = ""; 321 // Don't count noobships. 322 $num = count($entry) - 1; 323 $columns = floor($num/$this->break_); 324 if(!$columns) $columns = 1; 325 $width_mod = 1/$columns; 368 326 $width = round($width_mod*100); 369 if($widthmod > 0) $width_abs = round($width_mod*(760-60/$width_mod)); 370 else $width_abs = round($width_mod*600); 371 372 $html .= "<table class=kb-subtable width=\"100%\" border=\"0\" cellspacing=0>"; 373 if ($this->break_) 374 $html .= "<tr><td valign=top width=\"$width%\"><table class=kb-table cellspacing=\"1\" width=\"100%\">"; 375 $counter = 1; 376 377 if ($this->verbose_) 378 { 379 $header = "<tr class=kb-table-header><td class=kb-table-cell width=\"$width_abs\">Ship class</td><td class=kb-table-cell width=60 align=center>Kills</td><td class=kb-table-cell width=60 align=center>ISK (M)</td><td class=kb-table-cell width=60 align=center>Losses</td><td class=kb-table-cell width=60 align=center>ISK (M)</td></tr>"; 380 } 381 else 382 { 383 $header = "<tr class=kb-table-header><td class=kb-table-cell width=\"$width_abs\">Ship class</td><td class=kb-table-cell width=30 align=center>K</td><td class=kb-table-cell width=30 align=center>L</td></tr>"; 384 } 385 386 $html .= $header; 387 388 foreach ($entry as $k => $v) 389 { 390 if (!$v['id'] || $v['id'] == 3) 391 continue; 392 if ($this->break_ && $counter > $this->break_) 393 { 394 $html .= "</table></td>"; 395 $html .= "<td valign=top width=\"$width%\"><table class=kb-table cellspacing=\"1\">"; 396 $html .= $header; 397 $counter = 1; 398 } 399 400 if (!$odd) 401 { 402 $odd = true; 403 $class = 'kb-table-row-odd'; 404 } 405 else 406 { 407 $odd = false; 408 $class = 'kb-table-row-even'; 409 } 410 411 if ($_GET['scl_id'] != "" && $v['id'] == $_GET['scl_id']) 412 $highlight = "-hl"; 413 else 414 $highlight = ""; 415 416 if ($v['kills'] == 0) 417 $kclass = "kl-kill-null"; 418 else 419 $kclass = "kl-kill"; 420 421 if ($v['losses'] == 0) 422 $lclass = "kl-loss-null"; 423 else 424 $lclass = "kl-loss"; 425 426 $html .= "<tr class=".$class.">"; 427 428 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 429 $qrystring = preg_replace("/&page=([0-9]?[0-9])/", "", $qrystring); 430 $qrystring = preg_replace("/&/", "&", $qrystring); 431 if ($this->view_) 432 { 433 $qrystring .= '&view='.$this->view_; 434 } 435 $html .= "<td nowrap class=kb-table-cell><b>"; 436 437 if ($this->filter_) $html .= "<a class=kb-shipclass".$highlight." href=\"?".$qrystring."&scl_id=".$v['id']."\">"; 438 439 $html .= $k; 440 441 if ($this->filter_) $html .= "</a>"; 442 443 $html .= "</b></td>"; 444 445 $html .= "<td class=".$kclass." align=center>".$v['kills']."</td>"; 446 if ($this->verbose_) 447 $html .= "<td class=".$kclass." align=center>".round($v['kills_isk']/1000000000, 2)."</td>"; 448 449 $html .= "<td class=".$lclass." align=center>".$v['losses']."</td>"; 450 if ($this->verbose_) 451 $html .= "<td class=".$lclass." align=center>".round($v['losses_isk']/1000000000, 2)."</td>"; 452 453 $html .= "</tr>"; 454 455 $counter++; 456 457 $this->tkcount_ += $kcount; 458 $this->tkisk_ += $kisk; 459 $this->tkpoints_ += $kpoints; 460 $this->tlcount_ += $lcount; 461 $this->tlisk_ += $lisk; 462 $this->tlpoints_ += $lpoints; 463 } 464 if ($this->break_) 465 $html .= "</table></td>"; 466 467 $html .= "</tr></table>"; 468 469 if (config::get('summarytable_summary')) 470 { 471 if (config::get('summarytable_efficiency')) 472 { 473 $efficiency = round($this->tkisk_ / (($this->tkisk_ + $this->tlisk_) == 0 ? 1 : ($this->tkisk_ + $this->tlisk_)) * 100, 2); 474 if($this->tkisk_ + $this->tlisk_ < 2000000000) 475 $html .= '<table style="text-align:center; width:90%;" border=0 cellspacing=2>' 476 .'<tr align=center> 477 <td width=30%><span style="text-align:right;" class="killcount">' .$this->tkcount_.' Ships killed ('.round($this->tkisk_/1000000, 2).'M ISK)</span></td> 478 <td width=30%><span style="text-align:center;" class="losscount">'.$this->tlcount_.' Ships lost ('.round($this->tlisk_/1000000, 2).'M ISK)</span></td> 479 <td width=30%><span style="text-align:left;" class="efficency">'.$efficiency.'% Efficiency (ISK)</span></td> 480 </tr> 481 </table>'; 482 else 483 $html .= '<table style="text-align:center; width:90%;" border=0 cellspacing=2>' 484 .'<tr align=center> 485 <td width=30%><span style="text-align:right;" class="killcount">' .$this->tkcount_.' Ships killed ('.round($this->tkisk_/1000000000, 2).'B ISK)</span></td> 486 <td width=30%><span style="text-align:center;" class="losscount">'.$this->tlcount_.' Ships lost ('.round($this->tlisk_/1000000000, 2).'B ISK)</span></td> 487 <td width=30%><span style="text-align:left;" class="efficency">'.$efficiency.'% Efficiency (ISK)</span></td> 488 </tr> 489 </table>'; 490 } 491 else 492 { 493 if($this->tkisk_ + $this->tlisk_ < 2000000000) 494 $html .= '<table style="width:100%" border=0 cellspacing=2>' 495 .'<tr align=center><td style="width:51%;"><span style="text-align:right;" class="killcount">' 496 .$this->tkcount_.' Ships killed ('.round($this->tkisk_/1000000, 2).'M ISK)</span></td><td style="width:49%;"><span class="losscount">'.$this->tlcount_.' Ships lost ('.round($this->tlisk_/1000000, 2).'M ISK)</span></td></tr></table>'; 497 else 498 $html .= '<table style="width:100%" border=0 cellspacing=2>' 499 .'<tr align=center><td style="width:51%;"><span style="text-align:right;" class="killcount">' 500 .$this->tkcount_.' Ships killed ('.round($this->tkisk_/1000000000, 2).'B ISK)</span></td><td style="width:49%;"><span class="losscount">'.$this->tlcount_.' Ships lost ('.round($this->tlisk_/1000000000, 2).'B ISK)</span></td></tr></table>'; 501 } 502 } 503 504 if ($_GET['scl_id'] != "") 505 { 506 $html .= "<table align=center><tr><td align=center valign=top class=weeknav>"; 507 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 508 $qrystring = preg_replace("/&/", "&", $qrystring); 509 $html .= "[<a href=\"?".$qrystring."\">clear filter</a>]</td></tr></table>"; 510 } 511 512 return $html; 513 } 327 if($this->verbose_) $width_abs = round($width_mod*(760-240*$columns)); 328 else $width_abs = round($width_mod*(760-60*$columns)); 329 $summary = array(); 330 $count = 0; 331 foreach ($entry as $k => $v) 332 { 333 if($v['id'] == 3) continue; 334 if($count && $this->break_ && $count%$this->break_ == 0) $v['break'] = 1; 335 else $v['break'] = 0; 336 if($_GET['scl_id'] && $_GET['scl_id'] == $v['id']) $v['hl'] = 1; 337 else $v['hl'] = 0; 338 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 339 $qrystring = preg_replace("/&page=([0-9]?[0-9])/", "", $qrystring); 340 $qrystring = preg_replace("/&/", "&", $qrystring); 341 if ($this->view_) 342 { 343 $qrystring .= '&view='.$this->view_; 344 } 345 $v['url'] = $querystring; 346 $v['kisk'] = round($v['kills_isk']/1000000, 2); 347 $v['lisk'] = round($v['losses_isk']/1000000, 2); 348 $v['name'] = $k; 349 350 $summary[] = $v; 351 352 $this->tkcount_ += $kcount; 353 $this->tkisk_ += $kisk; 354 $this->tkpoints_ += $kpoints; 355 $this->tlcount_ += $lcount; 356 $this->tlisk_ += $lisk; 357 $this->tlpoints_ += $lpoints; 358 $count++; 359 360 } 361 global $smarty; 362 $smarty->assign('summary', $summary); 363 $smarty->assign('count', count($entry)); 364 $smarty->assign('break', $this->break_); 365 $smarty->assign('width', $width); 366 $smarty->assign('width_abs', $width_abs); 367 $smarty->assign('columns', $columns); 368 $smarty->assign('verbose', $this->verbose_); 369 $smarty->assign('filter', $this->filter_); 370 $smarty->assign('losses', 1); 371 372 if (config::get('summarytable_summary')) 373 { 374 $smarty->assign('summarysummary', 1); 375 if (config::get('summarytable_efficiency')) 376 $smarty->assign('efficiency', round($this->tkisk_ / (($this->tkisk_ + $this->tlisk_) == 0 ? 1 : ($this->tkisk_ + $this->tlisk_)) * 100, 2)); 377 else $smarty->assign('efficiency', 0); 378 $smarty->assign('kiskB', round($this->tkisk_/1000000000, 2)); 379 $smarty->assign('liskB', round($this->tlisk_/1000000000, 2)); 380 $smarty->assign('kiskM', round($this->tkisk_/1000000, 2)); 381 $smarty->assign('liskM', round($this->tlisk_/1000000, 2)); 382 $smarty->assign('kcount', $this->tkcount_); 383 $smarty->assign('lcount', $this->tlcount_); 384 } 385 386 if ($_GET['scl_id'] != "") 387 { 388 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", '?'.$_SERVER['QUERY_STRING']); 389 $qrystring = preg_replace("/&/", "&", $qrystring); 390 $smarty->assign('clearfilter',$qrystring); 391 } 392 393 $html .= $smarty->fetch(get_tpl('summarytable')); 394 395 return $html; 396 } 514 397 } 515 398 ?> -
dev/common/includes/class.killsummarytable.public.php
r377 r392 114 114 $odd = false; 115 115 $prevdate = ""; 116 $html .= "<table class=kb-subtable width=\"100%\" border=\"0\" cellspacing=0>"; 117 if ($this->break_) 118 $html .= "<tr><td valign=top><table class=kb-table cellspacing=\"1\" width=\"100%\">"; 119 $counter = 1; 116 // Don't count noobships. 117 $num = count($entry) - 1; 118 $columns = floor($num/$this->break_); 119 if(!$columns) $columns = 1; 120 $width_mod = 1/$columns; 121 $width = round($width_mod*100); 122 if($this->verbose_) $width_abs = round($width_mod*(760-120*$columns)); 123 else $width_abs = round($width_mod*(760-30*$columns)); 120 124 121 if ($this->verbose_) 122 { 123 $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=60 align=center>Kills</td><td class=kb-table-cell width=60 align=center>ISK (M)</td></tr>"; 124 } 125 else 126 { 127 $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=30 align=center>K</td></tr>"; 128 } 129 $html .= $header; 125 $summary = array(); 126 $count = 0; 127 foreach ($entry as $k => $v) 128 { 129 if($v['id'] == 3) continue; 130 if($count && $this->break_ && $count%$this->break_ == 0) $v['break'] = 1; 131 else $v['break'] = 0; 132 if($_GET['scl_id'] && $_GET['scl_id'] == $v['id']) $v['hl'] = 1; 133 else $v['hl'] = 0; 134 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 135 $qrystring = preg_replace("/&page=([0-9]?[0-9])/", "", $qrystring); 136 $qrystring = preg_replace("/&/", "&", $qrystring); 137 if ($this->view_) 138 { 139 $qrystring .= '&view='.$this->view_; 140 } 141 $v['url'] = $querystring; 142 $v['kisk'] = round($v['kills_isk']/1000000, 2); 143 $v['name'] = $k; 130 144 131 foreach ($entry as $k => $v) 132 { 133 if (!$v['id'] || $v['id'] == 3) 134 continue; 135 if ($this->break_ && $counter > $this->break_) 136 { 137 $html .= "</table></td>"; 138 $html .= "<td valign=top><table class=kb-table cellspacing=\"1\">"; 139 $html .= $header; 140 $counter = 1; 141 } 145 $summary[] = $v; 142 146 143 if (!$odd) 144 { 145 $odd = true; 146 $class = 'kb-table-row-odd'; 147 } 148 else 149 { 150 $odd = false; 151 $class = 'kb-table-row-even'; 152 } 147 $this->tkcount_ += $kcount; 148 $this->tkisk_ += $kisk; 149 $this->tkpoints_ += $kpoints; 150 $count++; 151 } 152 global $smarty; 153 $smarty->assign('summary', $summary); 154 $smarty->assign('count', count($entry)); 155 $smarty->assign('break', $this->break_); 156 $smarty->assign('width', $width); 157 $smarty->assign('width_abs', $width_abs); 158 $smarty->assign('columns', $columns); 159 $smarty->assign('verbose', $this->verbose_); 160 $smarty->assign('filter', $this->filter_); 153 161 154 if ($_GET['scl_id'] != "" && $v['id'] == $_GET['scl_id']) 155 $highlight = "-hl"; 156 else 157 $highlight = ""; 162 if (config::get('summarytable_summary')) 163 { 164 $smarty->assign('summarysummary', 1); 165 $smarty->assign('efficiency', 0); 166 $smarty->assign('kiskB', round($this->tkisk_/1000000000, 2)); 167 $smarty->assign('kiskM', round($this->tkisk_/1000000, 2)); 168 $smarty->assign('kcount', $this->tkcount_); 169 } 158 170 159 if ($v['kills'] == 0) 160 $kclass = "kl-kill-null"; 161 else 162 $kclass = "kl-kill"; 171 if ($_GET['scl_id'] != "") 172 { 173 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", '?'.$_SERVER['QUERY_STRING']); 174 $qrystring = preg_replace("/&/", "&", $qrystring); 175 $smarty->assign('clearfilter',$qrystring); 176 } 163 177 164 $html .= "<tr class=".$class.">"; 165 166 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 167 $qrystring = preg_replace("/&page=([0-9]?[0-9])/", "", $qrystring); 168 if ($this->view_) 169 { 170 $qrystring .= '&view='.$this->view_; 171 } 172 $html .= "<td class=kb-table-cell><b>"; 173 174 if ($this->filter_) $html .= "<a class=kb-shipclass".$highlight." href=\"?".$qrystring."&scl_id=".$v['id']."\">"; 175 176 $html .= $k; 177 178 if ($this->filter_) $html .= "</a>"; 179 180 $html .= "</b></td>"; 181 182 $html .= "<td class=".$kclass." align=center>".$v['kills']."</td>"; 183 if ($this->verbose_) 184 $html .= "<td class=".$kclass." align=center>".round($v['kills_isk']/1000000, 2)."</td>"; 185 186 $html .= "</tr>"; 187 188 $counter++; 189 190 $this->tkcount_ += $kcount; 191 $this->tkisk_ += $kisk; 192 $this->tkpoints_ += $kpoints; 193 194 } 195 if ($this->break_) 196 $html .= "</table></td>"; 197 198 $html .= "</tr></table>"; 199 200 if (config::get('summarytable_summary')) 201 { 202 $html .= '<table width=100% border=0 cellspacing=2>' 203 .'<tr align=center><td class="killcount">'; 204 if($this->tkisk_ < 1000000000) 205 $html .= $this->tkcount_.' Ships killed ('.round($this->tkisk_/1000000, 2).'M ISK)</td></tr></table>'; 206 else 207 $html .= $this->tkcount_.' Ships killed ('.round($this->tkisk_/1000000000, 2).'B ISK)</td></tr></table>'; 208 209 } 210 211 if ($_GET['scl_id'] != "") 212 { 213 $html .= "<table align=center><tr><td align=center valign=top class=weeknav>"; 214 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 215 $html .= "[<a href=\"?".$qrystring."\">clear filter</a>]</td></tr></table>"; 216 } 178 $html .= $smarty->fetch(get_tpl('summarytable')); 217 179 218 180 return $html; -
dev/common/includes/class.toplist.php
r376 r392 175 175 } 176 176 177 // Return SQL for date filter using currently set date limits177 // Convert given date ranges to SQL date range. 178 178 function getDateFilter() 179 179 { 180 $qstartdate = 0; 181 $qenddate = 2147483647; 182 $sql = ''; 183 184 /* Priority order of date filters: 185 * weekno > monthno > startWeek > yearno 186 * weekno > monthno > yearno 187 * startDate and endDate are used if they restrict the date range further 188 * monthno, weekno and startweek are not used if no year is set 189 */ 190 if($this->yearno_ && $this->weekno_) 191 { 192 if ($this->weekno_ == 1) 193 { 194 $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 195 $qenddate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_).' weeks - 1 minute UTC'); 196 } 197 else if ($this->weekno_ == 53) 198 { 199 $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 200 $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 201 } 202 else 203 { 204 $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 205 $qenddate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_).' weeks - 1 minute UTC'); 206 } 207 } 208 else if($this->yearno_ && $this->monthno_) 209 { 210 $qstartdate = strtotime($this->yearno_.'-'.$this->monthno_.'-1 00:00 UTC'); 211 if($this->monthno_ == 12) $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 212 else $qenddate = strtotime(($this->yearno_).'-'.($this->monthno_ + 1).'-1 00:00 - 1 minute UTC'); 213 } 214 else if($this->yearno_ && $this->startweekno_) 215 { 216 if ($this->startweekno_ == 1) $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 217 else $qstartdate = strtotime($this->yearno_.'-1-1 last Monday + '.($this->weekno_-1).' weeks UTC'); 218 } 219 else if($this->yearno_) 220 { 221 $qstartdate = strtotime($this->yearno_.'-1-1 00:00 UTC'); 222 $qenddate = strtotime(($this->yearno_).'-12-31 23:59 UTC'); 223 } 224 //If set use the latest startdate and earliest enddate set. 225 if($this->startDate_ && $qstartdate < strtotime($this->startDate_." UTC")) $qstartdate = strtotime($this->startDate_." UTC"); 226 if($this->endDate_ && $qenddate > strtotime($this->endDate_." UTC")) $qenddate = strtotime($this->endDate_." UTC"); 227 228 if($qstartdate > 0) $sql .= " and kll.kll_timestamp >= '".gmdate('Y-m-d H:i',$qstartdate)."'"; 229 if($qenddate < 2147483647) $sql .= " and kll.kll_timestamp <= '".gmdate('Y-m-d H:i',$qenddate)."'"; 230 return $sql; 180 $qstartdate = makeStartDate($this->weekno_, $this->yearno_, $this->monthno_, $this->startweekno_, $this->startDate_); 181 $qenddate = makeEndDate($this->weekno_, $this->yearno_, $this->monthno_, $this->endDate_); 182 if($qstartdate || $qenddate) $sql .= " AND "; 183 { 184 if($qstartdate) $sql .= " kll.kll_timestamp >= '".gmdate('Y-m-d H:i',$qstartdate)."' "; 185 if($qstartdate && $qenddate) $sql .= " AND "; 186 if($qenddate) $sql .= " kll.kll_timestamp <= '".gmdate('Y-m-d H:i',$qenddate)."' "; 187 } 188 return $sql; 231 189 } 232 190 … … 953 911 function generate() 954 912 { 955 $sql = "select count(distinct ind.ind_kll_id) as cnt, ind.ind_wep_id as itm_id 956 from kb3_inv_detail ind 957 inner join kb3_items itm on (itm_id = ind.ind_wep_id)"; 958 if (DB_USE_CCP) 959 { 960 $sql = "select count(distinct ind.ind_kll_id) as cnt, ind.ind_wep_id as itm_id 961 from kb3_inv_detail ind 962 inner join kb3_invtypes itm on (typeID = ind.ind_wep_id)"; 963 } 913 $sql = "select count(distinct ind.ind_kll_id) as cnt, ind.ind_wep_id as itm_id 914 from kb3_inv_detail ind 915 inner join kb3_invtypes itm on (typeID = ind.ind_wep_id)"; 964 916 965 917 if ($this->invplt_) … … 974 926 $this->setSQLTop($sql); 975 927 // since ccps database doesnt have icons for ships this will also fix the ship as weapon bug 976 if (DB_USE_CCP)$sqlbottom .=" and itm.icon != ''".928 $sqlbottom .=" and itm.icon != ''". 977 929 " and itm.typeName != 'Unknown'". 978 930 " group by ind.ind_wep_id order by 1 desc limit 20"; 979 else $sqlbottom .= " and itm.itm_icon not in ( '1', 'icon_null' )".980 " and itm.itm_name != 'Unknown'".981 " group by ind.ind_wep_id order by 1 desc limit 20";982 931 $this->setSQLBottom($sqlbottom); 983 932 } -
dev/common/includes/globals.php
r391 r392 7 7 else 8 8 { 9 $svn_rev = '39 1';9 $svn_rev = '392'; 10 10 } 11 11 define('SVN_REV', $svn_rev); … … 86 86 return $test; 87 87 } 88 89 // Return start date 90 function makeStartDate($week = 0, $year = 0, $month = 0, $startweek = 0, $startdate = 0) 91 { 92 /* Priority order of date filters: 93 * weekno > monthno > startWeek > yearno 94 * weekno > monthno > yearno 95 * startDate and endDate are used if they restrict the date range further 96 * monthno, weekno and startweek are not used if no year is set 97 */ 98 $qstartdate=0; 99 if(intval($year)>0) 100 { 101 if($week) 102 { 103 if ($week == 1) 104 {$qstartdate = strtotime($year.'-1-1 00:00 UTC');} 105 else 106 {$qstartdate = strtotime($year.'-1-1 last Monday + '.($week-1).' weeks UTC');} 107 } 108 else if($month) 109 {$qstartdate = strtotime($year.'-'.$month.'-1 00:00 UTC');} 110 else if($startweek) 111 { 112 if ($startweek == 1) {$qstartdate = strtotime($year.'-1-1 00:00 UTC');} 113 else{ $qstartdate = strtotime($year.'-1-1 last Monday + '.($week-1).' weeks UTC');} 114 } 115 else 116 {$qstartdate = strtotime($year.'-1-1 00:00 UTC');} 117 } 118 //If set use the latest startdate and earliest enddate set. 119 if($startdate && $qstartdate < strtotime($startdate." UTC")) $qstartdate = strtotime($startdate." UTC"); 120 return $qstartdate; 121 } 122 123 // Return end date 124 function makeEndDate($week = 0, $year = 0, $onth = 0, $enddate = 0) 125 { 126 /* Priority order of date filters: 127 * weekno > monthno > startWeek > yearno 128 * weekno > monthno > yearno 129 * startDate and endDate are used if they restrict the date range further 130 * monthno, weekno and startweek are not used if no year is set 131 */ 132 if($year) 133 { 134 if($week) 135 { 136 if ($week == 53) 137 $qenddate = strtotime(($year).'-12-31 23:59 UTC'); 138 else 139 $qenddate = strtotime($year.'-1-1 last Monday + '.($week).' weeks - 1 minute UTC'); 140 } 141 else if($onth) 142 { 143 if($onth == 12) $qenddate = strtotime(($year).'-12-31 23:59 UTC'); 144 else $qenddate = strtotime(($year).'-'.($onth + 1).'-1 00:00 - 1 minute UTC'); 145 } 146 else 147 $qenddate = strtotime(($year).'-12-31 23:59 UTC'); 148 } 149 //If set use the earliest enddate. 150 if($enddate && (!$qenddate || ($qenddate && $qenddate > strtotime($enddate." UTC")))) $qenddate = strtotime($enddate." UTC"); 151 152 return $qenddate; 153 } -
dev/common/index.php
r383 r392 67 67 $config = new Config(KB_SITE); 68 68 //$ApiCache = new ApiCache(KB_SITE); 69 define('DB_USE_CCP', true);70 69 define('KB_HOST', config::get('cfg_kbhost')); 71 70 define('MAIN_SITE', config::get('cfg_mainsite')); -
dev/common/kill_detail.php
r391 r392 80 80 $qry = new DBQuery(); 81 81 $qry->execute("INSERT INTO kb3_item_price (typeID, price) VALUES ('".$IID."', '".$Val."') ON DUPLICATE KEY UPDATE price = '".$Val."'"); 82 foreach($kill->destroyeditems_ as &$ditem) 83 { 84 if($ditem->getItem()->getID() == $IID) $ditem->value = $Val; 85 } 86 foreach($kill->droppeditems_ as &$ditem) 87 { 88 if($ditem->getItem()->getID() == $IID) $ditem->value = $Val; 89 } 90 $qry->execute("UPDATE kb3_kills SET kll_isk_loss = ".$kill->calculateISKLoss()." WHERE kll_id = ".$kill->getID()); 82 91 } 83 92 } -
dev/mods/apoc_fitting/kill_detail.php
r391 r392 65 65 66 66 if (config::get('item_values')) 67 67 { 68 68 $smarty->assign('item_values', 'true'); 69 69 70 70 if ($page->isAdmin()) 71 { 72 $smarty->assign('admin', 'true'); 73 74 if (isset($_POST['submit']) && $_POST['submit'] == 'UpdateValue') 75 { 76 // Send new value for item to the database 77 $IID=$_POST['IID']; 78 $Val=$_POST[$IID]; 79 $qry=new DBQuery(); 80 $qry->execute("INSERT INTO kb3_item_price (typeID, price) VALUES ('" . $IID . "', '" . $Val 81 . "') ON DUPLICATE KEY UPDATE price = '" . $Val . "'"); 82 } 83 } 84 } 71 { 72 $smarty->assign('admin', 'true'); 73 74 if (isset($_POST['submit']) && $_POST['submit'] == 'UpdateValue') 75 { 76 // Send new value for item to the database 77 $IID=$_POST['IID']; 78 $Val=$_POST[$IID]; 79 $qry=new DBQuery(); 80 $qry->execute("INSERT INTO kb3_item_price (typeID, price) VALUES ('" . $IID . "', '" . $Val 81 . "') ON DUPLICATE KEY UPDATE price = '" . $Val . "'"); 82 foreach($kill->destroyeditems_ as &$ditem) 83 { 84 if($ditem->getItem()->getID() == $IID) $ditem->value = $Val; 85 } 86 foreach($kill->droppeditems_ as &$ditem) 87 { 88 if($ditem->getItem()->getID() == $IID) $ditem->value = $Val; 89 } 90 $qry->execute("UPDATE kb3_kills SET kll_isk_loss = ".$kill->calculateISKLoss()." WHERE kll_id = ".$kill->getID()); 91 } 92 } 93 } 85 94 86 95 if ($page->isAdmin()) -
dev/mods/rank_mod/rank.php
r378 r392 13 13 function generate() 14 14 { 15 $sql = "select count(1) as cnt, ind.ind_wep_id as itm_id, itm.itm_group as itm_grp 16 from kb3_inv_detail ind 17 inner join kb3_items itm on (itm_id = ind.ind_wep_id)"; 18 if (DB_USE_CCP) 19 { 20 $sql = "select count(*) as cnt, ind.ind_wep_id as itm_id, itm.GroupID as itm_grp 21 from kb3_inv_detail ind 22 inner join kb3_invtypes itm on (typeID = ind.ind_wep_id)"; 23 } 15 $sql = "select count(*) as cnt, ind.ind_wep_id as itm_id, itm.GroupID as itm_grp 16 from kb3_inv_detail ind 17 inner join kb3_invtypes itm on (typeID = ind.ind_wep_id)"; 24 18 25 19 if ($this->invplt_) … … 33 27 34 28 $this->setSQLTop($sql); 35 if (DB_USE_CCP) 36 { 37 // since ccps database doesnt have icons for ships this will also fix the ship as weapon bug 38 $this->setSQLBottom(" and itm.volume < '12000' 39 and itm.typeName != 'Unknown' 40 group by ind.ind_wep_id order by 1 desc"); 41 } 42 else 43 $this->setSQLBottom(" //and itm.itm_icon not in ( '1', 'icon_null' ) 44 and itm.itm_name != 'Unknown' 45 group by ind.ind_wep_id order by 1 desc"); 29 $this->setSQLBottom(" and itm.volume < '12000' 30 and itm.typeName != 'Unknown' 31 group by ind.ind_wep_id order by 1 desc"); 46 32 } 47 33 } -
dev/mods/rss_feed/class.rss.php
r173 r392 27 27 while ($kill = $this->kill_list_->getKill()) 28 28 { 29 if ($kill->isClassified()) 30 { 31 continue; 32 } 29 33 $url = KB_HOST; 30 34 if(strncasecmp("http://", KB_HOST, 7)) … … 51 55 <br /><b>Victim:</b> ".$kill->getVictimName()." 52 56 <br /><b>Corp:</b> ".shorten($kill->getVictimCorpName())." 57 <br /><b>Alliance:</b> ".shorten($kill->getVictimAllianceName())." 53 58 <br /><b>System:</b> ".shorten($kill->getSolarSystemName(), 10)." 54 59 <br /><b>Date:</b> ".$timestamp." … … 57 62 <br /><b>Final Blow:</b> ".$kill->getFBPilotName()." 58 63 <br /><b>Corp:</b> ".shorten($kill->getFBCorpName())." 64 <br /><b>Alliance:</b> ".shorten($kill->getFBAllianceName())." 59 65 </p> 60 66 ]]>