Initial commit

This commit is contained in:
Ben Ramey
2017-03-02 20:30:40 -06:00
commit ab3c6fc8d5
10773 changed files with 515124 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
define('MAGPIE_DIR', '..' . DIRECTORY_SEPARATOR);
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";
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
define('MAGPIE_DIR', '..'.DIRECTORY_SEPARATOR);
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>

View File

@@ -0,0 +1,66 @@
<?php
define('MAGPIE_DIR', '..'.DIRECTORY_SEPARATOR);
require_once(MAGPIE_DIR.'rss_fetch.inc');
$url = $_GET['rss_url'];
?>
<html
<body LINK="#999999" VLINK="#000000">
<form>
<input type="text" name="rss_url" size="40" value="<?php echo $url ?>"><input type="Submit">
</form>
<?php
if ( $url ) {
echo "displaying: $url<p>";
$rss = fetch_rss( $url );
echo slashbox ($rss);
}
echo "<pre>";
print_r($rss);
echo "</pre>";
?>
</body>
</html>
<?php
# just some quick and ugly php to generate html
#
#
function slashbox ($rss) {
echo "<table cellpadding=2 cellspacing=0><tr>";
echo "<td bgcolor=#006666>";
# get the channel title and link properties off of the rss object
#
$title = $rss->channel['title'];
$link = $rss->channel['link'];
echo "<a href=$link><font color=#FFFFFF><b>$title</b></font></a>";
echo "</td></tr>";
# foreach over each item in the array.
# displaying simple links
#
# we could be doing all sorts of neat things with the dublin core
# info, or the event info, or what not, but keeping it simple for now.
#
foreach ($rss->items as $item ) {
echo "<tr><td bgcolor=#cccccc>";
echo "<a href=$item[link]>";
echo $item['title'];
echo "</a></td></tr>";
}
echo "</table>";
}
?>

View File

@@ -0,0 +1,58 @@
<?php
// Define path to Smarty files (don't forget trailing slash)
// and load library. (you'll want to change this value)
//
// NOTE: you can also simply add Smarty to your include path
define('SMARTY_DIR', '/home/kellan/projs/magpierss/scripts/Smarty/');
require_once(SMARTY_DIR.'Smarty.class.php');
// define path to Magpie files and load library
// (you'll want to change this value)
//
// NOTE: you can also simple add MagpieRSS to your include path
define('MAGPIE_DIR', '/home/kellan/projs/magpierss/');
require_once(MAGPIE_DIR.'rss_fetch.inc');
require_once(MAGPIE_DIR.'rss_utils.inc');
// optionally show lots of debugging info
# define('MAGPIE_DEBUG', 2);
// optionally flush cache quickly for debugging purposes,
// don't do this on a live site
# define('MAGPIE_CACHE_AGE', 10);
// use cache? default is yes. see rss_fetch for other Magpie options
# define('MAGPIE_CACHE_ON', 1)
// setup template object
$smarty = new Smarty;
$smarty->compile_check = true;
// url of an rss file
$url = $_GET['rss_url'];
if ( $url ) {
// assign a variable to smarty for use in the template
$smarty->assign('rss_url', $url);
// use MagpieRSS to fetch remote RSS file, and parse it
$rss = fetch_rss( $url );
// if fetch_rss returned false, we encountered an error
if ( !$rss ) {
$smarty->assign( 'error', magpie_error() );
}
$smarty->assign('rss', $rss );
$item = $rss->items[0];
$date = parse_w3cdtf( $item['dc']['date'] );
$smarty->assign( 'date', $date );
}
// parse smarty template, and display using the variables we assigned
$smarty->display('simple.smarty');
?>

View File

@@ -0,0 +1,31 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: rss_date_parse
* Purpose: parse rss date into unix epoch
* Input: string: rss date
* default_date: default date if $rss_date is empty
*
* NOTE!!! parse_w3cdtf provided by MagpieRSS's rss_utils.inc
* this file needs to be included somewhere in your script
* -------------------------------------------------------------
*/
function smarty_modifier_rss_date_parse ($rss_date, $default_date=null)
{
if($rss_date != '') {
return parse_w3cdtf( $rss_date );
} elseif (isset($default_date) && $default_date != '') {
return parse_w3cdtf( $default_date );
} else {
return;
}
}
?>

View File

@@ -0,0 +1,46 @@
<html>
<head>
<title>A Simple RSS Box: I'm not a designer</title>
</head>
<body>
<form>
<b>RSS File:</b>
<input type=text" name="rss_url" value="{$rss_url}" size="50">
<input type="submit">
</form>
<b>Displaying:</b> {$rss_url}
<p>
{* if $error display the error
elseif parsed RSS object display the RSS
else solicit user for a URL
*}
{if $error }
<b>Error:</b> {$error}
{elseif $rss}
<table border=1>
<tr>
<th colspan=2>
<a href="{$rss->channel.link}">{$rss->channel.title}</a>
</th>
</tr>
{foreach from=$rss->items item=item}
<tr>
<td>
<a href="{$item.link}">{$item.title}</a>
</td>
<td>
{$item.dc.date|rss_date_parse|date_format:"%A, %B %e, %Y"}
</td>
</tr>
{/foreach}
</table>
{else}
Enter the URL of an RSS file to display.
{/if}
</body>
</html>