[crossing fingers hoping this thread hasn't been dormant for too long] 
I think this is a great solution. I was using Rss-to-Javascript, but lately found it to take forever for my page to load because it was waiting on the feed to show up. With this simplereader method, it's almost instantaneous.
I just have two questions:
1. I've followed this thread and learned that to make the failed permission error to go away I had to create a folder giving it a chmod of 777. The error still appears.
2. How do I control the length of an entry? I just wish to make them a little shorter.
The page I'm currently working on is www.familywebwatch.com/MultiFlex21/index2.php.
Your help is very much appreciated 
Member
From: Pell City, Alabama USA
Registered: 2004-11-17
Posts: 2084
I've been thanked 5 times.
Offline
to control the length of the entry, just chop a little bit of it off.
so right after you do this:
Code:
// The description often has encoded HTML entities in it, and
// we probably don't want these, so we'll decode them
$description[$counter][1] = html_entity_decode( $description[$counter][1]);
add something like this
Code:
$description[$counter][1] = substr($description[$counter][1], 0, 128 );
where the 128 is how many characters you want the maximum to be
as to the permission denied error, if you tried the CHMOD already I don't know what else to tell you, sorry
you can supress the error though - read the thread and there is a discussion of how to set the error warning level so the warning message is not displayed. or you could just remove the caching code entirely and not use it
TombOfTheMutilated.NET - Destroying The Minds of America's Youth Since 2001
Member
From: Sydney, Australia
Registered: 2004-10-23
Posts: 593
I've been thanked 0 times.
Offline
davincim wrote:
[crossing fingers hoping this thread hasn't been dormant for too long]
You can just check the date of the last post - at the top, left of each post... 
The last post before yours was 17th August - That doesn't matter at all - Just thought you might want to know how to check the age of a thread since last posting...
Wiz 
I cried because I had no shoes - until I saw a man who had no feet...
Thanks, Wizard! I must have looked at an even earlier post to find a much older date.
Mutilated1, thanks for the assist. I'm almost there.
Adding that bit of code helped me shorten the amount of text to display in the entries. I'm still troubled by the error messages though.
I referenced a few messages back to find your comment about not removing the caching code. If I'm referencing my own feed, is there no concern? Also in that comment it was mentioned that the directory that's containing the script be chmod'ed at 664, but not the Reader.php file. But what if that IS the directory containing the Reader.php file? In other words, I've got SimpleReader.php running in a child directory and that's the only thing running in there. What should the properties be for that file (I ask because I accidentally changed it and forgot what to revert back to).
I've had some success: www.familywebwatch.com/MultiFlex21/index2.php. If I need to put back the cache code, please let me know.
Oh sorry, one more thing I forgot. After adding that code to shorten the entries, I noticed that the [...] is missing from the end of the entries. How can I bring that back yet still reduce the amount of text? I think it looks better to keep that so that it doesn't look like a mistake.
Any help with my two last inquiries would be very much appreciated. 
Member
From: Pell City, Alabama USA
Registered: 2004-11-17
Posts: 2084
I've been thanked 5 times.
Offline
well you might consider removing the caching code - its worth thinking about.
If you're using your own feed, its most likely ok as long as your feed doesn't make a lot of database queries or something.
To answer your question about the CHMOD properties, that shouldn't matter what the CHMOD of the reader file is, so long as you've got them set so that the file will execute. But the CHMOD of the directory - if you've tried 664 and that didn
t work, then try 666.
TombOfTheMutilated.NET - Destroying The Minds of America's Youth Since 2001
Yeah, I removed my cache, but I just wanted to see if there's any negative impact to that. I see a slight lag, from time to time, for the page to load, and I wonder if it's my host or the script pulling the feeds. Not sure how to investigate that one, but will continue to keep an eye on it.
One other the question I had from a post or two ago is the "[...]" missing from my entries. It disappeared when I reduced the amount of characters displayed. How do I bring that back to avoid the awkward look it has as a result?
Again, thanks so much for your help. This method is definitely better than the one I was using previously.
Member
From: Pell City, Alabama USA
Registered: 2004-11-17
Posts: 2084
I've been thanked 5 times.
Offline
right after that other line that you added, add this...
Code:
$description[$counter][1] .= "[...]";
OR
if that [...] thing is meant to be a link to the rest...
try this instead
Code:
$description[$counter][1] .= " <a href='$link[$counter][1]'>[...]</a>";
TombOfTheMutilated.NET - Destroying The Minds of America's Youth Since 2001
Done. Thanks. 
Member
From: Pell City, Alabama USA
Registered: 2004-11-17
Posts: 2084
I've been thanked 5 times.
Offline
Glad you got it figured out. Have fun with it.
TombOfTheMutilated.NET - Destroying The Minds of America's Youth Since 2001
Member
From: York, England
Registered: 2005-11-04
Posts: 605
I've been thanked 11 times.
Offline
Mutilated1 wrote:
Code:
$description[$counter][1] = substr($description[$counter][1], 0, 128 );where the 128 is how many characters you want the maximum to be
oo, thats a nice simple one! Ive been using this function so i can have trailing ...... Which kind of gives the impression that there's more to come
Works well.
Code: php
function Truncate ($str, $length=10, $trailing='.....')
{
// take off chars for the trailing
$length-=strlen($trailing);
if (strlen($str) > $length)
{
// string exceeded length, truncate and add trailing dots
return substr($str,0,$length).$trailing;
}
else
{
// string was already short enough, return the string
$res = $str;
}
return $res;
}
In use:
($STRING is the string to truncate)
Code: php
$variable = Truncate("$STRING",17);
17 is number of characters to truncate to.
so if
$STRING = "Hello, my name is Andy";
echo"$variable";
would produce
Hello, my name is.....
i have some question here. Let have an example of the code...
Code: php
<?php require_once(ABSPATH . WPINC . '/rss-functions.php'); ?>
<div width="280px" style="float:left;">
<?php
$rss = fetch_rss('http://www.bharian.com.my/m/BHarian/RSS/rss?mysec=Nasional');
echo '<ul>';
foreach ($rss->items as $item)
{
$desc = substr(strip_tags($item['description']),0,300);
echo '<li><a target="_blank" href="'. $item['link'] .'" title="header=[] body=[' . $item['description'] . ']">' . $item['title'] . '</a></li>';
}
echo '</ul>';
?>
</div>]
I have put the rss feed from the site into my blog, and its show about 20 headlines ( example )..My question,
How to limit the headlines that appear in my blog, from 20 to just 10 headlines...Somebody help me.
What should i insert into that code...
Member
From: Pell City, Alabama USA
Registered: 2004-11-17
Posts: 2084
I've been thanked 5 times.
Offline
I suggest you ask that in a wordpress/magpie topic since thats the code library you're using.
This topic is about the article in this topic ( http://www.site-reference.com/articles/ … d-PHP.html ) and the code thats linked there.
I really can't help you with wordpress/magpie since I didn't have anything to do with it, and honestly I don't know if it does what you're asking or not.
However, if you were using the library and following the instructions in my article... you'd just do something like this
Code:
<?php
include("Reader.php");
$myRSS = new rssReader();
$myRSS->createHtmlFromRSSUrl("http://www.bharian.com.my/m/BHarian/RSS/rss?mysec=Nasional",10);
?>
notice the 10 at the end - that makes 10 entries on your page
simple huh ?
TombOfTheMutilated.NET - Destroying The Minds of America's Youth Since 2001
hey all
im new to php and i struggle
noone in the office seems interested in helping me write the code so i guess i will have to ask for help
i have read through the pages so far but as yet i cant understand it all and i dont wana look more like a fool
i need to know how to pull an existing rss feed of one of our sites on to the others.
i can do it in .asp but i cant get it an .php can any one help
Moderator
From: Yorkshire, UK
Registered: 2006-08-19
Posts: 2793
I've been thanked 77 times.
Offline
temogin wrote:
hey all
im new to php and i struggle
noone in the office seems interested in helping me write the code so i guess i will have to ask for help
i have read through the pages so far but as yet i cant understand it all and i dont wana look more like a fool
i need to know how to pull an existing rss feed of one of our sites on to the others.
i can do it in .asp but i cant get it an .php can any one help
Have you read the original article?
http://www.site-reference.com/articles/ … d-PHP.html
It's not the way I would do it, I'd use this function I've been using for years
Code: php
<?
function GetXMLasArray($feed_url) {
$feed_content = file_get_contents($feed_url);
$xml_doc = utf8_decode($feed_content);
// Parse the XML document
$parser = xml_parser_create();
xml_parse_into_struct($parser,$xml_doc,$data_values,$index) or die(xml_error_string(xml_get_error_code($parser)));
xml_parser_free($parser);
$ttags=array(); // Temporary array for storing tag names
for($i=0;$i<=count($data_values)-1;$i++) {
if(trim($data_values[$i][value])) {
$data[$data_values[$i][tag]][count($data[$data_values[$i][tag]])] = $data_values[$i][value];
//-------------------////---------------------------------//
$ttags[$data_values[$i][tag]] = $data_values[$i][tag];
}
}
$tags = array();
// Extract and save the tag names to the array
foreach($ttags as $tagi) {
array_push($tags,$tagi);
}
return $data;
}
?>
call it like$xml_data = GetXMLasArray("http://www.some-site.com/feed.xml");
you can do a print_r($xml_data) on it to see what data's in there to help test/debug then use a loop to format the data
Code: php
<?
for($i=0;$i<count($xml_data);$i++) {
$content.=$xml_data[$i]['some-field']."<br />\n";
}
?>
New member
From: Melbourne
Registered: 2007-09-22
Posts: 1
I've been thanked 0 times.
Offline
Hi
thanks for the code, could be what I'm looking for. I was having trouble all afternoon trying to get rid of the
Code: php
Warning: fopen(4c3cd2487ee4aadc0bfe0c2655d54f7b): failed to open stream: Permission denied...
business and CHMOD didn't help. I think it's to do with the webhost (ilisys) using php in safe mode as have had similar problems getting file uploads to work. If I moved the files around I also could get this:
Code:
Warning: fopen(): open_basedir restriction in effect. File(/assets/cache/4c3cd2487ee4aadc0bfe0c2655d54f7b) is not within the allowed path(s): (/home/xyz.com/:/usr/local/lib/php:/tmp/php_upload)
I found a work around that's a bit messy for now...
By the way I'm using the advanced version, the simple one worked fine.
I found that the advanced script worked fine if the script and the page calling it were in the same directory - not much for me. And I could get it to work if I had reader.php in every bloody directory and pointed it to the cache folder using a relative path. I wanted just one reader.php so after trying all sorts of variations I settled on this:
-Page(s) calling the script can be anywhere (in my case www/resource/rsstest.php) It calls the script using
Code: php
include("../reader.php");
-The script itself is in the root directory above (seems to work when its up there don't ask me why...www/reader.php ) This file calls the cache using
So now I can't see the cache directory at all, but it works. I will email my webhost soon to see where else I can put it.
I've never had the same difficulty with other php scripts requiring caches, not sure what the issue is. But hey it works so may contain a clue for someone.
Peter
| Never |


