Changeset 380
- Timestamp:
- 06/21/09 12:09:36 (13 years ago)
- Location:
- dev/common
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/admin/admin_feedsyndication.php
r370 r380 1 1 <?php 2 // //// 3 // //// ////// 4 // //// liq's feed syndication mod v1.6 5 // Kovell: last kill function activated and current year = 2008 changed in 1.6 6 // ////////// 7 // ////////// 8 // ////////// 9 // ////////// 2 /* 3 * EDK Feed Syndication v1.7 4 * based on liq's feed syndication mod v1.5 5 * 6 */ 7 10 8 // set this to 1 if you are running a master killboard and want 11 9 // to even fetch mails not related to your corp / alliance 12 define(MASTER, 0); 13 14 $version = "v1.6"; 10 define('MASTER', 0); 11 15 12 @set_time_limit(0); 16 13 require_once('feed_fetcher.php'); … … 19 16 require_once('common/includes/class.alliance.php'); 20 17 21 $page = new Page("Administration - Feed Syndication " . $ version);18 $page = new Page("Administration - Feed Syndication " . $feedversion); 22 19 $page->setCachable(false); 23 20 $page->setAdmin(); … … 66 63 $friends = "on"; 67 64 else $friends = ""; 65 if ($_POST['apikills'] && in_array ($i, $_POST['apikills'])) 66 $apikills = "on"; 67 else $friends = ""; 68 68 $fstr = config::get('fetch_url_' . $i); 69 69 $ftmp = explode(':::', $fstr); 70 // reset the feed lastkill details if the URL or friends has changed 71 if($_POST[$url] != $ftmp[0] || $friends != $ftmp[2] || ($_POST['newkills'] && !in_array ($i, $_POST['newkills'])) ) 72 config::set($url, $_POST[$url] . ':::' . 0 . ':::' . $friends); 70 // reset the feed lastkill details if the URL, friends or api status has changed 71 if($_POST[$url] != $ftmp[0] || $friends != $ftmp[2] || $apikills != $ftmp[3] || 72 ($_POST['newkills'] && !in_array ($i, $_POST['newkills'])) ) 73 config::set($url, $_POST[$url] . ':::' . 0 . ':::' . $friends . ':::' . $apikills); 73 74 } 74 75 else … … 87 88 if ($tmp[2] == "on") 88 89 $friend[$i] = $tmp[2]; 90 if ($tmp[3] == "on") 91 $apikills[$i] = $tmp[3]; 89 92 } 90 93 // building the request query and fetching of the feeds … … 112 115 if ($friend[$i]) 113 116 $str .= '&friend=1'; 117 if ($apikills[$i]) 118 $str .= '&apikills=1'; 114 119 if ($_POST['fetch_losses']) 115 120 $str .= "&losses=1"; … … 167 172 $html .= "><b>New kills only?</b><br>"; 168 173 174 $html .= "<td><input type=checkbox name=apikills[] id=apikills value=" . $i; 175 if ($apikills[$i]) 176 $html .= " checked=\"checked\""; 177 $html .= "><b>API verified only?</b><br>"; 178 169 179 $html .= "<td><input type=checkbox name=fetch_feed[] id=fetch value=" . $i; 170 180 if ($feed[$i]) -
dev/common/admin/feed_fetcher.php
r370 r380 1 1 <?php 2 ////// 3 ////// ////// 4 ////// liq's feed syndication mod v1.6 5 // Kovell: last kill function activated in 1.6 6 //////////// 7 // Fetcher class used with common/feed.php on a remote board to fetch kills 8 // with a given pilot, corp or alliance 9 10 11 // Fetches $this->lastkllid_ = last kill in feed 12 // $this->finalkllid_ = last kill on board including kills not in feed 2 /* 3 * EDK Feed Syndication v1.7 4 * based on liq's feed syndication mod v1.5 5 * 6 */ 13 7 14 8 @set_time_limit(0); 15 9 @ini_set('memory_limit',999999999); 10 $feedversion = "v1.7"; 16 11 17 12 require_once( "common/includes/class.kill.php" ); 18 13 require_once( "common/includes/class.parser.php" ); 19 if ( file_exists("common/includes/class.comments.php") ) // for the Eve-Dev Comment Class 20 require_once( "common/includes/class.comments.php" ); 21 if ( file_exists("../../common/class.comment.php") ) // for the D2 Killboard Comment Class 22 require_once( "common/class.comment.php" ); 14 require_once( "common/includes/class.comments.php" ); 23 15 24 16 $insideitem = false; … … 61 53 function grab($url, $str, $trackfriend = '', $trackkey = '') 62 54 { 63 global $x, $uurl ;55 global $x, $uurl, $feedversion; 64 56 // $this->trackurl_ = $trackurl; 65 57 $this->trackfriend_ = $trackfriend; 66 58 $this->trackkey_ = $trackkey; 67 59 $x=0; 68 $fetchurl = $url.$str; 60 $fetchurl = $url.$str."&board=".urlencode(KB_TITLE); 61 if(!strpos($fetchurl,'?')) $fetchurl = 62 substr_replace($fetchurl,'?', strpos($fetchurl,'&'),0); 69 63 $uurl = $url; 70 64 $xml_parser = xml_parser_create("UTF-8"); … … 76 70 77 71 $http = new http_request($fetchurl); 72 $http->set_useragent("EDK Feedfetcher ".$feedversion); 78 73 $http->set_timeout(120); 79 $http->set_cookie('D2', 'a%3A4%3A%7Bi%3A0%3Bs%3A4%3A%221456%22%3Bi%3A1%3Bs%3A40%3A%22ca313afe9822b1d172ce660758e915fe81810780%22%3Bi%3A2%3Bi%3A1359068654%3Bi%3A3%3Bi%3A2%3B%7D');80 74 $http->set_cookie('PHPSESSID', 'a2bb4a7485eaba91b9d8db6aafd8ec5d'); 81 #Cookie: D2=; PHPSESSID=a2bb4a7485eaba91b9d8db6aafd8ec5d82 75 $data = $http->get_content(); 83 $data = trim(preg_replace('<<!--.*?-->>', '', $data)); // remove <!-- Cached --> message, else it will break gzinflate84 76 // $data = trim(preg_replace('<<!--.*?-->>', '', $data)); // remove <!-- Cached --> message, else it will break gzinflate 77 $data = preg_replace('<<!--.*?-->>', '', $data); // remove <!-- Cached --> message, else it will break gzinflate 85 78 if (!@gzinflate($data)) 86 79 { … … 116 109 function startElement($parser, $name, $attrs) 117 110 { 118 global $insideitem, $tag, $title, $description, $link ;111 global $insideitem, $tag, $title, $description, $link, $apiID; 119 112 // if ($insideitem) 120 113 $tag = $name; … … 127 120 function endElement($parser, $name) 128 121 { 129 global $insideitem, $tag, $title, $description, $link, $html, $x, $uurl ;122 global $insideitem, $tag, $title, $description, $link, $html, $x, $uurl, $apiID; 130 123 131 124 if ($name == "ITEM") … … 133 126 if ( isset( $description ) ) 134 127 { 135 $parser = new Parser( $description ); 136 $killid = $parser->parse( true ); 128 // If the kill has an external id then check if it is already 129 // on this board. 130 $apiID = intval($apiID); 131 if( $apiID) 132 { 133 $qry = new DBQuery(); 134 $qry->execute("SELECT 1 FROM kb3_kills WHERE kll_external_id = ".$apiID); 135 if(!$qry->recordCount()) 136 { 137 $parser = new Parser( $description ); 138 $killid = $parser->parse( true ); 139 } 140 else 141 { 142 $killid = -3; 143 $html .= "Killmail already posted <a href=\"?a=kill_detail&kll_external_id=".$apiID."\">here</a>.<br>"; 144 } 145 } 146 else 147 { 148 $parser = new Parser( $description ); 149 $killid = $parser->parse( true ); 150 } 137 151 if($this->trackkey_ != '' && $this->tracklast_ < intval($title) && intval($title) > 0) 138 152 { 139 153 config::set($this->trackkey_, $uurl . ':::' . intval($title) . ':::' . $this->trackfriend_); 140 154 } 141 if ( $killid == 0 || $killid == -1 || $killid == -2 )155 if ( $killid == 0 || $killid == -1 || $killid == -2 || $killid == -3) 142 156 { 143 157 if ( $killid == 0 && config::get('fetch_verbose') ) … … 146 160 $html .= "Killmail is not related to ".KB_TITLE.".<br>"; 147 161 if ( $killid == -1 && config::get('fetch_verbose') ) 148 $html .= "Killmail already posted <a href=\"?a=kill_detail& kll_id=".$parser->dupeid_."\">here</a>.<br>";162 $html .= "Killmail already posted <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>.<br>"; 149 163 } 150 164 else 151 165 { 152 153 166 $qry = new DBQuery(); 154 167 $qry->execute( "insert into kb3_log (log_kll_id, log_site, log_ip_address, log_timestamp) values( ". … … 156 169 $html .= "Killmail successfully posted <a href=\"?a=kill_detail&kll_id=".$killid."\">here</a>.<br>"; 157 170 158 if (c lass_exists('Comments') && config::get('fetch_comment'))159 { // for the Eve-Dev Comment Class171 if (config::get('fetch_comment')) 172 { 160 173 $comments = new Comments($killid); 161 174 $comments->addComment("Feed Syndication", config::get('fetch_comment')." mail fetched from: ".$uurl.")"); 162 }163 if (class_exists('Comment') && config::get('fetch_comment'))164 { // for the D2 Killboard Comment Class165 $comment = new Comment($killid);166 $comment->postComment(config::get('fetch_comment')." \n\n\n <i>mail fetched from:\n ".$uurl."</i>", "liquidism");167 175 } 168 176 $x++; … … 174 182 $link = ""; 175 183 $insideitem = false; 184 $apiID = false; 176 185 } 177 186 } … … 179 188 function characterData($parser, $data) 180 189 { 181 global $insideitem, $tag, $title, $description, $link ;190 global $insideitem, $tag, $title, $description, $link, $apiID; 182 191 if ($insideitem) 183 192 { … … 193 202 $link .= $data; 194 203 break; 204 case "APIID": 205 $apiID .= $data; 195 206 } 196 207 } -
dev/common/feed.php
r370 r380 2 2 /* 3 3 * Create a syndication feed of kills stored on this board. 4 * 5 * Flags 6 * week = week 7 * year = year 8 * lastkllid = return all kills lastkllid on (ordered by kll_id) 9 * range = return all kills with lastkllid <= id <= lastkllid + range 10 * APIkills = restrict results to kills with an external id set 11 * pilot = pilot to retrieve kills for 12 * corp = corp_name = corp to retrieve kills for 13 * alli = alli_name = alliance to retrieve kills for 14 * master = retrieve all kills 15 * friend = set pilot/corp/alli as involved killer (default is victim) 16 * combined = return both kills and losses 17 * 4 18 */ 5 19 @set_time_limit(120); … … 12 26 13 27 $config = new Config(KB_SITE); 14 $qry = new DBQuery(); 15 if(config::get('kill_classified')) 16 { 17 $qry->execute('SELECT max(kll_id) as finalkill FROM kb3_kills WHERE kll_timestamp < "'.(date('Y-m-d H:i:s',time()-config::get('kill_classified')*60*60)).'"'); 18 } 19 else $qry->execute('SELECT max(kll_id) as finalkill FROM kb3_kills'); 20 $row=$qry->getRow(); 21 $finalkill = intval($row['finalkill']); 28 // maximum amount of kills to return. 29 $maxreturned = 100; 22 30 $html .= '<?xml version="1.0" encoding="UTF-8" ?> 23 31 <rss version="2.0"> … … 26 34 <link>'.KB_HOST.'</link> 27 35 <description>Kill Feed v1.6</description> 28 <copyright>'.KB_TITLE.'</copyright> 29 <finalkill>'.$finalkill.'</finalkill>\n'; 30 if($_GET['combined']) $html .= '<combined>true</combined>\n'; 36 <copyright>'.KB_TITLE."</copyright>\n"; 37 if($_GET['combined']) $html .= "<combined>true</combined>\n"; 31 38 $klist = new KillList(); 32 39 $klist->setPodsNoobShips(true); … … 53 60 54 61 $kid = intval($_GET['lastkllid']); 55 if ($kid && method_exists($klist, 'setMinKllID'))62 if ($kid) 56 63 { 57 64 $klist->setMinKllID($kid); 58 65 $klist->setOrderBy(' kll.kll_id ASC'); 59 66 $klist->setOrdered(true); 60 } 61 67 $klist->setLimit($maxreturned); 68 if(intval($_GET['range'])) $klist->setMaxKllID(intval($_GET['range'])+$kid); 69 } 70 // If asked, set feed to only retrieve kills with an external id set. 71 if (intval($_GET['APIkills'])) $klist->setAPIKill(); 62 72 if ($_GET['pilot'] || $_GET['pilot_name']) 63 73 { … … 193 203 194 204 $kills = array(); 205 $finalkill = 0; 195 206 while ($kill = $klist->getKill()) 196 207 { … … 199 210 continue; 200 211 } 201 212 if($finalkill < $kill->getID())$finalkill = $kill->getID(); 202 213 $kills[$kill->getID()] = $kill->getTimestamp(); 203 214 } … … 206 217 asort($kills); 207 218 } 219 $qry = new DBQuery(); 220 // If kills returned = $maxreturned assume that it was limited and set 221 // last kill as the lower of highest kill id returned or highest non-classified 222 // kill 223 if($klist->getCount() != $maxreturned) 224 { 225 $qry = new DBQuery(); 226 if(config::get('kill_classified')) 227 { 228 $qry->execute('SELECT max(kll_id) as finalkill FROM kb3_kills WHERE kll_timestamp < "'.(date('Y-m-d H:i:s',time()-config::get('kill_classified')*60*60)).'"'); 229 } 230 else $qry->execute('SELECT max(kll_id) as finalkill FROM kb3_kills'); 231 $row=$qry->getRow(); 232 $finalkill = intval($row['finalkill']); 233 } 234 elseif(config::get('kill_classified')) 235 { 236 // Check if there are classified kills with lower kill ids still to come. 237 $qry->execute('SELECT max(kll_id) as finalkill FROM kb3_kills WHERE kll_timestamp < "'.(date('Y-m-d H:i:s',time()-config::get('kill_classified')*60*60)).'"'); 238 $row=$qry->getRow(); 239 if($finalkill > intval($row['finalkill'])) $finalkill = intval($row['finalkill']); 240 } 241 242 $html .= '<finalkill>'.$finalkill.'</finalkill>\n'; 208 243 foreach ($kills as $id => $timestamp) 209 244 { … … 213 248 <description><![CDATA[ '.$kill->getRawMail().' ]]></description> 214 249 <guid>?a=kill_detail&kll_id='.$id.'</guid> 215 <pubDate>'.strftime("%a, %d %b %Y %T %Z", strtotime($timestamp))."</pubDate> 216 </item>\n"; 250 <pubDate>'.strftime("%a, %d %b %Y %T %Z", strtotime($timestamp))."</pubDate>\n"; 251 if($kill->getExternalID()) $html .= "<apiID>".$kill->getExternalID()."</apiID>\n"; 252 $html .= '</item>\n'; 217 253 } 218 254 $html .= '</channel></rss>'; -
dev/common/includes/class.killlist.php
r376 r380 70 70 else 71 71 { 72 $this->sql_ .= 'select kll.kll_id, kll.kll_timestamp, plt.plt_name, 73 crp.crp_name, crp.crp_id, ali.all_name, ali.all_id, 74 kll.kll_system_id, kll.kll_ship_id, 75 kll.kll_victim_id, plt.plt_externalid, 76 kll.kll_crp_id, kll.kll_points, kll.kll_isk_loss, 77 shp.shp_class, shp.shp_name, 78 shp.shp_externalid, shp.shp_id, 79 scl.scl_id, scl.scl_class, scl.scl_value, 80 sys.sys_name, sys.sys_sec, 81 fbplt.plt_name as fbplt_name, 82 fbplt.plt_externalid as fbplt_externalid, 83 fbcrp.crp_name as fbcrp_name'; 72 $this->sql_ .= 'select kll.kll_id, kll.kll_timestamp, kll.kll_external_id, 73 plt.plt_name, crp.crp_name, crp.crp_id, 74 ali.all_name, ali.all_id, 75 kll.kll_system_id, kll.kll_ship_id, 76 kll.kll_victim_id, plt.plt_externalid, 77 kll.kll_crp_id, kll.kll_points, kll.kll_isk_loss, 78 shp.shp_class, shp.shp_name, 79 shp.shp_externalid, shp.shp_id, 80 scl.scl_id, scl.scl_class, scl.scl_value, 81 sys.sys_name, sys.sys_sec, 82 fbplt.plt_name as fbplt_name, 83 fbplt.plt_externalid as fbplt_externalid, 84 fbcrp.crp_name as fbcrp_name'; 84 85 } 85 86 } … … 157 158 if($this->apikill_) 158 159 { 159 $this->sql_ .= $sqlwhereop." ANDkll.kll_external_id IS NOT NULL ";160 $this->sql_ .= $sqlwhereop." kll.kll_external_id IS NOT NULL "; 160 161 $sqlwhereop = ' AND '; 161 162 } … … 206 207 if ($this->minkllid_) 207 208 { 208 $this->sql_ .= $sqlwhereop.'kll.kll_id > '.$this->minkllid_.' '; 209 $this->sql_ .= $sqlwhereop.'kll.kll_id >= '.$this->minkllid_.' '; 210 $sqlwhereop = ' AND '; 211 } 212 213 // Get all kills before given kill id (used for feed syndication) 214 if ($this->maxkllid_) 215 { 216 $this->sql_ .= $sqlwhereop.'kll.kll_id <= '.$this->maxkllid_.' '; 209 217 $sqlwhereop = ' AND '; 210 218 } … … 390 398 $kill->setFBCorpName($row['fbcrp_name']); 391 399 $kill->setKillPoints($row['kll_points']); 392 $kill->iskloss_ = $row['kll_isk_loss']; 400 $kill->setExternalID($row['kll_external_id']); 401 $kill->setISKLoss($row['kll_isk_loss']); 393 402 $kill->plt_ext_ = $row['plt_externalid']; 394 403 $kill->fbplt_ext_ = $row['fbplt_externalid']; … … 631 640 function setAPIKill($hasid = true) 632 641 { 633 $this-> extid_ = $hasid;642 $this->apikill_ = $hasid; 634 643 } 635 644 … … 641 650 function setMinKllID($id) 642 651 { 643 $this->timeframe_ = '';644 652 $this->minkllid_ = $id; 653 } 654 655 function setMaxKllID($id) 656 { 657 $this->maxkllid_ = $id; 645 658 } 646 659