Advertisement
Guest User

Untitled

a guest
Mar 6th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.94 KB | None | 0 0
  1. <?php
  2. //* Totally Secure Generic Browser Interface for Amcrest H.264 Based IP Camera Models Version: V5.0 - Options: Display Only Or Display With Controls *
  3. //****************************************************************************************************************************************************
  4. //
  5. // Purpose:
  6. //
  7. // Allows Accessing any Amcrest H.264 Based IP Camera from a web page with total security and anonymity with HTTP or HTTPS access.
  8. // No camera information of any kind is exposed. No IP Address, DDNS, User Id or password for any camera is exposed.
  9. // This Interface can be used with camera controls enabled or disabled. It can also be protected from unauthorized access as well.
  10. // If you need image resizing or custom text in camera images you can use the original version for camera images and this for camera
  11. // controls only.
  12. //
  13. // Enter your User Id and Password below.
  14. $user = "";
  15. $password = "";
  16. // Camera can be left at zero as a default unless you have a NVR/DVR where you can choose many different cameras then it can be 0-32
  17. $camera = "0";
  18. // Change below to be your Amcrest User and Password and H.264 IP Camera IP Adddress or DDNS and Port.
  19. $ipcam_url = "http://User:Password@ISPipAddresorDDNS:Port";
  20. // Change to false to deny Amcrest H.264 IP Camera Display Use ("Used when using the original custom image version for displaying camera images").
  21. $allow_camera_display = true;
  22. // Change to false to deny Amcrest H.264 IP Camera Control Use.
  23. $allow_camera_controls = true;
  24. // This controls Pan and Tilt speed for PTZ controls execept presets. Values can be 1 - 8. 8 being the fastest.
  25. $ptz_speed = 4;
  26. // This controls Zoom speed. Values can be 1 - 8. 8 being the fastest.
  27. $zoom_speed = 4;
  28. // Change the below to true and change the URLs below to check for unauthorized usage from specific html or php.
  29. $protect_from_unauthorized_usage = false;
  30. if ($protect_from_unauthorized_usage) {
  31. if ((!isset($_SERVER['HTTP_REFERER'])) || (($_SERVER['HTTP_REFERER'] !== 'http://107.170.59.150/Amcrest/SecureImageDisplayControl.htm') && ($_SERVER['HTTP_REFERER'] !== 'http://107.170.59.150/Amcrest/SecureImageDisplayControlLogin.php') && ($_SERVER['HTTP_REFERER'] !== 'https://107.170.59.150/Amcrest/SecureImageDisplayControl.htm') && ($_SERVER['HTTP_REFERER'] !== 'https://107.170.59.150/Amcrest/SecureImageDisplayControlLogin.php'))) {
  32. sleep(5);
  33. $access_denied = realpath('accessdenied.jpg');
  34. if (!empty($access_denied)) {
  35. header("Content-type: image/jpeg");
  36. echo file_get_contents($access_denied);
  37. }
  38. die();
  39. }
  40. }
  41. if(!empty($_GET)) {
  42. if ((empty($_GET['t'])) && (!empty($_GET['cmd'])) && ($allow_camera_controls)) {
  43. if ((!empty($_GET['name'])) && ($_GET['cmd'] == "ptzGotoPresetPoint"))
  44. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=GotoPreset&arg1=0&arg2=".urlencode($_GET['name'])."arg3=0&arg4=0";
  45. else if ((0 === strpos($_GET['cmd'], 'zoom')) || (0 === strpos($_GET['cmd'], 'ptz'))) {
  46. switch ($_GET['cmd']) {
  47. case "ptzReset":
  48. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=PositionReset&arg1=0&arg2=0&arg3=0&arg4=0";
  49. break;
  50. case "ptzMoveTopLeft":
  51. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=LeftUp&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  52. break;
  53. case "ptzMoveTopLeftStop":
  54. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=LeftUp&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  55. break;
  56. case "ptzMoveBottomLeft":
  57. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=LeftDown&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  58. break;
  59. case "ptzMoveBottomLeftStop":
  60. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=LeftDown&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  61. break;
  62. case "ptzMoveLeft":
  63. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=Left&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  64. break;
  65. case "ptzMoveLeftStop":
  66. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=Left&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  67. break;
  68. case "ptzMoveUp":
  69. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=Up&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  70. break;
  71. case "ptzMoveUpStop":
  72. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=Up&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  73. break;
  74. case "ptzMoveDown":
  75. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=Down&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  76. break;
  77. case "ptzMoveDownStop":
  78. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=Down&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  79. break;
  80. case "ptzMoveRight":
  81. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=Right&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  82. break;
  83. case "ptzMoveRightStop":
  84. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=Right&arg1=0&arg2=$ptz_speed&arg3=0&arg4=0";
  85. break;
  86. case "ptzMoveBottomRight":
  87. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=RightDown&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  88. break;
  89. case "ptzMoveBottomRightStop":
  90. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=RightDown&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  91. break;
  92. case "ptzMoveTopRight":
  93. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=RightUp&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  94. break;
  95. case "ptzMoveTopRightStop":
  96. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=RightUp&arg1=$ptz_speed&arg2=$ptz_speed&arg3=0&arg4=0";
  97. break;
  98. case "zoomIn":
  99. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=ZoomTele&arg1=0&arg2=$zoom_speed&arg3=0&arg4=0";
  100. break;
  101. case "zoomOut":
  102. $ipcam_url .= "/cgi-bin/ptz.cgi?action=start&channel=$camera&code=ZoomWide&arg1=0&arg2=$zoom_speed&arg3=0&arg4=0";
  103. break;
  104. case "zoomInStop":
  105. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=ZoomTele&arg1=0&arg2=$zoom_speed&arg3=0&arg4=0";
  106. break;
  107. case "zoomOutStop":
  108. $ipcam_url .= "/cgi-bin/ptz.cgi?action=stop&channel=$camera&code=ZoomWide&arg1=0&arg2=$zoom_speed&arg3=0&arg4=0";
  109. break;
  110. default:
  111. die();
  112. }
  113. }
  114. else die();
  115. }
  116. else if (($allow_camera_display) && (empty($_GET['cmd'])) && (!empty($_GET['t'])))
  117. $ipcam_url .= "/cgi-bin/snapshot.cgi?channel=$camera";
  118. else
  119. die();
  120. $curl_handle = curl_init();
  121. if ((!empty($user)) && (!empty($password))) {
  122. curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
  123. curl_setopt($curl_handle, CURLOPT_USERPWD, "$user:$password");
  124. }
  125. curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
  126. curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
  127. curl_setopt($curl_handle, CURLOPT_URL, $ipcam_url);
  128. $my_image = curl_exec($curl_handle);
  129. curl_close($curl_handle);
  130. }
  131. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement