Not Reviewed
Show More
Add another comment
| @@ -0,0 +1,10 | |||
|
|
1 | <IfModule mod_rewrite.c> | |
|
|
2 | RewriteEngine On | |
|
|
3 | RewriteBase /rss/ | |
|
|
4 | RewriteRule ^index.php$ rss.php | |
|
|
5 | RewriteRule ^megatokyo.xml$ rss.php | |
|
|
6 | RewriteRule ^strips.xml$ rss.php?type=strips | |
|
|
7 | RewriteRule ^rants.xml$ rss.php?type=rants | |
|
|
8 | RewriteRule ^status.xml$ rss.php?type=status | |
|
|
9 | Header set X-Powered-By Nikuman | |
|
|
10 | </IfModule> | |
|
|
1 | NO CONTENT: new file 100644 |
| @@ -0,0 +1,183 | |||
|
|
1 | <?php | |
|
|
2 | ||
|
|
3 | require_once('../LocalSettings.php'); | |
|
|
4 | ||
|
|
5 | /* Get the database working */ | |
|
|
6 | $link = mysqli_connect(DB_SERVER, DB_READ_USER, DB_READ_PASS, DB_NAME) or trigger_error('Problem connecting to the SQL database server: '.mysqli_error($link), E_USER_ERROR); | |
|
|
7 | ||
|
|
8 | function numeric_entities($string){ | |
|
|
9 | $mapping = array(); | |
|
|
10 | foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity){ | |
|
|
11 | $mapping[$entity] = '&#' . ord($char) . ';'; | |
|
|
12 | } | |
|
|
13 | return str_replace(array_keys($mapping), $mapping, $string); | |
|
|
14 | } | |
|
|
15 | ||
|
|
16 | function Excerpt( $excerpt ) { | |
|
|
17 | $excerpt = strip_tags( $excerpt ); | |
|
|
18 | if (strlen($excerpt) > 455) { | |
|
|
19 | $excerpt = substr($excerpt,0,452) . '...'; | |
|
|
20 | } | |
|
|
21 | return $excerpt; | |
|
|
22 | } | |
|
|
23 | ||
|
|
24 | function datesort( $a , $b ) { | |
|
|
25 | if( $a->udate == $b->udate ) return 0; | |
|
|
26 | return( $a->udate > $b->udate ) ? -1 : 1; | |
|
|
27 | } | |
|
|
28 | ||
|
|
29 | function utfentities($string) | |
|
|
30 | { | |
|
|
31 | return htmlentities($string, ENT_COMPAT, 'UTF-8'); | |
|
|
32 | } | |
|
|
33 | ||
|
|
34 | function _query( $s, $byid = false ) { | |
|
|
35 | global $link; | |
|
|
36 | $r = mysqli_query($link, $s ) or die( mysqli_error($link) ); | |
|
|
37 | $ret=array(); | |
|
|
38 | $i=0; | |
|
|
39 | ||
|
|
40 | if( $byid ) { | |
|
|
41 | while ($row = mysqli_fetch_object($r) ) | |
|
|
42 | $ret[$row->id] = $row; | |
|
|
43 | } else { | |
|
|
44 | while ($row = mysqli_fetch_object($r) ) | |
|
|
45 | $ret[$i++] = $row; | |
|
|
46 | } | |
|
|
47 | return $ret; | |
|
|
48 | } | |
|
|
49 | ||
|
|
50 | @$f_title = $type = $_GET['type']; | |
|
|
51 | ||
|
|
52 | $f_items = array(); | |
|
|
53 | $f_desc = 'News and Comics from Megatokyo.'; | |
|
|
54 | ||
|
|
55 | /*if( $type == 'status' or $type == '') { | |
|
|
56 | // Status Box Updates | |
|
|
57 | $f_title = 'Megatokyo Status Updates'; | |
|
|
58 | $s = _query( "SELECT MAX(id)+1 as m FROM strip" ); // Permalinks to strips? | |
|
|
59 | ||
|
|
60 | $s = _query( "SELECT DISTINCT SUBTIME( published, eta ) as dd, UNIX_TIMESTAMP(published) as udate, text, UNIX_TIMESTAMP(eta) as eta, percentage | |
|
|
61 | FROM status s | |
|
|
62 | ORDER BY udate DESC | |
|
|
63 | LIMIT 5"); | |
|
|
64 | foreach( $s as $k=>$v ) { | |
|
|
65 | $s[$k]->link = 'http://www.megatokyo.com/'; | |
|
|
66 | $s[$k]->title = "Update: $v->percentage%: " . htmlentities($v->text, ENT_COMPAT, ini_get('default_charset')); | |
|
|
67 | ||
|
|
68 | $d = date( 'l F jS, H:i', $v->eta ); | |
|
|
69 | $dd = (int) (( $v->eta - $v->udate )/3600); | |
|
|
70 | ||
|
|
71 | $s[$k]->desc = "<![CDATA[Status Update. | |
|
|
72 | <br/>$v->percentage% complete. | |
|
|
73 | <br/>Next comic should be posted at: $d. ($dd hours)]]>"; | |
|
|
74 | $s[$k]->date = date( DATE_RFC822, $v->udate ); | |
|
|
75 | $s[$k]->guid = $s[$k]->link; | |
|
|
76 | } | |
|
|
77 | $f_items = array_merge( $f_items, $s ); | |
|
|
78 | }*/ | |
|
|
79 | ||
|
|
80 | if( $type == 'strips' or $type == '') { | |
|
|
81 | $f_title = 'Megatokyo Comics'; | |
|
|
82 | $s = _query("SELECT DISTINCT s.id, UNIX_TIMESTAMP(s.published) as udate, t.description as chapdesc, t.name as chapname, s.title | |
|
|
83 | FROM media_t media, strip s, strip_t t | |
|
|
84 | WHERE s.media = media.id AND s.published < NOW() | |
|
|
85 | AND s.type = t.id | |
|
|
86 | ORDER BY s.id DESC LIMIT 5") or die(mysqli_error($link)); | |
|
|
87 | foreach($s as $k=>$v) { | |
|
|
88 | $s[$k]->link = SITE_HOST . SITE_PATH . "/strip/$v->id"; | |
|
|
89 | #$s[$k]->title = "Comic [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"'; | |
|
|
90 | $s[$k]->title = "Comic [$v->id] \"" . numeric_entities(utfentities($v->title)) . '"'; | |
|
|
91 | $s[$k]->desc = "<![CDATA[$v->chapdesc comic $v->id | |
|
|
92 | <br/>[<a href=\"http://www.megatokyo.com/\">read...</a>] | |
|
|
93 | <br/>[<a href=\"" . $s[$k]->link . "\">permalink</a>] | |
|
|
94 | ]]>"; | |
|
|
95 | $s[$k]->date = date( DATE_RFC822, $v->udate ); | |
|
|
96 | $s[$k]->guid = $s[$k]->link; | |
|
|
97 | } | |
|
|
98 | $f_items = array_merge( $f_items, $s ); | |
|
|
99 | } | |
|
|
100 | ||
|
|
101 | if( $type == 'rants' or $type == '' ) { | |
|
|
102 | $f_title = 'Megatokyo Rants'; | |
|
|
103 | $contributers = _query("SELECT * FROM contributor", true); | |
|
|
104 | $s = _query("SELECT r.id, r.body as body, UNIX_TIMESTAMP(r.published) as udate, r.author as authorno, r.title | |
|
|
105 | FROM rant r | |
|
|
106 | WHERE r.published < NOW() | |
|
|
107 | AND r.status = 'published' | |
|
|
108 | ORDER BY udate DESC LIMIT 5"); | |
|
|
109 | foreach($s as $k=>$v) { | |
|
|
110 | $s[$k]->link = SITE_HOST . SITE_PATH . "/rant/$v->id"; | |
|
|
111 | $s[$k]->author = utfentities( $contributers[$v->authorno]->name, ENT_COMPAT, ini_get('default_charset') ); | |
|
|
112 | $s[$k]->title = "Rant [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"'; | |
|
|
113 | $s[$k]->desc = "<![CDATA[" . Excerpt($v->body) . "<p>[<a href=\"" . $s[$k]->link . "\">permalink</a>]</p>]]>"; | |
|
|
114 | $s[$k]->date = date( DATE_RFC822, $v->udate ); | |
|
|
115 | $s[$k]->guid = $s[$k]->link; | |
|
|
116 | } | |
|
|
117 | $f_items = array_merge( $f_items, $s ); | |
|
|
118 | } | |
|
|
119 | ||
|
|
120 | if( $type == '' ) | |
|
|
121 | { | |
|
|
122 | $f_title = 'Megatokyo Comics and News'; | |
|
|
123 | $s = _query("SELECT UNIX_TIMESTAMP(published) as udate, body, url FROM rss_comment ORDER BY published DESC LIMIT 5"); | |
|
|
124 | ||
|
|
125 | foreach($s as $k=>$v) | |
|
|
126 | { | |
|
|
127 | $s[$k]->link = $v->url; | |
|
|
128 | $s[$k]->title = $v->body; | |
|
|
129 | $s[$k]->date = date( DATE_RFC822, $v->udate ); | |
|
|
130 | $s[$k]->guid = $s[$k]->date; | |
|
|
131 | $s[$k]->desc = ''; | |
|
|
132 | } | |
|
|
133 | $f_items = array_merge( $f_items, $s ); | |
|
|
134 | } | |
|
|
135 | ||
|
|
136 | usort( $f_items, 'datesort' ); | |
|
|
137 | ||
|
|
138 | $f_date = $f_items[0]->date; | |
|
|
139 | ||
|
|
140 | $rfc1123_date = gmdate( 'D, d M Y H:i:s ', $f_items[0]->udate ) . 'GMT'; | |
|
|
141 | $etag = md5( $rfc1123_date ); | |
|
|
142 | ||
|
|
143 | /* Conditional Get */ | |
|
|
144 | header( "Last-Modified: $rfc1123_date" ); | |
|
|
145 | header( "ETag: \"$etag\""); | |
|
|
146 | ||
|
|
147 | if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $rfc1123_date ) { | |
|
|
148 | header('HTTP/1.0 304 Not Modified'); | |
|
|
149 | exit; | |
|
|
150 | } | |
|
|
151 | if( isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag ) { | |
|
|
152 | header('HTTP/1.0 304 Not Modified'); | |
|
|
153 | exit; | |
|
|
154 | } | |
|
|
155 | ||
|
|
156 | header("XX-Powered-By: Nikuman"); | |
|
|
157 | header("Content-Type: application/rss+xml;charset=utf-8"); | |
|
|
158 | ||
|
|
159 | echo '<?xml version="1.0" encoding="utf-8"?>', "\n"; | |
|
|
160 | ?> | |
|
|
161 | <rss version="2.0"> | |
|
|
162 | <channel> | |
|
|
163 | <title><?php echo $f_title; ?></title> | |
|
|
164 | <link>http://www.megatokyo.com</link> | |
|
|
165 | <description><?php echo $f_desc; ?></description> | |
|
|
166 | <language>en-us</language> | |
|
|
167 | <copyright>Fred Gallagher</copyright> | |
|
|
168 | <managingEditor>piro@megatokyo.com</managingEditor> | |
|
|
169 | <pubDate><?php echo $f_date; ?></pubDate> | |
|
|
170 | <lastBuildDate><?php echo $f_date; ?></lastBuildDate> | |
|
|
171 | <ttl>15</ttl> | |
|
|
172 | ||
|
|
173 | <?php if( count( $f_items )) foreach( $f_items as $v ): ?> | |
|
|
174 | <item> | |
|
|
175 | <title><?php echo $v->title; ?></title> | |
|
|
176 | <link><?php echo $v->link; ?></link> | |
|
|
177 | <description><?php echo $v->desc; ?></description> | |
|
|
178 | <guid><?php echo $v->guid; ?></guid> | |
|
|
179 | <pubDate><?php echo $v->date; ?></pubDate> | |
|
|
180 | </item> | |
|
|
181 | <?php endforeach; ?> | |
|
|
182 | </channel> | |
|
|
183 | </rss> | |
| @@ -0,0 +1,188 | |||
|
|
1 | <?php | |
|
|
2 | ||
|
|
3 | require_once('../LocalSettings.php'); | |
|
|
4 | ||
|
|
5 | /* Get the database working */ | |
|
|
6 | $link = mysqli_connect(DB_SERVER, DB_READ_USER, DB_READ_PASS, DB_NAME) or trigger_error('Problem connecting to the SQL database server: '.mysqli_error($link), E_USER_ERROR); | |
|
|
7 | ||
|
|
8 | function numeric_entities($string){ | |
|
|
9 | $mapping = array(); | |
|
|
10 | foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity){ | |
|
|
11 | $mapping[$entity] = '&#' . ord($char) . ';'; | |
|
|
12 | } | |
|
|
13 | return str_replace(array_keys($mapping), $mapping, $string); | |
|
|
14 | } | |
|
|
15 | ||
|
|
16 | function Excerpt( $excerpt ) { | |
|
|
17 | $excerpt = strip_tags( $excerpt ); | |
|
|
18 | if (strlen($excerpt) > 455) { | |
|
|
19 | $excerpt = substr($excerpt,0,452) . '...'; | |
|
|
20 | } | |
|
|
21 | return $excerpt; | |
|
|
22 | } | |
|
|
23 | ||
|
|
24 | function datesort( $a , $b ) { | |
|
|
25 | if( $a->udate == $b->udate ) return 0; | |
|
|
26 | return( $a->udate > $b->udate ) ? -1 : 1; | |
|
|
27 | } | |
|
|
28 | ||
|
|
29 | function utfentities($string) | |
|
|
30 | { | |
|
|
31 | return htmlentities($string, ENT_COMPAT, 'UTF-8'); | |
|
|
32 | } | |
|
|
33 | ||
|
|
34 | function _query( $s, $byid = false ) { | |
|
|
35 | global $link; | |
|
|
36 | $r = mysqli_query($link, $s ) or die( mysqli_error($link) ); | |
|
|
37 | $ret=array(); | |
|
|
38 | $i=0; | |
|
|
39 | ||
|
|
40 | if( $byid ) { | |
|
|
41 | while ($row = mysqli_fetch_object($r) ) | |
|
|
42 | $ret[$row->id] = $row; | |
|
|
43 | } else { | |
|
|
44 | while ($row = mysqli_fetch_object($r) ) | |
|
|
45 | $ret[$i++] = $row; | |
|
|
46 | } | |
|
|
47 | return $ret; | |
|
|
48 | } | |
|
|
49 | ||
|
|
50 | @$f_title = $type = $_GET['type']; | |
|
|
51 | ||
|
|
52 | $f_items = array(); | |
|
|
53 | $f_desc = 'News and Comics from Megatokyo.'; | |
|
|
54 | ||
|
|
55 | /*if( $type == 'status' or $type == '') { | |
|
|
56 | // Status Box Updates | |
|
|
57 | $f_title = 'Megatokyo Status Updates'; | |
|
|
58 | $s = _query( "SELECT MAX(id)+1 as m FROM strip" ); // Permalinks to strips? | |
|
|
59 | ||
|
|
60 | $s = _query( "SELECT DISTINCT SUBTIME( published, eta ) as dd, UNIX_TIMESTAMP(published) as udate, text, UNIX_TIMESTAMP(eta) as eta, percentage | |
|
|
61 | FROM status s | |
|
|
62 | ORDER BY udate DESC | |
|
|
63 | LIMIT 5"); | |
|
|
64 | foreach( $s as $k=>$v ) { | |
|
|
65 | $s[$k]->link = 'http://www.megatokyo.com/'; | |
|
|
66 | $s[$k]->title = "Update: $v->percentage%: " . htmlentities($v->text, ENT_COMPAT, ini_get('default_charset')); | |
|
|
67 | ||
|
|
68 | $d = date( 'l F jS, H:i', $v->eta ); | |
|
|
69 | $dd = (int) (( $v->eta - $v->udate )/3600); | |
|
|
70 | ||
|
|
71 | $s[$k]->desc = "<![CDATA[Status Update. | |
|
|
72 | <br/>$v->percentage% complete. | |
|
|
73 | <br/>Next comic should be posted at: $d. ($dd hours)]]>"; | |
|
|
74 | $s[$k]->date = date( DATE_RFC822, $v->udate ); | |
|
|
75 | $s[$k]->guid = $s[$k]->link; | |
|
|
76 | } | |
|
|
77 | $f_items = array_merge( $f_items, $s ); | |
|
|
78 | }*/ | |
|
|
79 | ||
|
|
80 | if( $type == 'strips' or $type == '') { | |
|
|
81 | $f_title = 'Megatokyo Comics'; | |
|
|
82 | $s = _query("SELECT DISTINCT s.id, UNIX_TIMESTAMP(s.published) as udate, t.description as chapdesc, t.name as chapname, s.title | |
|
|
83 | FROM media_t media, strip s, strip_t t | |
|
|
84 | WHERE s.media = media.id AND s.published < NOW() | |
|
|
85 | AND s.type = t.id | |
|
|
86 | ORDER BY s.id DESC LIMIT 5") or die(mysqli_error($link)); | |
|
|
87 | foreach($s as $k=>$v) { | |
|
|
88 | $s[$k]->link = SITE_HOST . SITE_PATH . "/strip/$v->id"; | |
|
|
89 | #$s[$k]->title = "Comic [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"'; | |
|
|
90 | $s[$k]->title = "Comic [$v->id] \"" . numeric_entities(utfentities($v->title)) . '"'; | |
|
|
91 | $s[$k]->desc = "<![CDATA[$v->chapdesc comic $v->id | |
|
|
92 | <br/>[<a href=\"http://www.megatokyo.com/\">read...</a>] | |
|
|
93 | <br/>[<a href=\"" . $s[$k]->link . "\">permalink</a>] | |
|
|
94 | ]]>"; | |
|
|
95 | $s[$k]->date = date( DATE_RSS, $v->udate ); | |
|
|
96 | $s[$k]->guid = $s[$k]->link; | |
|
|
97 | $s[$k]->perm = 'true'; | |
|
|
98 | } | |
|
|
99 | $f_items = array_merge( $f_items, $s ); | |
|
|
100 | } | |
|
|
101 | ||
|
|
102 | if( $type == 'rants' or $type == '' ) { | |
|
|
103 | $f_title = 'Megatokyo Rants'; | |
|
|
104 | $contributers = _query("SELECT * FROM contributor", true); | |
|
|
105 | $s = _query("SELECT r.id, r.body as body, UNIX_TIMESTAMP(r.published) as udate, r.author as authorno, r.title | |
|
|
106 | FROM rant r | |
|
|
107 | WHERE r.published < NOW() | |
|
|
108 | AND r.status = 'published' | |
|
|
109 | ORDER BY udate DESC LIMIT 5"); | |
|
|
110 | foreach($s as $k=>$v) { | |
|
|
111 | $s[$k]->link = SITE_HOST . SITE_PATH . "/rant/$v->id"; | |
|
|
112 | $s[$k]->author = utfentities( $contributers[$v->authorno]->name, ENT_COMPAT, ini_get('default_charset') ); | |
|
|
113 | $s[$k]->title = "Rant [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"'; | |
|
|
114 | $s[$k]->desc = "<![CDATA[" . Excerpt($v->body) . "<p>[<a href=\"" . $s[$k]->link . "\">permalink</a>]</p>]]>"; | |
|
|
115 | $s[$k]->date = date( DATE_RSS, $v->udate ); | |
|
|
116 | $s[$k]->guid = $s[$k]->link; | |
|
|
117 | $s[$k]->perm = 'true'; | |
|
|
118 | } | |
|
|
119 | $f_items = array_merge( $f_items, $s ); | |
|
|
120 | } | |
|
|
121 | ||
|
|
122 | if( $type == '' ) | |
|
|
123 | { | |
|
|
124 | $f_title = 'Megatokyo Comics and News'; | |
|
|
125 | $s = _query("SELECT UNIX_TIMESTAMP(published) as udate, body, url FROM rss_comment ORDER BY published DESC LIMIT 5"); | |
|
|
126 | ||
|
|
127 | foreach($s as $k=>$v) | |
|
|
128 | { | |
|
|
129 | $s[$k]->link = $v->url; | |
|
|
130 | $s[$k]->title = $v->body; | |
|
|
131 | $s[$k]->date = date( DATE_RSS, $v->udate ); | |
|
|
132 | $s[$k]->guid = date( DATE_W3C, $s[$k]->udate); | |
|
|
133 | $s[$k]->desc = ''; | |
|
|
134 | $s[$k]->perm = 'false'; | |
|
|
135 | } | |
|
|
136 | $f_items = array_merge( $f_items, $s ); | |
|
|
137 | } | |
|
|
138 | ||
|
|
139 | usort( $f_items, 'datesort' ); | |
|
|
140 | ||
|
|
141 | $f_date = $f_items[0]->date; | |
|
|
142 | ||
|
|
143 | $rfc1123_date = gmdate( 'D, d M Y H:i:s ', $f_items[0]->udate ) . 'GMT'; | |
|
|
144 | $etag = md5( $rfc1123_date ); | |
|
|
145 | ||
|
|
146 | /* Conditional Get */ | |
|
|
147 | header( "Last-Modified: $rfc1123_date" ); | |
|
|
148 | header( "ETag: \"$etag\""); | |
|
|
149 | ||
|
|
150 | if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $rfc1123_date ) { | |
|
|
151 | header('HTTP/1.0 304 Not Modified'); | |
|
|
152 | exit; | |
|
|
153 | } | |
|
|
154 | if( isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag ) { | |
|
|
155 | header('HTTP/1.0 304 Not Modified'); | |
|
|
156 | exit; | |
|
|
157 | } | |
|
|
158 | ||
|
|
159 | header("XX-Powered-By: Nikuman"); | |
|
|
160 | header("Content-Type: application/rss+xml;charset=utf-8"); | |
|
|
161 | ||
|
|
162 | echo '<?xml version="1.0" encoding="utf-8"?>', "\n"; | |
|
|
163 | ?> | |
|
|
164 | <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | |
|
|
165 | <channel> | |
|
|
166 | <title><?php echo $f_title; ?></title> | |
|
|
167 | <link>http://www.megatokyo.com</link> | |
|
|
168 | <atom:link href="<?php echo SITE_HOST . $_SERVER['REQUEST_URI'] ?>" rel="self" type="application/rss+xml" /> | |
|
|
169 | <description><?php echo $f_desc; ?></description> | |
|
|
170 | <language>en-us</language> | |
|
|
171 | <copyright>Fred Gallagher</copyright> | |
|
|
172 | <managingEditor>piro@megatokyo.com (Fred Gallagher)</managingEditor> | |
|
|
173 | <pubDate><?php echo $f_date; ?></pubDate> | |
|
|
174 | <lastBuildDate><?php echo $f_date; ?></lastBuildDate> | |
|
|
175 | <ttl>15</ttl> | |
|
|
176 | ||
|
|
177 | <?php if( count( $f_items )) foreach( $f_items as $v ): ?> | |
|
|
178 | <item> | |
|
|
179 | <title><?php echo $v->title; ?></title> | |
|
|
180 | <link><?php echo $v->link; ?></link> | |
|
|
181 | <description><?php echo $v->desc; ?></description> | |
|
|
182 | <guid isPermaLink="<?php echo $v->perm; ?>"><?php echo $v->guid; ?></guid> | |
|
|
183 | <pubDate><?php echo $v->date; ?></pubDate> | |
|
|
184 | </item> | |
|
|
185 | <?php endforeach; ?> | |
|
|
186 | </channel> | |
|
|
187 | </rss> | |
|
|
188 | ||
|
|
1 | NO CONTENT: new file 100644, binary diff hidden |
Comments 0
You need to be logged in to leave comments.
Login now
