PDA

View Full Version : PHP Code in template


cmmguy
09-25-2008, 08:08 PM
I am trying to get a piece of code to work that would usually sit in a php file. I want it in a section of a template. This function (is supposed to) return the string that is appended to the url for the chatbox. This string will autolog the user on with their user name from the forum.

For some reason unknown to my limited experience, the function does not work - I had it located in the index.php file. Here is the Function part.:


// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTTA HERE... ###
($hook = vBulletinHook::fetch_hook('forumhome_complete')) ? eval($hook) : false;

// ### CHAT integration: start ###
function shoutmix($name = '') {
return htmlspecialchars(
'&name='.rawurlencode($name)
.'&code='.md5($name.'XXXXXXXXX'));
}
$shoutmix = $vbulletin->userinfo['userid'] ? shoutmix($vbulletin->userinfo['username']) : '';
// ### CHAT integration: end ###


[Note: the XXXXXXXXX is the key for my chatbox

I think the function is in the wrong location to work or the scope is not right or ??
Can I move or recode this into only the template so that I dont have to worry about those details? Could someone suggest a recode of the template part to include what is function.

If I get this working, I would like to post the outcome as a new ChatBox solution.

Thank you and please "drill" me with any questions.

J



This is the actual code for the footer

<!-- Begin CHAT - http://www.shoutmix.com -->
<iframe title="chatname" src="http://www2.shoutmix.com/?chatname$shoutmix" width="160" height="400" frameborder="0" scrolling="auto">
<a href="http://www2.shoutmix.com/?chatname$shoutmix">View shoutbox</a>
</iframe>
<!-- End CHAT -->






NOTE: This is for a chatbox that will be in the side column of forum with the modification in the footer template(using the side column mod).

Dismounted
09-26-2008, 05:40 AM
Plugin @ global_start:
if ($vbulletin->userinfo['userid'])
{
$shoutmix = '&name=' . rawurlencode($vbulletin->userinfo['username']) . '&code=' . md5($vbulletin->userinfo['username'] . 'XXXXXXXXX');
}

cmmguy
09-29-2008, 03:59 PM
That works! Thank you so much.

Now, when a user logs out, how can I clear that variable so that the Chat box does not stay logged on.

Dismounted
09-30-2008, 05:17 AM
I don't know how your chat box works - so I cannot comment.

cmmguy
10-01-2008, 02:44 PM
I appreciate your help.

If I can clear the variable $shoutmix by setting it to $shoutmix="" that would log off during the next screen refresh.

What hook is right after the vbulletin logoff steps? Or where can I find that info.

Thanks

Dismounted
10-01-2008, 02:58 PM
You could have found that info quite easily in login.php. The hook is logout_process. You will need to bring the variable into scope first by doing "global $shoutmix".