submit_post not parsing bbcode

Discussion forum for MOD Writers regarding MOD Development.
Locked
anarchOi
Registered User
Posts: 52
Joined: Fri Jan 06, 2006 11:48 pm

submit_post not parsing bbcode

Post by anarchOi » Mon Jul 08, 2013 9:34 pm

When adding a new topic with submit_post() the bbcodes are not parsed. For example if i try to add an image to the post it will just display

Code: Select all

[img]http://www.example.com/test.gif[/img]
instead of displaying the image

enable_bbcode is set inside the submit_post() function

Code: Select all

'enable_bbcode'=> TRUE
what's wrong ?

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: submit_post not parsing bbcode

Post by EXreaction » Tue Jul 09, 2013 2:12 am

What code are you using when you call submit_post?

ungovernable
Registered User
Posts: 27
Joined: Sun Jul 24, 2011 7:37 pm

Re: submit_post not parsing bbcode

Post by ungovernable » Tue Jul 09, 2013 8:28 am

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);




$topictitle = "test";
$topictext = "[IMG]http://www.anarcho-punk.net/banner.jpg[/IMG]";
$userid = 2;
$username = "test";
$forumid = "102";

$query = "SELECT * FROM phpbb_topics WHERE topic_title = '$topictitle' AND forum_id = '$forumid' AND topic_poster = '$userid'";
$res = mysql_query($query) or die(mysql_error());
$exist = mysql_num_rows($res);
if ($exist == 1) {
echo "item # $itemnumber already exists ($title)<br><br>";
}
if ($exist == 0) {
echo "item # $itemnumber posted ($title)<br><br>";

		$user->data['user_id'] = $userid;
		$user->data['username'] = "$username";
		$user->session_begin();
		$auth->acl($user->data);
		$user->setup();
		$realuserdata= $user-> data;

		$sql= 'SELECT u.* FROM '. USERS_TABLE. ' u WHERE u.user_id= 2';  // Your account of choice
		$result= $db-> sql_query( $sql );
		if( $row= $db-> sql_fetchrow( $result ) ) {
			// Only overwrite Keys which actually exist, no other ones
			foreach( $row as $k1=> $v1 ) if( isset( $user-> data[$k1] ) ) $user-> data[$k1]= $v1;
		};
		$db-> sql_freeresult( $result );

		  $poll = $uid = $bitfield = $options = '';
		  $allow_bbcode = true;
		  generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
		  generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

		$newdata= array
		( 'topic_title'=> $topictitle
		, 'post_text'=> '$topictext'
		, 'poster_id'=> $user-> data['user_id']
		, 'forum_id'=> $forumid  // Forum of choice
		, 'force_approved_state'=> TRUE
		, 'icon_id'=> 0
		, 'enable_bbcode'=> TRUE
		, 'enable_smilies'=> FALSE
		, 'enable_urls'=> TRUE
		, 'enable_sig'=> TRUE
		, 'message'=> '[IMG]https://www.google.ca/images/srpr/logo4w.png[/IMG]'
		, 'message_md5'=> md5( $message )
		, 'bbcode_bitfield'=> $bitfield
		, 'bbcode_uid'=> $uid
		, 'post_edit_locked'=> FALSE
		, 'topic_type'=> POST_NORMAL
		, 'enable_indexing'=> TRUE
		, 'notify_set'=> FALSE
		, 'notify'=> FALSE
		, 'post_time'=> time()
		, 'topic_first_poster_name' => '$username'
		);

		$aUnused= array();
		submit_post( 'post', $newdata['topic_title'], $user-> data['username'], $newdata['topic_type'], $aUnused, $newdata, TRUE, FALSE );

		// Revert data from logged on user
		$user-> data= $realuserdata;
} // fin post
?>

ungovernable
Registered User
Posts: 27
Joined: Sun Jul 24, 2011 7:37 pm

Re: submit_post not parsing bbcode

Post by ungovernable » Tue Jul 09, 2013 10:18 am

Fixed it. Had the wrong variable in generate_text_for_storage... stupid error hehe

Locked

Return to “[3.0.x] MOD Writers Discussion”