D-Link Forums

The Graveyard - Products No Longer Supported => IP Cameras => DCS-930L => Topic started by: acellier on September 23, 2013, 05:42:47 PM

Title: php code to test all built-in modes
Post by: acellier on September 23, 2013, 05:42:47 PM
The following php code can be run on a server (or locally with MAMP) to select 1 of several camera and 1 of 9 built-in modes of browser viewing.

The php generates an html page, then after your two selections, click the final link for the result.
Tested with DCS-930L, 931L, 932L

<?php
//Testing script for D-Link IP cameras DCS-930L, 932L, 931L ...
//Version 2013 09 232 1730 by A. Cellier
$Cameras = [31,32,33,40,44] ; $NumberOfCameras = count($Cameras) ; //final 2-digits of cameras' LAN ip
echo '<FORM action="' . htmlentities($_SERVER['PHP_SELF']) . '" method="post">' ; echo "<p style='text-align:center;'>";
echo '<i>Choose</i> Camera: '; echo '<SELECT NAME="PickCamera" OnChange="submit();">' ; 
$mycount = 0 ;
while ( $mycount <= $NumberOfCameras - 1)
   {    {   echo '<OPTION VALUE="' . $Cameras[$mycount] . '" ' ;
         if ( $_POST['PickCamera'] == $Cameras[$mycount] )  { echo "SELECTED " ; }
//         echo "> " . $Cameras[$mycount] . '</OPTION>' ;
         echo "> # " . ($mycount + 1) . " ... " . $Cameras[$mycount] . '</OPTION>' ;
      }
      $mycount++ ;
   }
   echo "</SELECT> <br/> \n" ;
//
if (isset($_POST['PickCamera'])) { $_COOKIE['PickCamera'] = PickCamera ; } ;
$Camera =  $_POST['PickCamera'] ; $CameraIP = "YOUR.WAN.I.P:80" . $Camera ;      //e.g., "192.168.100.9:80" – assumes assigned port is 80nn
echo "Cam" . substr($Camera,-1,1) . ", IP = " . $CameraIP . "<br/>" ;      //cameras are on ports 80nn where nn is final 2-digits of camera's LAN ip

$LiveViews =  ["stsdev.htm", "video.cgi", "audio.cgi", "mvideo.htm", "lphone.htm", "mjpeg.cgi", "image/jpeg.cgi", "mobile.htm", "iphone.htm"] ; $NumberOfLiveViews = count($LiveViews) ;
echo '<FORM action="' . htmlentities($_SERVER['PHP_SELF']) . '" method="post">' ; echo "<p style='text-align:center;'>";
echo '<i>Choose</i>LiveView: '; echo '<SELECT NAME="PickLiveView" OnChange="submit();">' ; 
$mycount2 = 0 ;
while ( $mycount2 <= $NumberOfLiveViews - 1)
   {    {   echo '<OPTION VALUE="' . $LiveViews[$mycount2] . '" ' ;
         if ( $_POST['PickPickLiveView'] == $LiveViews[$mycount2] )  { echo "SELECTED " ; }
//         echo "> " . $LiveViews[$mycount2] . '</OPTION>' ;
         echo "> # " . ($mycount2 + 1) . " ... " . $LiveViews[$mycount2] . '</OPTION>' ;
      }
      $mycount2++ ;
   }
   echo "</SELECT> <br/> \n" ;
//
if (isset($_POST['PickLiveView'])) { $_COOKIE['PickLiveView'] = PickLiveView ; } ;
$LiveView =  $_POST['PickLiveView'] ;
echo "LiveView = " . $LiveView . "<br/>" ;

//echo "<br/><form method=\"GET\" action=\"http://" . $CameraIP . "/" . $LiveView . " \"> <input type=\"submit\" value=\"Go to Cam" . substr($Camera,-1,1) ."\"></form> " ;
echo "<br/>... <a href=\"http://" . $CameraIP . "/" . $LiveView . " \"> Go to Cam" . substr($Camera,-1,1) .  "</a> " . $LiveView . " ... " ;

$controls = ["jview.htm", "wizard.htm", "advanced.htm", "stsdev.htm"] ;
$imgviews = ["mjpeg.cgi", "image/jpeg.cgi", "mobile.htm", "iphone.htm"] ;





?>

<html>    <head>    <title> camtest </title></head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
  { var item = window.localStorage.getItem('PickCamera') ;
    $('select[name=PickCamera]').val(item) ;
    $('select[name=PickCamera]').change(function() { window.localStorage.setItem('PickCamera', $(this).val()); } ) ;
  } ) ;
$(document).ready(function()
  { var item = window.localStorage.getItem('PickLiveView') ;
    $('select[name=PickLiveView]').val(item) ;
    $('select[name=PickLiveView]').change(function() { window.localStorage.setItem('PickLiveView', $(this).val()); } ) ;
  } ) ;
</script>