Changeset 170 for dev/mods

Show
Ignore:
Timestamp:
01/06/07 16:35:16 (14 years ago)
Author:
liq
Message:

fliq's feed syndication mod 1.4

Location:
dev/mods/feed_syndication
Files:
1 added
1 removed
3 modified

Legend:

Unmodified
Added
Removed
  • dev/mods/feed_syndication/feed_fetcher.php

    r152 r170  
    22        ////// 
    33//////  ////// 
    4 //////  liq's feed syndication mod v1.3 
     4//////  liq's feed syndication mod v1.4 
    55//////////// 
    66//////////// 
     
    1010 
    1111@set_time_limit(0); 
     12@ini_set('memory_limit',999999999); 
     13 
    1214require_once( "common/class.kill.php" ); 
    1315require_once( "common/class.parser.php" ); 
    1416if ( file_exists("../../common/class.comments.php") ) // for the Eve-Dev Comment Class 
    15         require_once( "class.comments.php" ); 
     17        require_once( "common/class.comments.php" ); 
    1618if ( file_exists("../../common/class.comment.php") ) // for the D2 Killboard Comment Class 
    17         require_once( "class.comment.php" ); 
     19        require_once( "common/class.comment.php" ); 
    1820 
    1921$insideitem = false; 
     
    8183                }        
    8284                 
    83                 if (!xml_parse( $xml_parser, $data, feof($fp) ) && !feof($fp) ) 
     85                if (!xml_parse( $xml_parser, $data, @feof($fp) ) && !@feof($fp) ) 
    8486                        return "<i>Error getting XML data from ".$url."</i><br><br>";            
    8587                         
    8688                @fclose($fp); 
    8789                xml_parser_free($xml_parser); 
    88                  
    89                 if ($x) 
    90                         $html .= "<div class=block-header2>".$x." kills added from feed: ".$url." <i>(".$cprs.")</i></div>"; 
    91                 else 
    92                         $html .= "<div class=block-header2>No kills added from feed: ".$url." <i>(".$cprs.")</i></div>"; 
    93                 //echo "url:".$url." --- "; 
    94                 //echo " strg:".$str; 
     90 
     91                if ( getConfig('fetch_verbose') ) { 
     92                        if ($x) 
     93                                $html .= "<div class=block-header2>".$x." kills added from feed: ".$url."<br>".$str." <i><br>(".$cprs.")</i><br><br></div>"; 
     94                        else 
     95                                $html .= "<div class=block-header2>No kills added from feed: ".$url."<br>".$str." <i><br>(".$cprs.")</i><br><br></div>"; 
     96                } else { 
     97                        if ($x) 
     98                                $html .= "<div class=block-header2>".$x." kills added from feed: ".$url." <i>(".$cprs.")</i><br><br></div>"; 
     99                        else 
     100                                $html .= "<div class=block-header2>No kills added from feed: ".$url." <i>(".$cprs.")</i><br><br></div>"; 
     101                } 
    95102                 
    96103return $html; 
     
    161168 
    162169} 
    163  
    164170?> 
  • dev/mods/feed_syndication/readme.txt

    r152 r170  
    11        ////// 
    22//////  ////// 
    3 //////  liq's feed syndication mod v1.3 
     3//////  liq's feed syndication mod v1.4 
    44//////////// 
    55//////////// 
     
    1111//INSTALLATION: 
    1212 
     13### --> STANDALONE version: 
     141. put all files in your /common directory 
     15 
     162. add the following line to common/admin_menu.php: 
     17$menubox->addOption( "Feeds", "?a=admin_feed" ); 
     18or if you use eve-dev kilboard version 1.2.0 and above (using smarty templates): 
     19$menubox->addOption("link", "Feeds", "?a=admin_feed"); 
     20 
     213. wee. youre done. 
     22 
     234. you can access the feed interface now via the menubox in admin menu  
     24 
     25 
     26### --> MOD version: 
    13271. create directory mods/feed 
     28 
    14292. put the files settings.php and feed_fetcher.php in /mods/feed_syndication directory. 
     30 
    15313. put feed.php in your /common directory 
     32 
    16333. login as admin and enable the feed-mod in 'Mods' 
     34 
    17354. wee. youre done. 
    1836 
     375. click 'Settings' in the 'Mods' menu to access the feed interface 
     38 
    1939additionally you can add the following line to common/admin_menu.php for direct access: 
    20 $menubox->addOption( "Feeds", "?a=settings_feed_syndication" ); 
     40$menubox->addOption( "Feeds", "?a=settings_feed" ); 
    2141or if you use eve-dev kilboard version 1.2.0 and above (using smarty templates): 
    22 $menubox->addOption("link", "Feeds", "?a=settings_feed_syndication"); 
     42$menubox->addOption("link", "Feeds", "?a=settings_feed"); 
    2343 
    2444 
     
    3858-> enter feed urls in the format: http://killboard.eve-d2.com/?a=feed 
    3959 
    40 -> a list of known feeds can be found here: http://www.eve-dev.net/e107_plugins/forum/forum_viewtopic.php?1896 
     60-> a list of known feeds can be found here: http://myeve.eve-online.com/ingameboard.asp?a=topic&threadID=443506&page=1#2 
    4161 
    42 -> clicking the 'fetch' button will get all kills of the actual week. 
     62-> your actual week is automatically selected in the first and last week boxes. 
    4363 
    44 -> ticking the 'grab-ALL-mails-box' will grab the kills of ALL weeks (iteration from week #1 through to week #52)! 
    45 ** be careful with this option! it can take several minutes or even hours to have all the kills parsed and added to your database ** 
    46 ** be patient. don't close your browser, don't reload. you only need to use this ONCE to initialize a feed connection. 
    47 after initializing, weekly updates are totally sufficient to keep your board uptodate ** 
     64-> clicking the 'fetch' button will by default get all kills of the actual week unless you select a different timeframe. 
     65 
     66-> selecting a timeframe with the first and last week boxes lets the fetcher get all mails of this timeframe. 
     67** be careful with this option! it can take several minutes or even hours to have all  
     68the kills parsed and added to your database, especially if you select a really long timeframe ** 
     69** be patient. don't close your browser, don't reload. after doing a full fetch first, weekly updates are totally sufficient to keep your board uptodate ** 
     70 
    4871 
    4972-> by default their kills aka. your losses get fetched unless you tick the 'get kills' 
     
    5376checks and decides if a fetched stream supports GZip compression - if not it uses regular html/rss output. 
    5477 
     78 
    5579-> if you are running a master killboard (eg. to supply and share killdata with other killboards) edit settings.php and set 'MASTER' to 1. 
    5680the board will then even fetch kills not related to the alliance or corp ID you set in the killboards config.php. 
    57 leave this option untouched if youre running a normal killboard for your corp or alliance - it will just slow things down. 
     81leave this option untouched if youre running a normal killboard for your corp or alliance - it will just slow things down and 
     82wont work for you without modifications to the parser class. 
    5883 
    59 -> the feed is not supposed to be human readable so ffs dont complain about the formatting, 
     84-> the feed is not supposed to be human readable so ffs dont complain about the formatting. 
    6085for human readable rss output use the rss mod ( /?a=rss ) instead. 
    6186 
     
    6388 
    6489//VERSION CHANGES: 
     90 
     91 
     92//v1.4 
     93 
     94feed.php: 
     95- added selection of the year to output 
     96- added support for friend<->friend killboard fetching 
     97- minor code cleanups 
     98- other stuff i forgot 
     99 
     100feed_fetcher.php: 
     101- added a fix for the memory exhaustion bug some boards had (check if your php is running in php-safe-mode. if so, disable it) 
     102- improved verbose output 
     103 
     104admin_feed.php / settings.php 
     105- replaced the grab-all switch with an advanced range selection system by week and year 
     106- added support for friend<->friend killboard fetching 
     107- minor code cleanups 
     108- other stuff i forgot 
     109 
    65110 
    66111//v1.3 
  • dev/mods/feed_syndication/settings.php

    r152 r170  
    22        ////// 
    33//////  ////// 
    4 //////  liq's feed syndication mod v1.3 
     4//////  liq's feed syndication mod v1.4 
    55//////////// 
    66//////////// 
     
    1212// to even fetch mails not related to your corp / alliance 
    1313define( MASTER, 0 ); 
    14  
    15  
    1614 
    1715@set_time_limit(0); 
     
    2220require_once( 'common/class.alliance.php' ); 
    2321 
    24         $page = new Page( "Administration - Feeds" ); 
     22        $page = new Page( "Administration - Feed Syndication v1.4" ); 
    2523        $page->setAdmin(); 
    2624 
     
    3331                $feedcount = 3; 
    3432 
    35  
    3633        if ( $_POST['submit'] || $_POST['fetch']  ) { 
    37                         if ( ctype_digit($_POST['fetch_feed_count']) ) { 
    38                         setConfig('fetch_feed_count', $_POST['fetch_feed_count']); 
     34                        if ( ctype_digit($_POST['fetch_feed_count']) && $_POST['fetch_feed_count'] > 0) { 
    3935                        $feedcount = $_POST['fetch_feed_count']; 
     36                        setConfig('fetch_feed_count', $feedcount); 
    4037                        for ($i = 99; $i>=$feedcount; $i--) { 
    4138                                delConfig('fetch_url_'.$i); 
    4239                        } 
    4340                } 
    44  
    4541                if ( $_POST['fetch_verbose'] ) 
    4642                        setConfig('fetch_verbose', '1'); 
     
    6056                for ($i = 1; $i<=$feedcount; $i++) { 
    6157                        $url = "fetch_url_".$i; 
     58                        $friends = $_POST["friend_".$i]; 
    6259                        if ( preg_match($validurl ,$_POST[$url]) ) { 
    63                                 setConfig($url, $_POST[$url].':::'.$time[$i]); 
     60                                setConfig($url, $_POST[$url].':::'.$time[$i].':::'.$friends); 
    6461                                $feed[$i] = $_POST[$url]; 
    6562                } else 
     
    6865                } 
    6966        } 
    70  
    7167        $feed = array(); 
    7268        for ($i = 1; $i<=$feedcount; $i++) { 
     
    7571                $feed[$i] = $tmp[0]; 
    7672                $time[$i] = $tmp[1]; 
     73                $friend[$i] = $tmp[2]; 
    7774        } 
    78  
    7975        if ( $_POST['fetch'] ) { 
    8076         if (CORP_ID && !MASTER) { 
     
    8581             $alli = new Alliance(ALLIANCE_ID); 
    8682             $myid = '&alli='.urlencode($alli->getName()); 
    87                 } 
    88  
     83                 } 
    8984                 for ($i=1; $i<=$feedcount; $i++) { 
    9085                        $feedfetch = new Fetcher(); 
     
    9287                        if (preg_match($validurl , $feed[$i]) && $_POST["fetch_feed_".$i]) { 
    9388                            $str = ''; 
    94                                 if ($time[$i]) 
    95                         $str .= '&lastkllid='.$time[$i]; 
     89                                //if ($time[$i]) 
     90                //      $str .= '&lastkllid='.$time[$i]; 
     91                                if ($friend[$i]) 
     92                        $str .= '&friend=1'; 
    9693                                if ( $_POST['fetch_losses'] ) 
    9794                        $str .= "&losses=1"; 
    9895                                if ( !getConfig('fetch_compress') ) 
    9996                        $str .= "&gz=1"; 
    100                                 if ( $_POST['graball'] ) { 
    101                                         for ($l = 1; $l<=52; $l++) { 
     97                                if ( $_POST['range1'] && $_POST['range2'] ) { 
     98                                        if ( $_POST['range1'] > $_POST['range2'] ) { 
     99                                                $range1 = $_POST['range2']; 
     100                                                $range2 = $_POST['range1']; 
     101                                        } else { 
     102                                                $range1 = $_POST['range1']; 
     103                                                $range2 = $_POST['range2']; 
     104                                        } 
     105                                        for ($l = $range1; $l<=$range2; $l++) { 
    102106                                                $html .= "<b>Week: ". $l ."</b><br>"; 
    103                                                 $html .= $feedfetch->grab( $feed[$i]."&week=".$l, $myid.$str ); 
     107                                                $html .= $feedfetch->grab( $feed[$i]."&year=".$_POST['year']."&week=".$l, $myid.$str ); 
    104108                                        } 
    105109                            } else 
    106110                                $html .= $feedfetch->grab( $feed[$i], $myid.$str ); 
    107111                        } 
    108  
    109                     setConfig($cfg, $feed[$i].':::'.$lastkllid); 
     112                    setConfig($cfg, $feed[$i].':::'.$lastkllid.':::'.$friend); 
    110113            $time[$i] = $lastkllid; 
    111114                } 
    112115        } 
    113116 
    114         $html .= "<form id=options name=options method=post action=?a=settings_feed>"; 
     117        $html .= "<form id=options name=options method=post action=?a=settings_feed_syndication>"; 
    115118    $html .= "</table>"; 
    116119 
    117120    $html .= "<div class=block-header2>Feeds</div><table>"; 
    118  
    119121    for ($i = 1; $i<=$feedcount; $i++) { 
    120122        $html .= "<tr><td width=85px><b>Feed url #".$i."</b></td><td><input type=text name=fetch_url_".$i." size=50 class=password value=\""; 
     
    122124           $html .= $feed[$i]; 
    123125        $html .= "\"> "; 
     126                $html .= "<input type=checkbox name=friend_".$i." id=friend_".$i; 
     127                if ( $friend[$i] ) 
     128                        $html .= " checked=\"checked\""; 
     129                $html .= "><b>Friend?</b>"; 
    124130                $html .= "<input type=checkbox name=fetch_feed_".$i." id=fetch_feed_".$i; 
    125131        if ( $feed[$i] ) 
     
    128134                $html .= "</td></tr>"; 
    129135        } 
    130  
    131136        $html .= "</table><i>Example: http://killboard.eve-d2.com/?a=feed</i><br><br><br>"; 
    132137 
    133         $html .= "<table><tr><td height=30px width=150px><b>Get kills instead of losses?</b></td>"; 
     138    $html .= "<table><tr><td height=20px width=150px><b>First week:</b></td>"; 
     139        $html .= '<td><select name="range1">'; 
     140        $now = date("W"); 
     141        for ($i = 1; $i<=52; $i++) { 
     142                if ( $now == $i ) 
     143                        $html .= '<option selected="selected "value="'.$i.'">'.$i.'</option>';   
     144                else 
     145                        $html .= '<option value="'.$i.'">'.$i.'</option>';  
     146        }                        
     147        $html .= '</select>'; 
     148    $html .= "<i></i></td></tr>"; 
     149        $html .= "<tr><td height=20px width=150px><b>Last week:</b></td>"; 
     150        $html .= '<td><select name="range2">'; 
     151        for ($i = 52; $i>=1; $i--) { 
     152                if ( $now == $i ) 
     153                        $html .= '<option selected="selected "value="'.$i.'">'.$i.'</option>';   
     154                else 
     155                        $html .= '<option value="'.$i.'">'.$i.'</option>'; 
     156        }                        
     157        $html .= '</select>';    
     158    $html .= "<i></i></td></tr>"; 
     159         
     160        $html .= "<tr><td height=20px width=150px><b>Year:</b></td>"; 
     161        $html .= '<td><select name="year">'; 
     162        $html .= '<option "value="2009">2009</option>';  
     163        $html .= '<option "value="2008">2008</option>';  
     164        $html .= '<option selected="selected "value="">2007</option>';   
     165        $html .= '<option "value="2006">2006</option>';  
     166        $html .= '<option "value="2005">2005</option>';  
     167        $html .= '</select>';    
     168    $html .= "</td></tr>"; 
     169        $html .= "<tr><td height=40px width=150px><b>Get kills instead of losses?</b></td>"; 
    134170        $html .= "<td><input type=checkbox name=fetch_losses id=fetch_losses>"; 
    135         $html .= "<i> (by default only your losses get fetched, when ticked all kills where one of your pilots is involved get fetched instead)</i></td></tr>"; 
    136  
    137     $html .= "<tr><td height=30px width=150px><b>Grab ALL mails from the feed servers?</b></td>"; 
    138         $html .= "<td><input type=checkbox name=graball id=graball>"; 
    139     $html .= "<i> (fetches all mails from the feed servers! use this may take upto several hours depending on the amount of kills to import!)</i></td>"; 
    140         $html .= "</tr></table><br><br>"; 
    141  
     171        $html .= "<i> (by default only their kills, your losses, get fetched, when ticked this is inversed)</i></td></tr>"; 
     172        $html .= "</table><br><br>"; 
    142173        $html .= "<input type=submit id=submit name=fetch value=\"Fetch!\"><br><br>"; 
    143174 
     
    145176        $html .= "<tr><td height=30px width=150px><b>Number of feeds:</b></td>"; 
    146177        $html .= "<td><input type=text name=fetch_feed_count size=2 maxlength=2 class=password value=\"".$feedcount."\"</td></tr>"; 
    147  
    148178        $html .= "<tr><td height=50px width=150px><b>Comment for automatically parsed killmails?</b></td>"; 
    149179        $html .= "<td><input type=text size=50 class=password name=fetch_comment id=fetch_comment value=\""; 
     
    151181                $html .= getConfig('fetch_comment'); 
    152182        $html .= "\"><br><i> (leave blank for none)</i><br></td></tr>"; 
    153  
    154183        $html .= "<tr><td height=30px width=150px><b>Enable compression?</b></td>"; 
    155184    $html .= "<td><input type=checkbox name=fetch_compress id=fetch_compress"; 
     
    158187        $html .= "><i> (enables GZip compression for feeds that support this feature, for streams that do not support GZip compression regular html mode will be used automatically)</i></td>"; 
    159188        $html .= "</tr>"; 
    160          
    161189        $html .= "<tr><td height=30px width=150px><b>Verbose mode?</b></td>"; 
    162190    $html .= "<td><input type=checkbox name=fetch_verbose id=fetch_verbose"; 
    163191        if ( getConfig('fetch_verbose') ) 
    164192                $html .= " checked=\"checked\""; 
    165         $html .= "><i> (displays errormessages when the imported mail is rejected for being malformed, already existing, not being related etc.)</i></td>"; 
     193        $html .= "><i> (displays advanced feed request information and errormessages when the imported mail is rejected for being malformed, already exists or is not related to your corp or alliance)</i></td>"; 
    166194        $html .= "</tr></table><br><br>"; 
    167  
    168195    $html .= "<input type=submit id=submit name=submit value=\"Save\">"; 
    169196        $html .= "</form>"; 
     
    172199    $page->setContent( $html ); 
    173200    $page->generate(); 
    174  
    175201?>