vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP Code in template (https://vborg.vbsupport.ru/showthread.php?t=191898)

cmmguy 09-25-2008 08:08 PM

PHP Code in template
 
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.:

PHP Code:

// ### 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
HTML Code:

<!-- 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:
PHP Code:

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".


All times are GMT. The time now is 04:20 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02093 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete