vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Add Who's Online Locations From Admin CP (https://vborg.vbsupport.ru/showthread.php?t=66569)

Trigunflame 06-25-2004 10:00 PM

Add Who's Online Locations From Admin CP
 
General Info
This hack was requested to be available on Vbulletin 3. Being bored, I figured I would take the task in hand and complete it, to be better than it ever was before.

The original designer of the hack (on Vbulletin 2) is the well known Chen Avinadav, which being the great coder that he is, I dont particularly agree with his methods in this case, which he used a an excess query to select data from a template and loop through. This uses the built in datastore of vb3, therefore using No extra queries.

Therefore this hack is Completely original, in every way. I have used a different method, for accomplishing this, and the control panel I have created is intuitive and utlilizes a great many of vbulletins built in controls and phrases. Looking at the code itself on the admin panel alone you will see I didnt just throw this together and slap it on the site. Total creation time was around 4 hours, the code itself not being the main part, just mainly working out issues with the control panel etc..

Features
My version which is completely new, allows you to add the filename for the who's online along with the location name, and URL Title of the link.

The control panel which was the longest part, is pretty concise in how it works considering what I did to it. Provides a good bit of error checking to keep from accidentally doing stuff you didn't intend to do.

Also should note, the deletion part of the script uses JavaScript to confirm whether or not you wish to delete the selected Location.

I hope this gets a lot of installs, being as that my other 2 hacks/bug fixes were really just something I did in a few minutes and didn't put a great deal of effort into, judging by the fact I didnt have to "edit" any vbulletin files, to do what I wanted.

This is really my first release on this site, that I can say I believe is unique in its effort, and shows some insight on things for the newer coders out there. I have put a great deal of effort into the setup of everything as well as the readme file to be concise and as easy to read and understand as possible.

Hopefully hack of the month, lol.. j/k

Installation
I have provided an readme file inside of the zip, with information on how to install the hack, and what needs to be done to do so. Its a fairly easy installation, as you only have to add things.

Other Misc.
Files To Modify: 2
Total Modifications: 6
Installation Difficulty: Easy

Version Updates
Version 1.0 = First Release
Version 1.1 = Fixed Weird Query Error For Some People
Version 1.2 = Added ability to enable/disable links for locations

Click install if you like. Thanks. :)
https://vborg.vbsupport.ru/

RapCheck 06-26-2004 06:51 PM

Would this be able to differ things such as, index.php, index.php?page=contact, index.php?page=links all as different who's online locations?

So basically, using vbindex created pages, would I be able to add the extra pages to the who's online with this hack?

SnowBot 06-26-2004 06:57 PM

WOW so usefull :) nice work :)

Trigunflame 06-26-2004 06:58 PM

Quote:
---------------------------------------------------------------------
Would this be able to differ things such as, index.php, index.php?page=contact, index.php?page=links all as different who's online locations?


So basically, using vbindex created pages, would I be able to add the extra pages to the who's online with this hack?
---------------------------------------------------------------------

Maybe later I will implement that, but right now that would be way too much trouble. In the array I would have to specify what variable would determine which pages to look for, I obviously wouldnt just make it to match against ?page= only, then i would have to have it loop through sub arrays for that.

Thats a lot more than what this hack is generally designed for, its just to add it for different .php files.

If you want, a little later I will create a seperate hack and paste it in this thread just for that purpose of allowing multiple locations per .php file.

PHP Code:

$custom_online = array(
    
'testing.php' => array(
        
'activity' => 'testing.php',
        
'action' => 'Playing around',
        
'where' => 'Join the fun',
        
'sub' => array(
            
'page' => array(
                
'show' => array(
                    
'action' => 'showing stuff',
                    
'where' => 'come see'
                
),
                
'tell' => array(
                    
'action' => 'telling this',
                    
'where' => 'wanna tell'
                
)
            ),
            
't' => array(
                
'1' => array(
                    
'action' => 'viewing thread 1',
                    
'where' => 'come look'
                
),
                
'2' => array(
                    
'action' => 'viewing thread 2',
                    
'where' => 'come see'
                
)
            )
        )
    )
); 

Is an example of what that multidimentional array could look like...not very pretty, which is why i didnt make this hack to start off like that in the first place.

Princeton 06-26-2004 07:19 PM

installation was flawless :up:

Trigunflame 06-26-2004 07:22 PM

Were the instructions clear enough for your liking? How about the control panel? I wanna fix anything wrong if you see it.. lol

ChrisSy 06-26-2004 07:49 PM

excellent, a very useful hack- thankyou!

Acido 06-26-2004 07:55 PM

Works perfectly. Big Thanx !

FleaBag 06-26-2004 08:20 PM

Wasn't expecting this to come along so soon!

Getting an SQL error on the first install step at the moment. Attempting to work out why now. :)

Trigunflame 06-26-2004 08:24 PM

Hmm, can you paste the error, it should work fine with about any type of vb3 installation. Do you have table prefixes etc..?

FleaBag 06-26-2004 08:29 PM

Here you go... No table prefixes - I don't like to over-complicate.

Quote:

Database error in vBulletin 3.0.1:
Invalid SQL:
INSERT INTO datastore
VALUES ('custom_online', 'a:0:{}');
mysql error: You have an error in your SQL syntax near ';
' at line 3
mysql error number: 1064
Date: Saturday 26th of June 2004 02:28:44 PM

Dean C 06-26-2004 08:31 PM

This looks great! Thanks for sharing with the community :)

58sniper 06-26-2004 08:32 PM

I'm getting an error as well during the first step (running whos_online.php)

Code:

Database error in vBulletin 3.0.1:

Invalid SQL:
                        INSERT INTO datastore
                        VALUES ('custom_online', 'a:0:{}');
               
mysql error: You have an error in your SQL syntax near ';
                ' at line 3

mysql error number: 1064


FleaBag 06-26-2004 08:34 PM

Same error as myself.

Trigunflame 06-26-2004 08:41 PM

Try This

PHP Code:

Find This:

// Install
$DB_site->query("
    INSERT INTO "
.TABLE_PREFIX."datastore 
    VALUES ('custom_online', '"
.addslashes(serialize($array))."');
"
);

And 
replace it with this:

$DB_site->query("INSERT INTO " TABLE_PREFIX "datastore VALUES ('custom_online', 'a:0:{}')");

Tell me if that works.. 


FleaBag 06-26-2004 08:45 PM

That worked, thank you. :)

Trigunflame 06-26-2004 08:55 PM

Ok good, I reuploaded the zip file with the fix. Should work fine now for everyone.

FleaBag 06-26-2004 08:57 PM

Not sure where I went wrong... It doesn't seem to have worked. No errors, it just says that locations I have added are unknown locations.

Trigunflame 06-26-2004 09:00 PM

Show me a screenshot of your current (custom_online.php) in the browser. If you put the modifications where I told you, it should work just fine.

Remember its doing this based on single filenames, I havn't added support for multiple pages via ?this=that etc...

58sniper 06-26-2004 09:27 PM

The first posted fix resolved my issue as well. It's working now.

The one minor thing I'd change it the ability to NOT show a link to the particular location. I've managed to obtain that with this hack by just putting a space in the URL Display field. But a checkbox or something to not show a link would be nice..

Other than that, this was a MUCH needed hack and should become part of vBulletin

Dan 06-26-2004 10:44 PM

Quote:

Originally Posted by princeton
installation was flawless :up:

very nice :) looks very useful for some people

SnowBot 06-27-2004 12:14 AM

Question

If you have to files with same name but in 2 seperate directories how would you add them?

For example

forum/index.php
/links/index.php

ChrisBaktis 06-27-2004 12:17 AM

Awesome Hack!!!! I have been pulling my hair out trying to figure out how to do this manually - your a life saver!

** Chris Clicks Install!

Trigunflame 06-27-2004 12:48 AM

Ok people, cause of 58Sniper I updated the hack to allow you to enable/disable whether links are shown or not for locations.

Enjoy.

Trigunflame 06-27-2004 12:53 AM

Quote:

Originally Posted by SnowBot
Question

If you have to files with same name but in 2 seperate directories how would you add them?

For example

forum/index.php
/links/index.php

Unless you rewrote partly how vbulletin does this stupid, I dont believe that is possible. Vbulletin automatically finds filename by using REGEX to determine base filename, and then compares it doesnt look for which directory it is located in, as everything in its eyes are relative to itself (online.php)

Maybe try renaming one of them to a slightly different name, ie index2.php this can be done easily enough in vbulletins configuration files plus the

// Example
define('THIS_SCRIPT','index2.php');

directive at the top of each script name, helps the script know what its current filename is, when it referrs to itself.

ImportPassion 06-27-2004 12:55 AM

Quote:

Originally Posted by RapCheck
Would this be able to differ things such as, index.php, index.php?page=contact, index.php?page=links all as different who's online locations?


So basically, using vbindex created pages, would I be able to add the extra pages to the who's online with this hack?

I would like this as well, along with being to distinguish between 2 index.php in 2 diff dirs.
At least this is a jumping point.

SnowBot 06-27-2004 01:28 AM

Quote:

Originally Posted by Trigunflame
Ok people, cause of 58Sniper I updated the hack to allow you to enable/disable whether links are shown or not for locations.

Enjoy.

where are the upgrade instructions ? what do we have to change ? :) thanks

SnowBot 06-27-2004 01:31 AM

i got it btw but you may wanna add that to your first post :) to just overwrite the file :)

Trigunflame 06-27-2004 01:32 AM

Quote:
----------------------------------------------------------
I would like this as well, along with being to distinguish between 2 index.php in 2 diff dirs.
At least this is a jumping point.
----------------------------------------------------------

It would require a good bit of modification, I might release an update for that in a day or 2.

Quote:
----------------------------------------------------------
i got it btw but you may wanna add that to your first post to just overwrite the file
----------------------------------------------------------

Well you need to replace that code in the readme, on the (functions_online.php) file also, as I changed some directives.

wrongful 06-27-2004 01:47 AM

Thanks a lot. This is exactly what I needed. Installed fine. :)

teksigns 06-27-2004 04:08 AM

i found a bug !

example :
forum installed at:

/forum

i have a script thats installed at and uses the forum engine ....

/forum/links/links.php

my script shows up in the whos online fine and is clickable before i add
the new custom discription.

once i add it... it shows up and displays fine .
however the link is not pointing to the correct location

the link tried to take me to : /forum/links.php

not /forum/links/links.php

can you please fix ....

teksigns 06-27-2004 04:16 AM

ok i fixed it myself already !

heres how....


in : functions_online.php


find:

Code:

if ($value['showlink'] == 1)
{
        $userinfo['where'] = "<a href=\"$key?$session[sessionurl]\">$value[where]</a>";
}


replace with:

Code:

if ($value['showlink'] == 1)
{
$url = htmlspecialchars_uni(stripslashes($userinfo['location']));
$url = addslashes($url);
$url = preg_replace('/(s|sessionhash)=[a-z0-9]{32}(&|&amp;){0,1}/', '', $url);
if ($session['sessionurl'] != '')
{
if (strpos($url, '?') !== false)
{
$url .= "&amp;$session[sessionurl]";
}
else
{
$url .= "?$session[sessionurl]";
}}
        $userinfo['location'] = stripslashes(stripslashes($url));
        $userinfo['location'] = ereg_replace('&amp;','&',$userinfo[location]);
        $userinfo['where'] = "<a href=\"$userinfo[location]\">$value[where]</a>";
}


great hack !



Quote:

edited my post ....removed the function file include from the code ....

Acido 06-27-2004 09:31 AM

Quote:

Originally Posted by teksigns
ok i fixed it myself already !

heres how....


in : functions_online.php


find:

Code:

if ($value['showlink'] == 1)
{
        $userinfo['where'] = "<a href=\"$key?$session[sessionurl]\">$value[where]</a>";
}


replace with:

Code:

if ($value['showlink'] == 1)
{
        require_once('./includes/functions_login.php');
        $userinfo['location'] = stripslashes(fetch_replaced_session_url(htmlspecialchars_uni(stripslashes($userinfo['location']))));
        $userinfo['location'] = ereg_replace('&amp;','&',$userinfo[location]);
        $userinfo['where'] = "<a href=\"$userinfo[location]\">$value[where]</a>";
}


great hack !

I cant find the code in functions_online.php :(

Trigunflame 06-27-2004 10:59 AM

Quote:
---------------------------------------------------------
if ($value['showlink'] == 1)
{
require_once('./includes/functions_login.php');
$userinfo['location'] = stripslashes(fetch_replaced_session_url(htmlspecia lchars_uni(stripslashes($useri nfo['location']))));
$userinfo['location'] = ereg_replace('&amp;','&',$userinfo[location]);
$userinfo['where'] = "<a href=\"$userinfo[location]\">$value[where]</a>";
}
---------------------------------------------------------

That is not a bug in the script, all this does is compare filenames which im using vbulletins method. No way would i Include (functions_login.php) a Whole other functions file into the login functions.. a much easier way to do it im sure.

PET 06-27-2004 01:09 PM

exactly what i need ! No need to manualy edit php's :)

teksigns 06-27-2004 01:31 PM

Acido ,

you must have already installed his hack inorder to find the code ......

if you havent installed the hack itself then the code will not be there.

Oblivion Knight 06-27-2004 02:10 PM

Awesome, I'll take a look at this when 3.0.2 is released.. :)
I don't want to do any more modifying when there is another upgrade just around the corner.

teksigns 06-27-2004 02:16 PM

Quote:

Originally Posted by Trigunflame
Quote:
---------------------------------------------------------
if ($value['showlink'] == 1)
{
require_once('./includes/functions_login.php');
$userinfo['location'] = stripslashes(fetch_replaced_session_url(htmlspecia lchars_uni(stripslashes($useri nfo['location']))));
$userinfo['location'] = ereg_replace('&amp;','&',$userinfo[location]);
$userinfo['where'] = "<a href=\"$userinfo[location]\">$value[where]</a>";
}
---------------------------------------------------------

That is not a bug in the script, all this does is compare filenames which im using vbulletins method. No way would i Include (functions_login.php) a Whole other functions file into the login functions.. a much easier way to do it im sure.



ok i altered it so you it dont use the include any longer ......

this is the code im using now and it works just the same without the include .

Code:

if ($value['showlink'] == 1)
{
$url = htmlspecialchars_uni(stripslashes($userinfo['location']));
$url = addslashes($url);
$url = preg_replace('/(s|sessionhash)=[a-z0-9]{32}(&|&amp;){0,1}/', '', $url);
if ($session['sessionurl'] != '')
{
if (strpos($url, '?') !== false)
{
$url .= "&amp;$session[sessionurl]";
}
else
{
$url .= "?$session[sessionurl]";
}}
        $userinfo['location'] = stripslashes(stripslashes($url));
        $userinfo['location'] = ereg_replace('&amp;','&',$userinfo[location]);
        $userinfo['where'] = "<a href=\"$userinfo[location]\">$value[where]</a>";
}


hope this works for everyone else

Bryan Ex 06-27-2004 04:33 PM

Just so I'm clear before installing... will this work for indexing php pages outside the VB main directory? For example, an integrated application like a gallery script.

Trigunflame 06-27-2004 09:06 PM

Quote:

Originally Posted by teksigns
ok i altered it so you it dont use the include any longer ......

this is the code im using now and it works just the same without the include .

Code:

if ($value['showlink'] == 1)
{
$url = htmlspecialchars_uni(stripslashes($userinfo['location']));
$url = addslashes($url);
$url = preg_replace('/(s|sessionhash)=[a-z0-9]{32}(&|&amp;){0,1}/', '', $url);
if ($session['sessionurl'] != '')
{
if (strpos($url, '?') !== false)
{
$url .= "&amp;$session[sessionurl]";
}
else
{
$url .= "?$session[sessionurl]";
}}
        $userinfo['location'] = stripslashes(stripslashes($url));
        $userinfo['location'] = ereg_replace('&amp;','&',$userinfo[location]);
        $userinfo['where'] = "<a href=\"$userinfo[location]\">$value[where]</a>";
}


hope this works for everyone else

Ill post an addition tonight or tomorrow, thats still way to much code to do something so simple.


All times are GMT. The time now is 04:26 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.01317 seconds
  • Memory Usage 1,860KB
  • 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
  • (7)bbcode_code_printable
  • (2)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete