Page 1 of 1
Magpierrss: open source, pls help me to solve this error
Posted: Thu Jan 04, 2007 1:00 pm
by red_army
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello,
I am not developer actually, I got script and it used to be run properly as it show http://www.nysetechnical.com and http://www.cbzale.com
I upload the same script to server for other domains, but there are errors:
Quote:
Warning: MagpieRSS: Failed to parse RSS file. (syntax error at line 2, column 62) in /home/asia/public_html/cpatricks/magpierss/rss_fetch.inc on line 238
Warning: Invalid argument supplied for foreach() in /home/asia/public_html/cpatricks/index.php on line 122
I don't know what's wrong, could you please kindly advise me exactly and deeply what's line I have to change the code and which code I have to replace it?
thanks in advanced
FYI
this is index.php
Quote:
Code: Select all
<?php
$myhost = $_SERVER["SERVER_NAME"];
if(!$_SERVER["QUERY_STRING"]) {
// exit();
include ("index.inc");
exit();
}
//$keywords = $_SERVER["QUERY_STRING"];
$keyword = $_SERVER["QUERY_STRING"];
$keyword = str_replace("-", " ", $keyword);
$keyword = str_replace("+", " ", $keyword);
$keyword = str_replace("_", " ", $keyword);
//$worldfind4 = "-";
//$worldreplace4 = " ";
//$search = str_replace($worldfind4, $worldreplace4, $search);
//$worldfind1 = "-";
//$worldreplace1 = " ";
//$search = str_replace($worldfind1, $worldreplace1, $search);
?>
<html>
<head>
<meta name="description" content="<?php echo $keyword; ?>">
<meta name="keywords" content="<?php echo $keyword; ?>">
<META name="verify-v1" content="wEuqAEomxrj6cklo08Mptnn7f0vLgtU/w1IhqpmD4BA=" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-us">
<title><?php echo $keyword; ?> | <?php echo $_SERVER["HTTP_HOST"]; ?></title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#3300cc" vlink="#660066" alink="#FF0000">
<p>
<center>
<table border=0 bgcolor="#669933" cellpadding=3 cellspacing=0 width=600><tr><td valign=middle align=left>
</td>
<td align=right valign=middle>
</td></tr>
<tr><td bgcolor="#cccccc" align=right colspan=2>
<font face="Arial"><a href="http://<? echo $_SERVER["SERVER_NAME"]; ?>/"><? echo $_SERVER["SERVER_NAME"]; ?></a></font>
</td></tr></table>
<p>
<FORM accept-charset="UTF-8" action="http://<? echo $_SERVER["SERVER_NAME"]; ?>/search.php" method="GET">
<input size=30 name=search>
<input type=submit value="Search">
<a href="http://<? echo $_SERVER["SERVER_NAME"]; ?>/advanced.htm"><small><i>advanced</i></small></a>
</form>
<p>
<div align="center">
<table border="0" id="table1" cellspacing="0" cellpadding="0" width=600>
<tr>
<td width=600>
<?php include ("adsense.inc"); ?>
<font face="Arial">
<?php
$keywords = $_SERVER["QUERY_STRING"];
$keywords = stripslashes ( $_SERVER["QUERY_STRING"] );
$keywords = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $keywords);
$keywords = ereg_replace("[^[] ]","",$keywords);
$keywords = preg_replace('/\s\s+/', ' ', $keywords);
if ($keywords == ""){$keywords = "untitled";}
//$keywords = str_replace(" ", "+", $keywords);
$keywords = str_replace(" ", "-", $keywords);
//$keywords = str_replace("|", "", $keywords);
//$keywords = trim($keywords);
//$keywords = str_replace($worldfind3, $worldreplace3, $keywords);
define('MAGPIE_DIR', './magpierss/');
//define('MAGPIE_CACHE_DIR', './magpierss/cache');
//define('MAGPIE_CACHE_DIR', '/tmp/www.unlimitedseek.info');
define('MAGPIE_CACHE_DIR', './magpierss/cache');
define('MAGPIE_CACHE_ON', 1);
require_once(MAGPIE_DIR.'rss_fetch.inc');
error_reporting(E_ERROR);
//$url = "http://rwsm.directtaps.net/p5/rss.aspx?query=$keywords";
//$url = "http://blogsearch.google.com/blogsearch_feeds?hl=en&ie=utf-8&num=100&output=rss&q=$keywords";
//http://blogsearch.google.com/blogsearch_feeds?hl=en&q=make+money+adsense&ie=utf-8&num=100&output=rss
//$url = "http://blogsearch.google.com/blogsearch_feeds?hl=en&ie=utf-8&num=100&output=rss&q=$keywords";
//http://search.blogger.com/blogsearch_feeds?q=earn+money+cash&hl=en&ui=blg&ie=utf-8&num=100&output=rss
//$url = "http://rwsm.directtaps.net/p5/rss.aspx?query=$keywords";
//$file = "http://rssfeedsgenerator.com/services/clickbank.php?c=0&a=iamnewbies&q=$kkeywordss";
$url = "http://rssfeedsgenerator.com/services/clickbank.php?c=0&a=iamnewbies&q=$keywords";
if ( $url ) {
$rss = fetch_rss( $url );
// echo "Channel: " . $rss->channel['title'] . "<p>";
if ( $rss ) {
echo "<ul>";
$ii= 0;
foreach ($rss->items as $item) {
if($ii++ >= 20) break;
$href = $item['link'];
$title = $item['title'];
$titlesearch = strip_tags ( $title );
$titlesearch = stripslashes ( $titlesearch );
$titlesearch = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $titlesearch);
$titlesearch = ereg_replace("[^[] ]","",$titlesearch);
$titlesearch = preg_replace('/\s\s+/', ' ', $titlesearch);
if ($titlesearch == ""){$titlesearch = "untitled";}
// $titlesearch = str_replace(" ", "-", $titlesearch);
$keysearch = explode (" ", $titlesearch);
// $newkeyword = $keysearch[0]."-".$keysearch[1]."-".$keysearch[2];
// $newkeyword = $keysearch[0]."-".$keysearch[1];
$newkeyword = $keysearch[0];
$description = $item['description'];
// echo "<li> $image<a href=$href>$title</a> <br> $description </li>";
// echo "<li> $image<a href=?$newkeyword>$title</a> <br> $description ";
echo "<li> $image<a href=$href><b>$title</b></a> <br> $description <br>";
echo "<font size='2' face='sans-serif, Arial, Helvetica'><b>Related:</b> ";
for ($i=0; $i<count($keysearch); $i++) {
// echo "• <A HREF='http://" .$_SERVER["SERVER_NAME"]. "/?" . $keysearch[$i] . "'>" . $keysearch[$i] . "</A> \n";
echo "• <A HREF='http://" .$_SERVER["SERVER_NAME"]. "/" . $keysearch[$i] . ".htm'>" . $keysearch[$i] . "</A> \n";
}
echo "</li><br><br>\n";
}
echo "</ul>";
}
}
else {
echo "An error occured! " .
"Consider donating more $$$ for restoration of services." .
"<br>Error Message: ";
}
?>
</font>
</td>
</tr>
</table>
</td></tr></table>
</div>
<table border=0 cellpadding=0 cellspacing=0 width=600><tr><td align=left valign=bottom>
</td><td align=right valign=bottom>
</td></tr></table>
<table border=0 bgcolor="#669933" cellpadding=2 cellspacing=0 width=600><tr><td valign=middle>
<font color="#ffffff" face="sans-serif, Arial, Helvetica" size="-2">
Copyright © 2006 <? echo $_SERVER["SERVER_NAME"]; ?> . All rights reserved.
</font>
</td></tr></table><font size="-2"><br></font>
<font color="#666666" face="sans-serif, Arial, Helvetica" size="-1"><br>
</font>
</center>
<div align="center"><font face="Arial"><a href="http://<? echo $_SERVER["SERVER_NAME"]; ?>/">
<? echo $_SERVER["SERVER_NAME"]; ?></a> </font></div>
<?php include ("stats.inc"); ?>
</body>
</html>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
this is rss_fetch
Posted: Thu Jan 04, 2007 1:02 pm
by red_army
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<?php
/*
* Project: MagpieRSS: a simple RSS integration tool
* File: rss_fetch.inc, a simple functional interface
to fetching and parsing RSS files, via the
function fetch_rss()
* Author: Kellan Elliott-McCrea <kellan@protest.net>
* 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
*
*/
// Setup MAGPIE_DIR for use on hosts that don't include
// the current path in include_path.
// with thanks to rajiv and smarty
if (!defined('DIR_SEP')) {
define('DIR_SEP', DIRECTORY_SEPARATOR);
}
if (!defined('MAGPIE_DIR')) {
define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP);
}
require_once( MAGPIE_DIR . 'rss_parse.inc' );
require_once( MAGPIE_DIR . 'rss_cache.inc' );
// for including 3rd party libraries
define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP);
require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc');
/*
* CONSTANTS - redefine these in your script to change the
* behaviour of fetch_rss() currently, most options effect the cache
*
* MAGPIE_CACHE_ON - Should Magpie cache parsed RSS objects?
* For me a built in cache was essential to creating a "PHP-like"
* feel to Magpie, see rss_cache.inc for rationale
*
*
* MAGPIE_CACHE_DIR - Where should Magpie cache parsed RSS objects?
* This should be a location that the webserver can write to. If this
* directory does not already exist Mapie will try to be smart and create
* it. This will often fail for permissions reasons.
*
*
* MAGPIE_CACHE_AGE - How long to store cached RSS objects? In seconds.
*
*
* MAGPIE_CACHE_FRESH_ONLY - If remote fetch fails, throw error
* instead of returning stale object?
*
* MAGPIE_DEBUG - Display debugging notices?
*
*/
/*=======================================================================*\
Function: fetch_rss:
Purpose: return RSS object for the give url
maintain the cache
Input: url of RSS file
Output: parsed RSS object (see rss_parse.inc)
NOTES ON CACHEING:
If caching is on (MAGPIE_CACHE_ON) fetch_rss will first check the cache.
NOTES ON RETRIEVING REMOTE FILES:
If conditional gets are on (MAGPIE_CONDITIONAL_GET_ON) fetch_rss will
return a cached object, and touch the cache object upon recieving a
304.
NOTES ON FAILED REQUESTS:
If there is an HTTP error while fetching an RSS object, the cached
version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off)
\*=======================================================================*/
define('MAGPIE_VERSION', '0.72');
$MAGPIE_ERROR = "";
function fetch_rss ($url) {
// initialize constants
init();
if ( !isset($url) ) {
error("fetch_rss called without a url");
return false;
}
// if cache is disabled
if ( !MAGPIE_CACHE_ON ) {
// fetch file, and parse it
$resp = _fetch_remote_file( $url );
if ( is_success( $resp->status ) ) {
return _response_to_rss( $resp );
}
else {
error("Failed to fetch $url and cache is off");
return false;
}
}
// else cache is ON
else {
// Flow
// 1. check cache
// 2. if there is a hit, make sure its fresh
// 3. if cached obj fails freshness check, fetch remote
// 4. if remote fails, return stale object, or error
$cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
if (MAGPIE_DEBUG and $cache->ERROR) {
debug($cache->ERROR, E_USER_WARNING);
}
$cache_status = 0; // response of check_cache
$request_headers = array(); // HTTP headers to send with fetch
$rss = 0; // parsed RSS object
$errormsg = 0; // errors, if any
// store parsed XML by desired output encoding
// as character munging happens at parse time
$cache_key = $url . MAGPIE_OUTPUT_ENCODING;
if (!$cache->ERROR) {
// return cache HIT, MISS, or STALE
$cache_status = $cache->check_cache( $cache_key);
}
// if object cached, and cache is fresh, return cached obj
if ( $cache_status == 'HIT' ) {
$rss = $cache->get( $cache_key );
if ( isset($rss) and $rss ) {
// should be cache age
$rss->from_cache = 1;
if ( MAGPIE_DEBUG > 1) {
debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
}
return $rss;
}
}
// else attempt a conditional get
// setup headers
if ( $cache_status == 'STALE' ) {
$rss = $cache->get( $cache_key );
if ( $rss and $rss->etag and $rss->last_modified ) {
$request_headers['If-None-Match'] = $rss->etag;
$request_headers['If-Last-Modified'] = $rss->last_modified;
}
}
$resp = _fetch_remote_file( $url, $request_headers );
if (isset($resp) and $resp) {
if ($resp->status == '304' ) {
// we have the most current copy
if ( MAGPIE_DEBUG > 1) {
debug("Got 304 for $url");
}
// reset cache on 304 (at minutillo insistent prodding)
$cache->set($cache_key, $rss);
return $rss;
}
elseif ( is_success( $resp->status ) ) {
$rss = _response_to_rss( $resp );
if ( $rss ) {
if (MAGPIE_DEBUG > 1) {
debug("Fetch successful");
}
// add object to cache
$cache->set( $cache_key, $rss );
return $rss;
}
}
else {
$errormsg = "Failed to fetch $url ";
if ( $resp->status == '-100' ) {
$errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)";
}
elseif ( $resp->error ) {
# compensate for Snoopy's annoying habbit to tacking
# on '\n'
$http_error = substr($resp->error, 0, -2);
$errormsg .= "(HTTP Error: $http_error)";
}
else {
$errormsg .= "(HTTP Response: " . $resp->response_code .')';
}
}
}
else {
$errormsg = "Unable to retrieve RSS file for unknown reasons.";
}
// else fetch failed
// attempt to return cached object
if ($rss) {
if ( MAGPIE_DEBUG ) {
debug("Returning STALE object for $url");
}
return $rss;
}
// else we totally failed
error( $errormsg );
return false;
} // end if ( !MAGPIE_CACHE_ON ) {
} // end fetch_rss()
/*=======================================================================*\
Function: error
Purpose: set MAGPIE_ERROR, and trigger error
\*=======================================================================*/
function error ($errormsg, $lvl=E_USER_WARNING) {
global $MAGPIE_ERROR;
// append PHP's error message if track_errors enabled
if ( isset($php_errormsg) ) {
$errormsg .= " ($php_errormsg)";
}
if ( $errormsg ) {
$errormsg = "MagpieRSS: $errormsg";
$MAGPIE_ERROR = $errormsg;
trigger_error( $errormsg, $lvl);
}
}
function debug ($debugmsg, $lvl=E_USER_NOTICE) {
trigger_error("MagpieRSS [debug] $debugmsg", $lvl);
}
/*=======================================================================*\
Function: magpie_error
Purpose: accessor for the magpie error variable
\*=======================================================================*/
function magpie_error ($errormsg="") {
global $MAGPIE_ERROR;
if ( isset($errormsg) and $errormsg ) {
$MAGPIE_ERROR = $errormsg;
}
return $MAGPIE_ERROR;
}
/*=======================================================================*\
Function: _fetch_remote_file
Purpose: retrieve an arbitrary remote file
Input: url of the remote file
headers to send along with the request (optional)
Output: an HTTP response object (see Snoopy.class.inc)
\*=======================================================================*/
function _fetch_remote_file ($url, $headers = "" ) {
// Snoopy is an HTTP client in PHP
$client = new Snoopy();
$client->agent = MAGPIE_USER_AGENT;
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;
$client->use_gzip = MAGPIE_USE_GZIP;
if (is_array($headers) ) {
$client->rawheaders = $headers;
}
@$client->fetch($url);
return $client;
}
/*=======================================================================*\
Function: _response_to_rss
Purpose: parse an HTTP response object into an RSS object
Input: an HTTP response object (see Snoopy)
Output: parsed RSS object (see rss_parse)
\*=======================================================================*/
function _response_to_rss ($resp) {
$rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING );
// if RSS parsed successfully
if ( $rss and !$rss->ERROR) {
// find Etag, and Last-Modified
foreach($resp->headers as $h) {
// 2003-03-02 - Nicola Asuni (http://www.tecnick.com) - fixed bug "Undefined offset: 1"
if (strpos($h, ": ")) {
list($field, $val) = explode(": ", $h, 2);
}
else {
$field = $h;
$val = "";
}
if ( $field == 'ETag' ) {
$rss->etag = $val;
}
if ( $field == 'Last-Modified' ) {
$rss->last_modified = $val;
}
}
return $rss;
} // else construct error message
else {
$errormsg = "Failed to parse RSS file.";
if ($rss) {
$errormsg .= " (" . $rss->ERROR . ")";
}
error($errormsg);
return false;
} // end if ($rss and !$rss->error)
}
/*=======================================================================*\
Function: init
Purpose: setup constants with default values
check for user overrides
\*=======================================================================*/
function init () {
if ( defined('MAGPIE_INITALIZED') ) {
return;
}
else {
define('MAGPIE_INITALIZED', true);
}
if ( !defined('MAGPIE_CACHE_ON') ) {
define('MAGPIE_CACHE_ON', true);
}
if ( !defined('MAGPIE_CACHE_DIR') ) {
define('MAGPIE_CACHE_DIR', './cache');
}
if ( !defined('MAGPIE_CACHE_AGE') ) {
define('MAGPIE_CACHE_AGE', 60*60); // one hour
}
if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
define('MAGPIE_CACHE_FRESH_ONLY', false);
}
if ( !defined('MAGPIE_OUTPUT_ENCODING') ) {
define('MAGPIE_OUTPUT_ENCODING', 'ISO-8859-1');
}
if ( !defined('MAGPIE_INPUT_ENCODING') ) {
define('MAGPIE_INPUT_ENCODING', null);
}
if ( !defined('MAGPIE_DETECT_ENCODING') ) {
define('MAGPIE_DETECT_ENCODING', true);
}
if ( !defined('MAGPIE_DEBUG') ) {
define('MAGPIE_DEBUG', 0);
}
if ( !defined('MAGPIE_USER_AGENT') ) {
$ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net';
if ( MAGPIE_CACHE_ON ) {
$ua = $ua . ')';
}
else {
$ua = $ua . '; No cache)';
}
define('MAGPIE_USER_AGENT', $ua);
}
if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout
}
// use gzip encoding to fetch rss files if supported?
if ( !defined('MAGPIE_USE_GZIP') ) {
define('MAGPIE_USE_GZIP', true);
}
}
// NOTE: the following code should really be in Snoopy, or at least
// somewhere other then rss_fetch!
/*=======================================================================*\
HTTP STATUS CODE PREDICATES
These functions attempt to classify an HTTP status code
based on RFC 2616 and RFC 2518.
All of them take an HTTP status code as input, and return true or false
All this code is adapted from LWP's HTTP::Status.
\*=======================================================================*/
/*=======================================================================*\
Function: is_info
Purpose: return true if Informational status code
\*=======================================================================*/
function is_info ($sc) {
return $sc >= 100 && $sc < 200;
}
/*=======================================================================*\
Function: is_success
Purpose: return true if Successful status code
\*=======================================================================*/
function is_success ($sc) {
return $sc >= 200 && $sc < 300;
}
/*=======================================================================*\
Function: is_redirect
Purpose: return true if Redirection status code
\*=======================================================================*/
function is_redirect ($sc) {
return $sc >= 300 && $sc < 400;
}
/*=======================================================================*\
Function: is_error
Purpose: return true if Error status code
\*=======================================================================*/
function is_error ($sc) {
return $sc >= 400 && $sc < 600;
}
/*=======================================================================*\
Function: is_client_error
Purpose: return true if Error status code, and its a client error
\*=======================================================================*/
function is_client_error ($sc) {
return $sc >= 400 && $sc < 500;
}
/*=======================================================================*\
Function: is_client_error
Purpose: return true if Error status code, and its a server error
\*=======================================================================*/
function is_server_error ($sc) {
return $sc >= 500 && $sc < 600;
}
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
this is index.php
Posted: Thu Jan 04, 2007 1:03 pm
by red_army
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<?php
$myhost = $_SERVER["SERVER_NAME"];
if(!$_SERVER["QUERY_STRING"]) {
// exit();
include ("index.inc");
exit();
}
//$keywords = $_SERVER["QUERY_STRING"];
$keyword = $_SERVER["QUERY_STRING"];
$keyword = str_replace("-", " ", $keyword);
$keyword = str_replace("+", " ", $keyword);
$keyword = str_replace("_", " ", $keyword);
//$worldfind4 = "-";
//$worldreplace4 = " ";
//$search = str_replace($worldfind4, $worldreplace4, $search);
//$worldfind1 = "-";
//$worldreplace1 = " ";
//$search = str_replace($worldfind1, $worldreplace1, $search);
?>
<html>
<head>
<meta name="description" content="<?php echo $keyword; ?>">
<meta name="keywords" content="<?php echo $keyword; ?>">
<META name="verify-v1" content="wEuqAEomxrj6cklo08Mptnn7f0vLgtU/w1IhqpmD4BA=" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-us">
<title><?php echo $keyword; ?> | <?php echo $_SERVER["HTTP_HOST"]; ?></title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#3300cc" vlink="#660066" alink="#FF0000">
<p>
<center>
<table border=0 bgcolor="#669933" cellpadding=3 cellspacing=0 width=600><tr><td valign=middle align=left>
</td>
<td align=right valign=middle>
</td></tr>
<tr><td bgcolor="#cccccc" align=right colspan=2>
<font face="Arial"><a href="http://<? echo $_SERVER["SERVER_NAME"]; ?>/"><? echo $_SERVER["SERVER_NAME"]; ?></a></font>
</td></tr></table>
<p>
<FORM accept-charset="UTF-8" action="http://<? echo $_SERVER["SERVER_NAME"]; ?>/search.php" method="GET">
<input size=30 name=search>
<input type=submit value="Search">
<a href="http://<? echo $_SERVER["SERVER_NAME"]; ?>/advanced.htm"><small><i>advanced</i></small></a>
</form>
<p>
<div align="center">
<table border="0" id="table1" cellspacing="0" cellpadding="0" width=600>
<tr>
<td width=600>
<?php include ("adsense.inc"); ?>
<font face="Arial">
<?php
$keywords = $_SERVER["QUERY_STRING"];
$keywords = stripslashes ( $_SERVER["QUERY_STRING"] );
$keywords = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $keywords);
$keywords = ereg_replace("[^[] ]","",$keywords);
$keywords = preg_replace('/\s\s+/', ' ', $keywords);
if ($keywords == ""){$keywords = "untitled";}
//$keywords = str_replace(" ", "+", $keywords);
$keywords = str_replace(" ", "-", $keywords);
//$keywords = str_replace("|", "", $keywords);
//$keywords = trim($keywords);
//$keywords = str_replace($worldfind3, $worldreplace3, $keywords);
define('MAGPIE_DIR', './magpierss/');
//define('MAGPIE_CACHE_DIR', './magpierss/cache');
//define('MAGPIE_CACHE_DIR', '/tmp/www.unlimitedseek.info');
define('MAGPIE_CACHE_DIR', './magpierss/cache');
define('MAGPIE_CACHE_ON', 1);
require_once(MAGPIE_DIR.'rss_fetch.inc');
error_reporting(E_ERROR);
//$url = "http://rwsm.directtaps.net/p5/rss.aspx?query=$keywords";
//$url = "http://blogsearch.google.com/blogsearch_feeds?hl=en&ie=utf-8&num=100&output=rss&q=$keywords";
//http://blogsearch.google.com/blogsearch_feeds?hl=en&q=make+money+adsense&ie=utf-8&num=100&output=rss
//$url = "http://blogsearch.google.com/blogsearch_feeds?hl=en&ie=utf-8&num=100&output=rss&q=$keywords";
//http://search.blogger.com/blogsearch_feeds?q=earn+money+cash&hl=en&ui=blg&ie=utf-8&num=100&output=rss
//$url = "http://rwsm.directtaps.net/p5/rss.aspx?query=$keywords";
//$file = "http://rssfeedsgenerator.com/services/clickbank.php?c=0&a=iamnewbies&q=$kkeywordss";
$url = "http://rssfeedsgenerator.com/services/clickbank.php?c=0&a=iamnewbies&q=$keywords";
if ( $url ) {
$rss = fetch_rss( $url );
// echo "Channel: " . $rss->channel['title'] . "<p>";
if ( $rss ) {
echo "<ul>";
$ii= 0;
foreach ($rss->items as $item) {
if($ii++ >= 20) break;
$href = $item['link'];
$title = $item['title'];
$titlesearch = strip_tags ( $title );
$titlesearch = stripslashes ( $titlesearch );
$titlesearch = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $titlesearch);
$titlesearch = ereg_replace("[^[] ]","",$titlesearch);
$titlesearch = preg_replace('/\s\s+/', ' ', $titlesearch);
if ($titlesearch == ""){$titlesearch = "untitled";}
// $titlesearch = str_replace(" ", "-", $titlesearch);
$keysearch = explode (" ", $titlesearch);
// $newkeyword = $keysearch[0]."-".$keysearch[1]."-".$keysearch[2];
// $newkeyword = $keysearch[0]."-".$keysearch[1];
$newkeyword = $keysearch[0];
$description = $item['description'];
// echo "<li> $image<a href=$href>$title</a> <br> $description </li>";
// echo "<li> $image<a href=?$newkeyword>$title</a> <br> $description ";
echo "<li> $image<a href=$href><b>$title</b></a> <br> $description <br>";
echo "<font size='2' face='sans-serif, Arial, Helvetica'><b>Related:</b> ";
for ($i=0; $i<count($keysearch); $i++) {
// echo "• <A HREF='http://" .$_SERVER["SERVER_NAME"]. "/?" . $keysearch[$i] . "'>" . $keysearch[$i] . "</A> \n";
echo "• <A HREF='http://" .$_SERVER["SERVER_NAME"]. "/" . $keysearch[$i] . ".htm'>" . $keysearch[$i] . "</A> \n";
}
echo "</li><br><br>\n";
}
echo "</ul>";
}
}
else {
echo "An error occured! " .
"Consider donating more $$$ for restoration of services." .
"<br>Error Message: ";
}
?>
</font>
</td>
</tr>
</table>
</td></tr></table>
</div>
<table border=0 cellpadding=0 cellspacing=0 width=600><tr><td align=left valign=bottom>
</td><td align=right valign=bottom>
</td></tr></table>
<table border=0 bgcolor="#669933" cellpadding=2 cellspacing=0 width=600><tr><td valign=middle>
<font color="#ffffff" face="sans-serif, Arial, Helvetica" size="-2">
Copyright © 2006 <? echo $_SERVER["SERVER_NAME"]; ?> . All rights reserved.
</font>
</td></tr></table><font size="-2"><br></font>
<font color="#666666" face="sans-serif, Arial, Helvetica" size="-1"><br>
</font>
</center>
<div align="center"><font face="Arial"><a href="http://<? echo $_SERVER["SERVER_NAME"]; ?>/">
<? echo $_SERVER["SERVER_NAME"]; ?></a> </font></div>
<?php include ("stats.inc"); ?>
</body>
</html>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
this is rss_cache.inc
Posted: Thu Jan 04, 2007 1:04 pm
by red_army
Code: Select all
<?php
/*
* Project: MagpieRSS: a simple RSS integration tool
* File: rss_cache.inc, a simple, rolling(no GC), cache
* for RSS objects, keyed on URL.
* 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:
* http://lists.sourceforge.net/lists/listinfo/magpierss-general
*
*/
class RSSCache {
var $BASE_CACHE = './cache'; // where the cache files are stored
var $MAX_AGE = 3600; // when are files stale, default one hour
var $ERROR = ""; // accumulate error messages
function RSSCache ($base='', $age='') {
if ( $base ) {
$this->BASE_CACHE = $base;
}
if ( $age ) {
$this->MAX_AGE = $age;
}
// attempt to make the cache directory
if ( ! file_exists( $this->BASE_CACHE ) ) {
$status = @mkdir( $this->BASE_CACHE, 0755 );
// if make failed
if ( ! $status ) {
$this->error(
"Cache couldn't make dir '" . $this->BASE_CACHE . "'."
);
}
}
}
/*=======================================================================*\
Function: set
Purpose: add an item to the cache, keyed on url
Input: url from wich the rss file was fetched
Output: true on sucess
\*=======================================================================*/
function set ($url, $rss) {
$this->ERROR = "";
$cache_file = $this->file_name( $url );
$fp = @fopen( $cache_file, 'w' );
if ( ! $fp ) {
$this->error(
"Cache unable to open file for writing: $cache_file"
);
return 0;
}
$data = $this->serialize( $rss );
fwrite( $fp, $data );
fclose( $fp );
return $cache_file;
}
/*=======================================================================*\
Function: get
Purpose: fetch an item from the cache
Input: url from wich the rss file was fetched
Output: cached object on HIT, false on MISS
\*=======================================================================*/
function get ($url) {
$this->ERROR = "";
$cache_file = $this->file_name( $url );
if ( ! file_exists( $cache_file ) ) {
$this->debug(
"Cache doesn't contain: $url (cache file: $cache_file)"
);
return 0;
}
$fp = @fopen($cache_file, 'r');
if ( ! $fp ) {
$this->error(
"Failed to open cache file for reading: $cache_file"
);
return 0;
}
if ($filesize = filesize($cache_file) ) {
$data = fread( $fp, filesize($cache_file) );
$rss = $this->unserialize( $data );
return $rss;
}
return 0;
}
/*=======================================================================*\
Function: check_cache
Purpose: check a url for membership in the cache
and whether the object is older then MAX_AGE (ie. STALE)
Input: url from wich the rss file was fetched
Output: cached object on HIT, false on MISS
\*=======================================================================*/
function check_cache ( $url ) {
$this->ERROR = "";
$filename = $this->file_name( $url );
if ( file_exists( $filename ) ) {
// find how long ago the file was added to the cache
// and whether that is longer then MAX_AGE
$mtime = filemtime( $filename );
$age = time() - $mtime;
if ( $this->MAX_AGE > $age ) {
// object exists and is current
return 'HIT';
}
else {
// object exists but is old
return 'STALE';
}
}
else {
// object does not exist
return 'MISS';
}
}
function cache_age( $cache_key ) {
$filename = $this->file_name( $url );
if ( file_exists( $filename ) ) {
$mtime = filemtime( $filename );
$age = time() - $mtime;
return $age;
}
else {
return -1;
}
}
/*=======================================================================*\
Function: serialize
\*=======================================================================*/
function serialize ( $rss ) {
return serialize( $rss );
}
/*=======================================================================*\
Function: unserialize
\*=======================================================================*/
function unserialize ( $data ) {
return unserialize( $data );
}
/*=======================================================================*\
Function: file_name
Purpose: map url to location in cache
Input: url from wich the rss file was fetched
Output: a file name
\*=======================================================================*/
function file_name ($url) {
$filename = md5( $url );
return join( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) );
}
/*=======================================================================*\
Function: error
Purpose: register error
\*=======================================================================*/
function error ($errormsg, $lvl=E_USER_WARNING) {
// append PHP's error message if track_errors enabled
if ( isset($php_errormsg) ) {
$errormsg .= " ($php_errormsg)";
}
$this->ERROR = $errormsg;
if ( MAGPIE_DEBUG ) {
trigger_error( $errormsg, $lvl);
}
else {
error_log( $errormsg, 0);
}
}
function debug ($debugmsg, $lvl=E_USER_NOTICE) {
if ( MAGPIE_DEBUG ) {
$this->error("MagpieRSS [debug] $debugmsg", $lvl);
}
}
}
?>
Posted: Thu Jan 04, 2007 1:09 pm
by jayshields
No one going to read all that. Re-post with the exact lines where the errors appear and someone will probably point you in the right direction.
Posted: Thu Jan 04, 2007 1:13 pm
by Kieran Huggins
sounds like your error reporting is set differently on each system...
read
http://www.php.net/manual/en/ref.errorf ... -reporting
jayshields is right, btw... I didn't read a single line of all that code!

Posted: Thu Jan 04, 2007 1:16 pm
by red_army
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[b]index.php[/b]
Code: Select all
$rss = fetch_rss( $url );
// echo "Channel: " . $rss->channel['title'] . "<p>";
if ( $rss ) {
rss_fetch.inc
Code: Select all
if ( $errormsg ) {
$errormsg = "MagpieRSS: $errormsg";
$MAGPIE_ERROR = $errormsg;
trigger_error( $errormsg, $lvl);
}
thanks
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Thu Jan 04, 2007 1:19 pm
by feyd
Five out of five posts I've needed to edit.
Please use the syntax highlighting red_army.
Posted: Thu Jan 04, 2007 1:25 pm
by red_army
oh, sorry,
anyway, pls kindly advise me how to solve it.
I quite question that why there are errors, I use the same script as I installed for nysetechnical.com and cbzale.com but there are error when I installed for the others domains such as cpatricks.com.
Posted: Thu Jan 04, 2007 1:55 pm
by Kieran Huggins
I think MagpieRSS is helping you already:
"Failed to parse RSS file"
Check you RSS URL
Posted: Thu Jan 04, 2007 2:03 pm
by red_army
it should not be that, as i told you, i use the same script as i installed for 2 sites.
why those 2 sites are no problem, but i have.
pls advice