A new Periodic Spore?

Manages technical infrastructure for the board and website; make administrative requests here

Moderator: Erik Mortis

Post Reply
User avatar
Scott of Hyperborea
Posts: 2816
Joined: Wed Mar 24, 2004 5:17 pm
Location: Ireland

A new Periodic Spore?

Post by Scott of Hyperborea »

The old Periodic Spore didn't work because it never got updated.

However, the Malarbor bar itself does get updated quite often. I think it would be cool if there were some way to archive each Malarbor bar automatically after it was saved. All the old updates would be saved to a .txt file or a blog or something with dates, so anyone who wanted to see what was happening in Shireroth on June 11, 2008 could look up the Malarbar for that day.

Would that take a lot of programming work?
User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: A new Periodic Spore?

Post by Ari Rahikkala »

I made a forum for Malarbor updates. If my calculations are correct, the Malarbor text should always be taken from the content of the first post of the newest thread on that forum (by postID and topicID respectively). The Malarbaristas should be able to post new threads on that forum, whereas normal users should only be able to reply.

(do we want to allow replies, actually? Might be a better idea to ensure the archive is in chronological order...)

Currently the only special feature of that forum is snarfing the Malarbar text from post contents. It's not quite obvious how to design the interface for the other features (changing the text that normally says "Malarbor says", and changing the Malarbor image), but I propose:

- the beginning of the post title, until the first colon character, is taken as the "Malarbor says" part of the text. Thus, you could name those threads something like "Malarbor says: Hasan I replaced by Kaiser Mortisberg III", to make the archive more useful.

- if the first line of the post contains nothing but an URL (specifically, if it starts with "http://", use that as the source for the Malarbor image. If it contains other text, use the default image.
No-one should be without a parasol, Sirocco.
User avatar
b3n|<3r|\|
Posts: 1536
Joined: Sun Feb 24, 2008 3:51 pm

Re: A new Periodic Spore?

Post by b3n|<3r|\| »

*drool*

Wonderful ideas Ari. I think that would work.
Vilhelm von Benkern - The Dolphin-...Count
:: Formerly just "benkern"
:: Rook Sentry of the Order of the Vorpal Blade
:: Count of Mar Sara IIRC
:: Former Baron of Absentia AFAIK, before that Baron of Vorpmadal TBH; also Former Duke of Yardistan IMHO
:: Dux Emeritus of the Order of Mischievous Intent

It takes moo to mango!
Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: A new Periodic Spore?

Post by Erik Mortis »

This is.. BRILLIANCE! All around.
User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: A new Periodic Spore?

Post by Ari Rahikkala »

Jonas was asking me for the code to this, for Batavia's use... I'm going to go to sleep very soon, but before that, here's the important bit in include/functions.php:

Code: Select all

$malsays_forum = 177; // this per-site magic number is the forum ID of the forum that the Malarbor updates will go on
global $bbcode;

// this query gets the content plus the bbcode stuff that I don't understand from the oldest post of the newest threads on the $malsays_forum forum
$sql = "SELECT post_text, bbcode_uid, bbcode_bitfield FROM phpbb_posts AS p JOIN phpbb_topics AS t ON p.topic_id = t.topic_id WHERE t.forum_id = $malsays_forum ORDER BY t.topic_id DESC, p.post_id ASC LIMIT 1;";


$result = $db->sql_query ($sql);

$malsays; // don't blame me, I'm a C programmer, I need to declare my variables no matter what :(

if ($row = $db->sql_fetchrow ($result)) { 
  $message = $row['post_text'];
  $message = censor_text ($message); // I'm not quite sure what censor_text exactly does. I *hope* it censors words in the censorlist out of text.

// all the bbcode-related lines are just snarfed from different parts of the phpbb codebase, don't ask me how they work
  $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); 
  $bbcode = new bbcode(base64_encode($bbcode_bitfield));

  $bbcode->bbcode_second_pass ($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
  $malsays['message'] = smiley_text (bbcode_nl2br ($message));
}
else {
  $malsays['message'] = "Nothing, actually."; // put in a really stupid replacement if there's no post in the database to read the message out of
} 

// the following comment and the last two lines of code are from phpBB.
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
'MALSAYS_TITLE' => "Malarbor says",
'MALSAYS_MESSAGE' => $malsays['message'],
'MALSAYS_PICTURE' => "images/malarbor.png",
'SITENAME'                                              => $config['sitename'],

'SITE_DESCRIPTION'                              => $config['site_desc'],
'PAGE_TITLE'                                    => $page_title,
You can find out the place in functions.php where this code is supposed to go by searching for the last two lines - they're there in the original phpBB. Basically, what's going on in here is that the first part (from the first line to $template->assign vars...) reads the content of the appropriate message (the oldest message in the newest thread on the announcements forum) in to $malsays, and the second part feeds the content (plus a few other things for which I'm currently using default values - that's going to change, I guess) into phpBB's template system.

For this code to work, the bbcode class needs to be available in functions.php. This is easy to do: Just add

Code: Select all

include_once ("bbcode.php");
to the beginning of the file. The problem with that is that PHP will die on you if you try to load the class several times, so you'll also have to change "include" to "include_once" *everywhere else where bbcode.php is loaded*. Here's the list of files that include_once bbcode (I'm pretty sure that on most of these, the include_once was there to begin with and I only changed a few - I just don't remember which ones I changed anymore :()

Code: Select all

]$ grep -R include_once.\*bbcode.\*\$phpEx *
includes/functions_posting.php:		include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/ucp/ucp_pm_viewmessage.php:		include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/ucp/ucp_pm_viewmessage.php:				include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/mcp/mcp_queue.php:					include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/mcp/mcp_warn.php:			include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/mcp/mcp_reports.php:					include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/mcp/mcp_topic.php:		include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
includes/mcp/mcp_post.php:		include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
memberlist.php:				include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
search.php:				include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
viewtopic.php:include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);



You should begin by backing the board up and then trying to apply these changes to it. Don't forget to change those includes to include_onces *before* you add that one include_once to functions.php - otherwise PHP will yell at you for redeclaring the bbcode class.

The most important thing that you'll gain from all this is the variable MALSAYS_MESSAGE that you can use anywhere in the template code. To make use of it... well... this is very, very board-specific. You should just check template/overall_header.html in the style that you're using and see where you can put it.
No-one should be without a parasol, Sirocco.
Post Reply

Return to “Ministry of the Interior”

Who is online

Users browsing this forum: No registered users and 5 guests