PDA

View Full Version : Define new variable for showthread.php


doa24uk
08-03-2009, 01:14 PM
Hi guys,

I am wanting to define a new variable for use on showthread.php page ...

The variable is based on a previously defined variable from Psionic Vision's Hide Hack Resurrection - here (https://vborg.vbsupport.ru/showthread.php?t=179034)

The variable $message is already defined & outputted on showthread.php

I simply want to use $message to define a new variable like this

$message2 = base64_encode($message);

My question is, where should I put this code??

I have already asked on the support thread but Psionic has told me he doesn't support custom modifications ... cmon guys, it ain't that difficult!

I should say that there is a super useful & important mod waiting to be released that relies on this new variable....


Many thanks in advance

EnIgMa1234
08-03-2009, 01:28 PM
Have you tried including it in a plugin using one of the showthread hooks?

doa24uk
08-03-2009, 01:39 PM
ummm ......... please explain how I'd do this? Haven't really got my head round vbulletin structure yet....

ps. Thanks for the quick reply :)

Lynne
08-03-2009, 02:27 PM
You would create a plugin using a template_hook that takes $message and changes it how you want. I'm guessing that you would want to use one of hte postbit_ hooks (postbit_display_complete?)since $message is a postbit variable. So, you'd want something like:
$this->post['message2'] = base64_encode($this->post['message']);

doa24uk
08-03-2009, 04:06 PM
Aggghh I'm still lost. I've tried understanding it via this post (https://vborg.vbsupport.ru/showthread.php?t=188874) but I still can't get my damn head around it!

Lynne, do you know of any users on here I could contact to format my code into a mod (paid or unpaid)??

Lynne
08-03-2009, 04:29 PM
This will help you more - Adding or Editing a Plugin (http://www.vbulletin.com/docs/html/add_plugin) Try following that to create a plugin.

doa24uk
08-03-2009, 06:36 PM
I've created a new plugin

Product - vs hide Hack Resurrection
Hook Location - postbit_display_complete
Code -


$this->post['message2'] = "test-text";
echo $message2;


----

I've also tried without the echo - just $message2 & also tried echo'ing $message2 from postbit template ...

Nothing so far ... what the heck am I doing wrong??

Lynne
08-03-2009, 10:20 PM
you don't want to echo anything. Remove the echo and then put $message2 in your postbit.

doa24uk
08-04-2009, 09:19 AM
Hmm OK the test variables are working now, but I have a problem with teh original $message.

It seems like at some point the $message variable turns from being the text inside the HIDE tags

this content here

& at some point it is parsed into the entire post...



The full topic post is then held in the topic variable

this content here

See, like this



So I need a way to intercept it before it gets parsed as such..

Here's what's in the hide hack xml file (notice the $message variable - which does output the text I need correctly)


<template name="bbcode_hposts" templatetype="template" date="1155999281" username="admin" version="2.7.0"><![CDATA[<div style="margin: 5px 20px 20px 20px;" id="<if condition="$canview">enb<else />dis</if>_hhr_hide::{$this->vars['postid']}_{$hidefieldid}">
<table cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%">
<tr>
<td class="alt2" style="border:1px inset">
<div>$caption:</div>
<div style="font-style:italic">
<if condition="$canview">
$message
<else />
$vbphrase[hidetag_accessdenied]
</if>

</div>
</td>
</tr>
</table>
</div>]]></template>

And here's what is currently in the postbit_display_complete


$post['message'] = $GLOBALS['hhr']->parse_bbcode($post['message'], $forum['forumid'], $thread['threadid'], $post['postid'], $post['userid']);

Lynne
08-04-2009, 03:20 PM
Once you 'post' a message, the entire text includes any bbcode tags that you have in there. They aren't stored separately. So, I'm not sure about what you mean about intercepting it between when it is just the bbcode and when it is the full message.

doa24uk
08-04-2009, 03:52 PM
When creating a new topic or replying, a user can enter any text they wish between HIDE codes


Any text they wish


As you can see by the xml file in the previous posted, this is referenced by $message but then at some point the BBcode is parsed & the text above is combined with the other text in the post & the $message variable is overwritten so that it contains the entire post.

As far as I can tell, for me just to get "Any text they wish" I need to set the $message2 variable before it is parsed or combined into the "reformed" $message variable.

Here's the php script from the Hide hack if that's any help.... (next post)

doa24uk
08-04-2009, 03:55 PM
Here's the php file for the hide hack if this helps .....

Again, thank you so much for your patience & persistence Lynne! You're a star! (looks for the paypal button)

Lynne
08-04-2009, 04:11 PM
You realize that if you have post caching on, that the post is parsed when it is posted, not when it is displayed, right? So you need to 'intercept' the post when it is being posted, not displayed or else you won't be able to change what is hidden or not.

(I have no experience with hide hacks, so I'm really not the best person to help out with this.)

doa24uk
08-07-2009, 01:12 PM
Hi Lynne,

Ok so I've now been messing about with the newthread_post_start hook & it looks initially like this may be the area to be playing with (pre-caching)

Anyway, the HIDE hack has the following code in misc_bbcode_complete & I've managed to create a variable & echo it then exit() when the post is submitted, so I think we may be getting closer ... could you take a look at the php code & see if any answers are hidden there ??


// establish link to the engine
if (!isset($hhr)) { global $hhr; }

// initialize main bbcodes
$hhrbbcodes = array();
$shortcut = str_replace('|HIDE', '', $hhr->tags[$vbulletin->options['hidetag_shortcut']]);
$show['shortcut'] = false;

if (($vbulletin->options['enable_hposts_tag'] && ($permissions['hhroptions'] & $vbulletin->bf_ugp['hhroptions']['enable_hposts_tag'])))
{
if ($shortcut == 'HIDE-POSTS') { $show['shortcut'] = true; }
$hhrbbcodes['HIDE-POSTS'] = array(
'explanation' => $vbphrase['hidetag_explanation_hposts'],
'twoparams' => true,
'samplestamp' => 'X',
'sampleoption' => '5',
);
}
if (($vbulletin->options['enable_hrply_tag'] && ($permissions['hhroptions'] & $vbulletin->bf_ugp['hhroptions']['enable_hrply_tag'])))
{
if ($shortcut == 'HIDE-REPLY') { $show['shortcut'] = true; }
$hhrbbcodes['HIDE-REPLY'] = array(
'explanation' => $vbphrase['hidetag_explanation_hrply'],
'twoparams' => false,
);
}
if (($vbulletin->options['enable_htnx_tag'] && ($permissions['hhroptions'] & $vbulletin->bf_ugp['hhroptions']['enable_htnx_tag'])))
{
if ($shortcut == 'HIDE-THANKS') { $show['shortcut'] = true; }
$hhrbbcodes['HIDE-THANKS'] = array(
'explanation' => $vbphrase['hidetag_explanation_htnx'],
'twoparams' => false,
);
}
if (($vbulletin->options['enable_hrplytnx_tag'] && ($permissions['hhroptions'] & $vbulletin->bf_ugp['hhroptions']['enable_hrplytnx_tag'])))
{
if ($shortcut == 'HIDE-REPLY-THANKS') { $show['shortcut'] = true; }
$hhrbbcodes['HIDE-REPLY-THANKS'] = array(
'explanation' => $vbphrase['hidetag_explanation_hrplytnx'],
'twoparams' => false,
);
}
if (($vbulletin->options['enable_showtogroups_tag'] && ($permissions['hhroptions'] & $vbulletin->bf_ugp['hhroptions']['enable_showtogroups_tag'])))
{
if ($shortcut == 'SHOWTOGROUPS') { $show['shortcut'] = true; }
$hhrbbcodes['SHOWTOGROUPS'] = array(
'explanation' => $vbphrase['hidetag_explanation_showtogroups'],
'twoparams' => true,
'samplestamp' => 'X,Y,Z',
'sampleoption' => '5,6,7',
);
}

// construct shortcut bbcode
if ($show['shortcut']) {
$hhrbbcodes = array_merge(array('HIDE' => array(
'explanation' => construct_phrase($vbphrase['hidetag_explanation_hide'], strtolower($shortcut), $shortcut),
'twoparams' => false,
)), $hhrbbcodes);
}

// construct bbcodes
foreach ($hhrbbcodes as $code => $info) {
$code = strtolower($code);

$bbcode = array(
'title' => ucwords(str_replace('-', ' ', $code)),
'bbcodetag' => $code,
'bbcodeexplanation' => $info['explanation'],
);

if ($code != 'hide') {
if ($info['twoparams']) {
$bbcode['tag'] = '[' . $bbcode['bbcodetag'] . '=<span class="highlight">' . $info['samplestamp'] . '</span>]<span class="highlight">' . $vbphrase['value'] . '</span>[/' . $bbcode['bbcodetag'] . ']';
$bbcode['bbcodeexample'] = '[' . $bbcode['bbcodetag'] . '=' . $info['sampleoption'] . ']' . $vbphrase['hidetag_hidden_data'] . '[/' . $bbcode['bbcodetag'] . ']';
} else {
$bbcode['tag'] = '[' . $bbcode['bbcodetag'] . ']<span class="highlight">' . $vbphrase['value'] . '</span>[/' . $bbcode['bbcodetag'] . ']';
$bbcode['bbcodeexample'] = '[' . $bbcode['bbcodetag'] . ']' . $vbphrase['hidetag_hidden_data'] . '[/' . $bbcode['bbcodetag'] . ']';
}

$bbcode['output'] = $hhr->parse_bbcode($bbcode['bbcodeexample'], 0, 0, 0, 0);
eval('$template[\'bbcodebits\'] .= "' . fetch_template('help_bbcodes_bbcode') . '";');
} else {
eval('$template[\'bbcodebits\'] .= "' . fetch_template('help_bbcodes_hide') . '";'); // special case
}

eval('$template[\'bbcodelinks\'] .= "' . fetch_template('help_bbcodes_link') . '";');
}