Cheers chaps. Greatly appreciated.
1,027 2008-01-04 16:14
Re: FindClan.com (11 replies, posted in PunBB 1.2 show off)
Style doesn't look decent enough, I still think there is a lot of work to be done by me to get it nice. I think the borders are a bit too harsh on the eye and the colours are out of depth, so viewing and scrolling down forums is not the nicest thing to do.
To be totally truthful, I quite like those borders. One of the problems with a lot of the darker themes tends to be their lack of distinction between sections. I think it works quite well myself.
The code SHOULD be written correctly from the start, I agree, but I didn't really get my claws on this till a month or so ago. It died for a while, see, so I didn't really bother with such things.
I wasn't inferring either yourself or Liquidator in that comment. I had occasion to read the other participants website, and when they are stating things such as this as their strongpoints:
Quote:
proper, easy to use/edit Coding, Typography, Accessibility (yes, so that even blind people can easily use my websites), Navigation, Content and Search Engine Optimization.
End quote.
then in my book, that makes any lack of validity, (which by virtue also ruins accessibility), a perfectly good and honest criticism. As the saying goes, if you are going to stand yourself upon a pedestal.......
style problems - which IE will always be a fucking dick about.
Ain't that the truth. As I mentioned, apologies if you thought my comments were a reflection upon yourself or Liquidators efforts. They were not. I was merely pointing out the hypocritical nature of the site against the above quote.
1,028 2008-01-04 02:29
Re: Detaching a function (5 replies, posted in Programming)
Cheers.
Edit: Just out of curiosity, does the 'not natively' bit mean there is an alternative way to do it?
1,029 2008-01-04 01:45
Topic: Detaching a function (5 replies, posted in Programming)
Is there any way in PHP to detach a running function so that it will continue in the background, so that the calling script may carry on with its tasks?
Cheers,
Matt
1,030 2008-01-03 23:07
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
I will stress very highly about this, multi-dimensional arrays *ARE NOT* my strongpoint, so this script may be completely flawed. I would honestly suggest not testing it until one of the other, more learned ones, have given it a once over at least. But, here is my claim for ridicule, :
<?php
// Include the SimplePie library
require_once 'simplepie.inc';
require 'shorten.php';
// Because we're using multiple feeds, let's just set the headers here.
header('Content-type:text/html; charset=utf-8');
// These are the feeds we want to use
mysql_connect(localhost,$db_username,$db_password);
@mysql_select_db($db_name) or die( "Unable to select database");
$query="SELECT id, firstname, username, rssfeed FROM members WHERE rssfeed!=''";
$result=mysql_query($query);
$feeds = array();
$i = 0;
$xf = 0;
$xi = 0;
$xx = 0;
while ($cur_feed = mysql_fetch_assoc($result))
{
$feeds[$i][uid] = $cur_feed['id'];
$feeds[$i][feed] = $cur_feed['rssfeed'];
$feeds[$i][fname] = $cur_feed['firstname'];
$feeds[$i][uname] = $cur_feed['username'];
$i++;
}
// This array will hold the items we'll be grabbing.
$first_items = array();
// Let's go through the array, feed by feed, and store the items we want.
while ($xi <= $i)
{
$url = $feeds[$xi][feed];
// Use the long syntax
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->init();
// How many items per feed should we try to grab?
$items_per_feed = 1;
// As long as we're not trying to grab more items than the feed has, go through them one by one and add them to the array.
for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++)
{
$first_items[$xx][feed] = $feed->get_item($x);
$first_items[$xx][uid] = $feeds[$xi][uid];
$first_items[$xx][fname] = $feeds[$xi][fname];
$first_items[$xx][uname] = $feeds[$xi][uname];
$xx++;
}
$xi++;
// We're done with this feed, so let's release some memory.
unset($feed);
}
/*
// We need to sort the items by date with a user-defined sorting function. Since usort() won't accept "SimplePie::sort_items", we need to wrap it in a new function.
function sort_items($a, $b)
{
return SimplePie::sort_items($a, $b);
}
// Now we can sort $first_items with our custom sorting function.
usort($first_items, "sort_items");
*/
$counter = 0;
while ($xf <= $xx)
{
$item = $first_items[$xf][feed];
$user_id = $first_items[$xf][uid];
$firstname = $first_items[$xf][fname];
$username = $first_items[$xf][uname];
$feed = $item->get_feed();
$counter++;
$xf++;
if ($counter >= 10)
{
break;
}
if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_id.'.jpg'))
{
$avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$user_id.'.jpg" alt="" />';
}
else
{
$avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/nopicture.png" alt="" />';
}
$picture = '<div id="feedpicture"><a href="member.php?id='.$user_id.'" title="'.$firstname.'\'s Member Page">'.$avatar_field.'</a></div>';
// Begin the (X)HTML page.
?>
<h3><?php echo $picture; ?><a href="<?php echo $item->get_permalink(); ?>" target="_blank"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></h3>
<!-- get_content() prefers full content over summaries -->
<? echo trim(substr((str_replace("\n", ' ', str_replace("\r", ' ', strip_tags($item->get_description())))),0,300)); ?>
... <i>more</i></a><br />
<p class="footnote"><a href="member.php?id=<?php echo $user_id; ?>" title="<?php echo $firstname.'\'s Member Page'; ?>"><?php echo $username; ?></a> | <a href="<?php echo $feed->get_permalink(); ?>" target="_blank"><?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('M j, Y | g:i a'); ?></p><br />
<?php
}
?>
Seriously though, regarding the caution. I would wait until it's been checked over first. It could do anything from literally nothing, upto going into a constant while loop.
Edit: The sorting is also disabled, as that would have reset all the keys.
1,031 2008-01-03 19:43
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
Post the complete script you're using.
1,032 2008-01-03 17:50
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++) { $first_items[] = $feed->get_item($x); $user_id = $id_array[$x]; $firstname = $first[$x]; $x++; }
You have already set user_id and firstname at the top of the loop. You shouldn't have them in that loop too. All you are achieving there is running through the array without doing anything with the info. They're already set. Echo the output where you need it.
1,033 2008-01-03 17:13
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
I give up for now.
Well stop stripping parts off the code you're given then.
$query="SELECT id, firstname, username, rssfeed FROM members WHERE rssfeed!=''";
$result=mysql_query($query);
$feeds = array();
$id_array = array();
$first = array();
while ($cur_feed = mysql_fetch_assoc($result))
{
$feeds[] = $cur_feed['rssfeed'];
$id_array[] = $cur_feed['id'];
$first[] = $cur_feed['firstname'];
}
// This array will hold the items we'll be grabbing.
$first_items = array();
// Let's go through the array, feed by feed, and store the items we want.
$ix = 0;
foreach ($feeds as $url)
{
$user_id = $id_array[$ix];
$firstname = $first[$ix];
$ix++;
// Use the long syntax
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->init();
1,034 2008-01-03 17:11
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
The while is still wrong.
I'd never noticed that.
1,035 2008-01-03 16:31
Re: How to change the line height of each topic in the topics list page? (2 replies, posted in PunBB 1.2 modifications, plugins and integrations)
Thanks for what?
1,036 2008-01-03 16:28
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
$query="SELECT id, firstname, username, rssfeed FROM members WHERE rssfeed!=''"; $result=mysql_query($query); $feeds = array(); $id_array = array(); $first = array(); while ($cur_feed = mysql_fetch_assoc($result)) $feeds[] = $cur_feed['rssfeed']; $id_array[] = $cur_feed['id']; $first[] = $cur_feed['firstname']; // This array will hold the items we'll be grabbing. $first_items = array(); // Let's go through the array, feed by feed, and store the items we want. $ix = 0; foreach ($feeds as $url) { $user_id = $id_array[$ix]; $firstname = $first[$ix]; $ix++; // Use the long syntax $feed = new SimplePie(); $feed->set_feed_url($url); $feed->init();
1,037 2008-01-03 16:16
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
I had already tried that one, Elbekko. Thanks though.
Just post the code you already have to hand. It'll be far less painful that way.
1,038 2008-01-03 16:15
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
foreach ($feeds as $url) { $user_id = $id_array[$ix]; $ix++; $firstname = $first[$ix]; $ix++; ...
That last bit only needs one increment, to keep the relationship intact:
foreach ($feeds as $url)
{
$user_id = $id_array[$ix];
$firstname = $first[$ix];
$ix++;
1,039 2008-01-03 16:03
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
I've also tried this:
for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++) { $first_items[] = $feed->get_item($x); $user_id = $id_array[$ix]; $firstname = $first[$ix]; $ix++; }
Should I use mysql_fetch_row or another variation?
You only want that var incremented once inside the loop, btw, as above.
Edit: In fact, if you're only wanting that info inside of the same loops as the $x count, you can ditch the $ix altogether and just use the $x var.
1,040 2008-01-03 15:57
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
If I remember correctly offhand, fetch_assoc should be fine. I forgot to mention, btw, remember to set
$ix = 0;
initially outside of the foreach loop.
1,041 2008-01-03 04:25
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
Simplest way, I believe, is to create arrays for each item, i.e:
$feeds = array();
$id_array = array();
while ($cur_feed = mysql_fetch_assoc($result))
{
$feeds[] = $cur_feed['rssfeed'];
$id_array[] = $cur_feed['id'];
.....................etc, etc
then in the foreach loop do along the lines of:
$user_id = $id_array[$ix];
$ix++;
or echo or whatever you want to do with it.
1,042 2008-01-02 16:30
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
Matt: I think you confused implode with explode
Possibly. It's not an error I'll make a second time though, thanks to your correction. They will go giving these functions similar names and confusing people.
1,043 2008-01-02 16:20
Re: Happy New Year (13 replies, posted in General discussion)
Indeed. Happy New Year folks! Give us a few more days and we should have 1.3 beta up for grabs.
Just to be an awkward git and go against the flow, are you sure you're not rushing a beta out just to placate people?
1,044 2008-01-02 16:17
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
That's a numerically indexed array with one element. So key 0 points to a comma delineated list of URLs.
The two are NOT equivalent.
My apologies. I never realised until you just explained it that implode doesn't actually split them. That's one I'll remember for future reference. Explains why that code I posted was buggered too. Thanks for the explanation.
1,045 2008-01-02 15:01
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
Matt:
1. That is a numerically indexed array, not an comma delineated list of URLs, which is what you are proposing.
The Simplepie array or the one we've created? Judging by their docs, the code for creating that array I posted earlier and then using the implode inside their array should give output which is similar to that in their documentation for the set_feed_url.
2. I wasn't saying that it doesn't allow you to use multiple URLs. We know that works since Peter has done it in this topic already. I was saying that I don't think it allows you to get the most recent post from each URL in the array. That example doesn't seem to do that.
My apologies. I misinterpreted that one.
1,046 2008-01-02 14:46
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
If so, I don't believe SimplePie allows you to do that just using its functions. Doing that involves doing what you were doing (calling each feed URL one by one), storing the results for each feed together in an array, and then sorting those results.
It would appear it does, by the looks of it. From the Simplepie docs:
// Multiple feeds
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://simplepie.org/blog/feed/',
'http://digg.com'
));
$feed->enable_order_by_date(false);
$feed->cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
$feed->init();
echo $feed->get_title();
1,047 2008-01-02 14:42
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
Just out of curiosity, change this line:
$feed->set_feed_url(implode(', ', $rss_feeds));
to:
$feed->set_feed_url(array("'".implode("', '", $rss_feeds)."'"));
or:
$feed->set_feed_url(array(implode(', ', $rss_feeds)));
I believe that first syntax should be correct for creating/keeping the single-quotes, but may be wrong.
Edit: I've just edited that code above for the array bit. Hadn't noticed the lack of it until Smartys mentioned.
1,048 2008-01-02 14:07
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
The question you keep repeating is moot. You have all the info you need in this thread to do exactly what you require. Note my last post, regarding the array and a foreach loop. And if Simplepie was not the point of this thread, then why mention this:
With your array solutions the SimplePie scripts behaves very different than when I put in a regular list of feeds. They're not the same thing. I don't know how to work with arrays, so I'm at a new dead end if I have to start editing how SimplePie code handles arrays.
Seriously, the problem is not with any of the code which has been supplied to you, but with something else. However, if you wish to prove the point, use that first array code I posted, and then use this to echo each line individually, (providing that rssfeed is the only content being put into each line in the array):
foreach ($feed_array as $value)
{
echo $value."\n";
}
The problem is that you have your mind set upon a specific answer you want, rather than the possibility of a better solution.
1,049 2008-01-02 12:40
Re: FindClan.com (11 replies, posted in PunBB 1.2 show off)
Style looks decent enough. The tabs are screwed in the Moz class browsers too, however.
However, just one slight nitpick. What is so hard about developing a compliant and valid site with regards to Xhtml/html? It's even more ironic when one of your designers professes to be something akin to the bees knees with regards to design, accessibility, usability and so on. Before you point out the fact, I know the site is still being worked upon, but the code should be written correctly from day one, not hacked together and then cleaned up as an after thought.
1,050 2008-01-02 10:38
Re: RSS feeds from database + associated data (skip NULL in MySQL output) (92 replies, posted in Programming)
Smartys, my original question was about inserting output from one part of a PHP script elsewhere in the same script, instead of echo-ing it. I should never have brought up SimplePie! I've been saying all along that I don't want to go into SimplePie, which works fine elsewhere in my site.
No, your original question was regarding Simplepie and RSS feeds.
Just look at the code you've already been given. With the array you create, you can do what the chuff you like with it later, whether that's using it in a foreach loop and echoing the content, sorting, splitting or whatever else takes your fancy.