(2011-12-26, 08:24 PM)Dennis Tsang Wrote: [ -> ]Can you post the code you're using both in xmlhttp.php and the button? I'm kind of confused what this does.
It's a plugin which user can Put his message between [payment=money][/payment] tag and the other users buy that message by clicking on it's button.
All of the functions work perfectly but after click on the buy button the post will be displayed without BBCODE translation:
And the page should be refreshed for translating BBCODE tags !
XMLHTTP:
function bank_buy()
{
global $db, $lang, $theme, $mybb, $post, $posts, $parser, $charset, $forum, $posthandler, $message;
require_once MYBB_ROOT."inc/functions.php";
require_once MYBB_ROOT."inc/functions_post.php";
$lang->load("bank");
if ($mybb->input['action'] == "pay" && $_SERVER['REQUEST_METHOD']=="POST")
{
if(!verify_post_check($mybb->input['my_post_key'], true))
{
xmlhttp_error($lang->invalid_post_code);
}
$pid=$_GET['pid'];
$tid=$_GET['tid'];
$money=$_GET['pay'];
$uid = intval($mybb->user['uid']);
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."bank_pay WHERE uid=$uid");
$result=$db->fetch_array($query);
$query1 = $db->query("SELECT * FROM ".TABLE_PREFIX."posts WHERE pid=$pid");
$result1=$db->fetch_array($query1);
$pst=$result1['message'];
$post = get_post($pid);
$pay=intval($result['pay']);
if (!$uid)
{
xmlhttp_error($lang->not_user);
}
if($money>$pay)
{
xmlhttp_error($lang->send_notmonay);
}
else{
buy_do($pid,$tid,$money,$uid);
}
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$parser_options = array(
"allow_html" => $forum['allowhtml'],
"allow_mycode" => $forum['allowmycode'],
"allow_smilies" => $forum['allowsmilies'],
"allow_imgcode" => $forum['allowimgcode'],
"allow_videocode" => $forum['allowvideocode'],
"me_username" => $post['username'],
"filter_badwords" => 1
);
if($post['smilieoff'] == 1)
{
$parser_options['allow_smilies'] = 0;
}
$post['message'] = $parser->parse_message($pst, $parser_options);
echo $post['message']
}
}
JS File:
function pay(postid,threadid,pay)
{
this.spinner = new ActivityIndicator("body", {image: "images/spinner_big.gif"});
pid = postid;
tid = threadid;
new Ajax.Request('xmlhttp.php?action=pay&pid='+ pid +'&tid='+ tid +'&pay='+ pay +'&my_post_key='+ my_post_key, {method: 'post',postBody:"pid="+pid, onComplete:pay_done});
return false;
}
function pay_done(request)
{
if(this.spinner)
{
this.spinner.destroy();
this.spinner = '';
}
if(request.responseText.match(/<error>(.*)<\/error>/))
{
message = request.responseText.match(/<error>(.*)<\/error>/);
alert(message[1]);
}
else if(request.responseText)
{
var message=request.responseText;
$("pid_"+pid).innerHTML = message;
Thread.qeCache[pid] = "";
}
}
Button:
<input type="button" value="'.$lang->money_buy.'" name="bank_bt" onclick="pay(\''.$pid.'\',\''.$tid.'\',\''.$pay.'\')" >