diff --git a/rss/rss.old.php b/rss/rss.old.php
deleted file mode 100644
index 61cbeb9..0000000
--- a/rss/rss.old.php
+++ /dev/null
@@ -1,183 +0,0 @@
- $entity){
- $mapping[$entity] = '' . ord($char) . ';';
- }
- return str_replace(array_keys($mapping), $mapping, $string);
-}
-
-function Excerpt( $excerpt ) {
- $excerpt = strip_tags( $excerpt );
- if (strlen($excerpt) > 455) {
- $excerpt = substr($excerpt,0,452) . '...';
- }
- return $excerpt;
-}
-
-function datesort( $a , $b ) {
- if( $a->udate == $b->udate ) return 0;
- return( $a->udate > $b->udate ) ? -1 : 1;
-}
-
-function utfentities($string)
-{
- return htmlentities($string, ENT_COMPAT, 'UTF-8');
-}
-
-function _query( $s, $byid = false ) {
- global $link;
- $r = mysqli_query($link, $s ) or die( mysqli_error($link) );
- $ret=array();
- $i=0;
-
- if( $byid ) {
- while ($row = mysqli_fetch_object($r) )
- $ret[$row->id] = $row;
- } else {
- while ($row = mysqli_fetch_object($r) )
- $ret[$i++] = $row;
- }
- return $ret;
-}
-
-@$f_title = $type = $_GET['type'];
-
-$f_items = array();
-$f_desc = 'News and Comics from Megatokyo.';
-
-/*if( $type == 'status' or $type == '') {
- // Status Box Updates
- $f_title = 'Megatokyo Status Updates';
- $s = _query( "SELECT MAX(id)+1 as m FROM strip" ); // Permalinks to strips?
-
- $s = _query( "SELECT DISTINCT SUBTIME( published, eta ) as dd, UNIX_TIMESTAMP(published) as udate, text, UNIX_TIMESTAMP(eta) as eta, percentage
- FROM status s
- ORDER BY udate DESC
- LIMIT 5");
- foreach( $s as $k=>$v ) {
- $s[$k]->link = 'http://www.megatokyo.com/';
- $s[$k]->title = "Update: $v->percentage%: " . htmlentities($v->text, ENT_COMPAT, ini_get('default_charset'));
-
- $d = date( 'l F jS, H:i', $v->eta );
- $dd = (int) (( $v->eta - $v->udate )/3600);
-
- $s[$k]->desc = "$v->percentage% complete.
-
Next comic should be posted at: $d. ($dd hours)]]>";
- $s[$k]->date = date( DATE_RFC822, $v->udate );
- $s[$k]->guid = $s[$k]->link;
- }
- $f_items = array_merge( $f_items, $s );
-}*/
-
-if( $type == 'strips' or $type == '') {
- $f_title = 'Megatokyo Comics';
- $s = _query("SELECT DISTINCT s.id, UNIX_TIMESTAMP(s.published) as udate, t.description as chapdesc, t.name as chapname, s.title
- FROM media_t media, strip s, strip_t t
- WHERE s.media = media.id AND s.published < NOW()
- AND s.type = t.id
- ORDER BY s.id DESC LIMIT 5") or die(mysqli_error($link));
- foreach($s as $k=>$v) {
- $s[$k]->link = SITE_HOST . SITE_PATH . "/strip/$v->id";
- #$s[$k]->title = "Comic [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"';
- $s[$k]->title = "Comic [$v->id] \"" . numeric_entities(utfentities($v->title)) . '"';
- $s[$k]->desc = "chapdesc comic $v->id
-
[read...]
-
[link . "\">permalink]
- ]]>";
- $s[$k]->date = date( DATE_RFC822, $v->udate );
- $s[$k]->guid = $s[$k]->link;
- }
- $f_items = array_merge( $f_items, $s );
-}
-
-if( $type == 'rants' or $type == '' ) {
- $f_title = 'Megatokyo Rants';
- $contributers = _query("SELECT * FROM contributor", true);
- $s = _query("SELECT r.id, r.body as body, UNIX_TIMESTAMP(r.published) as udate, r.author as authorno, r.title
- FROM rant r
- WHERE r.published < NOW()
- AND r.status = 'published'
- ORDER BY udate DESC LIMIT 5");
- foreach($s as $k=>$v) {
- $s[$k]->link = SITE_HOST . SITE_PATH . "/rant/$v->id";
- $s[$k]->author = utfentities( $contributers[$v->authorno]->name, ENT_COMPAT, ini_get('default_charset') );
- $s[$k]->title = "Rant [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"';
- $s[$k]->desc = "body) . "
[link . "\">permalink]
]]>";
- $s[$k]->date = date( DATE_RFC822, $v->udate );
- $s[$k]->guid = $s[$k]->link;
- }
- $f_items = array_merge( $f_items, $s );
-}
-
-if( $type == '' )
-{
- $f_title = 'Megatokyo Comics and News';
- $s = _query("SELECT UNIX_TIMESTAMP(published) as udate, body, url FROM rss_comment ORDER BY published DESC LIMIT 5");
-
- foreach($s as $k=>$v)
- {
- $s[$k]->link = $v->url;
- $s[$k]->title = $v->body;
- $s[$k]->date = date( DATE_RFC822, $v->udate );
- $s[$k]->guid = $s[$k]->date;
- $s[$k]->desc = '';
- }
- $f_items = array_merge( $f_items, $s );
-}
-
-usort( $f_items, 'datesort' );
-
-$f_date = $f_items[0]->date;
-
-$rfc1123_date = gmdate( 'D, d M Y H:i:s ', $f_items[0]->udate ) . 'GMT';
-$etag = md5( $rfc1123_date );
-
-/* Conditional Get */
-header( "Last-Modified: $rfc1123_date" );
-header( "ETag: \"$etag\"");
-
-if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $rfc1123_date ) {
- header('HTTP/1.0 304 Not Modified');
- exit;
-}
-if( isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag ) {
- header('HTTP/1.0 304 Not Modified');
- exit;
-}
-
-header("XX-Powered-By: Nikuman");
-header("Content-Type: application/rss+xml;charset=utf-8");
-
-echo '', "\n";
-?>
-
-
-
- http://www.megatokyo.com
-
- en-us
- Fred Gallagher
- piro@megatokyo.com
-
-
- 15
-
-
- -
- title; ?>
- link; ?>
- desc; ?>
- guid; ?>
- date; ?>
-
-
-
-
diff --git a/rss/rss.php b/rss/rss.php
index da37320..201f084 100644
--- a/rss/rss.php
+++ b/rss/rss.php
@@ -3,47 +3,66 @@
require_once('../LocalSettings.php');
/* Get the database working */
-$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);
+$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);
-function numeric_entities($string){
+function numeric_entities($string)
+{
$mapping = array();
- foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity){
+ foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity)
+ {
$mapping[$entity] = '' . ord($char) . ';';
}
return str_replace(array_keys($mapping), $mapping, $string);
}
-function Excerpt( $excerpt ) {
- $excerpt = strip_tags( $excerpt );
- if (strlen($excerpt) > 455) {
- $excerpt = substr($excerpt,0,452) . '...';
+function Excerpt($excerpt)
+{
+ $excerpt = strip_tags($excerpt);
+ if (strlen($excerpt) > 455)
+ {
+ $excerpt = substr($excerpt, 0, 452) . '...';
}
return $excerpt;
}
-function datesort( $a , $b ) {
- if( $a->udate == $b->udate ) return 0;
- return( $a->udate > $b->udate ) ? -1 : 1;
+function datesort($a, $b)
+{
+ if ($a->udate == $b->udate)
+ {
+ return 0;
+ }
+
+ return ($a->udate > $b->udate) ? -1 : 1;
}
function utfentities($string)
{
- return htmlentities($string, ENT_COMPAT, 'UTF-8');
+ return htmlentities($string, ENT_COMPAT | ENT_XML1);
}
-function _query( $s, $byid = false ) {
+function _query($s, $byid = false)
+{
global $link;
- $r = mysqli_query($link, $s ) or die( mysqli_error($link) );
- $ret=array();
- $i=0;
+ $r = mysqli_query($link, $s) or die(mysqli_error($link));
+ $ret = array();
+ $i = 0;
- if( $byid ) {
- while ($row = mysqli_fetch_object($r) )
+ if ($byid)
+ {
+ while ($row = mysqli_fetch_object($r))
+ {
$ret[$row->id] = $row;
- } else {
- while ($row = mysqli_fetch_object($r) )
+ }
+ }
+ else
+ {
+ while ($row = mysqli_fetch_object($r))
+ {
$ret[$i++] = $row;
+ }
}
+
return $ret;
}
@@ -77,54 +96,66 @@ $f_desc = 'News and Comics from Megatokyo.';
$f_items = array_merge( $f_items, $s );
}*/
-if( $type == 'strips' or $type == '') {
+if ($type == 'strips' or $type == '')
+{
$f_title = 'Megatokyo Comics';
- $s = _query("SELECT DISTINCT s.id, UNIX_TIMESTAMP(s.published) as udate, t.description as chapdesc, t.name as chapname, s.title
- FROM media_t media, strip s, strip_t t
- WHERE s.media = media.id AND s.published < NOW()
- AND s.type = t.id
- ORDER BY s.id DESC LIMIT 5") or die(mysqli_error($link));
- foreach($s as $k=>$v) {
+
+ $comic_query = 'SELECT s.id, UNIX_TIMESTAMP(s.published) as udate, t.description as chapdesc, t.name as chapname, s.title
+ FROM strip s JOIN strip_t t ON s.type = t.id
+ WHERE s.published <= NOW()
+ ORDER BY s.id DESC LIMIT 5';
+
+ $s = _query($comic_query) or die(mysqli_error($link));
+
+ foreach($s as $k => $v)
+ {
$s[$k]->link = SITE_HOST . SITE_PATH . "/strip/$v->id";
- #$s[$k]->title = "Comic [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"';
- $s[$k]->title = "Comic [$v->id] \"" . numeric_entities(utfentities($v->title)) . '"';
+ $s[$k]->title = "Comic [$v->id] \"" . utfentities($v->title) . '"';
$s[$k]->desc = "chapdesc comic $v->id
-
[read...]
-
[link . "\">permalink]
+
[read...]
+
[link . "\">permalink]
]]>";
- $s[$k]->date = date( DATE_RSS, $v->udate );
+ $s[$k]->date = date(DATE_RSS, $v->udate);
$s[$k]->guid = $s[$k]->link;
$s[$k]->perm = 'true';
}
- $f_items = array_merge( $f_items, $s );
+
+ $f_items = array_merge($f_items, $s);
}
-if( $type == 'rants' or $type == '' ) {
+if ($type == 'rants' or $type == '')
+{
$f_title = 'Megatokyo Rants';
- $contributers = _query("SELECT * FROM contributor", true);
- $s = _query("SELECT r.id, r.body as body, UNIX_TIMESTAMP(r.published) as udate, r.author as authorno, r.title
- FROM rant r
- WHERE r.published < NOW()
- AND r.status = 'published'
- ORDER BY udate DESC LIMIT 5");
- foreach($s as $k=>$v) {
+
+ $rant_query = 'SELECT r.id, r.body, UNIX_TIMESTAMP(r.published) as udate, c.name, r.title
+ FROM rant r JOIN contributor c ON r.author = c.id
+ WHERE r.published <= NOW() AND r.status = "published"
+ ORDER BY r.published DESC LIMIT 5';
+
+ $s = _query($rant_query) or die(mysqli_error($link));
+
+ foreach($s as $k => $v)
+ {
$s[$k]->link = SITE_HOST . SITE_PATH . "/rant/$v->id";
- $s[$k]->author = utfentities( $contributers[$v->authorno]->name, ENT_COMPAT, ini_get('default_charset') );
- $s[$k]->title = "Rant [$v->id] \"" . utfentities($v->title, ENT_COMPAT, ini_get('default_charset')) . '"';
+ $s[$k]->author = utfentities($v->name);
+ $s[$k]->title = "Rant [$v->id] \"" . utfentities($v->title) . '"';
$s[$k]->desc = "body) . "[link . "\">permalink]
]]>";
- $s[$k]->date = date( DATE_RSS, $v->udate );
+ $s[$k]->date = date(DATE_RSS, $v->udate);
$s[$k]->guid = $s[$k]->link;
$s[$k]->perm = 'true';
}
- $f_items = array_merge( $f_items, $s );
+
+ $f_items = array_merge($f_items, $s);
}
-if( $type == '' )
+if ($type == '')
{
$f_title = 'Megatokyo Comics and News';
+
+ /*
$s = _query("SELECT UNIX_TIMESTAMP(published) as udate, body, url FROM rss_comment ORDER BY published DESC LIMIT 5");
- foreach($s as $k=>$v)
+ foreach($s as $k => $v)
{
$s[$k]->link = $v->url;
$s[$k]->title = $v->body;
@@ -133,48 +164,53 @@ if( $type == '' )
$s[$k]->desc = '';
$s[$k]->perm = 'false';
}
+
$f_items = array_merge( $f_items, $s );
+ */
}
-usort( $f_items, 'datesort' );
+usort($f_items, 'datesort');
$f_date = $f_items[0]->date;
-$rfc1123_date = gmdate( 'D, d M Y H:i:s ', $f_items[0]->udate ) . 'GMT';
-$etag = md5( $rfc1123_date );
+$rfc1123_date = gmdate('D, d M Y H:i:s T', $f_items[0]->udate);
+$etag = md5($rfc1123_date);
/* Conditional Get */
-header( "Last-Modified: $rfc1123_date" );
-header( "ETag: \"$etag\"");
+header("Last-Modified: $rfc1123_date");
+header("ETag: \"$etag\"");
-if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $rfc1123_date ) {
+if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $rfc1123_date)
+{
header('HTTP/1.0 304 Not Modified');
exit;
}
-if( isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag ) {
+
+if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag)
+{
header('HTTP/1.0 304 Not Modified');
exit;
}
header("XX-Powered-By: Nikuman");
-header("Content-Type: application/rss+xml;charset=utf-8");
+header("Content-Type: application/rss+xml; charset=utf-8");
echo '', "\n";
?>
-
+
- http://www.megatokyo.com
-
+ https://megatokyo.com
- en-us
+ en-US
Fred Gallagher
piro@megatokyo.com (Fred Gallagher)
+ http://cyber.harvard.edu/rss/rss.html
15
-
+
-
title; ?>
link; ?>
@@ -182,6 +218,6 @@ echo '', "\n";
guid; ?>
date; ?>
-
+