Advertisement
Guest User

Untitled

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