If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Controlling Hours of Access to Embedded Network Camera

I have an Axis network (IP) camera that I would like to embed in my website. Axis provides the code (see below), and it works. However, I would like to limit the hours during the day when people have access to view the camera (or, alternatively, the web page where the camera appears). I would like to limit the hours to Monday through Friday, 9 a.m. to 7 p.m. E.S.T.

If you have any suggestions, please let me know. I have only rudimentary knowledge of code, so if you have any suggestions, it would be helpful if you could provided any suggested changes or additions to the existing code below.

I am also open to other suggestions for accomplishing the same goal. Thanks in advance.

There's a significant problem with this: if someone is already on the page, you can't force them to leave. So you can decide when you want to show them the page and when you don't, but once it is loaded there's nothing to stop them from keeping the page open.

I'm not sure exactly what you are doing this for, but if it's for privacy and it's very important that the page is never viewable outside of those hours, this is not going to be solved by PHP.

Javascript can do this easily enough, but it's not guaranteed because Javascript can be disabled-- it's like a request to the browser to reload the page (or hide the camera, or whatever) but not a guaranteed command-- because the browser can ignore Javascript. It'll work for 95%+ of your visitors, but for that 5%, they may know how to disable it and intentionally view longer.

The best solution I can think of is requiring that the page refreshes every 5-15 minutes so that the PHP code (which will always work) will block them from using the page at the wrong times (or within 5-15 minutes of the wrong times, at least). However, it's also very hard to force a page to refresh. A meta refresh tag or a refresh header sent from PHP would be possible, but I do believe that can be overridden by the browser/user settings as well, although it's a lot harder to get around than Javascript (which usually has a simple "off" button).

So.... there's NO way to do this effectively if you need 100% reliability. The solution would be to actually stop the video feed at those times, which is technically possible but might be difficult (or even effectively impossible) depending on what kind of software you're using for it. I'd suggest contacting technical support for the camera and/or software.

Additionally, if the camera feed is available on the website then I imagine that with a bit of creativity and knowledge, users could extract that from the site (for example, embed it on their own page, personal or public) and watch any time they'd like. Therefore, it's really not about the webpage at all, but about the camera feed itself.

One thing you could explore would be using Flash or another plugin to load the camera feed, and those could disable it at the times you indicated. They're also much harder to reverse engineer. But someone who knows what they're doing could probably extract the camera feed from them as well, as mentioned above. Check with a Flash programmer to see if there's a good solution to this. But I still think dealing with it at the source is the best idea.

Many thanks. I'm already in over my head here. I use Godaddy, and tried including the entire code in one of Godaddy's "script" boxes. It came back with a message that only Javascript may be entered. I then tried to open up the HTML editor. However, I ended up with only the following appearing

= 9 && $hr <= 19) ) { ?>

That also appears as text on the previewed page. Any suggestions?

Originally Posted by Beverleyh

Something like this;

PHP Code:

<?php
$day = date('l'); // get day of week
$hr = date('G'); // get hour of day
$wkend = array('Saturday', 'Sunday');
// check if day is not Saturday or Sunday, and between the hours of 9am and 7pm inclusive
if ( (!in_array($day, $wkend)) && ($hr >= 9 && $hr <= 19) ) {
?>

<!-- Put your page code here -->

<?php } else { ?>

<p>Sorry, come back between 9am and 7pm, Monday to Friday, to see something interesting.</p>

<?php } ?>

You might also need to calculate an hour offset depending on your server time/location

Thanks. As I said in the previous response, I can see that I'm already in over my head. The reason for limiting the hours is indeed for privacy. The network camera is to show my dog during weekdays when I'm not at home. I'm not overly concerned (though maybe I should be) if someone manages to stay on past the deadline, as it would probably get very boring after a while. I also doubt that anyone would really want to go through the effort to embed the video on another page, though I do understand the concern. My main concern is that someone will simply stumble onto the camera at a time when I don't want to give access.

The difficulty here is that I want to have access to the camera (through sources other than my website) at all times, so I can't shut off the camera. I was using a hosting service that re-streamed the video, and that worked very well, but it has raised its rates by a huge amount. That makes it no longer feasible to use this service.

Originally Posted by djr33

There's a significant problem with this: if someone is already on the page, you can't force them to leave. So you can decide when you want to show them the page and when you don't, but once it is loaded there's nothing to stop them from keeping the page open.

I'm not sure exactly what you are doing this for, but if it's for privacy and it's very important that the page is never viewable outside of those hours, this is not going to be solved by PHP.

Javascript can do this easily enough, but it's not guaranteed because Javascript can be disabled-- it's like a request to the browser to reload the page (or hide the camera, or whatever) but not a guaranteed command-- because the browser can ignore Javascript. It'll work for 95%+ of your visitors, but for that 5%, they may know how to disable it and intentionally view longer.

The best solution I can think of is requiring that the page refreshes every 5-15 minutes so that the PHP code (which will always work) will block them from using the page at the wrong times (or within 5-15 minutes of the wrong times, at least). However, it's also very hard to force a page to refresh. A meta refresh tag or a refresh header sent from PHP would be possible, but I do believe that can be overridden by the browser/user settings as well, although it's a lot harder to get around than Javascript (which usually has a simple "off" button).

So.... there's NO way to do this effectively if you need 100% reliability. The solution would be to actually stop the video feed at those times, which is technically possible but might be difficult (or even effectively impossible) depending on what kind of software you're using for it. I'd suggest contacting technical support for the camera and/or software.

Additionally, if the camera feed is available on the website then I imagine that with a bit of creativity and knowledge, users could extract that from the site (for example, embed it on their own page, personal or public) and watch any time they'd like. Therefore, it's really not about the webpage at all, but about the camera feed itself.

One thing you could explore would be using Flash or another plugin to load the camera feed, and those could disable it at the times you indicated. They're also much harder to reverse engineer. But someone who knows what they're doing could probably extract the camera feed from them as well, as mentioned above. Check with a Flash programmer to see if there's a good solution to this. But I still think dealing with it at the source is the best idea.

kblaw, please note that your recent posts were caught by our automatic spam filter-- they're approved now (and you did nothing wrong) but in case you can't see something you post, that's why-- and a moderator will approve it as soon as possible.

For PHP, you will need to use a .php page and have access to the plain-text source code. I'm not sure what you mean by "using GoDaddy", but if you're referring to some preview-based ("WYSIWYG") editor, then you will need to start using FTP with access to the code directly. GoDaddy has PHP enabled by default, so that shouldn't be a problem.

And note that Beverley's script is just fine for access to the page, if that's part of what you want to do. Combined with some other methods to actually block the camera feed at those times, Beverley's method will allow you to put a friendly message up for users.

Thanks. As I said in the previous response, I can see that I'm already in over my head. The reason for limiting the hours is indeed for privacy. The network camera is to show my dog during weekdays when I'm not at home. I'm not overly concerned (though maybe I should be) if someone manages to stay on past the deadline, as it would probably get very boring after a while. I also doubt that anyone would really want to go through the effort to embed the video on another page, though I do understand the concern. My main concern is that someone will simply stumble onto the camera at a time when I don't want to give access.

The difficulty here is that I want to have access to the camera (through sources other than my website) at all times, so I can't shut off the camera. I was using a hosting service that re-streamed the video, and that worked very well, but it has raised its rates by a huge amount. That makes it no longer feasible to use this service.

I understand. The bottom line is that if you put it on the internet, it's public. One option would be to put all of this behind a password system so that no one else can view it. But still they'd end up being able to get access to the camera feed without a password, if they knew where to look.

What's in your favor at the moment is that others don't know where to look. That's what I'd suggest using-- put it on an obscure page on your website that only you know about (don't ever link to it) and just use it yourself. If the public knows about it, they can view it at other times.

If you only want to discourage people from viewing at other times, you can use Beverley's method. But if you want to actually prevent them for privacy reasons (and that's a good idea), then you will need to do something more than that.

Originally Posted by Crazykld69

Couldnt the person just grab their ip and then locate them using their ip and change the timestamp according to their ip?

I'm not sure what you mean exactly. But, yes, someone could find the IP. That would potentially allow them to view the camera at other times and actually also allow them to locate where the camera is geographically, although it probably wouldn't let them know the exact address, just the city and the internet provider. (On the other hand, that information may already be available based on the registration of the domain name.)

----
There are three things that I suggest:
1. Put this in some weird place on your website where no one will find it. Maybe add a password-- look into .htaccess passwords for something easy and secure. Never link to this or make it public.
2. Contact the company that does the streaming. Ask them for help.
3. Look into alternatives. Surely there must be some company out there that requires a password to view the stream. And I don't think it would be all that expensive, at least if you look around for various options. Even if it is expensive, that might be what you need to deal with to make this private.

It's all up to you, but you need to decide how important privacy is and what you'd be willing to do about it-- turn off the camera? pay more? switch services? deal with the privacy risk?

Finally, you can also consider dealing with this at the other end. For example, you could try to:
--manually turn off the camera at those times
--set it to automatically turn off at those times if that's an option
--even try something like buying a switch that's on a timer for that circuit-- there are consumer devices out there for that so that you can have certain lights on at certain times of the day, and I don't think they're expensive or hard to use-- but for that you'd need to be sure that it wouldn't disrupt the stream. If you can simply switch the power to the camera on and off without disabling the streaming and allowing it to start up the next time the camera is turned on, that sounds like a great idea to me. Cheap, easy and reliable. But that might only work with certain streaming software (or maybe none-- I'm not sure).

1. The ideal solution continues to be using a service that restreams the video. I am still exploring alternative services that might not be so expensive. I actually have several cameras. The original cost for my current restreaming service was less than $10 per month, but it will be increasing to about $75 per month. I cannot justify that cost for a non-commercial website.

2. Over the weekend, I sent a service inquiry to Axis Cameras asking about any solution it might offer. I am waiting for its response.

3. In the meantime, I am willing to live with a system that is not completely secure, as long as it discourages the average person from logging in at off-hours. I do need to keep the cameras on during off-hours, so that I have my own access to the cameras through other applications, but I want anyone to have access at other hours through my website. Thus, concealing links or using password protection on the website won't work for me.

4. I use Godaddy's Website Tonight. Apparently, based on some research I did, it does not support PHP. Is there an alternative using Javascript?

1-2. This is a fairly specialized service, so while that is obviously expensive, you may end up needing to choose between the cost and the quality of service. There just isn't going to be any alternative to manipulating the streaming itself.

3. The PHP solution will work for this in that they can only START viewing the camera at certain times.

4. No, not really. There are 2 problems:
1) Javascript time would be based on the user's computer, not the server (which would be at a constant geographical location) or the camera. So if someone in China or someone in Italy or someone in Canada were looking at tis, they'd have access at completely different times due to time zones. You could TRY to figure this out, but it would probably require referring to the server's time and finding the offset. That's possible. But it means using PHP again.
2) You can completely control the browser using Javascript-- force the page to reload, navigate to a different page, hide the camera, etc. The problem, as I said earlier, is that it's not actually all that powerful-- if Javascript is disabled (or someone wants to go through the trough the trouble of manipulating the commands, which is all possible because it's all on the user's computer), then it's useless. Javascript NEVER works for security. Javascript ONLY works to enhance the user's experience by helping them with additional OPTIONAL features. It's a one-way relationship-- the code MAY help the user, but it cannot be relied upon for anything beyond that. (One option would be to require Javascript to load the page in the first place; that kind of script can be somewhat effective. But if you know what you're doing, you could allow JS to load the page then disable it, or simply reverse engineer the code to find the raw code and work from there.)

You should not be using Godaddy's "Website Tonight" if you want ANY kind of control over your website, especially at this level. It's just not designed for that. It's basically a template with a bit of flexibility, but nothing like what you'd need here. As a metaphor, it's sort of like the difference between being a painter and using making "color-by-number" pictures-- the second is certainly easier and faster, but at some point you'll find yourself asking "wait, I want to make a picture of something else." So, it's time to consider upgrading. Code is relatively accessible if you're willing to take the time to figure it out.

However, as I said before, this is properly solved at the level of the camera feed anyway. So you don't necessarily need PHP. In that case you can just keep your current website and not change a thing-- but then find some way to deal with the camera.

My best suggestion is still to make this private. Why should anyone else be able to see it anyway? I'm confused. Or, here's an idea, why not create two cameras, one that is disabled at those times, but available to the public, and another one that is password protected (or just hidden from the public on an unknown page) that only you can view? Low-tech, but maybe that would work for you.

Just an update on this, and a further question. I purchased a separate web hosting service and domain from Godaddy for the purpose of running the cameras with the code suggested above. I am using Drupal for now, and it appears to work fine.

So as avoid rebuilding any of the main website, I would like to embed the video from the new site on the main website. I realize that this is less than ideal. I am able to embed the entire web page, but would like to embed only the video itself. Is there a way to do this (understandng that I am restricted to using HTML)? Again, please bear in mind that I have only a rudimentary knowledge of code. Thanks in advance.