Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Controlling Hours of Access to Embedded Network Camera

  1. #1
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.



    Code:
    <SCRIPT LANGUAGE="JavaScript">
    // Set the BaseURL to the URL of your camera
    var BaseURL = "http://98.242.185.88:4956/"; 
    // DisplayWidth & DisplayHeight specifies the displayed width & height of the image.
    // You may change these numbers, the effect will be a stretched or a shrunk image
    var DisplayWidth = "640";
    var DisplayHeight = "480";
    // This is the path to the image generating file inside the camera itself
    var File = "axis-cgi/mjpg/video.cgi?resolution=640x480";
    // No changes required below this point
    var output = "";
    if ((navigator.appName == "Microsoft Internet Explorer") &&
       (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k"))
    {
      // If Internet Explorer under Windows then use ActiveX 
      output  = '<OBJECT ID="Player" width='
      output += DisplayWidth;
      output += ' height=';
      output += DisplayHeight;
      output += ' CLASSID="CLSID:DE625294-70E6-45ED-B895-CFFA13AEB044" ';
      output += 'CODEBASE="';
      output += BaseURL;
      output += 'activex/AMC.cab#version=5,6,2,2">';
      output += '<PARAM NAME="MediaURL" VALUE="';
      output += BaseURL;
      output += File + '">';
      output += '<param name="MediaType" value="mjpeg">';
      output += '<param name="ShowStatusBar" value="0">';
      output += '<param name="ShowToolbar" value="0">';
      output += '<param name="AutoStart" value="1">';
      output += '<param name="StretchToFit" value="1">';
      // Remove the // for the ptz settings below to use the code for click-in-image. 
         //  output += '<param name="PTZControlURL" value="';
         //  output += BaseURL;
         //  output += '/axis-cgi/com/ptz.cgi?camera=1">';
         //  output += '<param name="UIMode" value="ptz-relative">'; // or "ptz-absolute"
      output += '<BR><B>Axis Media Control</B><BR>';
      output += 'The AXIS Media Control, which enables you ';
      output += 'to view live image streams in Microsoft Internet';
      output += ' Explorer, could not be registered on your computer.';
      output += '<BR></OBJECT>';
    } else {
      // If not IE for Windows use the browser itself to display
      theDate = new Date();
      output  = '<IMG SRC="';
      output += BaseURL;
      output += File;
      output += '&dummy=' + theDate.getTime().toString(10);
      output += '" HEIGHT="';
      output += DisplayHeight;
      output += '" WIDTH="';
      output += DisplayWidth;
      output += '" ALT="Camera Image">';
    }
    document.write(output);
    document.Player.ToolbarConfiguration = "play,+snapshot,+fullscreen"
    
    // Remove the // below to use the code for Motion Detection. 
      // document.Player.UIMode = "MDConfig";
      // document.Player.MotionConfigURL = "/axis-cgi/operator/param.cgi?ImageSource=0"
      // document.Player.MotionDataURL = "/axis-cgi/motion/motiondata.cgi";
    </SCRIPT>
    Last edited by traq; 11-25-2012 at 09:45 PM. Reason: formatting - please use the forum's BBCode tags

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,940
    Thanks
    16
    Thanked 304 Times in 303 Posts
    Blog Entries
    11

    Default

    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 >= && $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
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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?


    Quote Originally Posted by Beverleyh View Post
    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 >= && $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

  5. #5
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

    Quote Originally Posted by djr33 View Post
    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.

  6. #6
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    341
    Thanks
    5
    Thanked 31 Times in 29 Posts

    Default

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

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    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.

    Quote 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).
    Last edited by djr33; 11-26-2012 at 02:30 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the enlightening responses. A few notes:

    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?

    Thanks again.

    4.

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2010, 11:35 PM
  2. Need freeware multiple-IP-camera DVR software for Windows
    By techno_race in forum Computer hardware and software
    Replies: 2
    Last Post: 06-27-2010, 11:40 PM
  3. Replies: 1
    Last Post: 02-20-2009, 01:33 PM
  4. Connect to database over a network
    By fobos in forum MySQL and other databases
    Replies: 2
    Last Post: 12-23-2008, 03:27 PM
  5. Choosing A Video Camera
    By Jack in forum The lounge
    Replies: 16
    Last Post: 05-03-2007, 11:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •