-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapturer.php
More file actions
37 lines (32 loc) · 719 Bytes
/
capturer.php
File metadata and controls
37 lines (32 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
function capturer_put($request){
$pid =shell_exec('/usr/bin/python motion.py > /dev/null 2>/dev/null & echo $!');
//Printing additional info
file_put_contents("pid.tmp",$pid);
}
function capturer_delete($request){
if (!file_exists("pid.tmp")){
return;
}
$pid = file_get_contents("pid.tmp");
//unlink("pid.tmp");
$result = shell_exec('kill -9 ' . $pid);
echo $result;
}
function capturer_error($request){
echo "Error 501";
}
$method = $_SERVER['REQUEST_METHOD'];
$request = explode("/",substr(@$_SERVER['PATH_INFO'],1));
switch ($method){
case 'PUT':
capturer_put($request);
break;
case 'DELETE':
capturer_delete($request);
break;
default:
capturer_error($request);
break;
}
?>