I have recently created a small webcam page. I want to figure out a way to count how many people are viewing the webcam at any one time. I think I can do this by using sessions. When the first user begins veiwing the webcam, a session is started. Once another user begins viewing the webcam, I'll start another session. This will continue giving me X amount of users viewing the webcam at the same time. Question number 1: Can I use count() to count the amount of session? Question number 2: I want to display the amount of sessions to everyone viewing the webcam, how?
The page I'm using does not yet contain any PHP, but it will. Here is the code from the page that will be displayed:
.:TUCK:.
The page I'm using does not yet contain any PHP, but it will. Here is the code from the page that will be displayed:
Code:
<html>
<head>
<title>Tuck's WebCam</title>
<link rel="stylesheet" type="text/css" href="tucknet.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<!-- Script stolen from GeneriCam - [URL unfurl="true"]http://occonnect.com/johnqpublic[/URL]
Thanks to the Nose, Sito and S.A. Dave -->
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
// browser sniffer:
browserVer = parseInt(navigator.appVersion);
if (navigator.appName == "Microsoft Internet Explorer" && browserVer < 4)
{
alert("Internet Explorer 3 users need to hit 'Refesh' to update the image");
}
//this eliminates JavaScript error messages
onError=null
// The variables you need to change are: the filename of the picture,
// the refresh rate, the expected time to download and further down,
// the FORM ACTION (look for the ***).
var picname = "[URL unfurl="true"]http://www.batnet.com/ctuck/gifs/ispy.jpg";[/URL] // set this to the filename of your campicture
var speed = 8; // "var speed" is the refresh rate adjustment in seconds
var y = 1; // expected time to download the picture file. It MUST be
// set at a smaller number than the "speed" variable!
var x = speed; // current countdown
var cachepic = new Image();
// Change "JSCamRemoteNT.html" to whatever you want to call the page that
// opens in the remote window.
function openremoteWindow()
{
stopClock();
open ("JSCamRemoteNT.html","JSCamRemote", "height=310,width=340,scrollbars=0,resizable=yes,status=0")
}
function stopClock() {
x = "00";
}
function startClock() {
if (x != "00") {
x = x - 1;
if (x == y) {
recache()
}
if (x <= 0)
{
reload()
}
timerID = setTimeout("startClock()", 1000);
}
}
function recache() {
var now = new Date();
var camImg = picname + "?" + now.getTime();
cachepic.src = camImg;
}
function reload() {
document.images.campicture.src = cachepic.src;
x = speed;
}
//end hide -->
</SCRIPT>
<BODY>
<TABLE WIDTH="100%" HEIGHT="50" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD ALIGN="CENTER" BGCOLOR="#aaddff" HEIGHT="5"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="0">
<TR><TD></TD></TR></TABLE></TD>
</TR>
<TR>
<TD ALIGN="CENTER" BGCOLOR="#ffffff"><FONT FACE="ARIAL" SIZE="6"
COLOR="#000099"><B>JavaScriptCam</B></FONT></TD>
</TR>
<TR>
<TD ALIGN="CENTER" BGCOLOR="#aaddff" HEIGHT="5"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="0">
<TR><TD></TD></TR></TABLE></TD>
</TR>
</TABLE>
<!-- In the section below, change "CamPic.jpg" to whatever you call your cam image -->
<CENTER>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="ffffff">
<TR><TD ALIGN="center"><A HREF="javascript:openremoteWindow()"><IMG
NAME="campicture" SRC="[URL unfurl="true"]http://www.batnet.com/ctuck/gifs/ispy.jpg"[/URL] ALT="Picture" BORDER="0" HEIGHT="240"
WIDTH="320" RELOAD="30"></A></TD>
</TR>
</TABLE>
</CENTER>
<TABLE WIDTH="100%" BORDER="0">
<TR>
<TD WIDTH="100%" ALIGN="CENTER" COLSPAN="2"><FONT SIZE="3">Click on the image for a remote window.</FONT>
<BR>
<FONT SIZE="3">PLEASE DO NOT HIT RELOAD!!</FONT></TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
startClock()
//end hide -->
</SCRIPT>
</body>
</html>