-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the RSS reader and made it PHP 5.3 compatibile by changing a …
…split() to explode()
- Loading branch information
Showing
10 changed files
with
2,493 additions
and
2,493 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
<?php | ||
/* | ||
* Project: MagpieRSS: a simple RSS integration tool | ||
* File: rss_utils.inc, utility methods for working with RSS | ||
* Author: Kellan Elliott-McCrea <kellan@protest.net> | ||
* Version: 0.51 | ||
* License: GPL | ||
* | ||
* The lastest version of MagpieRSS can be obtained from: | ||
* http://magpierss.sourceforge.net | ||
* | ||
* For questions, help, comments, discussion, etc., please join the | ||
* Magpie mailing list: | ||
* magpierss-general@lists.sourceforge.net | ||
*/ | ||
|
||
|
||
/*======================================================================*\ | ||
Function: parse_w3cdtf | ||
Purpose: parse a W3CDTF date into unix epoch | ||
NOTE: http://www.w3.org/TR/NOTE-datetime | ||
\*======================================================================*/ | ||
|
||
function parse_w3cdtf ( $date_str ) { | ||
|
||
# regex to match wc3dtf | ||
$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; | ||
|
||
if ( preg_match( $pat, $date_str, $match ) ) { | ||
list( $year, $month, $day, $hours, $minutes, $seconds) = | ||
array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); | ||
|
||
# calc epoch for current date assuming GMT | ||
$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); | ||
|
||
$offset = 0; | ||
if ( $match[10] == 'Z' ) { | ||
# zulu time, aka GMT | ||
} | ||
else { | ||
list( $tz_mod, $tz_hour, $tz_min ) = | ||
array( $match[8], $match[9], $match[10]); | ||
|
||
# zero out the variables | ||
if ( ! $tz_hour ) { $tz_hour = 0; } | ||
if ( ! $tz_min ) { $tz_min = 0; } | ||
|
||
$offset_secs = (($tz_hour*60)+$tz_min)*60; | ||
|
||
# is timezone ahead of GMT? then subtract offset | ||
# | ||
if ( $tz_mod == '+' ) { | ||
$offset_secs = $offset_secs * -1; | ||
} | ||
|
||
$offset = $offset_secs; | ||
} | ||
$epoch = $epoch + $offset; | ||
return $epoch; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
|
||
?> | ||
<?php | ||
/* | ||
* Project: MagpieRSS: a simple RSS integration tool | ||
* File: rss_utils.inc, utility methods for working with RSS | ||
* Author: Kellan Elliott-McCrea <kellan@protest.net> | ||
* Version: 0.51 | ||
* License: GPL | ||
* | ||
* The lastest version of MagpieRSS can be obtained from: | ||
* http://magpierss.sourceforge.net | ||
* | ||
* For questions, help, comments, discussion, etc., please join the | ||
* Magpie mailing list: | ||
* magpierss-general@lists.sourceforge.net | ||
*/ | ||
|
||
|
||
/*======================================================================*\ | ||
Function: parse_w3cdtf | ||
Purpose: parse a W3CDTF date into unix epoch | ||
NOTE: http://www.w3.org/TR/NOTE-datetime | ||
\*======================================================================*/ | ||
|
||
function parse_w3cdtf ( $date_str ) { | ||
|
||
# regex to match wc3dtf | ||
$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; | ||
|
||
if ( preg_match( $pat, $date_str, $match ) ) { | ||
list( $year, $month, $day, $hours, $minutes, $seconds) = | ||
array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); | ||
|
||
# calc epoch for current date assuming GMT | ||
$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); | ||
|
||
$offset = 0; | ||
if ( $match[10] == 'Z' ) { | ||
# zulu time, aka GMT | ||
} | ||
else { | ||
list( $tz_mod, $tz_hour, $tz_min ) = | ||
array( $match[8], $match[9], $match[10]); | ||
|
||
# zero out the variables | ||
if ( ! $tz_hour ) { $tz_hour = 0; } | ||
if ( ! $tz_min ) { $tz_min = 0; } | ||
|
||
$offset_secs = (($tz_hour*60)+$tz_min)*60; | ||
|
||
# is timezone ahead of GMT? then subtract offset | ||
# | ||
if ( $tz_mod == '+' ) { | ||
$offset_secs = $offset_secs * -1; | ||
} | ||
|
||
$offset = $offset_secs; | ||
} | ||
$epoch = $epoch + $offset; | ||
return $epoch; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,80 @@ | ||
<?php | ||
|
||
ini_set('display_errors', 1); | ||
ini_set('error_reporting', E_ALL); | ||
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); | ||
define('MAGPIE_DIR', '../'); | ||
define('MAGPIE_DEBUG', 1); | ||
|
||
// flush cache quickly for debugging purposes, don't do this on a live site | ||
define('MAGPIE_CACHE_AGE', 10); | ||
|
||
require_once(MAGPIE_DIR.'rss_fetch.inc'); | ||
|
||
|
||
if ( isset($_GET['url']) ) { | ||
$url = $_GET['url']; | ||
} | ||
else { | ||
$url = 'http://magpierss.sf.net/test.rss'; | ||
} | ||
|
||
|
||
test_library_support(); | ||
|
||
$rss = fetch_rss( $url ); | ||
|
||
if ($rss) { | ||
echo "<h3>Example Output</h3>"; | ||
echo "Channel: " . $rss->channel['title'] . "<p>"; | ||
echo "<ul>"; | ||
foreach ($rss->items as $item) { | ||
$href = $item['link']; | ||
$title = $item['title']; | ||
echo "<li><a href=$href>$title</a></li>"; | ||
} | ||
echo "</ul>"; | ||
} | ||
else { | ||
echo "Error: " . magpie_error(); | ||
} | ||
?> | ||
|
||
<form> | ||
RSS URL: <input type="text" size="30" name="url" value="<?php echo $url ?>"><br /> | ||
<input type="submit" value="Parse RSS"> | ||
</form> | ||
|
||
<h3>Parsed Results (var_dump'ed)</h3> | ||
<pre> | ||
<?php var_dump($rss); ?> | ||
</pre> | ||
|
||
<?php | ||
|
||
function test_library_support() { | ||
if (!function_exists('xml_parser_create')) { | ||
echo "<b>Error:</b> PHP compiled without XML support (--with-xml), Mapgie won't work without PHP support for XML.<br />\n"; | ||
exit; | ||
} | ||
else { | ||
echo "<b>OK:</b> Found an XML parser. <br />\n"; | ||
} | ||
|
||
if ( ! function_exists('gzinflate') ) { | ||
echo "<b>Warning:</b> PHP compiled without Zlib support (--with-zlib). No support for GZIP encoding.<br />\n"; | ||
} | ||
else { | ||
echo "<b>OK:</b> Support for GZIP encoding.<br />\n"; | ||
} | ||
|
||
if ( ! (function_exists('iconv') and function_exists('mb_convert_encoding') ) ) { | ||
echo "<b>Warning:</b> No support for iconv (--with-iconv) or multi-byte strings (--enable-mbstring)." . | ||
"No support character set munging.<br />\n"; | ||
} | ||
else { | ||
echo "<b>OK:</b> Support for character munging.<br />\n"; | ||
} | ||
} | ||
|
||
?> | ||
<?php | ||
|
||
ini_set('display_errors', 1); | ||
ini_set('error_reporting', E_ALL); | ||
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); | ||
define('MAGPIE_DIR', '../'); | ||
define('MAGPIE_DEBUG', 1); | ||
|
||
// flush cache quickly for debugging purposes, don't do this on a live site | ||
define('MAGPIE_CACHE_AGE', 10); | ||
|
||
require_once(MAGPIE_DIR.'rss_fetch.inc'); | ||
|
||
|
||
if ( isset($_GET['url']) ) { | ||
$url = $_GET['url']; | ||
} | ||
else { | ||
$url = 'http://magpierss.sf.net/test.rss'; | ||
} | ||
|
||
|
||
test_library_support(); | ||
|
||
$rss = fetch_rss( $url ); | ||
|
||
if ($rss) { | ||
echo "<h3>Example Output</h3>"; | ||
echo "Channel: " . $rss->channel['title'] . "<p>"; | ||
echo "<ul>"; | ||
foreach ($rss->items as $item) { | ||
$href = $item['link']; | ||
$title = $item['title']; | ||
echo "<li><a href=$href>$title</a></li>"; | ||
} | ||
echo "</ul>"; | ||
} | ||
else { | ||
echo "Error: " . magpie_error(); | ||
} | ||
?> | ||
|
||
<form> | ||
RSS URL: <input type="text" size="30" name="url" value="<?php echo $url ?>"><br /> | ||
<input type="submit" value="Parse RSS"> | ||
</form> | ||
|
||
<h3>Parsed Results (var_dump'ed)</h3> | ||
<pre> | ||
<?php var_dump($rss); ?> | ||
</pre> | ||
|
||
<?php | ||
|
||
function test_library_support() { | ||
if (!function_exists('xml_parser_create')) { | ||
echo "<b>Error:</b> PHP compiled without XML support (--with-xml), Mapgie won't work without PHP support for XML.<br />\n"; | ||
exit; | ||
} | ||
else { | ||
echo "<b>OK:</b> Found an XML parser. <br />\n"; | ||
} | ||
|
||
if ( ! function_exists('gzinflate') ) { | ||
echo "<b>Warning:</b> PHP compiled without Zlib support (--with-zlib). No support for GZIP encoding.<br />\n"; | ||
} | ||
else { | ||
echo "<b>OK:</b> Support for GZIP encoding.<br />\n"; | ||
} | ||
|
||
if ( ! (function_exists('iconv') and function_exists('mb_convert_encoding') ) ) { | ||
echo "<b>Warning:</b> No support for iconv (--with-iconv) or multi-byte strings (--enable-mbstring)." . | ||
"No support character set munging.<br />\n"; | ||
} | ||
else { | ||
echo "<b>OK:</b> Support for character munging.<br />\n"; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
<?php | ||
|
||
define('MAGPIE_DIR', '../'); | ||
require_once(MAGPIE_DIR.'rss_fetch.inc'); | ||
|
||
$url = $_GET['url']; | ||
|
||
if ( $url ) { | ||
$rss = fetch_rss( $url ); | ||
echo "Channel: " . $rss->channel['title'] . "<p>"; | ||
echo "<ul>"; | ||
foreach ($rss->items as $item) { | ||
$href = $item['link']; | ||
$title = $item['title']; | ||
echo "<li><a href=$href>$title</a></li>"; | ||
} | ||
echo "</ul>"; | ||
} | ||
?> | ||
|
||
<form> | ||
RSS URL: <input type="text" size="30" name="url" value="<?php echo $url ?>"><br /> | ||
<input type="submit" value="Parse RSS"> | ||
</form> | ||
|
||
<p> | ||
<h2>Security Note:</h2> | ||
This is a simple <b>example</b> script. If this was a <b>real</b> script we probably wouldn't allow strangers to submit random URLs, and we certainly wouldn't simply echo anything passed in the URL. Additionally its a bad idea to leave this example script lying around. | ||
<?php | ||
|
||
define('MAGPIE_DIR', '../'); | ||
require_once(MAGPIE_DIR.'rss_fetch.inc'); | ||
|
||
$url = $_GET['url']; | ||
|
||
if ( $url ) { | ||
$rss = fetch_rss( $url ); | ||
echo "Channel: " . $rss->channel['title'] . "<p>"; | ||
echo "<ul>"; | ||
foreach ($rss->items as $item) { | ||
$href = $item['link']; | ||
$title = $item['title']; | ||
echo "<li><a href=$href>$title</a></li>"; | ||
} | ||
echo "</ul>"; | ||
} | ||
?> | ||
|
||
<form> | ||
RSS URL: <input type="text" size="30" name="url" value="<?php echo $url ?>"><br /> | ||
<input type="submit" value="Parse RSS"> | ||
</form> | ||
|
||
<p> | ||
<h2>Security Note:</h2> | ||
This is a simple <b>example</b> script. If this was a <b>real</b> script we probably wouldn't allow strangers to submit random URLs, and we certainly wouldn't simply echo anything passed in the URL. Additionally its a bad idea to leave this example script lying around. | ||
</p> |
Oops, something went wrong.