First, see here:
http://spacejerk.netIn short, when a kill is viewed in kill_detail, I've added a block of code that writes the kill ID, date, and total loss values to a new database table. The net effect here is every time a kill is posted, it's added to the database, and every time it's viewed later its value is updated to keep up with current market prices. I then added a new box to the main page that queries results less than a specified number of days old, and pulls out the top few (configurable), and displays the ship image, value lost, pilot name, etc.
First you need to create a new DB table using PHPmyAdmin, named iskloss with three fields named LossID, LossDate, and TotalLoss. The types in the same order should be varchar(30), varchar(30), bigint(30), default setting should work for the options, and create primary index on LossID.
kill_detail.php (in mods/fitting/ if applicable) find this line:
$html = $smarty->fetch('../mods/fitting/kill_detail.tpl');and directly above it add:
Code:
//BEGIN TOP VALUE KILLS
$LossID = $kill->getID();
$LossDate = $kill->getTimeStamp();
$TotalLoss = ($TotalValue + $ship->getPrice());
$qry = new DBQuery;
$qry->execute("select * from kb3_invtypes where typeID = $ship->externalid_");
while($row = $qry->getRow())
{
$LostGroup = $row['marketGroupID'];
}
//Excludes structures, comment out if statement and the loop { }thingies to include them
if ($LostGroup < 478 || $LostGroup > 490)
{
//Change corp/victim ID to exclude friendlies, $kill->getVictimAllianceID() for alliance
if ($kill->getVictimCorpID() != 1)
{
$qry = new DBQuery;
$qry->execute("insert into iskloss values('$LossID','$LossDate','$TotalLoss') on duplicate key update TotalLoss=$TotalLoss");
}
}
//END TOP VALUE KILLS
FOR A VERTICAL DISPLAY BOX, UNDER TOP KILLER/SCORER BOXESGo to home.php (check your mod folders to find the right one), find
$page->generate(); at the end before the closing ?> and add this ABOVE it:
Code:
// TOP VALUE KILLS PROTOTYPE, POORLY WRITTEN BY DOCTORSTUPID2, OPTIMIZED BY CATARI
// Box name
$topbox = new box("Top Value Kills");
// Number of top value kills to display
$topValueCount = 5;
$qry = new DBQuery();
// Change interval value for history length, e.g. 7 DAY for weekly, 30 DAY for monthly, etc
$qry->execute("SELECT LossDate, TotalLoss, LossID FROM iskloss WHERE LossDate>=NOW()-INTERVAL 30 DAY ORDER BY TotalLoss DESC LIMIT $topValueCount");
for($boxgen = 1;$boxgen <= $topValueCount; $boxgen++){
$topValue = $qry->getRow();
$query = new DBQuery();
$query->execute("SELECT k.kll_victim_id, k.kll_ship_id, p.plt_name, s.shp_name, i.typeID
FROM kb3_kills k
JOIN kb3_pilots p ON p.plt_id = k.kll_victim_id
JOIN kb3_ships s ON s.shp_id = k.kll_ship_id
JOIN kb3_invtypes i ON i.typeName = s.shp_name
WHERE kll_id=".$topValue['LossID']);
$row = $query->getRow();
$topbox->addOption('caption','<div align="center"><p><font size="2">' . $row['plt_name'] . '</font><br />' . $row['shp_name'] . '<br /><a href="?a=kill_detail&kll_id=' . $topValue['LossID'] . '"><img src="img/ships/64_64/' . $row['typeID'] . '.png" border=0></a><br />' . number_format($topValue['TotalLoss'], 2, '.', ',') . ' ISK</p></div>');
if ($boxgen != $topValueCount)
{
// Seperator displayed between kills
$topbox->addOption('caption','<div align="center"><p><img src="img/kills.gif"></p></div>');
}
}
// Days to display at bottom of box, comment out to hide
$topbox->addOption('caption','<div align="center">(Past 30 Days)</div>');
$page->addContext($topbox->generate());
// END TOP VALUE KILLS
FOR A HORIZONTAL BOX BELOW THE KILL SUMMARY TABLEGo to home.php (check your mod folders to find the right one), find
// bad hax0ring, we really need mod callback stuff and add this ABOVE it:
Code:
//TOP VALUE MOD, CREDIT TO GREZ AND ANDYM
$topValueCount = 5;
$qry = new DBQuery();
$qry->execute("SELECT LossDate, TotalLoss, LossID FROM iskloss WHERE LossDate>=NOW()-INTERVAL 30 DAY ORDER BY TotalLoss DESC LIMIT 5");
$html .='<div class="kb-date-header">Top Value Kills, 30 Days</div><BR>';
$html .='<table width="100%" class="kb-table"><tr>';
for($boxgen = 1;$boxgen <= $topValueCount; $boxgen++){
$topValue = $qry->getRow();
$query = new DBQuery();
$query->execute("SELECT k.kll_victim_id, k.kll_ship_id, p.plt_name, s.shp_name, i.typeID
FROM kb3_kills k
JOIN kb3_pilots p ON p.plt_id = k.kll_victim_id
JOIN kb3_ships s ON s.shp_id = k.kll_ship_id
JOIN kb3_invtypes i ON i.typeName = s.shp_name
WHERE kll_id=".$topValue['LossID']);
$row = $query->getRow();
$html .='<td align="center" class="kb-table-row-odd"><table width="100%"><tr><td align="center" width="20%"><b><font size="1">'.$row['plt_name'].'</font></b></td></tr><tr><td align="center"><a href="?a=kill_detail&kll_id=' . $topValue['LossID'] . '"><img src="img/ships/64_64/' . $row['typeID'] . '.png" border=0></a></td></tr><tr><td align="center"><b><font size="1">'.$row['shp_name'].'</font></b></td></tr><tr><td align="center"><b><font size="1">'.number_format($topValue['TotalLoss'], 2,'.', ',').' ISK</font></b></td></tr></table></td>';
}
$html .='</tr></table>';
//END TOP VALUE MOD
All of the configuration is done in home.php, on the lines below.
change the number to how many kills you want displayed:
$topValueCount = 5;Change history length by modifying the INTERVAL value:
$qry->execute("SELECT * FROM iskloss WHERE LossDate>=NOW()-INTERVAL 30 DAY ORDER BY TotalLoss DESC LIMIT $boxgen");Also change this to reflect the history:
$topbox->addOption("caption","<P><CENTER>(Past 30 Days)</CENTER></P>"); And you're done, it will give an SQL error at the top of the home page until there are enough rows in the table to populate the list. From here just skim over your killboard, viewing any kills that you know to be high value (CS, BS, capital, etc), and the table will begin to populate itself. You only need to go as far back as you have it configured for, i.e. you don't need to view kills from 2008 to add them to the table, they (probably) won't be used.
Please feel free to make changes to the code here, I'm very new to PHP so please pick it apart and post suggestions/corrections/improvements. I could also use some pointers on formatting the box on the home page, I more or less just duplicated the menu/nav box
