MyBB Community Forums

Full Version: MyBB News System - what is it?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here: http://www.mybboard.com/archive.php?year=2006&month=7

The query tags mimick that of system used by 4D from Russia, is this system available?

It's clean consice and querys also the forum posts, a definite must have particluarly the news archival portion..

So many times when a question like this is asked and the reply is "oh.. um.. it's 'in-house' only, er we don't give it out.." -translation: we chopped it from a paid script!

If its not available mod/hack, please describe the method of coding and layout.

(Yes I did try to search, but good luck.. keywords like MyBB, and portal are way too generic)

Thanks!
I'm almost certain that this is coded specially for MyBB by Chris himself, I rather doubt it's an copy.
There is some scripts on this forum that takes the news straight from the forum (not archive style but).
Search for "Displaying News on Homepage" (With the quotes) if that's what you wish for.
CraKteR Wrote:There is some scripts on this forum that takes the news straight from the forum (not archive style but).

thanks, I'm looking for the news archival system
Hi,

Yes, it is essentially custom written by myself. It integrates with the forums here so we can manage news from the User CP.

Attached is a copy of archive.php which is what I assume you were after. Do with it what you wish.

A copy of the SQL:
CREATE TABLE `news` (
  `nid` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(100) NOT NULL default '',
  `poster_uid` int(10) NOT NULL default '0',
  `poster_username` varchar(50) NOT NULL default '',
  `message` text NOT NULL,
  `dateline` bigint(30) NOT NULL default '0',
  `dateline_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `more_link` varchar(120) NOT NULL default '',
  PRIMARY KEY  (`nid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

And an example row:
(17, 'MyBB 1.1.7 Released', 1, 'Chris Boulton', 'Due to a low risk browser based cross-site scripting vulnerability found in MyBB, we''re releasing a security update to the MyBB 1.1.x series. The exact vulnerability allows cross-site scripting by invalid input in to an avatar URL which will then cause certain browsers (Internet Explorer) to execute that input.\r\n\r\nWe recommend all users upgrade their copy of MyBB to the latest available release.\r\n\r\nThe release on the MyBB site has also been updated to 1.1.7.\r\n\r\nA list of changed files and manual patching instructions can be found at the link below. All users are urged to update to this release.', 1154054742, '2006-07-28 02:45:42', 'http://community.mybboard.net/showthread.php?tid=10853');
Thankyou Chris,

I may have something amiss as after changing the paths to my specs it returns only a blankk page (yes, I did populate the 'news' db table). I see the 'archive.php' requires a "local.php" file, is this necessary?

Also you mention a means to manage this through the User-CP, have you the code for this? Smile

I wish this was all included with the forum package Wink
g0rdy Wrote:Thankyou Chris,

I may have something amiss as after changing the paths to my specs it returns only a blankk page (yes, I did populate the 'news' db table). I see the 'archive.php' requires a "local.php" file, is this necessary?

Also you mention a means to manage this through the User-CP, have you the code for this? Smile

I wish this was all included with the forum package Wink
Yeah, or at least fully released as a mod. Loadsa people woulduse it.
anyone figure this out?
Sorry, I figured you'd be able to piece it together and all you wanted was the general idea from it.

I've stripped the majority of it out as it relates to version checking, random testimonial fetching and some other things you won't need.

You'll need to change the mysql_connect and mysql_select_db lines to match your database configuration

Here is the contents of local.php:
<?php
if(!defined("NO_MYSQL") && $_SERVER['MYBB_MYSQL_HOST'])
{
	mysql_connect($_SERVER['MYBB_MYSQL_HOST'], $_SERVER['MYBB_MYSQL_USER'], $_SERVER['MYBB_MYSQL_PASS']);
	mysql_select_db($_SERVER['MYBB_MYSQL_DB']);
}

//
// /me pat pat photomatt.com
//
function autop($pee, $br = 1)
{
    $pee = $pee . "\n"; // just to make things a little easier, pad the end
    $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
    $pee = preg_replace('!(<(?:table|ul|ol|li|pre|form|blockquote|h[1-6])[^>]*>)!', "\n$1", $pee); // Space things out a little
    $pee = preg_replace('!(</(?:table|ul|ol|li|pre|form|blockquote|h[1-6])>)!', "$1\n", $pee); // Space things out a little
    $pee = preg_replace("/(\r\n|\r)/", "\n", $pee); // cross-platform newlines
    $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
    $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t<p>$1</p>\n", $pee); // make paragraphs, including one at the end
    $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
    $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
    $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
    $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
    $pee = preg_replace('!<p>\s*(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)!', "$1", $pee);
    $pee = preg_replace('!(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
    if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
    $pee = preg_replace('!(</?(?:table|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee);
    $pee = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $pee);
    $pee = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $pee);
    
    return $pee;
}
?>

As for the user CP plugin, I'm not sure I want to release it until I've at least cleaned it up a bit. Here is the query used to insert a new post, however:
	$now = time();
	$dategmt = gmdate("Y-m-d H:i:s", $now);
	$newsitem = array(
		"nid" => "NULL",
		"title" => addslashes($mybb->input['title']),
		"poster_uid" => $mybb->user['uid'],
		"poster_username" => addslashes($mybb->user['username']),
		"message" => addslashes($mybb->input['message']),
		"dateline" => $now,
		"dateline_date" => $dategmt,
		"more_link" => addslashes($mybb->input['more_link'])
		);
	$site_db->insert_query("news", $newsitem);
So nice of you to share Chris. Smile