phpBBHacks.com - Tracking Visitors Throughout Your PHP Enabled Website
BadBoyForums.com, an unofficial Diddy and Bad Boy fan community
StatsForums Home   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in
FAQFAQ   SearchSearch   MemberlistMemberlist   TutorialsTutorials   ContactContact Us
Add Us:     MySpace     Facebook     StumbleUpon
Username:    Password:
Remember Me?    
Tracking Visitors Throughout Your PHP Enabled Website
BlinkList
del.icio.us
Furl
linkaGoGo
reddit
Simpy
Mister Wong
Yahoo! My Web

Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Integrating phpBB With Your Website
 See a User Guidelines violation? Please contact us.
Author Message

Lee McDermott
New User

Joined: 14 Dec 2002
Posts: 20

PostPosted: February 2nd 2003, 7:31 am    Post subject: Tracking Visitors Throughout Your PHP Enabled Website Reply with quote

The following tutorial is my first. Please let me know if you like it.

This will briefly teach you how to dynamically track the location of visitors throughout your website.

phpBB features a "Who is Online" feature displayed within the Administration index. What some people don't know is that it's possible to create your own options such as "Viewing site Homepage," etc.

To do this, your site must first initiate the userdata variable throughout every page you wish to track visitors. For this to work, all required phpBB config files need to be included. This can be done by pasting this first piece of code into your page(s):

Code:
<?define('IN_PHPBB', true);
$site_root_path = './';         // MAY NEED CHANGING
$phpbb_root_path2 = 'forum/';      // MAY NEED CHANGING
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
?>


Notice the part reading "PAGE_INDEX." This tells the phpBB session management system that you are viewing the Forum Index which is eventually displayed in the Admin CP. What we're gonna do is alter this to display different messages whilst also keeping old ones intact.

Next step: Open language/lang_english/lang_main.php with your favorite .txt editor and find the following line: $lang['Viewing_FAQ'] = 'Viewing FAQ';

Below this line, add a new variable to the array stating your own message. ie: $lang['Viewing_Homepage'] = 'Viewing Homepage';

Remember to take a note of what you entered. Now close and save the file and backtrack to your phpBB root directory and open the following file: includes/constants.php. Within the document find the following line: define('PAGE_GROUPCP', -11);

After the line add new lines to define what phpBB will recognize and also remember to increment the trailing number by 1 for each line you add. For example: define('VIEWING_HOMEPAGE', -12);

Save, Close and once again keep a note of what you entered.

Finally, we're gonna put it all together by configuring files within the admin directory. Once there open index.php and find the following:

Code:
case PAGE_PRIVMSGS:
                     $location = $lang['Viewing_priv_msgs'];
   $location_url = "index.$phpEx?pane=right";
                     break;


Please note that the above is found twice in the document and the following will need to therefore be added twice. After this add the following and change the variables according to what you previously entered.

Code:
case VIEWING_HOMEPAGE:
                     $location = $lang['Viewing_Homepage'];
   $location_url = "index.$phpEx?pane=right";
                     break;


That's basically it except for one thing. Remember right at the beginning when we initiated the $userdata variable on the homepage? Well, replace the red text with VIEWING_HOMEPAGE.

Now every time someone visits your site homepage outside of phpBB, it will be displayed in the Admin Index in the usual fashion.

The process will only display the one message but the process can be repeated multiple times to keep track of visitors ANYWHERE in your site. Cool, eh?

For more information on dynamic websites with phpBB, visit AJ Quick's brilliant tutorial.
Back to top
View user's profile Send private message

Thoul
VIP

Joined: 30 Jul 2002
Posts: 17676
Location: USA

PostPosted: March 31st 2004, 2:11 pm    Post subject: Reply with quote

Here's a minor addition. There is code in viewonline.php that is similar to that in admin/index.php.

In that file, look for the following:
Code:
            case PAGE_FAQ:
               $location = $lang['Viewing_FAQ'];
               $location_url = "faq.$phpEx";
               break;


After it, add this. You can replace file.php with the filename of the page you're tracking visitors on.
Code:
            case VIEWING_HOMEPAGE:
               $location = $lang['Viewing_Homepage'];
               $location_url = "file.php";
               break;

_________________
Phantasy Star: The Fringes of Algo

Install, remove, or upgrade SQL with Advanced DB Update Generator! Now with phpBB 3 Support!

My phpBB Books, Hacks, and Other Works «·» 70+ Listings @ phpBBHacks.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Integrating phpBB With Your Website All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Links: Big Message Boards - Free JavaScript - phpBB2 - phpbb styles - Suporte phpBB - phpBB.it - phpBB Česky - phpBB Turkiye - phpBBArabia.com - phpBB-fr.com - Romanian phpBB online community - phpBB-TW.net - phpBBservice.nl - phpBB Brasil

Network: iFroggy Network Blog - iFroggy Hosting - SportsForums.net - KarateForums.com - YanksBlog.com - PhotoshopForums.com - DeveloperCube - Managing Online Forums - ManagingCommunities.com - CommunityAdmins.com - DrGregHouse.com - Bad Boy Blog - BadBoyForums.com - SodaRatings.com - Patrick O'Keefe

< Advertising - Contact Us - Staff - User Guidelines >

Copyright © 2001-2008. iFroggy Network, phpBBHacks.com. All Rights Reserved. Privacy Policy. We Support phpBBHacks.com (of course!).
Powered by phpBB © phpBB Group. phpBB SEO. Hosted by 100MegsWebHosting. We are in no way affiliated with the phpBB Group. phpBB is copyright to the phpBB Group.