301

(40 replies, posted in Programming)

Because it's in FULLTEXT, which is only supported for MySQL.

Try logging out and in again. Have others do that too.

You'd be better off upgrading, if that's even possible.

The first bit you are correct about yes.

The second bit is merely accessing the SimplePie class, had to digg through the code a bit for that tongue

See if this works:

<?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();
$id_array = array();
$first = array();
$user = array();

$userinfo = array();

while ($cur_feed = mysql_fetch_assoc($result))
{
    $feeds[] = $cur_feed['rssfeed'];
    $userinfo[$cur_feed['rssfeed']] = $cur_feed;
}

// 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];
    $username = $user[$ix];
    $ix++;

    // 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[] = $feed->get_item($x);
    }
 
    // 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;
foreach($first_items as $item)
{
    $feed = $item->get_feed();
    $info = $userinfo[$item->feed->feed_url];
    
    $counter++;
    if($counter >= 10)
        break;
    
    if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg'))
    $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$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 $info['id']; ?>" title="<?php echo $info['firstname'].'\'s Member Page'; ?>"><?php echo $info['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
}
?>

I've sent a mail smile

307

(11 replies, posted in PunBB 1.2 show off)

The server seems a tad slow from time to time hmm

308

(11 replies, posted in PunBB 1.2 troubleshooting)

img { float: right; }

309

(5 replies, posted in Programming)

If your installation supports system() calls, yes.

system('php script.php &');

310

(11 replies, posted in PunBB 1.2 discussion)

Paul.

The while is still wrong.

$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'];
}
...
foreach ($feeds as $url)
{
    $user_id = $id_array[$ix];
    $ix++;

    $firstname = $first[$ix];
    $ix++;
...

313

(5 replies, posted in General discussion)

Yes, you all have one IP, unless your internet traffic is channeled over multiple connections.

Just wait a bit until pastebin.ca comes back up and you'll have access to the correct code.

315

(4 replies, posted in PunBB 1.2 bug reports)

It isn't strange, it's just how the browser handles page caching.

The code I've given should work providing you add the correct query.

Well, that'd mean the array ($feed_array) is empty.

$feed_array = array();
if ($db->num_rows($result))
{
   while ($cur_feed = $db->fetch_assoc($result))
       $feed_array[] = $cur_feed['rssfeed'];
}

$feed = new SimplePie($feed_array);

If that doesn't work, do a print_r() of $feed_array.

No, it probably means you have allow_url_fopen off.
Does it work with other links?

320

(2 replies, posted in Programming)

In VMWare, you can select the network type in the network card settings. Try NAT and Bridged, those usually work.

321

(3 replies, posted in Programming)

As I said on IRC.
http://www.pcre.org/

322

(6 replies, posted in Programming)

Whoops, I gave you the MySQLi one big_smile

For regular MySQL it would be:

mysql_data_seek($result, 0);

323

(13 replies, posted in PunBB 1.2 discussion)

It also means that every external link inside PunBB would be almost force opened in a new window for everyone, and that's just wrong behavior, that kind of thing should be controlled by the end user, not the software writer or the webmaster.

http://kb.mozillazine.org/Browser.link. … ir_effects

It still won't work. I doubt a link full of special characters, which are translated to their ASCII/UTF-8 values, is clearer than obvious english words.

325

(6 replies, posted in Programming)

http://be.php.net/manual/en/function.my … a-seek.php