diff --git a/Proxy.php b/Proxy.php new file mode 100644 index 0000000..235823b --- /dev/null +++ b/Proxy.php @@ -0,0 +1,17 @@ +\n"; // error handling +} else { + $urlstring = "GET ".$url." HTTP/1.0\r\n\r\n"; + fputs ($fp, $urlstring); + while ($str = trim(fgets($fp, 4096))) + header($str); + fpassthru($fp); + fclose($fp); +} +?> diff --git a/README.md b/README.md index 2c2c449..b57fe5e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # php-webcam-proxy Simple php proxy for mjpeg webcam endpoints + ## how to use + - Change the veriables in the top of `proxy.php`. + - done! diff --git a/exampleConfig.ini b/exampleConfig.ini deleted file mode 100644 index 9b05b32..0000000 --- a/exampleConfig.ini +++ /dev/null @@ -1,35 +0,0 @@ -;tenvis example -[wc1] -logFile="/tmp/tenvis.log" -username=user1 -password=pass1 -url="http://192.168.1.0:7777" -mjpeg="vjpeg.v?user={USER}&pwd={PASS}" -moveLeft="cgi-bin/control.cgi?action=cmd&code=2&value=4" -stopLeft="cgi-bin/control.cgi?action=cmd&code=3&value=4" -moveRight="cgi-bin/control.cgi?action=cmd&code=2&value=3" -stopRight="cgi-bin/control.cgi?action=cmd&code=3&value=3" -moveUp="cgi-bin/control.cgi?action=cmd&code=2&value=1" -stopUp="cgi-bin/control.cgi?action=cmd&code=3&value=1" -moveDown="cgi-bin/control.cgi?action=cmd&code=2&value=2" -stopDown="cgi-bin/control.cgi?action=cmd&code=3&value=2" -boundary=ipcamera - - -;foscam example -[wc2] -logFile = "/tmp/foscam.log" -url="http://192.168.1.0:80" -username = user -password = pass1 -mjpeg="videostream.cgi?user={USER}&pwd={PASS}" -moveLeft="decoder_control.cgi?command=6&user={USER}&pwd={PASS}" -stopLeft="decoder_control.cgi?command=1&user={USER}&pwd={PASS}" -moveRight="decoder_control.cgi?command=4&user={USER}&pwd={PASS}" -stopRight="decoder_control.cgi?command=1&user={USER}&pwd={PASS}" -moveUp="decoder_control.cgi?command=0&user={USER}&pwd={PASS}" -stopUp="decoder_control.cgi?command=1&user={USER}&pwd={PASS}" -moveDown="decoder_control.cgi?command=2&user={USER}&pwd={PASS}" -stopDown="decoder_control.cgi?command=1&user={USER}&pwd={PASS}" -boundary=ipcamera - diff --git a/index.html b/index.html deleted file mode 100644 index acbe51f..0000000 --- a/index.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - diff --git a/webcamProxy.php b/webcamProxy.php deleted file mode 100644 index 00c013e..0000000 --- a/webcamProxy.php +++ /dev/null @@ -1,58 +0,0 @@ -$value) { - $value = str_replace("{USER}", $currentConfig['username'], $value); - $value = str_replace("{PASS}", $currentConfig['password'], $value); - $newConfig[$key] = $value; - } - return $newConfig; -} - - -##MAIN: -if (!function_exists('curl_init')) { - echo "php curl support must be installed!!!"; - exit(1); -} -if(!isset($_GET['webcam']) || !isset($_GET["cmd"])) { - echo "require a webcam and a cmd param!"; - exit(1); -} -$tmp = file_get_contents("webcamConfig.ini"); -$configFile = parse_ini_string($tmp, true); -$currentConfig = $configFile[$_GET['webcam']]; - -header("Connection: close"); -header("Content-Type: multipart/x-mixed-replace;boundary=".$currentConfig['boundary']); - - -$currentConfig = UpdateConfigStrings($currentConfig); - -if($currentConfig['logFile'] !== false) { - $fp = fopen($currentConfig['logFile'], 'a'); - fwrite($fp, "IN FROM CLIENT:\n".print_r($_GET, true)."\n----------\n"); - fwrite($fp, print_r($currentConfig, true)."\n----------\n"); - fwrite($fp, $currentConfig['url']."/".$currentConfig[$_GET['cmd']]."\n----------\n"); - fclose($fp); -} - -$out = Fetch($currentConfig['url']."/".$currentConfig[$_GET['cmd']], $currentConfig);