[137] | 1 | <?php |
---|
| 2 | @set_time_limit(0); |
---|
| 3 | |
---|
[136] | 4 | // liq's feed syndication mod v1.0 |
---|
[137] | 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'); |
---|
[136] | 12 | |
---|
[137] | 13 | $page = new Page("Administration - Feeds"); |
---|
| 14 | $page->setAdmin(); |
---|
| 15 | $killboard = new Killboard(KB_SITE); |
---|
[136] | 16 | |
---|
[137] | 17 | // the rig0r basecode does not have this functions |
---|
| 18 | function setConfig($key, $value) |
---|
| 19 | { |
---|
| 20 | global $config; |
---|
[136] | 21 | |
---|
[137] | 22 | if (method_exists($config, 'setConfig')) |
---|
| 23 | { |
---|
| 24 | return $config->setConfig($key, $value); |
---|
| 25 | } |
---|
[136] | 26 | |
---|
[137] | 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(); |
---|
[136] | 158 | ?> |
---|