I've used this on the database:

UPDATE users SET rssfeed=NULL;

That sets all rssfeed fields to NULL. I had to manually restore two rssfeeds. I should probably have added WHERE rssfeed!='' to the query.

Now the rssfeed IS NOT NULL solution works just as well. Is that the correct way to do it? Is one method better than the other.

Anyway, on to step two (after a late brunch + some coffee)... smile

This actually worked for me:

$query="SELECT rssfeed FROM users WHERE rssfeed!=''";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {

$rssfeed=mysql_result($result,$i,"rssfeed");

echo "$rssfeed,<br />";

$i++;
}

It produces a nice output like this:

http://feeds.feedburner.com/website/rss,
http://www.blogblogblog.com/feed/,
http://www.bloggerdyblog.com/feed/,

With 'WHERE rssfeed IS NOT NULL' I still got a list of mostly empty commas. I hadn't set NULL as default for the RSS feed. I've corrected that now, but it seems to have no effect for rows that have already been created. Any way to fill the empty RSS fields with NULL? Is it worth the trouble?

For now I'll stick with what works, moving on to step two, how to insert that output into the SimplePie code. Going to test MattF's earlier suggestion now...

MattF wrote:

Have just read past the first line or two of your first post. big_smile

You may need to change that query to either:

$db->query('SELECT rssfeed FROM '.$db->prefix."users WHERE rssfeed!=''")

or:

$db->query('SELECT rssfeed FROM '.$db->prefix.'users WHERE rssfeed!=NULL')

Right! I've used something like that before. Didn't think of that.

That would solve half of the puzzle. Thanks again! :-)

Gotta run...

OK! And then I put '$feed_array[]' in the SimplePie code where I had '$rssfeeds' ?

I'll try it later. Have to run out to a New Year's Eve party...

Thanks again MattF!

Wow MattF, thanks for the quick response, on New Year's Eve! :-)

Going to test it now, will report back...

...I'm back. It's not clear to me how to use this solution. This obviously doesn't work:

$result = $db->query('SELECT rssfeed FROM members') or error('Unable to fetch feed information', __FILE__, __LINE__,$db->error());

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

// Initialize some feeds for use.
$feed = new SimplePie();
$feed->set_feed_url(array(
    $rssfeed
));

I assume I have to replace "simplepie command" with something, but then I'd have to start rewriting/customizing the SimplePie script.

I think your solution would apply "simplepie command" to each RSS feed seperately. I already have a solution that does that, but then all the posts together don't get sorted by date, for example.

I'm looking for a solution that takes the available RSS feeds from the database, puts them in a list (an "array"?), then leaves the rest to the regular Simplepie script.

The regular SimplePie multifeeds script needs something like this:

// Initialize some feeds for use.
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://www.website.com/?feed=rss2', 
'http://feeds.feedburner.com/someonesblog', 
'http://www.moreblogging.com/my_weblog/atom.xml',
));

So how can I get that RSS feed list from the database and instead of echoing it, insert it into SimplePie?

I'm a non-PHP coder trying to copy/paste a script together, struggling with probably basic stuff. Google is no help. Most tutorials go deep into the PHP mechanisms and jargon with overly fancy examples.

I let registered PunBB users add an RSS feed to their user data. I want to get a list of available RSS feeds from the database and insert it into the SimplePie script that will show the latest users posts on a page.

$query="SELECT rssfeed FROM users";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {

$rssfeed=mysql_result($result,$i,"rssfeed");

echo "$rssfeed,<br />";

$i++;
}

SimplePie requires something like this:

'http://www.website.com/?feed=rss2',
'http://feeds.feedburner.com/someonesblog',
'http://www.moreblogging.com/my_weblog/atom.xml',

The apostrophes are probably not essential, but the comma apparently is. With the code above I get lots of empty commas, because only a handful of people have submitted RSS feeds so far. How can I get the script to skip empty fields?

The echo output should then replace $memberfeeds in this bit of SimplePie code:

// Initialize some feeds for use.
$feed = new SimplePie();
$feed->set_feed_url(array(
    $memberfeeds
));

How can I do that? This obviously doesn't work:

$memberfeeds=echo "$rssfeed,<br />"

Something like that, but looped so it produces a list of all available RSS feeds.

Again, I couldn't find anything online. It's becoming one of those obsessions that eating up all my time. All suggestions are very welcome, including what keywords to search on and links to good tutorials or examples for these basic things.

Happy New Year!

Sorry, I'd overlooked Smartys' post from 2007-03-18. I should be able to figure it out (again).

But I need the solution for the "latest registered 5 users", instead of "users online". Any pointers how to do that?

Thanks all!

How do I actually show the results of Smarty's php code?

I've tried

<?php echo $pun_user_online ?>

within the html, but that didn't do anything.

Cool! Makes sense. I'll try this as soon as I have time.

Thanks! :-)

Smartys wrote:

Or you could allow users to delete their own accounts without deleting their posts by editing two lines of the code you pasted above.

That sounds good enough for me. I'd like to try that. For a non-php coder it's not obvious which two lines should be edited how, so any more pointers would be very much appreciated.

"Trapped" is somewhat overdramatic. I use PunBB as the general member registration script for my site. I'm just trying to be "customer-friendly". Offering a Delete Account option seems a must.

Thanks for all the suggestions!

Smartys wrote:
Peter wrote:

Why isn't there a delete option for users?

Because deleting is an administrative/maintenance action that can have effects on the entire board.

That's why I don't want to improvise this, but there really should be a Delete Account option for the user. You can't just trap users on your site. A Delete Account option is a basic requirement for any site that registers users.

If I can't find a solution I have to look for another script and start from scratch. :-(

Why isn't there a delete option for users?

I will puzzle with this when I have more time, but I don't want to mess it up.

Any suggestions how to "extract" the relevant code from profile.php, how to keep the right permissions checks and how to use it are very welcome.

Thanks Smartys, but copy what exactly, paste where?

I see this in profile.php, but it's part of a lot of other if/else code:

else if (isset($_POST['delete_user']) || isset($_POST['delete_user_comply']))
{
    if ($pun_user['g_id'] > PUN_ADMIN)
        message($lang_common['No permission']);

    confirm_referrer('profile.php');

    // Get the username and group of the user we are deleting
    $result = $db->query('SELECT group_id, username FROM users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
    list($group_id, $username) = $db->fetch_row($result);

    if ($group_id == PUN_ADMIN)
        message('Administrators cannot be deleted. In order to delete this user, you must first move him/her to a different user group.');

    if (isset($_POST['delete_user_comply']))
    {
        // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well
        if ($group_id < PUN_GUEST)
        {
            $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());

            while ($cur_forum = $db->fetch_assoc($result))
            {
                $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();

                if (in_array($id, $cur_moderators))
                {
                    unset($cur_moderators[$username]);
                    $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';

                    $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
                }
            }
        }

        // Delete any subscriptions
        $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE user_id='.$id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());

        // Remove him/her from the online list (if they happen to be logged in)
        $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$id) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error());

        // Should we delete all posts made by this user?
        if (isset($_POST['delete_posts']))
        {
            require PUN_ROOT.'include/search_idx.php';
            @set_time_limit(0);

            // Find all posts made by this user
            $result = $db->query('SELECT p.id, p.topic_id, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE p.poster_id='.$id) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
            if ($db->num_rows($result))
            {
                while ($cur_post = $db->fetch_assoc($result))
                {
                    // Determine whether this post is the "topic post" or not
                    $result2 = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['topic_id'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

                    if ($db->result($result2) == $cur_post['id'])
                        delete_topic($cur_post['topic_id']);
                    else
                        delete_post($cur_post['id'], $cur_post['topic_id']);

                    update_forum($cur_post['forum_id']);
                }
            }
        }
        else
            // Set all his/her posts to guest
            $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error());

        // Delete the user
        $db->query('DELETE FROM users WHERE id='.$id) or error('Unable to delete user', __FILE__, __LINE__, $db->error());

        redirect('index.php', $lang_profile['User delete redirect']);
    }

I've tried to use that code with a link like this:

<a href="profile.php?action=delete_user&id=<? echo $row['id']; ?>">Cancel Account</a>

But it didn't do anything. It just pulled up the regular profile.php editing menu (with Essentials, etc.).

What uses this delete_user code? I don't see anything related to deleting users/accounts in the regular user menus.

I use PunBB as central member registration system on my site. I really need a way to offer members the option to cancel their account.

Is there no way to do this? I see delete_user code in profile.php, but can't figure out how to use it for a Cancel Account option.

elbekko, again, I already had a default avatar/picture. That's not what my question was about.

My question was about removing the use_avatar field (or making it at least default 1) from the users table. It doesn't seem to serve any purpose if there's a default avatar.

Thanks MattF. I'm learning a lot recently. smile

I understand the other two database lines don't hurt, but I want to try to take use_avatar out entirely. I try to simplify where possible. On the other hand I add fields. For example, I can now let members put an RSS feed on their member page. And I added a simple math captcha from sNews to my registration form.

I'll share the finished product when I have it, so you can tell me where I messed up and broke security etc. wink

Thanks. It seems obvious, but sometimes I just don't know where to start. Posting here also helps me keep track of what I'm doing and finding solutions when I need them again later.

I'll see what happens if I remove all three of these lines (and any other mentions of use_avatar I can find). I'll report back later...

Smartys wrote:

If you upload a picture, use is set to yes. If you delete a picture, it's set to no. If you want to remove it, simply search for the code in profile.php

I use the resize-on-upload modification and I'm reorganizing the profile edit menus. I don't know why, but use_avatar does not get set automatically on upload or delete. I probably broke something, but that doesn't matter.

My question is how to take use_avatar out of the equation. Or set it to default 1. Removing all the lines that mention use_avatar from profile.php probably won't do it. Or would it?

What's a grep?

It doesn't matter where to display the avatar, I just want to make sure that whereever the code asks for an avatar it actually gets shown, that it's not sabotaged by a sneaky 0 in use_avatar.

Thanks MattF, but that part is already sorted out.

My problem is that even if you upload a picture, it only shows up if the user selects "Use avatar" (use_avatar in MySQL). This setting is hidden somewhere in PunBB's vague multilevel profile editing menus.

I want to simplify it; upload a picture and the picture shows up. Don't want a picture? Delete it and you'll get the "no picture" default. I want to take "use_avatar yes or no" out of the equation or at least make it default yes.

I want to "force" all my members to use avatars, because I have a customized punbb with a "no picture" picture that shows up when there's no avatar available. That gives members enough choice; if they don't want to upload a picture, they get the "no picture" badge of shame. ;-)

I changed the existing zeroes into ones with this query:

UPDATE users SET use_avatar = 1

How can I permanently lock use_avatar to 1? Or entirely remove the check from the code?

MattF wrote:

$username = '\''.$db->escape($firstname.' '.$lastname).'\'';

Thanks again.

This worked as well:

$username = $firstname.' '.$lastname;

Does 'db->escape' have advantages?

MattF wrote:

The exact same way as in the answer you were given last time you asked this question.
http://punbb.org/forums/viewtopic.php?id=16844

I looked at that, but it's not the same thing, is it? In that case I wanted to output from the database. In that case you call the field with something like "firstname".

In this case I want to equate "$username" with "$firstname $lastname" to submit data into the database. It's not at all obvious to me that these would require the same syntax and there are still many variations possible from the solution on that link to this situation.

Anyway, Smartys solution allowed me to test the principle, but only the firstname was entered as username. Edit: My mistake again. Should have used surname instead of lastname.

The solution works for me. I had to remove checks for the username. They are no longer needed, because using the real name kinda builds some checks in.

But I still need to figure out the right syntax. I'll try some variations...

Probably this?

$username = $firstname.' '.$lastname;

Yes, that works! Nice. Thanks a lot for the pointers. It saved me a lot of time puzzling.

I like this solution. It really simplifies the registration - just name and email. Any downsides I'm overlooking?

Thanks again Smartys! I'll give this a try.

But how can I get a space between first and last name? Something like this:

$username = '.$firstname.' '.$lastname.';
elbekko wrote:

It might be better to show the real name instead of the username where it's displayed.

OK, thanks for the reply, but that's not what I meant, need or asked about.

I want to simplify the registration process and login process as much as possible, make it as transparant as possible. Full name and email address would be enough. Good riddance BS usernames.

Apart from that, my question is a coding/syntax question. If I want to do this, how should I do it? Would adding

$username = $firstname $lastname

with the correct syntax do the trick? What would the correct syntax be?

Please, can any PHP-er give me a pointer on the correct syntax so I can at least try?

Or is there a way to search for the correct PHP syntax of these things? When I put "$username=" in a search engine the markup elelements are ignored and I get only irrelevant results about "username".

Another syntax question from this non-PHP coder...

I'd like to use the full names of members as usernames, instead of the silly fantasy names people are forced to come up with.

I guess I have to add a line before this line in register.php:

$db->query('INSERT INTO users ...

I guess I have to add something like this (and remove a seperate username field from the form and elsewhere in the code):

$username = $firstname $lastname

But what would the right syntax be? And would that do the trick?

And would it mess up the system? I've found no problems with spaces and capitals in usernames.