Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2013, 07:19 PM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default External PHP File - Display User Location in "Who's Online"

Hey all,
I have a question regarding external files.
To start off:
- I have vBulletin installed to mysite.com/forums.
- I have a homepage at mysite.com/index.php (which has working login to forums)

However, I've been unable to figure out what needs to be done so, if a user is viewing mysite.com/index.php, their User Location would read something like "Viewing Homepage SITENAME".
Essentially, I want it so there's a custom User Location that displays when a user is viewing mysite.com/index.php, because right now, the User Location only updates if the user is browsing any file in mysite.com/forums

Thanks for any and all help,
Mark
Reply With Quote
  #2  
Old 01-10-2013, 10:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You may be able to do it with a couple of plugins - I guess it depends on how the login on your home page is implemented. But if you look at this article https://vborg.vbsupport.ru/showthread.php?t=228112 and scroll to the bottom to the section "Instructions to Add your Page to the Who's Online List (WOL):", there's an example of the two plugins you need.
Reply With Quote
  #3  
Old 01-10-2013, 10:16 PM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You may be able to do it with a couple of plugins - I guess it depends on how the login on your home page is implemented. But if you look at this article https://vborg.vbsupport.ru/showthread.php?t=228112 and scroll to the bottom to the section "Instructions to Add your Page to the Who's Online List (WOL):", there's an example of the two plugins you need.
I've simply included global.php and copy and pasted the navbar login code into my homepage to get login to work.
Anyways, I gave your attempt a try. The location in the `session` table on my forums updates correctly (it displays / which means I'm on my homepage). Yet, on my Current Activity, it says 'Viewing Index SITENAME' instead of what is defined through the plugins you linked me to.
Reply With Quote
  #4  
Old 01-10-2013, 10:37 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...well, whatever you set $userinfo['activity'] to in the first plugin is the case you want to check for in the second plugin (it's 'mypage' in the example) - do you have yours that way? I think if the session table is showing '/' that must mean you used '/' and that the first plugin is working.

Edit: is your homepage called index.php? I suppose that might conflict with some of the existing cases.
Reply With Quote
  #5  
Old 01-10-2013, 10:50 PM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Hmm...well, whatever you set $userinfo['activity'] to in the first plugin is the case you want to check for in the second plugin (it's 'mypage' in the example) - do you have yours that way? I think if the session table is showing '/' that must mean you used '/' and that the first plugin is working.

Edit: is your homepage called index.php? I suppose that might conflict with some of the existing cases.
Yeah, my homepage is called index.php :/
Would renaming it to home.php be of some use?

P.S. For the Plugin online_location_process:
switch ($filename)
{
case '../':
Would '../' be correct, or would it need to be './' if I'm trying to evaluate the case of a file outside of my /forums/ directory?
Reply With Quote
  #6  
Old 01-10-2013, 10:58 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mko View Post
Yeah, my homepage is called index.php :/
Would renaming it to home.php be of some use?
That might work. You might also be able to create another plugin using hook online_location_preprocess and change $filename (if you can figure out how to know when you're on your homepage). For example, if you set a THIS_SCRIPT value in your home page (maybe with value 'homepage', then use this code on online_location_preprocess:

Code:
if (THIS_SCRIPT == 'homepage')
{
   $filename = 'homepage';
}

Then in the online_location_process plugin use case 'homepage'.

Quote:
P.S. For the Plugin online_location_process:
switch ($filename)
{
case '../':
Would '../' be correct, or would it need to be './' if I'm trying to evaluate the case of a file outside of my /forums/ directory?

I'm not sure - I'd probably need to set up a test and then print out the value to know for sure. But if the above works, then it won't matter.
Reply With Quote
  #7  
Old 01-10-2013, 11:20 PM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
That might work. You might also be able to create another plugin using hook online_location_preprocess and change $filename (if you can figure out how to know when you're on your homepage). For example, if you set a THIS_SCRIPT value in your home page (maybe with value 'homepage', then use this code on online_location_preprocess:

Code:
if (THIS_SCRIPT == 'homepage')
{
   $filename = 'homepage';
}
Then in the online_location_process plugin use case 'homepage'.




I'm not sure - I'd probably need to set up a test and then print out the value to know for sure. But if the above works, then it won't matter.
Alright. Renaming it to home.php works. I still get an 'Unknown Location' error.
My current online_location_process:
Code:
switch ($filename)
{
    case '../home.php':
        $userinfo['activity'] = 'homepage';
        break;
}
My current online_location_unknown:
Code:
switch ($userinfo['activity'])
{
    case 'homepage':
        $userinfo['where'] = '<a href="test.php?'.$vbulletin->session->vars[sessionurl].'">My Page</a>';
        $userinfo['action'] = "Viewing My Page";
        break;
}
It still seems to be an issue with the home.php's path, though :s

Also, for your snippet for online_location_preprocess, would I have to change the case in my online_location_process plugin to be 'homepage' instead of the filepath?
Reply With Quote
  #8  
Old 01-10-2013, 11:25 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you only need the file name, so maybe try using case 'home.php': and don't put any path.


Quote:
Also, for your snippet for online_location_preprocess, would I have to change the case in my online_location_process plugin to be 'homepage' instead of the filepath?

Yes, I believe so.
Reply With Quote
  #9  
Old 01-10-2013, 11:33 PM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think you only need the file name, so maybe try using case 'home.php': and don't put any path.

Yes, I believe so.
Neither of those options worked, sadly :c
I've tried: /home.php, ./home.php, ../home.php, /../home.php, ./../home.php, ../../home.php, home.php, and homepage.
Reply With Quote
  #10  
Old 01-11-2013, 12:25 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, you know, someone asked about this a while back and I made the same mistake - it doesn't work to check THIS_SCRIPT because that doesn't run until someone goes to look at the who's online info.

The idea of changing the script to home.php might work but I think maybe you need to call the function exec_shut_down() in your script or else the location never gets updated in the session table. (I think you can call it any time you're done with the vb part). And you don't need the online_location_preprocess plugin for that method.

(While you're trying that I'm going to look in to it more).
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:03 PM.


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.04685 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete