1 | <? |
---|
2 | |
---|
3 | // liq's feed syndication mod v1.2 |
---|
4 | |
---|
5 | @set_time_limit(0); |
---|
6 | require_once( "common/class.page.php" ); |
---|
7 | require_once( "common/admin_menu.php" ); |
---|
8 | require_once( "common/feed_fetcher.php" ); |
---|
9 | require_once( 'common/class.corp.php' ); |
---|
10 | require_once( 'common/class.alliance.php' ); |
---|
11 | |
---|
12 | $page = new Page( "Administration - Feeds" ); |
---|
13 | $page->setAdmin(); |
---|
14 | |
---|
15 | $validurl = "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"; |
---|
16 | $html .= "<table class=kb-subtable>"; |
---|
17 | |
---|
18 | if (getConfig('fetch_feed_count')) |
---|
19 | $feedcount = getConfig('fetch_feed_count'); |
---|
20 | else |
---|
21 | $feedcount = 3; |
---|
22 | |
---|
23 | |
---|
24 | if ( $_POST['submit'] || $_POST['fetch'] ) { |
---|
25 | if ( ctype_digit($_POST['fetch_feed_count']) ) { |
---|
26 | setConfig('fetch_feed_count', $_POST['fetch_feed_count']); |
---|
27 | $feedcount = $_POST['fetch_feed_count']; |
---|
28 | for ($i = 99; $i>=$feedcount; $i--) { |
---|
29 | delConfig('fetch_url_'.$i); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | if ( $_POST['fetch_verbose'] ) |
---|
34 | setConfig('fetch_verbose', '1'); |
---|
35 | else |
---|
36 | setConfig('fetch_verbose', '0'); |
---|
37 | |
---|
38 | if ( $_POST['fetch_comment'] ) |
---|
39 | setConfig('fetch_comment', $_POST['fetch_comment']); |
---|
40 | else |
---|
41 | setConfig('fetch_comment', ''); |
---|
42 | |
---|
43 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
44 | $url = "fetch_url_".$i; |
---|
45 | if ( preg_match($validurl ,$_POST[$url]) ) { |
---|
46 | setConfig($url, $_POST[$url].':::'.$time[$i]); |
---|
47 | $feed[$i] = $_POST[$url]; |
---|
48 | } else |
---|
49 | setConfig($url, ''); |
---|
50 | $feed[$i] = ''; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | $feed = array(); |
---|
55 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
56 | $str = getConfig('fetch_url_'.$i); |
---|
57 | $tmp = explode(':::', $str); |
---|
58 | $feed[$i] = $tmp[0]; |
---|
59 | $time[$i] = $tmp[1]; |
---|
60 | } |
---|
61 | |
---|
62 | if ( $_POST['fetch'] ) { |
---|
63 | if (CORP_ID) { |
---|
64 | $corp = new Corporation(CORP_ID); |
---|
65 | $myid = '&corp='.urlencode($corp->getName()); |
---|
66 | } |
---|
67 | if (ALLIANCE_ID) { |
---|
68 | $alli = new Alliance(ALLIANCE_ID); |
---|
69 | $myid = '&alli='.urlencode($alli->getName()); |
---|
70 | } |
---|
71 | |
---|
72 | for ($i=1; $i<=$feedcount; $i++) { |
---|
73 | $feedfetch = new Fetcher(); |
---|
74 | $cfg = "fetch_url_".$i; |
---|
75 | if (preg_match($validurl , $feed[$i]) && $_POST["fetch_feed_".$i]) { |
---|
76 | $str = ''; |
---|
77 | if ($time[$i]) |
---|
78 | $str .= '&lastkllid='.$time[$i]; |
---|
79 | if ( $_POST['fetch_losses'] ) |
---|
80 | $str .= "&losses=1"; |
---|
81 | if ( $_POST['graball'] ) { |
---|
82 | for ($l = 1; $l<=52; $l++) { |
---|
83 | $html .= "<b>Week: ". $l ."</b><br>"; |
---|
84 | $html .= $feedfetch->grab( $feed[$i].$myid.$str."&week=".$l ); |
---|
85 | } |
---|
86 | } else |
---|
87 | $html .= $feedfetch->grab( $feed[$i].$myid.$str ); |
---|
88 | } |
---|
89 | |
---|
90 | setConfig($cfg, $feed[$i].':::'.$lastkllid); |
---|
91 | $time[$i] = $lastkllid; |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | $html .= "<form id=options name=options method=post action=?a=admin_feed>"; |
---|
96 | $html .= "</table>"; |
---|
97 | |
---|
98 | $html .= "<div class=block-header2>Feeds</div><table>"; |
---|
99 | |
---|
100 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
101 | $html .= "<tr><td width=85px><b>Feed url #".$i."</b></td><td><input type=text name=fetch_url_".$i." size=50 class=password value=\""; |
---|
102 | if ( $feed[$i] ) |
---|
103 | $html .= $feed[$i]; |
---|
104 | $html .= "\"> "; |
---|
105 | $html .= "<input type=checkbox name=fetch_feed_".$i." id=fetch_feed_".$i; |
---|
106 | if ( $feed[$i] ) |
---|
107 | $html .= " checked=\"checked\""; |
---|
108 | $html .= "><b>Fetch?</b><br>"; |
---|
109 | $html .= "</td></tr>"; |
---|
110 | } |
---|
111 | |
---|
112 | $html .= "</table><i>Example: http://killboard.eve-d2.com/?a=feed</i><br><br><br>"; |
---|
113 | |
---|
114 | $html .= "<table><tr><td height=30px width=150px><b>Get kills instead of losses?</b></td>"; |
---|
115 | $html .= "<td><input type=checkbox name=fetch_losses id=fetch_losses>"; |
---|
116 | $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>"; |
---|
117 | |
---|
118 | $html .= "<tr><td height=30px width=150px><b>Grab ALL mails from the feed servers?</b></td>"; |
---|
119 | $html .= "<td><input type=checkbox name=graball id=graball>"; |
---|
120 | $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>"; |
---|
121 | $html .= "</tr></table><br><br>"; |
---|
122 | |
---|
123 | $html .= "<input type=submit id=submit name=fetch value=\"Fetch!\"><br><br>"; |
---|
124 | |
---|
125 | $html .= "<div class=block-header2>Options</div><table>"; |
---|
126 | $html .= "<tr><td height=30px width=150px><b>Number of feeds:</b></td>"; |
---|
127 | $html .= "<td><input type=text name=fetch_feed_count size=2 maxlength=2 class=password value=\"".$feedcount."\"</td></tr>"; |
---|
128 | |
---|
129 | $html .= "<tr><td height=50px width=150px><b>Comment for automatically parsed killmails?</b></td>"; |
---|
130 | $html .= "<td><input type=text size=50 class=password name=fetch_comment id=fetch_comment value=\""; |
---|
131 | if ( getConfig('fetch_comment') ) |
---|
132 | $html .= getConfig('fetch_comment'); |
---|
133 | $html .= "\"><br><i> (leave blank for none)</i><br></td></tr>"; |
---|
134 | |
---|
135 | $html .= "<tr><td height=30px width=150px><b>Verbose mode?</b></td>"; |
---|
136 | $html .= "<td><input type=checkbox name=fetch_verbose id=fetch_verbose"; |
---|
137 | if ( getConfig('fetch_verbose') ) |
---|
138 | $html .= " checked=\"checked\""; |
---|
139 | $html .= "><i> (displays errormessages when the imported mail is malformed, already exists, is not related etc.)</i></td>"; |
---|
140 | $html .= "</tr></table><br><br>"; |
---|
141 | |
---|
142 | $html .= "<input type=submit id=submit name=submit value=\"Save\">"; |
---|
143 | $html .= "</form>"; |
---|
144 | |
---|
145 | $page->addContext( $menubox->generate() ); |
---|
146 | $page->setContent( $html ); |
---|
147 | $page->generate(); |
---|
148 | |
---|
149 | ?> |
---|