Changeset 137
- Timestamp:
- 12/07/06 05:34:28 (16 years ago)
- Location:
- dev
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/admin_feed.php
r136 r137 1 <? 1 <?php 2 @set_time_limit(0); 3 2 4 // liq's feed syndication mod v1.0 5 require_once("class.page.php"); 6 require_once("db.php"); 7 require_once("admin_menu.php"); 8 require_once("feed_fetcher.php"); 9 require_once("class.killboard.php"); 10 require_once('class.corp.php'); 11 require_once('class.alliance.php'); 3 12 4 require_once( "class.page.php" ); 5 require_once( "db.php" ); 6 require_once( "admin_menu.php" ); 7 require_once( "feed_fetcher.php" ); 8 require_once( "class.killboard.php" ); 9 10 $page = new Page( "Administration - Feeds" ); 11 $page->setAdmin(); 12 $killboard = new Killboard( KB_SITE ); 13 14 $validurl = "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"; 15 16 $html .= "<table class=kb-subtable>"; 17 18 if ( $_POST['fetch'] ) { 19 $i=1; 20 while ( $i <= 5 ) { 21 @set_time_limit(0); 22 $feed = new Fetcher(); 23 $url = "fetch_url_".$i; 24 if ( preg_match( $validurl ,$config->getConfig($url) )) { 25 26 if ( $_POST['graball'] ) { 27 $l=1; 28 while ( $l <= 52 ) { 29 $html .= "<b>Week: ". $l ."</b><br>"; 30 $html .= $feed->generate( $config->getConfig($url)."&week=".$l ); 31 $l++; 32 } 33 } else 34 $html .= $feed->generate( $config->getConfig($url) ); 35 } 36 $i++; 37 } 38 } 13 $page = new Page("Administration - Feeds"); 14 $page->setAdmin(); 15 $killboard = new Killboard(KB_SITE); 39 16 40 if ( $_POST['submit'] ) { 41 42 $i=1; 43 while ( $i <= 5 ) { 44 $url = "fetch_url_".$i; 45 if ( preg_match($validurl ,$_POST[$url]) ) 46 $config->setConfig($url, $_POST[$url]); 47 else 48 $config->setConfig($url, ''); 49 $i++; 50 } 51 } 17 // the rig0r basecode does not have this functions 18 function setConfig($key, $value) 19 { 20 global $config; 52 21 53 $html .= "<br><form id=options name=options method=post action=?a=admin_feed>"; 54 $html .= "<input type=submit id=submit name=fetch value=\"Fetch\">"; 55 $html .= "<br><br><input type=checkbox name=graball id=graball>grab ALL kills from the feed servers? <br> <i>(use this may take upto several hours depending on the amount of kills to import!)</i>"; 56 $html .= "</form></table><br>"; 57 58 $html .= "<table class=kb-subtable>"; 59 $html .= "<div class=block-header2>Feed options</div>"; 60 $html .= "<form id=options name=options method=post action=?a=admin_feed>"; 61 $html .= "Feed url #1<input type=text name=fetch_url_1 size=50 class=password value=\"".$config->getConfig('fetch_url_1')."\"><br><br>"; 62 $html .= "Feed url #2<input type=text name=fetch_url_2 size=50 class=password value=\"".$config->getConfig('fetch_url_2')."\"><br><br>"; 63 $html .= "Feed url #3<input type=text name=fetch_url_3 size=50 class=password value=\"".$config->getConfig('fetch_url_3')."\"><br><br>"; 64 $html .= "Feed url #4<input type=text name=fetch_url_4 size=50 class=password value=\"".$config->getConfig('fetch_url_4')."\"><br><br>"; 65 $html .= "Feed url #5<input type=text name=fetch_url_5 size=50 class=password value=\"".$config->getConfig('fetch_url_5')."\"><br><br>"; 66 $html .= "<i>Example: http://killboard.eve-d2.com/?a=feed</i>"; 67 $html .= "<br><br><br><input type=submit id=submit name=submit value=\"Save\">"; 68 $html .= "</form></table>"; 22 if (method_exists($config, 'setConfig')) 23 { 24 return $config->setConfig($key, $value); 25 } 69 26 70 $page->addContext( $menubox->generate() ); 71 $page->setContent( $html ); 72 $page->generate(); 73 27 $qry = new DBQuery(); 28 $qry->execute("select cfg_value from kb3_config 29 where cfg_key = '".$key."' and cfg_site = '".KB_SITE."'"); 30 if ($qry->recordCount()) 31 { 32 $sql = "update kb3_config set cfg_value = '".$value."' 33 where cfg_site = '".KB_SITE."' and cfg_key = '".$key."'"; 34 } 35 else 36 { 37 $sql = "insert into kb3_config values ( '".KB_SITE."','".$key."','".$value."' )"; 38 } 39 $qry->execute($sql); 40 } 41 42 function getConfig($key) 43 { 44 global $config; 45 46 if (method_exists($config, 'getConfig')) 47 { 48 return $config->getConfig($key); 49 } 50 $qry = new DBQuery(); 51 $qry->query("select ".$key." from kb3_config where cfg_site = '".KB_SITE."'"); 52 $row = $qry->getRow(); 53 if (isset($row[$key])) 54 { 55 return $row[$key]; 56 } 57 return false; 58 } 59 60 $validurl = "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"; 61 62 $html .= "<table class=\"kb-subtable\">"; 63 64 $feed = array(); 65 for ($i = 1; $i<=5; $i++) 66 { 67 $str = getConfig('fetch_url_'.$i); 68 $tmp = explode(':::', $str); 69 $feed[$i] = $tmp[0]; 70 $time[$i] = $tmp[1]; 71 } 72 73 if ($_POST['fetch']) 74 { 75 $i = 1; 76 while ($i <= 5) 77 { 78 $feedfetch = new Fetcher(); 79 $url = "fetch_url_".$i; 80 if (preg_match($validurl , $feed[$i])) 81 { 82 $str = ''; 83 if (CORP_ID) 84 { 85 $corp = new Corporation(CORP_ID); 86 $str = '&corp_name='.urlencode($corp->getName()); 87 } 88 else 89 { 90 $all = new Alliance(ALLIANCE_ID); 91 $str = '&alliance_name='.urlencode($all->getName()); 92 } 93 if ($time[$i]) 94 { 95 $str .= '&lastkllid='.$time[$i]; 96 } 97 98 if ($_POST['graball']) 99 { 100 $l = 1; 101 while ($l <= 52) 102 { 103 $html .= "<b>Week: ".$l."</b><br>"; 104 $html .= $feedfetch->generate($feed[$i]."&week=".$l.$str); 105 $l++; 106 } 107 } 108 else 109 { 110 $html .= $feedfetch->generate($feed[$i].$str); 111 } 112 setConfig($url, $feed[$i].':::'.$lastkllid); 113 $time[$i] = $lastkllid; 114 } 115 $i++; 116 } 117 } 118 119 if ($_POST['submit']) 120 { 121 $i = 1; 122 while ($i <= 5) 123 { 124 $url = "fetch_url_".$i; 125 if (preg_match($validurl , $_POST[$url])) 126 { 127 setConfig($url, $_POST[$url].':::'.$time[$i]); 128 $feed[$i] = $_POST[$url]; 129 } 130 else 131 { 132 setConfig($url, ''); 133 } 134 $i++; 135 } 136 } 137 138 $html .= "<br><form id=options name=options method=post action=?a=admin_feed>"; 139 $html .= "<input type=submit id=submit name=fetch value=\"Fetch\">"; 140 $html .= "<br><br><input type=checkbox name=graball id=graball>grab ALL kills from the feed servers? <br> <i>(use this may take upto several hours depending on the amount of kills to import!)</i>"; 141 $html .= "</form></table><br>"; 142 143 $html .= "<table class=kb-subtable>"; 144 $html .= "<div class=block-header2>Feed options</div>"; 145 $html .= "<form id=options name=options method=post action=?a=admin_feed>"; 146 $html .= "Feed url #1<input type=text name=fetch_url_1 size=50 class=password value=\"".$feed[1]."\"><br><br>"; 147 $html .= "Feed url #2<input type=text name=fetch_url_2 size=50 class=password value=\"".$feed[2]."\"><br><br>"; 148 $html .= "Feed url #3<input type=text name=fetch_url_3 size=50 class=password value=\"".$feed[3]."\"><br><br>"; 149 $html .= "Feed url #4<input type=text name=fetch_url_4 size=50 class=password value=\"".$feed[4]."\"><br><br>"; 150 $html .= "Feed url #5<input type=text name=fetch_url_5 size=50 class=password value=\"".$feed[5]."\"><br><br>"; 151 $html .= "<i>Example: http://killboard.eve-d2.com/?a=feed</i>"; 152 $html .= "<br><br><br><input type=submit id=submit name=submit value=\"Save\">"; 153 $html .= "</form></table>"; 154 155 $page->addContext($menubox->generate()); 156 $page->setContent($html); 157 $page->generate(); 74 158 ?> -
dev/common/class.killlist.php
r86 r137 188 188 $this->sql_ = $nsql; 189 189 } 190 if ($this->minkllid_) 191 { 192 $this->sql_ .= ' WHERE kll.kll_id > \''.$this->minkllid_.'\' '; 193 } 194 190 195 // group by 191 196 if ($this->groupby_) $this->sql_ .= " group by " . implode(",", $this->groupby_); … … 414 419 } 415 420 421 function setMinKllID($id) 422 { 423 $this->timeframe_ = ''; 424 $this->minkllid_ = $id; 425 } 426 416 427 function getCount() 417 428 { -
dev/common/feed.php
r136 r137 1 1 <?php 2 @set_time_limit(0); 3 2 4 // liq's feed syndication mod v1.0 3 4 header('Content-type: text/xml');5 5 require_once("class.corp.php"); 6 6 require_once("class.alliance.php"); … … 28 28 $prevdate = ""; 29 29 $this->kill_list_->rewind(); 30 30 31 31 while ($kill = $this->kill_list_->getKill()) 32 32 { 33 $rawkill = new Kill( $kill->getID());34 35 33 $rawkill = new Kill($kill->getID()); 34 35 $html .= " 36 36 <item> 37 37 <title>".$rawkill->getID()."</title> 38 38 <description> <![CDATA[ ".$rawkill->getRawMail()." ]]> </description> 39 39 <guid>?a=kill_detail&kll_id=".$kill->getID()."</guid> 40 <pubDate>".strftime( 41 </item> "; 40 <pubDate>".strftime("%a, %d %b %Y %T %Z" , strtotime($kill->getTimeStamp()))."</pubDate> 41 </item> "; 42 42 } 43 43 return $html; 44 44 } 45 45 } 46 47 46 48 47 $html .= " … … 58 57 $klist->setPodsNoobShips(true); 59 58 60 if ($_GET['week']) {61 @set_time_limit(0); 62 $klist->setWeek( $_GET['week']);59 if ($_GET['week']) 60 { 61 $klist->setWeek($_GET['week']); 63 62 } 64 else 65 $klist->setWeek( date("W") ); 63 elseif (!$_GET['lastkllid']) 64 { 65 $klist->setWeek(date("W")); 66 } 67 if ($_GET['lastkllid']) 68 { 69 if (method_exists($klist, 'setMinKllID')) 70 { 71 $klist->setMinKllID($_GET['lastkllid']); 72 } 73 } 66 74 67 if (CORP_ID) 68 $klist->addInvolvedCorp(new Corporation(CORP_ID)); 69 if (ALLIANCE_ID) 70 $klist->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); 75 if ($_GET['corp_name']) 76 { 77 $corp = new Corporation(); 78 $corp->lookup($_GET['corp_name']); 79 $klist->addInvolvedCorp($corp); 80 } 81 elseif ($_GET['alliance_name']) 82 { 83 $ally = new Alliance(); 84 $ally->add($_GET['alliance_name']); 85 $klist->addInvolvedAlliance($ally); 86 } 71 87 72 88 $table = new RSSTable($klist); … … 76 92 </channel> 77 93 </rss>"; 78 94 79 95 echo $html; 80 81 96 ?> -
dev/common/feed_fetcher.php
r136 r137 1 1 <?php 2 @set_time_limit(0); 2 3 // liq's feed syndication mod v1.0 4 require_once("class.page.php"); 5 require_once("class.kill.php"); 6 require_once("class.parser.php"); 3 7 4 require_once( "class.page.php" ); 5 require_once( "class.kill.php" ); 6 require_once( "class.parser.php" ); 7 8 9 $insideitem = false; 8 $insideitem = false; 10 9 $tag = ""; 11 10 $title = ""; 12 11 $description = ""; 13 12 $link = ""; 14 $x =0;13 $x = 0; 15 14 16 class Fetcher 15 class Fetcher 17 16 { 18 19 function generate($url) { 20 global $x; 21 @set_time_limit(0); 22 $xml_parser = xml_parser_create(); 23 xml_set_object ( $xml_parser, $this ); 24 xml_set_element_handler($xml_parser, "startElement", "endElement"); 25 xml_set_character_data_handler ( $xml_parser, 'characterData' ); 26 $fp = @fopen($url,"r"); 27 while ($data = fread($fp, 4096)) { 28 if (!xml_parse( $xml_parser, $data, feof($fp) ) && !feof($fp) ) 29 return "<i>Error getting XML data from ".$url."</i><br><br>"; 30 } 31 fclose($fp); 32 xml_parser_free($xml_parser); 33 if ($x) 34 $html = "<div class=block-header2>".$x." kills added from feed: ".$url."</div>"; 35 else 36 $html = "<div class=block-header2>No kills added from feed: ".$url."</div>"; 37 38 return $html; 39 } 17 function generate($url, $lastkllid = 0) 18 { 19 global $x; 40 20 41 function startElement($parser, $name, $attrs) { 42 global $insideitem, $tag, $title, $description, $link; 43 if ($insideitem) { 44 $tag = $name; 45 } elseif ($name == "ITEM") { 46 $insideitem = true; 47 } 48 } 21 $xml_parser = xml_parser_create(); 22 xml_set_object($xml_parser, $this); 23 xml_set_element_handler($xml_parser, "startElement", "endElement"); 24 xml_set_character_data_handler ($xml_parser, 'characterData'); 49 25 50 function endElement($parser, $name) { 51 global $insideitem, $tag, $title, $description, $link, $html, $x; 26 $fp = @fopen($url, "r"); 27 $file = ''; 28 while ($data = fread($fp, 4096)) 29 { 30 $file .= $data; 31 } 32 fclose($fp); 52 33 53 if ($name == "ITEM") { 54 if ( isset( $description ) ) { 55 $parser = new Parser( $description ); 56 $killid = $parser->parse( true ); 57 if ( $killid == 0 || $killid == -1 || $killid == -2 || $killid == -3 ) { 58 $page = new Page( "Error" ); 59 if ( $killid == 0 ) 60 $html .= "Killmail is malformed.<br>"; 61 if ( $killid == -3 ) 62 $html .= "Killmail does not have a final blow! <p><br>To prevent the corruption of the database please just fake a <i>(laid the final blow)</i> behind one of the involved players on the killmail.<br><br><b>Example:</b><i><br>Name: liquidism (laid the final blow)</i></p>"; 63 if ( $killid == -2 ) 64 $html .= "Killmail is not related to ".KB_TITLE.".<br>"; 65 if ( $killid == -1 ) 66 $html .= "Killmail already posted <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>.<br>"; 67 } 68 else { 69 $qry = new DBQuery(); 70 $qry->execute( "insert into kb3_log values( ".$killid.", '".KB_SITE."','".$_SERVER['REMOTE_ADDR']."',now() )" ); 71 $html .= "Killmail has succsessfully been posted <a href=\"?a=kill_detail&kll_id=".$killid."\">here</a>.<br>"; 72 $x++; 73 } 74 } 75 $title = ""; 76 $description = ""; 77 $link = ""; 78 $insideitem = false; 79 } 80 } 34 if (!$file && file_exists('class.http.php')) 35 { 36 include_once('class.http.php'); 37 $file = new http($url); 38 $file = $file->get_content(); 39 } 40 if (!xml_parse($xml_parser, $file)) 41 return "<i>Error getting XML data from ".$url."</i><br><br>"; 42 xml_parser_free($xml_parser); 81 43 82 function characterData($parser, $data) { 83 global $insideitem, $tag, $title, $description, $link; 84 if ($insideitem) { 85 switch ($tag) { 86 case "TITLE": 87 $title .= $data; 88 break; 89 case "DESCRIPTION": 90 $description .= $data; 91 break; 92 case "LINK": 93 $link .= $data; 94 break; 95 } 96 } 97 } 44 if ($x) 45 { 46 $html = "<div class=block-header2>".$x." kills added from feed: ".$url."</div>"; 47 } 48 else 49 { 50 $html = "<div class=block-header2>No kills added from feed: ".$url."</div>"; 51 } 98 52 53 return $html; 54 } 99 55 56 function startElement($parser, $name, $attrs) 57 { 58 global $insideitem, $tag, $title, $description, $link; 59 if ($insideitem) 60 { 61 $tag = $name; 62 } 63 elseif ($name == "ITEM") 64 { 65 $insideitem = true; 66 } 67 } 100 68 69 function endElement($parser, $name) 70 { 71 global $insideitem, $tag, $title, $description, $link, $html, $x, $lastkllid; 72 73 if ($name == "ITEM") 74 { 75 if (isset($description)) 76 { 77 $parser = new Parser($description); 78 $killid = $parser->parse(true); 79 if ($killid == 0 || $killid == -1 || $killid == -2 || $killid == -3) 80 { 81 $page = new Page("Error"); 82 if ($killid == 0) 83 $html .= "Killmail is malformed.<br>"; 84 if ($killid == -3) 85 $html .= "Killmail does not have a final blow! <p><br>To prevent the corruption of the database please just fake a <i>(laid the final blow)</i> behind one of the involved players on the killmail.<br><br><b>Example:</b><i><br>Name: liquidism (laid the final blow)</i></p>"; 86 if ($killid == -2) 87 $html .= "Killmail is not related to ".KB_TITLE.".<br>"; 88 if ($killid == -1) 89 $html .= "Killmail already posted <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>.<br>"; 90 } 91 else 92 { 93 $qry = new DBQuery(); 94 $qry->execute("insert into kb3_log values( ".$killid.", '".KB_SITE."','".$_SERVER['REMOTE_ADDR']."',now() )"); 95 $html .= "Killmail has succsessfully been posted <a href=\"?a=kill_detail&kll_id=".$killid."\">here</a>.<br>"; 96 $x++; 97 } 98 } 99 if (trim($title) > $lastkllid || $lastkllid == 0) 100 { 101 $lastkllid = trim($title); 102 } 103 $title = ""; 104 $description = ""; 105 $link = ""; 106 $insideitem = false; 107 } 108 } 109 110 function characterData($parser, $data) 111 { 112 global $insideitem, $tag, $title, $description, $link; 113 if ($insideitem) 114 { 115 switch ($tag) 116 { 117 case "TITLE": 118 $title .= $data; 119 break; 120 case "DESCRIPTION": 121 $description .= $data; 122 break; 123 case "LINK": 124 $link .= $data; 125 break; 126 } 127 } 128 } 101 129 } 102 130 ?> -
dev/templates/icon.tpl
r115 r137 1 1 <!-- icon.tpl --> 2 <div class= item-icon style="background:url({$img}); height:32px; width:32px"><img src="{$icon}"/></div>2 <div class="item-icon" style="background: url({$img}); border: none; height:32px; width:32px"><img border="0" src="{$icon}"/></div> 3 3 <!-- /icon.tpl --> -
dev/templates/kill_detail.tpl
r135 r137 64 64 {if $slot.items} 65 65 <tr class="kb-table-row-even"> 66 <td width="32"><img src="img/{$slot.img}" alt="{$slot.text}" border="0"></td>66 <td class="item-icon" width="32"><img src="img/{$slot.img}" alt="{$slot.text}" border="0"></td> 67 67 <td colspan="2" class="kb-table-cell"><b>{$slot.text}</b> </td> 68 68 {if $config->getConfig('item_values')}