Changeset 418

Show
Ignore:
Timestamp:
07/12/09 03:25:31 (11 years ago)
Author:
kovell
Message:

Fixes: rank mod incorporates corplogo generation

Location:
dev
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dev/common/includes/globals.php

    r417 r418  
    77else 
    88{ 
    9         $svn_rev = '416'; 
     9        $svn_rev = '417'; 
    1010} 
    1111define('SVN_REV', $svn_rev); 
  • dev/mods/rank_mod/corp_detail.php

    r370 r418  
    66require_once('common/includes/class.killsummarytable.php'); 
    77require_once('common/includes/class.toplist.php'); 
     8require_once("common/includes/evelogo.php"); 
     9require_once("common/includes/class.eveapi.php"); 
    810require_once('mods/rank_mod/rank.php'); 
     11 
    912 
    1013if (!$crp_id = intval($_GET['crp_id'])) 
     
    2023    } 
    2124} 
     25 
     26$month = $_GET['m']; 
     27$year = $_GET['y']; 
     28 
     29if ($month == '') 
     30    $month = kbdate('m'); 
     31 
     32if ($year == '') 
     33    $year = kbdate('Y'); 
     34 
     35if ($month == 12) 
     36{ 
     37    $nmonth = 1; 
     38    $nyear = $year + 1; 
     39} 
     40else 
     41{ 
     42    $nmonth = $month + 1; 
     43    $nyear = $year; 
     44} 
     45if ($month == 1) 
     46{ 
     47    $pmonth = 12; 
     48    $pyear = $year - 1; 
     49} 
     50else 
     51{ 
     52    $pmonth = $month - 1; 
     53    $pyear = $year; 
     54} 
     55$monthname = kbdate("F", strtotime("2000-".$month."-2")); 
     56 
    2257$all_id = $_GET['all_id']; 
    2358$corp = new Corporation($crp_id); 
     
    3570array( 'type' => 'redcross', 'name' => 'Scorer', 'cnt' => 0,  'mname' =>'Iron Cross'),          // 1 
    3671array( 'type' => 'cross', 'name' => 'Solo Killer', 'cnt' => 0, 'mname' =>'Winged Cross'),       // 2 
    37 array( 'type' => 'wing1', 'name' => 'Damagedealer', 'cnt' => 0, 'mname' =>'Diamond Wing'),      // 3     
     72array( 'type' => 'wing1', 'name' => 'Damagedealer', 'cnt' => 0, 'mname' =>'Diamond Wing'),      // 3 
    3873array( 'type' => 'skull', 'name' => 'Final Blows', 'cnt' => 0, 'mname' =>'Red Skull'),          // 4 
    3974array( 'type' => 'globe', 'name' => 'Podkiller', 'cnt' => 0, 'mname' =>'Silver Globe'),         // 5 
     
    4378); 
    4479 
    45 $page = new Page('Corporation details - '.$corp->getName()); 
     80$corpname = str_replace(" ", "%20", $corp->getName() ); 
     81$myID = new API_NametoID(); 
     82$myID->setNames($corpname); 
     83$html .= $myID->fetchXML(); 
     84$myNames = $myID->getNameData(); 
     85 
     86$myAPI = new API_CorporationSheet(); 
     87$myAPI->setCorpID($myNames[0]['characterID']); 
     88 
     89$result .= $myAPI->fetchXML(); 
     90 
     91if ($result == "Corporation is not part of alliance.") 
     92{ 
     93        $page = new Page('Corporation details - '.$corp->getName()); 
     94} else { 
     95        $page = new Page('Corporation details - '.$corp->getName() . " [" . $myAPI->getTicker() . "]"); 
     96} 
    4697$html .= "<table class=kb-table width=\"100%\" border=\"0\" cellspacing=1><tr class=kb-table-row-even><td rowspan=8 width=128 align=center bgcolor=black>"; 
    4798 
     
    52103else 
    53104{ 
    54     $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
    55 } 
    56  
    57 $html .= "<td class=kb-table-cell width=180><b>Alliance:</b></td><td class=kb-table-cell>"; 
    58 if ($alliance->getName() == "Unknown" || $alliance->getName() == "None") 
    59 { 
    60     $html .= "<b>".$alliance->getName()."</b>"; 
    61 } 
    62 else 
    63 { 
    64     $html .= "<a href=\"?a=alliance_detail&all_id=".$alliance->getID()."\">".$alliance->getName()."</a>"; 
    65 } 
     105        if ($alliance != 0) 
     106        { 
     107                $mylogo = $myAPI->getLogo(); 
     108 
     109                if ($result == "Corporation is not part of alliance.") 
     110                { 
     111                        $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     112                } elseif ($result == "") { 
     113                        // create two sized logo's in 2 places - this allows checks already in place not to keep requesting corp logos each time page is viewed 
     114                        // class.thumb.php cannot work with png (although saved as jpg these are actually pngs) therefore we have to create the 128 size for it 
     115                        // doing this prevents the images being rendered each time the function is called and allows it to use one in the cache instead. 
     116                        CorporationLogo( $mylogo, 64, $corp->getID() ); 
     117                        CorporationLogo( $mylogo, 128, $corp->getID() ); 
     118 
     119                        $html .= "<img src=\"".$corp->getPortraitURL(128)."\" border=\"0\"></td>"; 
     120                } else { 
     121                        // some kind of error getting details from CCP so abort writing file(s) allowing us to try again later - in the meantime, lets print trusty default 
     122                        // error text will also appear where the picture is, which is nice 
     123                        $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     124                } 
     125        } else { 
     126                $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     127        } 
     128} 
     129 
    66130$k_cost=$kill_summary->getTotalKillISK(); 
    67131$l_cost=$kill_summary->getTotalLossISK(); 
     
    79143          if ($k_cost >= 1000000000) { 
    80144            $k_cost = round($k_cost / 1000000000, 2).'B'; 
    81           } else {  
     145          } else { 
    82146            $k_cost = round($k_cost / 1000000, 2).'M'; 
    83147          } 
    84148          if ($l_cost >= 1000000000) { 
    85149            $l_cost = round($l_cost / 1000000000, 2).'B'; 
    86           } else {  
     150          } else { 
    87151            $l_cost = round($l_cost / 1000000, 2).'M'; 
    88152          } 
     
    94158            $k_ratio = round($k_count / $l_count, 2).' : 1'; 
    95159          } 
    96 $html .= "</td></tr>"; 
    97 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>".$k_count."</td></tr>"; 
    98 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$l_count."</td></tr>"; 
    99 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".$k_cost."</td></tr>"; 
    100 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".$l_cost."</td></tr>"; 
    101 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Efficiency:</b></td><td class=kb-table-cell><b>" . $efficiency . "</b></td></tr>"; 
    102 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kill Ratio:</b></td><td class=kb-table-cell><b>" . $k_ratio . "</b></td></tr>"; 
    103  
    104 $html .= "</table>"; 
    105 $html .= "<br/>"; 
     160 
     161if ($result == "Corporation is not part of alliance.") 
     162{ 
     163        $html .= "<td class=kb-table-cell width=180><b>Alliance:</b></td><td class=kb-table-cell>"; 
     164        if ($alliance->getName() == "Unknown" || $alliance->getName() == "None") 
     165        { 
     166                $html .= "<b>".$alliance->getName()."</b>"; 
     167        } 
     168        else 
     169        { 
     170        $html .= "<a href=\"?a=alliance_detail&all_id=".$alliance->getID()."\">".$alliance->getName()."</a>"; 
     171        } 
     172        $html .= "</td></tr>"; 
     173        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>".$k_count."</td></tr>"; 
     174        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$l_count."</td></tr>"; 
     175        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".$k_cost."</td></tr>"; 
     176        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".$l_cost."</td></tr>"; 
     177        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Efficiency:</b></td><td class=kb-table-cell><b>" . $efficiency . "</b></td></tr>"; 
     178        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kill Ratio:</b></td><td class=kb-table-cell><b>" . $k_ratio . "</b></td></tr>"; 
     179        $html .= "</table>"; 
     180        $html .= "<br/>"; 
     181} else { 
     182        $html .= "<td class=kb-table-cell width=150><b>Alliance:</b></td><td class=kb-table-cell>"; 
     183        if ($alliance->getName() == "Unknown" || $alliance->getName() == "None") 
     184        { 
     185                $html .= "<b>".$alliance->getName()."</b>"; 
     186        } 
     187        else 
     188        { 
     189        $html .= "<a href=\"?a=alliance_detail&all_id=".$alliance->getID()."\">".$alliance->getName()."</a>"; 
     190        } 
     191        $html .= "</td><td class=kb-table-cell width=65><b>CEO:</b></td><td class=kb-table-cell><a href=\"?a=search&searchtype=pilot&searchphrase=" . $myAPI->getCeoName() . "\">" . $myAPI->getCeoName() . "</a></td></tr>"; 
     192        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>".$k_count."</td>"; 
     193        $html .= "<td class=kb-table-cell><b>HQ:</b></td><td class=kb-table-cell>" . $myAPI->getStationName() . "</td></tr>"; 
     194        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$l_count."</td>"; 
     195        $html .= "<td class=kb-table-cell><b>Members:</b></td><td class=kb-table-cell>" . $myAPI->getMemberCount() . "</td></tr>"; 
     196        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".$k_cost."</td>"; 
     197        $html .= "<td class=kb-table-cell><b>Shares:</b></td><td class=kb-table-cell>" . $myAPI->getShares() . "</td></tr>"; 
     198        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".$l_cost."</td>"; 
     199        $html .= "<td class=kb-table-cell><b>Tax Rate:</b></td><td class=kb-table-cell>" . $myAPI->getTaxRate() . "%</td></tr>"; 
     200        if ($kill_summary->getTotalKillISK()) 
     201        { 
     202        $efficiency = round($kill_summary->getTotalKillISK() / ($kill_summary->getTotalKillISK() + $kill_summary->getTotalLossISK()) * 100, 2); 
     203        } 
     204        else 
     205        { 
     206                $efficiency = 0; 
     207        } 
     208 
     209        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Efficiency:</b></td><td class=kb-table-cell><b>" . $efficiency . "</b></td>"; 
     210        $html .= "<td class=kb-table-cell><b>Website:</b></td><td class=kb-table-cell><a href=\"" . $myAPI->getUrl() . "\">" . $myAPI->getUrl() . "</a></td></tr>"; 
     211        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kill Ratio:</b></td><td class=kb-table-cell><b>" . $k_ratio . "</b></td>"; 
     212        $html .= "<td class=kb-table-cell></td><td class=kb-table-cell></td></tr>"; 
     213        $html .= "</table>"; 
     214        //$html .= "Corporation Description:"; 
     215        $html .= "<div class=kb-table-row-even style=width:100%;height:100px;overflow:auto>"; 
     216        $html .= $myAPI->getDescription(); 
     217        $html .= "</div>"; 
     218        $html .= "<br/>"; 
     219} 
    106220 
    107221if ($_GET['view'] == "" || $_GET['view'] == "kills" || $_GET['view'] == "losses") 
     
    113227{ 
    114228    case "": 
    115         $html .= "<div class=kb-kills-header>10 Most recent kills</div>"; 
    116  
     229                $html .= "<div class=kb-kills-header>10 Most recent kills in the last 30 days</div>"; 
    117230        $list = new KillList(); 
    118231        $list->setOrdered(true); 
     
    122235        if ($_GET['scl_id']) 
    123236            $list->addVictimShipClass(new ShipClass($_GET['scl_id'])); 
     237                $list->setStartDate(date('Y-m-d H:i',strtotime('- 30 days'))); 
    124238 
    125239        $ktab = new KillListTable($list); 
     
    128242        $html .= $ktab->generate(); 
    129243 
    130         $html .= "<div class=kb-losses-header>10 Most recent losses</div>"; 
     244        $html .= "<div class=kb-losses-header>10 Most recent losses in the last 30 days</div>"; 
    131245 
    132246        $list = new KillList(); 
     
    137251        if ($_GET['scl_id']) 
    138252            $list->addVictimShipClass(new ShipClass($_GET['scl_id'])); 
    139  
     253                $list->setStartDate(date('Y-m-d H:i',strtotime('- 30 days'))); 
     254         
    140255        $ltab = new KillListTable($list); 
    141256        $ltab->setLimit(10); 
     
    452567        $html .= "<tr><td width=34><b>Icon</b></td><td width=266><b>Rank Name</b></td><td width=150><b>Abbreviation</b></td><td width=150><b>Req. Rank Points</b></td><td width=150><b>Req. Kill Points</b></td></tr>"; 
    453568        foreach($rank_ttl as $level) { 
    454           $html .= "<tr height=36><td class=\"item-icon\" valign=\"top\" width=\"34\" height=\"36\">".$level['img']."</td>";     
     569          $html .= "<tr height=36><td class=\"item-icon\" valign=\"top\" width=\"34\" height=\"36\">".$level['img']."</td>"; 
    455570          $html .= "<td>".$level['title']."</td>"; 
    456571          $html .= "<td>".$level['abbr']."</td>"; 
     
    551666        while ($row = $qry->getRow()) { 
    552667          $rank=GetPilotRank($row['plt_id'],$kps,$temp1,$temp2,$temp3,$baserps,$bonusrps,$rps); 
    553           $pilots[]=array('plt_id' => $row['plt_id'], 'rank' => $rank, 'rps' => $rps);   
     668          $pilots[]=array('plt_id' => $row['plt_id'], 'rank' => $rank, 'rps' => $rps); 
    554669        } 
    555670        foreach ($pilots as $i => $data) { 
     
    567682        } 
    568683        if (strpos($rank_known, 'done')) 
    569         {                
     684        { 
    570685          $html .= '<td align=center>Damage<br>Done</td>'; 
    571686        } 
     
    597712          if (!$k_score) { $k_score = 0; } 
    598713          $k_count = $kill_list->getCount(); 
    599           $k_cost = $kill_list->getISK();        
     714          $k_cost = $kill_list->getISK(); 
    600715          $loss_list = new KillList(); 
    601716          $loss_list->addVictimPilot($pilot); 
     
    614729          if ($k_cost >= 1000000000) { 
    615730            $k_cost = round($k_cost / 1000000000, 2).'B'; 
    616           } else {  
     731          } else { 
    617732            $k_cost = round($k_cost / 1000000, 2).'M'; 
    618733          } 
    619734          if ($l_cost >= 1000000000) { 
    620735            $l_cost = round($l_cost / 1000000000, 2).'B'; 
    621           } else {  
     736          } else { 
    622737            $l_cost = round($l_cost / 1000000, 2).'M'; 
    623738          } 
     
    663778        break; 
    664779   case "known_members": 
    665         if (isset($_GET['page'])) {  
     780        if (isset($_GET['page'])) { 
    666781                $limit = ($_GET['page'] - 1)*30; 
    667782                $last_page = $_GET['page'] - 1; 
    668                 $next_page = $_GET['page'] + 1;   
     783                $next_page = $_GET['page'] + 1; 
    669784        } else { 
    670785                $limit = 0; 
    671786                $last_page = 0; 
    672                 $next_page = 2;   
     787                $next_page = 2; 
    673788        } 
    674789        $query = "SELECT * FROM `kb3_pilots` 
     
    705820        } 
    706821        $html .= '<td width=150>Name</td>'; 
    707          
     822 
    708823        if (strpos($rank_known, 'score')) 
    709824        { 
     
    711826        } 
    712827        if (strpos($rank_known, 'done')) 
    713         {                
     828        { 
    714829          $html .= '<td align=center>Damage<br>Done</td>'; 
    715830        } 
     
    741856          if (!$k_score) { $k_score = 0; } 
    742857          $k_count = $kill_list->getCount(); 
    743           $k_cost = $kill_list->getISK();        
     858          $k_cost = $kill_list->getISK(); 
    744859          $loss_list = new KillList(); 
    745860          $loss_list->addVictimPilot($pilot); 
     
    758873          if ($k_cost >= 1000000000) { 
    759874            $k_cost = round($k_cost / 1000000000, 2).'B'; 
    760           } else {  
     875          } else { 
    761876            $k_cost = round($k_cost / 1000000, 2).'M'; 
    762877          } 
    763878          if ($l_cost >= 1000000000) { 
    764879            $l_cost = round($l_cost / 1000000000, 2).'B'; 
    765           } else {  
     880          } else { 
    766881            $l_cost = round($l_cost / 1000000, 2).'M'; 
    767882          } 
     
    813928                INNER JOIN `kb3_pilots` plts 
    814929                ON ( plts.plt_id = rank.plt_id ) 
    815                 WHERE plts.plt_crp_id = ".$corp->getID()."  
     930                WHERE plts.plt_crp_id = ".$corp->getID()." 
    816931                ORDER BY 1 ASC, 2 DESC"; 
    817932        $qry->execute($query); 
     
    828943        $rank_badges = config::getnumerical('rankmod_badreqs'); 
    829944        $rank_sub_badges = config::getnumerical('rankmod_sub_badreqs'); 
    830         GetEnabledClasses($shipbadges);  
     945        GetEnabledClasses($shipbadges); 
    831946        $html .= "<div class=block-header2>Grantable Ship Combat Ribbons</div>"; 
    832947        $html .= "<table class=kb-table cellspacing=1 width=\"100%\">"; 
     
    8871002                $bottom = 'Gunner'; 
    8881003                $bottom2 = ' turret'; 
    889                 break;     
     1004                break; 
    8901005          } 
    8911006          $html .= "<tr class=kb-table-row-".$class." height=32><td><img src=\"".IMG_URL."/ranks/ribbons/".$weap['type']."_expert.gif\" border=\"0\"></td><td><b>Expert ".$weap['name']." ".$bottom."</b><br />".$weap['name']." Master 3rd Class</td><td>Awarded when a pilot does <b><i>".$rank_badges[$weap['cnt']][2]."</i></b> kills ".$conj." ".$weap['type'].$bottom2.".</td></tr>"; 
     
    9071022        break; 
    9081023} 
     1024 
     1025$html .= "<hr><b>Extended Corp Detail " . EVELOGOVERSION . " by " . FindThunk() . ". Logo generation by Entity. Thanks to Arkady and Exi.<b/></br>"; 
    9091026 
    9101027$menubox = new box("Menu");