Ok, a little background, I run a forum at
www.sitesyntax.com (Coincidentally it also has to do with coding websites, however, I haven't learned php yet)...
I've been coding a section where users can post a tutorial and have it show up. I've got the posting down, and I've got the list of tutorials down. I did it by making an invisible forum that it posts to.
What I still have to do is use AJAX to make a post clicked on the list show up in the main area, and I have to make it grab the most recent post out of the database and display it.
I can make it show the first (ie opposite of most recent) post show up, but it doesn't parse BBcode, and it does parse HTML.
Of course, this is a big security risk (As any forum owner would know).
Anyways, here's the code I use.
message is entered as the name of a <textarea> form element.
This is the php code for the display page
PHP Code:
<?php
// ########################################################################
// ## This page was ##
// ## Created by Jess O'Neill ##
// ## With help from Zoints Engineers ##
// ## Copywrite 2006 ##
// ########################################################################
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'tutorials');
Vbulletin stuff....
#######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
($hook = vBulletinHook::fetch_hook('tutorials')) ? eval($hook) : false;
$navbits = array();
$navbits[$parent] = 'tutorials';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
$threads = $db->query_read("SELECT thread.threadid, thread.title AS title, thread.forumid AS forumid,
thread.postuserid AS userid, thread.postusername AS username, thread.dateline,
thread.firstpostid, pagetext
FROM " . TABLE_PREFIX ."thread AS thread
LEFT JOIN " . TABLE_PREFIX ."post AS post ON ( thread.firstpostid = post.postid )
WHERE forumid = 23
ORDER BY thread.lastpost");
while ($thread = $db->fetch_array($threads))
{
eval('$tutorialslistbit .= "' . fetch_template('adv_portal_tutorialslistbit') . '";');
}
$recent = $db->query_first("SELECT thread.threadid, thread.title AS title, thread.forumid AS forumid,
thread.postuserid AS userid, thread.postusername AS username, thread.dateline,
thread.firstpostid, pagetext
FROM thread AS thread
LEFT JOIN post AS post ON ( thread.firstpostid = post.postid )
WHERE forumid = 23
ORDER BY thread.lastpost;");
$vbulletin->input->clean_array_gpc('p', array(
'message' => TYPE_NOHTML,
));
require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($vbulletin->GPC['message']);
eval('$tutorialslist = "' . fetch_template('adv_portal_tutorialslist') . '";');
eval('$tutorialsrecent = "' . fetch_template('adv_portal_tutorialsrecent') . '";');
eval('print_output("' . fetch_template('adv_portal_tutorials') . '");');
?>
(Everything under $recent is what control the recent tutorial part... What would switch it from getting the first post to the most recent post?
This is the php for the post page
PHP Code:
$vbulletin->input->clean_array_gpc('p', array(
'message' => TYPE_NOHTML,
));
require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($vbulletin->GPC['message']);
eval('print_output("' . fetch_template('adv_portal_tutorialsnew') . '");');
?>
The posts show up in the hidden forum with bbcode parsed and html not. But when they are loaded at
www.sitesyntax.com/vb/tutorials.php (You may have to be a member to see this page, I'm not totally sure), the bbcode is unparsed, and the html is.
The recent tutorial on there should read "<b> makes
bold</b>" instead of "
makes [ b]bold[/ b]"
Anybody with an understanding of php,sql, and vb that can help me out with this?