Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 11-12-2004, 11:26 PM   #1
Member (7 bit)
 
shartken's Avatar
 
Join Date: May 2004
Posts: 89
Send a message via Yahoo to shartken
Logging user's time viewing a page

I am setting up a sight where users pay for time to view a live video stream. I am having a little trouble setting up how to log the user's time viewing a page, and then kick them out when they're time has expired if they are still viewing that page.

I was thinking of making a two tables, one called IN and one called OUT. It will have the user ID, date, and time.

I don't know how to update the OUT table when a user leaves the page, since it is hard to pass to the server when a browser window is closed or when the page is left.

One idea I had was to run an infinite for loop, using a META refresh command that updates a record every minute or so. I am also using flash, so I could make an imbedded movie that loops every minute to update the OUT table.

If anyone did this before, please let me know what the correct way to do this would be.
shartken is offline   Reply With Quote
Old 11-12-2004, 11:44 PM   #2
Moderator
Staff
Premium Member
 
Join Date: Aug 2003
Location: Richmond, VA
Posts: 7,835
It may be only possible to make this with Flash or something like Java...thinking right off the top of my head, it would be rather hard to keep count on the server side (because Client side they control) and still let it be accountable.

kram
__________________
"For today, goodbye. For tomorrow, good luck. And forever, Go Blue!"
University of Michigan President Mary Sue Coleman
kram 2.0 is offline   Reply With Quote
Old 11-13-2004, 03:25 PM   #3
Member (7 bit)
 
shartken's Avatar
 
Join Date: May 2004
Posts: 89
Send a message via Yahoo to shartken
I think you are right. You have to do this on the client side. I tried implementing this and found using two tables very difficult, because you have to match up which OUT time goes to which IN time. I just combined them into one table that looks like this:

Userid IN OUT TIMESTAMP ID(index)

I have allow nulls set for OUT, and when the user enters the website, a PHP script sets the userid, and in, fields so it looks like this:

userid IN OUT TIMESTAMP ID
2 2004-1113-160933 2004-1113-160933 1

This script also saves the ID of the above record in a session variable.
Then I have a flash object run a PHP script called which runs an update query that updates the OUT field every minute based on the ID stored in the session.

It will then have to run a GROUP_BY (userid) query of this table which will have a calculated field total_time AS SUM(out-in) WHERE 'userid=$current_userid'. This will create a value for total_time_used.

Then the PHP script will compare the total_time_used with the total_time_bought. If the total_time_used is greater than total_time_bought, it will bring them to a new page. If not, it will exit the script.

I don't know what type of load this will put on the server. I expect a maximum of 10 simultaneous page viewers, so the server will run this 2 query script, producing 20 queries a minute max, which isn't too bad.

I surprised that this service hasn't been developed before, with all the adult websites out there

Comments, anyone?
shartken is offline   Reply With Quote
Old 11-13-2004, 03:30 PM   #4
Member (7 bit)
 
shartken's Avatar
 
Join Date: May 2004
Posts: 89
Send a message via Yahoo to shartken
Oh, yeah. Once I have this developed, I will put it on my website. Open sourced all the way!!!
shartken is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:11 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2