Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Mod Name / Version: Small Site Statistics 1.0

Description: This modification will collect and display in a box (like a pals box) the hits per month on your site. It can be altered to show the OS used, language etc.

Working Under: UBB.Threads 6.0-6.1-6.2-6.3

Mod Status: Finished

Any pre-requisites: none

Author(s): dimopoulos

Date: 06/06/03

Credits: Nikos Dimopoulos

Files Altered: The file that you want to collect the data, usually index.php

New Files: statistics.php

Database Altered: Yes, new table visits created

Info/Instructions: CAUTION!!!
This script will most probably increase the load on your database significantly, especially if you have a busy site. If you place the script that collects data in your front page then every visitor will require one hit in the database, so be careful before implementing it.

Instructions are included in the attached file.

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.


Attachments
83262-Small Site Statistics 1.0.zip (0 Bytes, 66 downloads)


Nikos
Sponsored Links
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Screenshot of what you will be able to see in a few months if you implement this modification.
Attachments
83263-visits.jpg (0 Bytes, 49 downloads)


Nikos
Joined: Jan 2003
Posts: 338
Enthusiast
Enthusiast
Offline
Joined: Jan 2003
Posts: 338
Very nice:

http://zlosnik.pl - look at the bottom of page

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Does this record hits, or unique visits?

Joined: Mar 2001
Posts: 644
Member
Member
Offline
Joined: Mar 2001
Posts: 644
Very cool Nikos.

Looks like it counts hits... I went to Slawek_L's link, hit refresh and it counted the refresh.

I'd like something like this for unique visitors myself, I have some users who just sit on the site all day and refresh.

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Very cool!

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
Very nice work


- Allen wavey
- What Drives You?
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Thanks guys.

Josh (other) and Zackary. Yes it will count hits even if they come from people that sit all day long and refresh the page.

I was thinking of incorporating some sort of a cookie to the user's machine which will tell the script that this user has visited the site and no longer do we need to keep these statistics. But how can you justify what is a valid time to live for a browsing? To me if a user hits refresh on a page just to increase the counter is not a valid hit, but the person who is there and reads some posts, does something else later and then refreshes the page again is a valid hit.

We can definitely enhance the script to become a proper pal box and to have it integrated with IIP providing information like the hits per day/month/year, referrer checks etc.

Once again this is not meant to replace retro stats or any other statistics package (especially your raw webserver files). And make sure that if you run this script on your site to monitor the MySQL performance over the period that you run the script. From personal experience, if you have a small site like mine circa 150 hits a day on average then you are fine. For more hits a day, please run your own metrics and let us all know about it.




Nikos
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
For the life of me I can't get this to work. I know the answer is staring me in my face.

I keep getting SQL Database only visible to forum administrator's.

I have cleared cookies. I have checked the MYDSL tables and I have even flushed and recreated. The code below is what I enter into the index.php

// --------------------------------------------------------------------------------------------------

// Include the threads main.inc.php file
include_once("{$palspath}/main.inc.php");

// Get the referrer information
$strPathInfo = addslashes(find_environmental("PATH_INFO"));
$strPathTranslated = addslashes(find_environmental("PATH_TRANSLATED"));
$strRemoteAddress = addslashes(find_environmental("REMOTE_ADDR"));
$strRemoteHost = addslashes(find_environmental("REMOTE_HOST"));
$strHTTPAccept = addslashes(find_environmental("HTTP_ACCEPT"));
$strHTTPAcceptLanguage = addslashes(find_environmental("HTTP_ACCEPT_LANGUAGE"));
$strHTTPUserAgent = addslashes(find_environmental("HTTP_USER_AGENT"));
$strHTTPCookie = addslashes(find_environmental("HTTP_COOKIE"));

// Initialize variables
$strQuery = "";

$strQuery = "
INSERT INTO visits
(
path_info,
path_translated,
remote_addr,
remote_host,
http_accept,
http_accept_language,
http_user_agent,
http_cookie
)
VALUES
(
'$strPathInfo',
'$strPathTranslated',
'$strRemoteAddress',
'$strRemoteHost',
'$strHTTPAccept',
'$strHTTPAcceptLanguage',
'$strHTTPUserAgent',
'$strHTTPCookie'
)
";
$dbh -> do_query($strQuery);

$strQuery = "SELECT COUNT(*) FROM ffff_visits";
$sth = $dbh -> do_query($strQuery);
list($lngTotalVisits) = $dbh -> fetch_array($sth);

$lngTotalVisits = number_format($lngTotalVisits);

$dbh -> finish_sth($sth);

// --------------------------------------------------------------------------------------------------

Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Chuck,

There is a slight error in the instructions (I should have used find/replace).

In my database I call the table ffff_visits while in the modification that I havge posted it is called visits. Hence the statement:
Code
<br />$strQuery = "SELECT COUNT(*) FROM ffff_visits";<br />$sth = $dbh -> do_query($strQuery);<br />list($lngTotalVisits) = $dbh -> fetch_array($sth);<br />

should be in fact
Code
<br />$strQuery = "SELECT COUNT(*) FROM [:"red"]visits[/]";<br />$sth = $dbh -> do_query($strQuery);<br />list($lngTotalVisits) = $dbh -> fetch_array($sth);<br />

Sorry about that everybody. I have ammended the instructions and also added an image file (bluebar.jpg) which needs to be in the images folder or wherever you need it to be (your choice in the script)


Nikos
Sponsored Links
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Nope must not like my server

If I put this in my index.php all I get is a white screen.

Same with statistics.php. I look and the table visits has a recorded entry for me. So its half working. But it stops the page from loading.

Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Weird. Let me check the scripts once more and I will let you know Chuck.


Nikos
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
I solved my problem by placing your script inbetween the Threada header and footer statements. So basically I modified it a bit.

You can see what I did. I placed your code in my index.php and then the resulting left code of statistics.php I made into the following attached.
Attachments
83510-statistics.txt (0 Bytes, 78 downloads)

Joined: Mar 2001
Posts: 644
Member
Member
Offline
Joined: Mar 2001
Posts: 644
Good points Nikos.

I'll consider this. I run the server here in my home and I don't get a HUGE amount of hits, but I hate to get "inflated" stats because I check the site between 5-10 times a day and I know other users do as well.

I have no other software or services to track stats on my site and this would be handy.

Thanks again for the great mod, I've added it to my "to add" list for when I upgrade to 6.3.

Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Chuck,

I can see what you did. Since I had that modification as a "pals" box on my site, I was sending the header and footer a lot earlier than this so I didn't need it. With your implementation you can have it even as a standalone page.

Thanks for that


Nikos
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Zackary,

I don't think that checking the site five or ten times a day makes inflated stats but I see what you mean. I had the same problem with a stupid person who managed to go and refresh so many times just to bring the counter up to 500,000. Fortunately I got there in time and killed his connection.

There is of course room for improvement on this script and if we all decide what is the acceptable time to live for a connection to become new then I can modify it to write to a cookie hence not double count hits.


Nikos
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Nikos yes I found out f from inadvertantly realizing from your directions you did not say pal box etc. So I tried running it standalone and realized wait it does not know what a tablewrapper variable is. HMM Okay let me add this and that. It's all good.

Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Nikos yes I found out f from inadvertantly realizing from your directions you did not say pal box etc. I did notice on this thread though it says can run in a box ( like a pal box ) So I tried running it standalone and realized wait it does not know what a tablewrapper variable is. HMM Okay let me add this and that. It's all good.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
badfrog
badfrog
somewhere on the coast of Maine
Posts: 94
Joined: March 2007
Forum Statistics
Forums63
Topics37,575
Posts293,932
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,835
Greg Hard 4,625
Top Posters(30 Days)
Gizmo 1
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)