Ninety percent of the time when this has cropped up in the past, it's been down to a second instance of PunBB running which had lax restrictions, which they were literally using as a backdoor to the main forum.

Gah. Now I feel like a dumbass. There was a backup directory sitting right there with 1.2.12 in it.

I'll see if that cleans it up. Thanks!

Hi folks,

Is there any (legit) way to add a user to the forum without using register.php? My forum has been sustaining a number of spambot attacks the last few days, so I temporarily disabled register.php with a simple die() statement at the top.

This morning, there were three more spammer accounts registered! I'm running 1.2.16, and it looks like they're inserting users right into the DB with an SQL injection attack somewhere. Is this a known weakness, or is there something else I'm not seeing? Is there an easy way to have Pun spew logs somewhere so I can observe it a little more closely and find out exactly what's going on?

Has anyone else seen anything like this?

3

(20 replies, posted in Feature requests)

I think PunBB could stand to take a page out of the Wordpress book in a lot of these cases. How about you skimp on the feature additions, and instead work on building up a nice corpus of plugin hooks? Then functionality that some value more than others can simply be implemented as a plugin... even if the plugin gets included with the default installations, it'll be something you can remove if you don't want it.

Then you can have code like:

if (!$pun_user['is_guest'] or plugin_force_guest())
// do stuff
else
//do other stuff

Of course, if there were a proper permissions handling library/object, then the hooks could be placed inside of that, but w/e. (I'm cautious about advocating too much abstraction... one of the huge strengths of Pun is how completely easy it is to find the code you're looking for...)

4

(2 replies, posted in Feature requests)

Well I'll be a dead-man; this is super-awesome news.

5

(2 replies, posted in Feature requests)

Hi Rickard, everyone,

I was wondering if it might be possible to include a few hooks into some of the display code. I'm not thinking of a whole plugin system like WP, simply some opportunities to augment various functions and arrays.

For example, I have a hack for linking to an on-site wiki, and I'd like to add one where users can indicate their L/L by putting [location]43.485731,-80.551908[/location] into their signature and have the parser hide that in regular display.

But I'm just leery of having to re-do these and other mods on every upgrade. In the example of bbcode parsing, couldn't there be code such as this in parser.php: (functions do_bbcode() and do_smilies(), respectively)

if (function_exists('punbb_mod_smilies')) punbb_mod_smilies($smiley_text, $smiley_img);
if (function_exists('punbb_mod_bbcode_regex')) punbb_mod_bbcode_regex($pattern, $replace);

Another example is the profiles. I've written a Mediawiki plugin that lets my users share logins between Pun and MW, and it would be cool to show MW-related data on their forum profiles. In that case, it would be down around lines 950-1000 in profile.php; add a few hooks similar to those above that would allow the output of an arbitrary function.

All we'd have to do is place/link those functions in the config.php file, and it's a way to perform slight modifications without bringing down the system on an upgrade.

I hope you'll consider this as a possibility. It's fairly unobtrusive, yet gives a lot of power to people who wish to *slightly* extend their PunBB.

Either way, thanks for a great (simple!) piece of software. Reading the Pun source is a breeze compared to dissecting the mess that is phpBB.

Mike

6

(5 replies, posted in PunBB 1.2 show off)

The comments link is just a link back to the thread itself, with the "replies". It's actually a little messy because Pun only keeps a link to the last post in the thread table, not a link to the first post:

    require_once(PUN_ROOT . 'include/parser.php');

    $large = 3; // full posts
    $small = 10; // parting shot links

    $query = 'SELECT id, poster, subject, posted, num_replies FROM `topics` WHERE forum_id=1003 ORDER BY posted DESC LIMIT ' . ($large + $small);
    $result = $db->query($query);
    
    while($large-- > 0)
    {
        $one = $db->fetch_assoc($result);

        $query_post = 'SELECT message, poster_id FROM posts WHERE topic_id='.$one['id'].' ORDER BY posted ASC LIMIT 1';        
        $result_post = $db->query($query_post);
        $one_post = $db->fetch_assoc($result_post);
        $full_text = $one_post['message'];
        
        echo '<h3>'.$one['subject'].'</h3>';
        echo '<h4>' . date("F j, Y", $one['posted']) . ' | ';
        echo '<a href="/forum/profile.php?id='.$one_post['poster_id'].'">'.$one['poster'].'</a></h4>';
        
        // parse BBCode; also convert smiley links
        echo str_replace('img/smilies/', '/forum/img/smilies/', parse_message($one_post['message'], 0));
        
        echo '<p class="permalink"><a href="/forum/viewtopic.php?id='.$one['id'].'">Discussion</a> ('.$one['num_replies'].')</p>';
    }
    
    // Parting shots
    echo '<h2 id="title-also">Also Recently</h2><div class="cleanlist"><ul>';
    while($one = $db->fetch_assoc($result))
    {
        echo '<li class="clearfix"><a href="/forum/viewtopic.php?id='.$one['id'].'">'.$one['subject'].'</a></li>';
    }
    echo '</ul></div>';

It's one initial query to get the titles and IDs of the threads, and then for each one that's being display in full, there's a second query to grab the text of it. There may be a more elegant solution involving GROUP BY or whatever, but this does the trick for a relatively low-volume site.

7

(7 replies, posted in PunBB 1.2 show off)

cody wrote:

Its a support/resource site for punbb.

Isn't there already... this one?

8

(5 replies, posted in PunBB 1.2 show off)

I've just switched us to a PunBB/Mediawiki combination from an old phpBB/Coppermine site.

PunBB: http://tron09.com/forum/

I'm pulling posts out of the first forum to create the news on the front page: http://tron09.com/

The usergroup system in Pun allows me to restrict access to certain users, and also appoint a subset as capable of posting to the front page.

I haven't changed the style much except to slap a header and footer on it. But I like the markup layout. I can tell that it won't be a major pain to style it. (Mediawiki was the biggest pain ever, but I beat it into shape...)

Yeah.

9

(33 replies, posted in News)

Rickard wrote:

If you like hdiff, wait until you encounter diff/patch. How the world would function without it is beyond me.

Hmm... I was all ready to write up some kind of script for applying the hdiff changes...

Then I realised that I'm on DreamHost and have shell access.

...

man patch

Interesting...

10

(2 replies, posted in PunBB 1.2 troubleshooting)

The markup around it is this:

<div class="inbox">
        <p class="postlink conr"><a href="post.php?tid=6394">Post reply</a></p>

So you can style the link with this:

.inbox .postlink a { color: #543; }

The mod that I've outlined above is described in full here:

http://punbb.org/forums/viewtopic.php?pid=50778

I'd asked about this here, so I'll just present my solution.

I have users segregated into public and private users, or "members" and "trons". I want the trons to have access to everything, and the members only the first two forums. This is covered by the engine. However, I also was the non-accessible forums to show up in the index listing, and a special message to show up when they're accessed by a non-tron.

In Index.php, around line 40, there's a big huge query. The entire WHERE condition needs to go, so it becomes this:

$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

In Viewforum.php, also around line 40, there's a condition immediately following the big query, which sends you to the "Bad Request" screen if you don't have permission or the forum doesn't exist. We want to split this so that it differentiates the two types of errors:

if (!$db->num_rows($result))
{
    $result = $db->query('SELECT f.forum_name FROM '.$db->prefix.'forums AS f WHERE f.id='.$id);
    if (!$db->num_rows($result))
        message($lang_common['Bad request']);
    else
        message($lang_common['No view']);        
}

Okay, you're done, unless you want to give the user a special message. In that case, change 'No view' above to 'Nope', and then add your custom line to the /lang/English/common.php file right below 'No view'.

You can see it all in action here: http://dev.tron09.com/forum/ (unless it's broken... this is a live dev site)

I like what I've got going with a combination forum/wiki for content management.

Example: http://tron09.com/

The News is a series of first-posts from forum topics.
"Top Trons" is highest posters from the forum.
The quotes are randomly selected lines from this wikipage.
"About" is currently a static block, but will soon be a pull from a wiki page.
"Sweet Links" is a del.icio.us inbox feed. (I may later control the feed subscriptions using a wiki page)

(All the news is outdated because it's an older DB snapshot that I'm doing the design around. And the design isn't finished; I know it's not quite right on IE.)

It definitely needs execute privs, since the cache contains files with PHP code in em.

If you can't set it to 777, can you chown it to the php user? (or else write a quick php script to "mkdir" a dir called cache somewhere that you can write, and then move it to the PunBB folder...)

15

(4 replies, posted in PunBB 1.2 troubleshooting)

I guess this is technically a "mod" question, but it's really just a regex question.

I want the following tags:

[wiki=Main Page]foo[/wiki]
[wiki=Main_Page]foo[/wiki]
[wiki]Main Page[/wiki]
[wiki]Main_Page[/wiki]

To all become links pointing to "/wiki/Main_Page"

So far I've modified the do_bbcode function in parser.php, and added these rules:

'#\[wiki\](.*?)\[/wiki\]#' -> '<a href="/wiki/$1" class="wikilink">$1</a>'
'#\[wiki=(.*?)\](.*?)\[/wiki\]#' -> '<a href="/wiki/$1" class="wikilink">$2</a>'

Is there some easy way to have it always convert underscores to spaces and vice-versa (depending on whether it's in the link or the label), without throwing an addition regex on there?

Thanks.

Paul wrote:

Not related to your question, but did you realise the forum is unusable on IE. The font-size needs adjusting. Because you are using a font size of 11px on body you need to delete the percentage font size which PunBB uses for IE.

I'm aware that the whole thing is a mess on IE. I develop mostly using Zend on a Linux box. IE bug-zapping is a later stage in development... but thanks for pointing it out.

My experience with PunBB has so far been peppered with pleasant surprises. The amount of thought that's gone into its design is clear in every facet. However, there's one small piece of functionality from phpBB that's I'd like to reproduce, if possible, without hacking the source:

Can I make a forum show up in the index.php listing, but then have viewforum.php redirect to a page asking the user to login or register?

The forum_perms table as described here just contains "read_forum", "post_replies", and "post_topics." I'm happy with all of the forums marked false for "read_forum" to still exhibit the behaviour outlined above, but before I hack the source to pieces, I'd like to check if this is something the plugin interface could handle...


(Not yet familiar with the plugin architecture...)

Thanks.

EDIT: Here's the board in question: http://dev.tron09.com/forum/ (there's about ten forums in all, and I'd like all of them to show on the index listing)

18

(71 replies, posted in Feature requests)

Connorhd wrote:

just put your header in main.tpl and remove the stuff you don't want from the current one? you don't need to display: none anything do you?

Ah, apparently I'm blind.

I had misunderstood the layout of main.tpl. Yes, I can see how to do it now, thanks. (and sorry for the bonehead question...)

19

(71 replies, posted in Feature requests)

I see .tpl files representing the different modes of operation, but would it be possible to have a head.tpl and foot.tpl that simply represent the "<div id="brdtitle" class="inbox">" and "<div id="brdfooter" class="block">" sections of the markup? I'm totally cool with designing on CSS, but I'd like to have a common header and footer across several portions of my site; something a little more graphically involved than what's possible with the markup available. (I understand that I could do it dumping stuff on top of main.tpl, and then display:none-ing the default header, but that's a bit of a hack... )