Changeset 370 for dev/mods

Show
Ignore:
Timestamp:
06/14/09 06:51:49 (11 years ago)
Author:
kovell
Message:

- SQL queries optimised for speed and error protection.
- feed syndication optimised
- front page includes optional clock and optional kill/loss display
- mysqli support added
- transaction protection of kills added where supported (mysqli and InnoDB)
- summary tables and contracts show total destroyed value instead of ship value
- html errors reduced
- related kill calculation improved
- query caching errors reduced
- minor bugfixes
- Smarty 2.6.25 added
- apoc fitting mod added and modded
- code optimisations
- code comments added (doxygen format)
- conflicting mods are now identified

Location:
dev/mods
Files:
28 added
3 modified

Legend:

Unmodified
Added
Removed
  • dev/mods/known_members/corp_detail.php

    r343 r370  
    88require_once("common/includes/class.toplist.php"); 
    99require_once("common/includes/class.pilot.php"); 
     10require_once("common/includes/evelogo.php"); 
     11require_once("common/includes/class.eveapi.php"); 
    1012 
    1113if (!$crp_id = intval($_GET['crp_id'])) 
     
    3032$summary_html = $kill_summary->generate(); 
    3133 
    32 $page = new Page('Corporation details - '.$corp->getName()); 
     34$corpname = str_replace(" ", "%20", $corp->getName() ); 
     35$myID = new API_NametoID(); 
     36$myID->setNames($corpname); 
     37$html .= $myID->fetchXML(); 
     38$myNames = $myID->getNameData(); 
     39                 
     40$myAPI = new API_CorporationSheet(); 
     41$myAPI->setCorpID($myNames[0]['characterID']); 
     42 
     43$result .= $myAPI->fetchXML(); 
     44 
     45if ($result == "Corporation is not part of alliance.") 
     46{ 
     47        $page = new Page('Corporation details - '.$corp->getName()); 
     48} else { 
     49        $page = new Page('Corporation details - '.$corp->getName() . " [" . $myAPI->getTicker() . "]"); 
     50}        
    3351$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>"; 
    3452 
     
    3957else 
    4058{ 
    41     $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     59        if ($alliance != 0) 
     60        {        
     61                $mylogo = $myAPI->getLogo(); 
     62                 
     63                if ($result == "Corporation is not part of alliance.") 
     64                { 
     65                        $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     66                } elseif ($result == "") { 
     67                        // 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 
     68                        // 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 
     69                        // doing this prevents the images being rendered each time the function is called and allows it to use one in the cache instead. 
     70                        CorporationLogo( $mylogo, 64, $corp->getID() ); 
     71                        CorporationLogo( $mylogo, 128, $corp->getID() ); 
     72                         
     73                        $html .= "<img src=\"".$corp->getPortraitURL(128)."\" border=\"0\"></td>"; 
     74                } else { 
     75                        // 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 
     76                        // error text will also appear where the picture is, which is nice 
     77                        $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     78                }        
     79        } else { 
     80                $html .= "<img src=\"".IMG_URL."/campaign-big.gif\" border=\"0\"></td>"; 
     81        } 
    4282} 
    4383 
    44 $html .= "<td class=kb-table-cell width=180><b>Alliance:</b></td><td class=kb-table-cell>"; 
    45 if ($alliance->getName() == "Unknown" || $alliance->getName() == "None") 
     84if ($result == "Corporation is not part of alliance.") 
    4685{ 
    47     $html .= "<b>".$alliance->getName()."</b>"; 
     86        $html .= "<td class=kb-table-cell width=180><b>Alliance:</b></td><td class=kb-table-cell>"; 
     87        if ($alliance->getName() == "Unknown" || $alliance->getName() == "None") 
     88        { 
     89                $html .= "<b>".$alliance->getName()."</b>"; 
     90        } 
     91        else 
     92        { 
     93        $html .= "<a href=\"?a=alliance_detail&all_id=".$alliance->getID()."\">".$alliance->getName()."</a>"; 
     94        } 
     95        $html .= "</td></tr>"; 
     96        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>".$kill_summary->getTotalKills()."</td></tr>"; 
     97        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$kill_summary->getTotalLosses()."</td></tr>"; 
     98        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".round($kill_summary->getTotalKillISK()/1000000000, 2)."B</td></tr>"; 
     99        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".round($kill_summary->getTotalLossISK()/1000000000, 2)."B</td></tr>"; 
     100        if ($kill_summary->getTotalKillISK()) 
     101        { 
     102        $efficiency = round($kill_summary->getTotalKillISK() / ($kill_summary->getTotalKillISK() + $kill_summary->getTotalLossISK()) * 100, 2); 
     103        } 
     104        else 
     105        { 
     106                $efficiency = 0; 
     107        } 
     108 
     109        $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>"; 
     110        $html .= "</table>"; 
     111        $html .= "<br/>"; 
     112} else { 
     113        $html .= "<td class=kb-table-cell width=150><b>Alliance:</b></td><td class=kb-table-cell>"; 
     114        if ($alliance->getName() == "Unknown" || $alliance->getName() == "None") 
     115        { 
     116                $html .= "<b>".$alliance->getName()."</b>"; 
     117        } 
     118        else 
     119        { 
     120        $html .= "<a href=\"?a=alliance_detail&all_id=".$alliance->getID()."\">".$alliance->getName()."</a>"; 
     121        } 
     122        $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>"; 
     123        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>".$kill_summary->getTotalKills()."</td>"; 
     124        $html .= "<td class=kb-table-cell><b>HQ:</b></td><td class=kb-table-cell>" . $myAPI->getStationName() . "</td></tr>"; 
     125        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$kill_summary->getTotalLosses()."</td>"; 
     126        $html .= "<td class=kb-table-cell><b>Members:</b></td><td class=kb-table-cell>" . $myAPI->getMemberCount() . "</td></tr>"; 
     127        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".round($kill_summary->getTotalKillISK()/1000000000, 2)."B</td>"; 
     128        $html .= "<td class=kb-table-cell><b>Shares:</b></td><td class=kb-table-cell>" . $myAPI->getShares() . "</td></tr>"; 
     129        $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".round($kill_summary->getTotalLossISK()/1000000000, 2)."B</td>"; 
     130        $html .= "<td class=kb-table-cell><b>Tax Rate:</b></td><td class=kb-table-cell>" . $myAPI->getTaxRate() . "%</td></tr>"; 
     131        if ($kill_summary->getTotalKillISK()) 
     132        { 
     133        $efficiency = round($kill_summary->getTotalKillISK() / ($kill_summary->getTotalKillISK() + $kill_summary->getTotalLossISK()) * 100, 2); 
     134        } 
     135        else 
     136        { 
     137                $efficiency = 0; 
     138        } 
     139 
     140        $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>"; 
     141        $html .= "<td class=kb-table-cell><b>Website:</b></td><td class=kb-table-cell><a href=\"" . $myAPI->getUrl() . "\">" . $myAPI->getUrl() . "</a></td></tr>"; 
     142        $html .= "</table>"; 
     143        //$html .= "Corporation Description:"; 
     144        $html .= "<div class=kb-table-row-even style=width:100%;height:100px;overflow:auto>"; 
     145        $html .= $myAPI->getDescription(); 
     146        $html .= "</div>"; 
     147        $html .= "<br/>"; 
    48148} 
    49 else 
    50 { 
    51     $html .= "<a href=\"?a=alliance_detail&all_id=".$alliance->getID()."\">".$alliance->getName()."</a>"; 
    52 } 
    53 $html .= "</td></tr>"; 
    54 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>".$kill_summary->getTotalKills()."</td></tr>"; 
    55 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$kill_summary->getTotalLosses()."</td></tr>"; 
    56 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".round($kill_summary->getTotalKillISK()/1000000000, 2)."B</td></tr>"; 
    57 $html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".round($kill_summary->getTotalLossISK()/1000000000, 2)."B</td></tr>"; 
    58 if ($kill_summary->getTotalKillISK()) 
    59 { 
    60     $efficiency = round($kill_summary->getTotalKillISK() / ($kill_summary->getTotalKillISK() + $kill_summary->getTotalLossISK()) * 100, 2); 
    61 } 
    62 else 
    63 { 
    64     $efficiency = 0; 
    65 } 
    66  
    67 $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>"; 
    68 $html .= "</table>"; 
    69 $html .= "<br/>"; 
    70149 
    71150if ($_GET['view'] == "" || $_GET['view'] == "kills" || $_GET['view'] == "losses") 
     
    527606} 
    528607 
     608$html .= "<hr><b>Extended Corp Detail " . EVELOGOVERSION . " by " . FindThunk() . ". Logo generation by Entity. Thanks to Arkady and Exi.<b/></br>"; 
     609 
    529610$menubox = new box("Menu"); 
    530611$menubox->setIcon("menu-item.gif"); 
  • dev/mods/mail_forward/init.php

    r198 r370  
    11<?php 
    22event::register('killmail_added', 'post_forward::handler'); 
     3event::register('killmail_imported', 'import_forward::importhandler'); 
    34 
    45class post_forward 
     
    1920    } 
    2021} 
     22 
     23 
     24class import_forward 
     25{ 
     26    function importhandler($object) 
     27    { 
     28                if (config::get('forward_active') == false) 
     29        { 
     30            return; 
     31        } 
     32        require_once('common/includes/class.http.php'); 
     33 
     34        $req = new http_request(config::get('forward_site').'?a=post'); 
     35 
     36        $req->set_postform('password', config::get('forward_pass')); 
     37        $req->set_postform('killmail', stripslashes($object->killmail_)); 
     38        $req->request(); 
     39   } 
     40} 
     41 
    2142?> 
  • dev/mods/value_fetch/fetcher.php

    r338 r370  
    2727                while ($row = $qry->getRow()) 
    2828                { 
     29                        if($i) $querytext .=","; 
     30                        else $querytext="INSERT INTO kb3_ships_values (shp_id, shp_value) VALUES "; 
     31                        $querytext .= "('".$row['id']."','".$row['price']."')"; 
    2932                        $i++; 
    30                         $qryins->execute("REPLACE INTO kb3_ships_values (shp_id, shp_value) VALUES ('".$row['id']."','".$row['price']."')"); 
    31                 } 
     33                } 
     34                $querytext .= " ON DUPLICATE KEY UPDATE shp_value = VALUES(shp_value);"; 
     35                $qry->execute($querytext); 
    3236                return $i; 
    3337        } 
     
    3842                $this->faction = $factionin; 
    3943                // Fetch the gzip file. 
    40                 $file = fopen($this->compfile, r); 
     44// Switch fopen to cURL if it exists 
     45if (function_exists('curl_init')) 
     46{ 
     47    $ch = curl_init(); 
     48    curl_setopt($ch, CURLOPT_URL, $this->compfile); 
     49    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     50    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
     51    $content = curl_exec($ch); 
     52    curl_close($ch); 
     53    if(strlen($content)==0) return 0; 
     54} 
     55else 
     56{ 
     57    $file = fopen($this->compfile , "r"); 
     58 
    4159                if (! $file) { 
    4260                        return 0; 
     
    4462                $content = stream_get_contents($file); 
    4563                fclose($file); 
    46          
    47                 $content = gzinflate($content); 
     64}        
     65                $content = gzinflate($content); 
    4866                // Old style, direct, no gzip! 
    4967                // $sxe = simplexml_load_file("http://svn.nsbit.dk/itemfetch/items.xml"); 
     
    5371                // New query 
    5472                $qry = new DBQuery(); 
     73 
    5574                foreach($sxe->market_stat as $stat) 
    5675                { 
    5776                        // If there is almost nothing for sale, AT ALL, don't include! 
    58                         //if ($stat->total_sell_volume < 5) continue; 
     77                        // if ($stat->total_sell_volume < 5) continue; 
    5978                        // Same average as used in value_editor (eve_central_sync) 
    6079                        //$weighted_average = round(((1.6 * $stat->avg_buy_price + 0.8 * $stat->avg_sell_price) / 2),0); 
     
    6988                        if (($this->faction == true) && ($stat->factionPrice > 0)) 
    7089                                $weighted_average = round($stat->factionPrice,0); 
    71                                  
    72                         // Insert into database, update values! 
    73                         $qry->execute("REPLACE INTO kb3_item_price (typeID, price) VALUES ('".$stat->typeid."','".number_format($weighted_average, 0, '', '')."')"); 
     90//                      if (!$weighted_average) continue;        
     91                        // Insert new values into the database and update the old 
     92                        // For the first item start the query. For later items add ',' 
     93                        if($i) $querytext .=","; 
     94                        else $querytext="INSERT INTO kb3_item_price (typeID, price) VALUES "; 
     95                        $querytext .= "(".$stat->typeid.",".number_format($weighted_average, 0, '', '').")"; 
    7496                        $i++; 
    7597                } 
    76          
     98                // Finish query with a check for duplicates. If so, just update 
     99                $querytext .= " ON DUPLICATE KEY UPDATE price = VALUES(price);"; 
     100                $qry->execute($querytext); 
    77101                return "Count: ".$i." <br><br>Cached on: ".date('H:i:s - j/m/Y',(int)($sxe->timestamp)); 
    78102        } 
     
    84108                $this->buy_median = null; 
    85109                $this->xml_parser = xml_parser_create(); 
    86                 xml_set_object($this->xml_parser, &$this); 
     110                xml_set_object($this->xml_parser, $this); 
    87111                // use case-folding so we are sure to find the tag in $map_array 
    88112                //xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING, true);