vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   [HowTo] Add Custom Pages to WOL (https://vborg.vbsupport.ru/showthread.php?t=82882)

noppid 06-10-2005 10:00 PM

[HowTo] Add Custom Pages to WOL
 
I'd like to suggest we follow the the way we did this in the past for the most part. We usually hacked into the two switch statements in the functions_online.php file. So staying with that convention, we can all easily coexist in the two necessary plugins will we need to use to accomplish this.

Why did I say coexist? Well based on this thread, multiple use of hooks, it seems it would be best to share a common plugin to a given hook location for now. That is if I understand it correctly.

So moving right along, this will help you create WOL plugins for your custom pages either way. If we all share a plugin or if we get a system that manages multiple plugins to a given hook, this should be a good example to follow when you need to display custom addin page WOL information.

There are two hook locations we need to add plugins to:
  • vBulletin : Who's Online? -> online_location_process
  • vBulletin : Who's Online? -> online_location_unknown

Add the online_location_process hook plugin...
Hook Location: online_location_process
Name: WOL Online Location Process
Active: YES
Code:
PHP Code:

if($filename=='YOUR_ADDIN_FILE.php'){$userinfo['activity'] = 'YOUR_ACTIVITY';} 


Add the online_location_unknown hook plugin...
Hook Location: online_location_unknown
Name: WOL Online Location Unknown
Active: YES
Code:
PHP Code:

if($userinfo['activity']=='YOUR_ACTIVITY')
{
    
$userinfo['where'] = '<a href="YOUR_ADDIN_FILE.php?'.$vbulletin->session->vars[sessionurl].'">'.$vbulletin->options[bbtitle].' YOUR_ACTIVITY</a>'
    
$userinfo['action'] = 'YOUR_ACTIVITY';
    
$handled true;



Following this convention should allow us to coexist in one plugin for each of those hooks or create good plugins for those hooks, either way.

I hope this is in the spirit of the howto forum and will be useful.

Regards

Revan 06-11-2005 09:12 AM

Thank you for this Howto, I earlier made a request for a new hook location in the middle of the switch() at vBcom, but I guess I can just make myself a new switch inside those 2 locations.
I did think of this myself, but I found it to be a better idea to be able to plugin in the middle of the switch. We'll see what the devs do :)

noppid 06-11-2005 11:19 PM

I thought that the logical place for this was in the switch too. But we can accomplish the same thing here.

My initial thought is that a hook in the switch would be more efficient then the bunch of if()'s this may create.

This will evolve. There's always more then one way to skin a cat. ;)

Creative Suite 06-12-2005 04:28 PM

wow..

merk 06-15-2005 12:53 AM

Quote:

Originally Posted by noppid
I thought that the logical place for this was in the switch too. But we can accomplish the same thing here.

My initial thought is that a hook in the switch would be more efficient then the bunch of if()'s this may create.

This will evolve. There's always more then one way to skin a cat. ;)

Im not sure that a hook inside the switch would work how you guys think it will.

You could just add another switch statement in your plugin code instead.

a few ifs wont slow the page down.

Revan 06-15-2005 08:31 AM

"a few"? You obviously have not seen the WOL location list for the RPG hack :p
Not saying it WILL slow it down, just saying that a hook in the middle of the switch as well would be more useful.

Marco van Herwaarden 06-15-2005 09:09 AM

Quote:

Originally Posted by Revan
"a few"? You obviously have not seen the WOL location list for the RPG hack :p
Not saying it WILL slow it down, just saying that a hook in the middle of the switch as well would be more useful.

Then please suggest so at vb.com.

PS i agree a hook at that spot would be welcomed.

Andreas 06-15-2005 10:58 AM

Erm ... you can't put the hook "in the middle of the switch".
You can only put one above it, below, or in one (ore more) of the case: statements - and this is how it does currently work: The hooks are in case default:, eg. will be executed when there is an unknown location.
Now if you have several custom locations put another switch there and everything is just fine.

noppid 06-15-2005 05:57 PM

I agree, maybe if a plugin has multiple pages to deal with, it should be inside an if() and have it's own switch statement to make it efficient?

Revan 06-15-2005 06:51 PM

Quote:

Originally Posted by MarcoH64
Then please suggest so at vb.com.

PS i agree a hook at that spot would be welcomed.

Been there, done that (quite literally as well) ;)
Quote:

Originally Posted by KirbyDE
Erm ... you can't put the hook "in the middle of the switch".
You can only put one above it, below, or in one (ore more) of the case: statements - and this is how it does currently work: The hooks are in case default:, eg. will be executed when there is an unknown location.
Now if you have several custom locations put another switch there and everything is just fine.

You can put a hook location in the middle of a switch just fine.
Remember before, when we edited the function to put in our own case:'s? That is what I mean. A hook that allows us to add case: instead of switch() in the default:

Andreas 06-15-2005 06:56 PM

Try it.
Place a custom hook somewhere between the cases and see what happens ;)

Revan 06-15-2005 07:41 PM

No. Because if I do that and Im wrong, Im gonna look stupid. So Im right until I am proven wrong from my own attempts, and seeing as I will not attempt it, I am right. ;)
*whistles*

Andreas 06-15-2005 07:49 PM

*G*
OK, I'm gonna try to explain the problem:
If you place a hook somewhere between the cases, it will never be executed - as it would be considered part of the case above the hook.
But this code ends with a break; - and thus the switch() is finished.

Now if you leave out the break; the hook would be executed - but only for this case.

zetetic 06-15-2005 07:51 PM

Quote:

Originally Posted by KirbyDE
The hooks are in case default:, eg. will be executed when there is an unknown location. Now if you have several custom locations put another switch there and everything is just fine.

This seems like the easiest solution to me. Just have one plug-in called "New WOL Entries" that contains its own switch statement, and update it every time you add a new plug-in. I don't see what's wrong with that approach...

Andreas 06-15-2005 07:54 PM

Quote:

Originally Posted by tmhall
This seems like the easiest solution to me. Just have one plug-in called "New WOL Entries" that contains its own switch statement, and update it every time you add a new plug-in. I don't see what's wrong with that approach...

I've gone one step further and adapted the existing Add WOL Locations from ACP Hack to create/update the necessary hook code automatically, so you can easily add/edit Locations without having to write a single line of PHP Code :)

zetetic 06-15-2005 07:56 PM

Quote:

Originally Posted by KirbyDE
I've gone one step further and adapted the existing Add WOL Locations from ACP Hack to create/update the necessary hook code automatically, so you can easily add/edit Locations without having to write a single line of PHP Code :)

Oh cool. I didn't even know that hack existed. :)

Dream 08-03-2005 04:26 AM

shouldnt process be setting the info and location unknown choosing the activity

Jako 08-04-2005 05:06 AM

I'm a bit confused on exactly where I need to add those lines of code. I'm currently using 3.0.8 so if anyone knows exactly where to add those lines of php code, I would really appreciate it.

GilbertZ 08-28-2005 10:30 PM

Thanks for the how to.
1.
Quote:

Originally Posted by KirbyDE
I've gone one step further and adapted the existing Add WOL Locations from ACP Hack to create/update the necessary hook code automatically, so you can easily add/edit Locations without having to write a single line of PHP Code :)

Could you provide the url please :)

2.
Jako, this is for 3.50. Doesn't work for 3.08.

3.
One question about this how to. Is the "Activity" a phrase? Can you provide an example of what "YOUR_ACTIVITY" would look like?

Quote:

Originally Posted by noppid
PHP Code:

if($filename=='YOUR_ADDIN_FILE.php'){$userinfo['activity'] = 'YOUR_ACTIVITY';} 

PHP Code:

if($userinfo['activity']=='YOUR_ACTIVITY')
{
    
$userinfo['where'] = '<a href="YOUR_ADDIN_FILE.php?'.$vbulletin->session->vars[sessionurl].'">'.$vbulletin->options[bbtitle].' YOUR_ACTIVITY</a>'
    
$userinfo['action'] = 'YOUR_ACTIVITY';
    
$handled true;




Andreas 08-29-2005 02:31 AM

1. => See my Profile

Jenta 10-07-2005 07:31 PM

seems u cant do phrasing in...
$userinfo['where'] = '<a href="YOUR_ADDIN_FILE.php?'.$vbulletin->session->vars[sessionurl].'">'.$vbulletin->options[bbtitle].PHRASE</a>';
unless someone wants to explain to me how

you can use them under viewing blah(the description) though

ps. can someone delete all the redirects in here?

dreamer81 11-08-2005 03:38 PM

uhhhhhh how do I add hooks? or do this???? ???

MrBen 02-18-2006 09:36 PM

How would I go about adding a custom WOL line for a URL like somepage.php?foo=bar

$filename only contains somepage.php so is there another variable that contains the querystring?

Thanks,
Ben

IrPr 04-11-2006 08:51 AM

Quote:

Originally Posted by imported_MrBen
How would I go about adding a custom WOL line for a URL like somepage.php?foo=bar

$filename only contains somepage.php so is there another variable that contains the querystring?

Thanks,
Ben

Me Too!

MrBen 04-12-2006 06:00 PM

Quote:

Originally Posted by IrPr
Me Too!

This is what I did in the end... It's basically the same as the OP but you add some code in another hook.


There are three hook locations we need to add plugins to:
  • vBulletin : Who's Online? -> online_location_preprocess
  • vBulletin : Who's Online? -> online_location_process
  • vBulletin : Who's Online? -> online_location_unknown

Add the online_location_preprocess hook plugin...
Hook Location: online_location_preprocess
Name: WOL Online Location PreProcess
Active: YES
Code:
PHP Code:

if ($loc == '/folder/index.php?foo=bar' OR $loc == '/folder/?foo=bar')
{
    
$filename 'foo_bar.php';


The rest is the same as the OP but I'll post it here for completeness...

Add the online_location_process hook plugin...
Hook Location: online_location_process
Name: WOL Online Location Process
Active: YES
Code:
PHP Code:

if($filename=='foo_bar.php'){$userinfo['activity'] = 'YOUR_ACTIVITY';} 


Add the online_location_unknown hook plugin...
Hook Location: online_location_unknown
Name: WOL Online Location Unknown
Active: YES
Code:
PHP Code:

if($userinfo['activity']=='YOUR_ACTIVITY')
{
    
$userinfo['where'] = '<a href="YOUR_ADDIN_FILE.php?'.$vbulletin->session->vars[sessionurl].'">'.$vbulletin->options[bbtitle].' YOUR_ACTIVITY</a>'
    
$userinfo['action'] = 'YOUR_ACTIVITY';
    
$handled true;


Ben

phill2003 09-03-2006 08:58 PM

Hi,

This is brill but i have a question if i may.

How do i go about giving seperate locations if 2 files share the same name. i have a gallery with an index.php and the whos online gives the location as the home page because thats index as well.

I tried this.

Code:

if ($loc == '/folder/index.php')
{
    $filename = 'index.php';

in the preprocess to hopefully get it to recognose the different index.php but it didnt.

Antivirus 10-15-2006 12:29 AM

One thing I notice about this is it only seems to work when the user is logged in, otherwise if it's a guest viewing a custom page, it just says "Viewing Index". Is there any way to get it to show custom locations for guests as well?

harmor19 10-16-2006 06:21 AM

Thank you for the tutorial.

ruinernix 10-18-2006 01:55 AM

I coded this to show my index.php properly, so I don't have to edit vb's code.. may have to customize it for your own needs ;) it's working for me... so I can show my pages from index.php and use hooks to properly name/show them. Hope it helps.

PHP Code:

require_once('global.php');
require_once(
'includes/functions_user.php');

if(
$vbulletin->userinfo['userid'] > 0
    
$location $vbulletin->db->query_first("SELECT location,sessionhash FROM " TABLE_PREFIX "session WHERE userid = ".$vbulletin->userinfo['userid']." ORDER BY lastactivity DESC LIMIT 1");
else
    
$location $vbulletin->db->query_first("SELECT location,sessionhash FROM " TABLE_PREFIX "session WHERE sessionhash = '".$vbulletin->session->vars['dbsessionhash']."' ORDER BY lastactivity DESC LIMIT 1");

if(
$location['sessionhash'] != "") {
    
$vbulletin->db->query_first("UPDATE " TABLE_PREFIX "session SET location = 'konspiracy.php?"$_SERVER["QUERY_STRING"] ."', lastactivity = '"TIMENOW ."' WHERE sessionhash = '"$location['sessionhash'] ."' LIMIT 1");
} else {
    
$vbulletin->db->query_first("INSERT INTO `session` ( `sessionhash` , `userid` , `host` , `idhash` , `lastactivity` , `location` , `useragent` , `styleid` , `languageid` , `loggedin` , `inforum` , `inthread` , `incalendar` , `badlocation` , `bypass` , `profileupdate` ) 
        VALUES ( '"
$vbulletin->session->vars['dbsessionhash']."', ".$vbulletin->userinfo['userid'].",  '".IPADDRESS."' , '".$vbulletin->session->vars['idhash']."', '".TIMENOW."', 'konspiracy.php?"$_SERVER["QUERY_STRING"] ."', '".$_SERVER["HTTP_USER_AGENT"]."', '0', '0', '1', '0', '0', '0', '0', '0', '0');");



Antivirus 11-10-2006 11:09 PM

Thanks Ruinerix, i think that will help, going to try it out this weekend.

Jon_Simmonds 03-03-2007 07:25 PM

I have a couple of scripts I want to link to my WOL but the scripts are in subdomains, any suggestions or pointers on how to write the WOL plugin for this to work?

Dream 03-24-2007 08:40 PM

I know you won't see this, but thank you worked like a charm :)

ArnyVee 12-08-2008 03:53 AM

Is this method still the way to go?

Just making sure before I do some work on my custom pages :D

vietfancy 01-12-2009 06:21 PM

Now that i can do something with my board.

Thanks

shooterdfl 03-29-2009 10:44 PM

Thanks for this, it works fine with the army and vbadvanced cmps mods. Using vbulletin 3.8.1.P1

HG-ILUSION 05-09-2009 01:37 AM

Quote:

Originally Posted by ruinernix (Post 1099285)
I coded this to show my index.php properly, so I don't have to edit vb's code.. may have to customize it for your own needs ;) it's working for me... so I can show my pages from index.php and use hooks to properly name/show them. Hope it helps.

PHP Code:

require_once('global.php');
require_once(
'includes/functions_user.php');

if(
$vbulletin->userinfo['userid'] > 0
    
$location $vbulletin->db->query_first("SELECT location,sessionhash FROM " TABLE_PREFIX "session WHERE userid = ".$vbulletin->userinfo['userid']." ORDER BY lastactivity DESC LIMIT 1");
else
    
$location $vbulletin->db->query_first("SELECT location,sessionhash FROM " TABLE_PREFIX "session WHERE sessionhash = '".$vbulletin->session->vars['dbsessionhash']."' ORDER BY lastactivity DESC LIMIT 1");

if(
$location['sessionhash'] != "") {
    
$vbulletin->db->query_first("UPDATE " TABLE_PREFIX "session SET location = 'konspiracy.php?"$_SERVER["QUERY_STRING"] ."', lastactivity = '"TIMENOW ."' WHERE sessionhash = '"$location['sessionhash'] ."' LIMIT 1");
} else {
    
$vbulletin->db->query_first("INSERT INTO `session` ( `sessionhash` , `userid` , `host` , `idhash` , `lastactivity` , `location` , `useragent` , `styleid` , `languageid` , `loggedin` , `inforum` , `inthread` , `incalendar` , `badlocation` , `bypass` , `profileupdate` ) 
        VALUES ( '"
$vbulletin->session->vars['dbsessionhash']."', ".$vbulletin->userinfo['userid'].",  '".IPADDRESS."' , '".$vbulletin->session->vars['idhash']."', '".TIMENOW."', 'konspiracy.php?"$_SERVER["QUERY_STRING"] ."', '".$_SERVER["HTTP_USER_AGENT"]."', '0', '0', '1', '0', '0', '0', '0', '0', '0');");



How I can use this?

It says "Unknow location" but it works.

Thanks

MagicThemeParks 09-20-2009 10:24 PM

I just followed the instructions and added the two plugins, but when I refresh the "Who's Online", it gives me a white screen with the following error....

Code:

Error 2 (net::ERR_FAILED): Unknown error.
....any ideas/suggestions on what I can do to fix this?


All times are GMT. The time now is 08:30 PM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02014 seconds
  • Memory Usage 1,871KB
  • 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
  • (2)bbcode_code_printable
  • (9)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (37)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