. *! -----------------------------------------------------------------------------** */ $chn = 0; $cmd = "donothing"; $debug = false; $debuglev = 6; if (isset($_GET['chn'])) $chn = $_GET['chn']; if (isset($_GET['cmd'])) $cmd = $_GET['cmd']; if (isset($_GET['debug']) ) $debug = $_GET['debug']; if (isset($_GET['debuglev'])) $debuglev = $_GET['debuglev']; $r_pipe="/tmp/camogm$chn.status"; $c_pipe="/var/volatile/camogm_cmd$chn"; if ($cmd=="status"){ $mode=0777; if(!is_file($r_pipe)){ umask(0); posix_mkfifo($r_pipe,$mode); } $fcmd=fopen($c_pipe,"w"); fprintf($fcmd, "xstatus=%s\n",$r_pipe); fclose($fcmd); $res=file_get_contents($r_pipe); xml_response($res); } if ($cmd=="list") { $res=""; if (isset($_GET['path'])) $path = $_GET['path']; else { $res = "the path is not set\n"; } if (is_dir($path)) { $files = scandir($path); foreach ($files as $file){ if (is_file("$path/$file")) $res .= "$path/$file\n"; if (is_dir("$path/$file")) $res .= "$path/$file\n"; } }else{ $res = "directory not found\n"; } xml_response("\n$res\n",true); } if ($cmd=="create_symlink"){ if (isset($_GET['path'])) { $path = $_GET['path']; if (is_dir($path)){ exec("ln -sf $path /www/pages/video;sync"); //if (file_exists("/tmp/video")) unlink("/tmp/video"); //exec("ln -sf $path /tmp/video"); } } } //camogm pipe commands $fcmd = fopen($c_pipe, "w"); if ($cmd=="start"){ fprintf($fcmd,"start;\n"); }else if ($cmd=="stop"){ fprintf($fcmd,"stop;\n"); exec('sync'); }else if ($cmd=="exit"){ fprintf($fcmd,"exit;\n"); exec('sync'); }else if ($cmd=="default"){ fprintf($fcmd,"format=mov;exif=0;prefix=/mnt/sda1/;\n"); }else{ fprintf($fcmd,"$cmd\n"); //exec('sync'); } fclose($fcmd); $res = "$chn\n"; $res .= "$cmd\n"; xml_response("\n$res\n",true); die("done"); function xml_response($msg,$addheader=false){ if ($addheader) $msg = "\n$msg"; header("Content-Type: text/xml"); header("Content-Length: ".strlen($msg)."\n"); header("Pragma: no-cache\n"); echo $msg; flush(); die(); } ?>