Commit 8ec453e8 authored by Andrey Filippov's avatar Andrey Filippov

changes before TE

parent f09457c0
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
*! start and stop commands for ajax execution *! start and stop commands for ajax execution
*! *!
*/ */
define('SSD_ROOT', '/mnt/sda1/');
$cmd = $_GET['cmd']; $cmd = $_GET['cmd'];
$debug = $_GET['debug']; $debug = $_GET['debug'];
$debuglev = $_GET['debuglev']; $debuglev = $_GET['debuglev'];
...@@ -140,11 +141,10 @@ if ($cmd == "run_camogm") ...@@ -140,11 +141,10 @@ if ($cmd == "run_camogm")
echo "camogm is running\n"; echo "camogm is running\n";
} }
} }
else if ($cmd == "status") else if (($cmd == "status") || ($cmd == "state"))
{ {
if (check_camogm_running()) $camogm_running = "on"; if (check_camogm_running()) $camogm_running = "on";
else $camogm_running = "off"; else $camogm_running = "off";
if ($camogm_running=="on"){ if ($camogm_running=="on"){
$pipe="/var/state/camogm.state"; $pipe="/var/state/camogm.state";
$mode=0777; $mode=0777;
...@@ -155,8 +155,14 @@ else if ($cmd == "status") ...@@ -155,8 +155,14 @@ else if ($cmd == "status")
$fcmd=fopen($cmd_pipe,"w"); $fcmd=fopen($cmd_pipe,"w");
fprintf($fcmd, "xstatus=%s\n",$pipe); fprintf($fcmd, "xstatus=%s\n",$pipe);
fclose($fcmd); fclose($fcmd);
$status=file_get_contents($pipe); $status=file_get_contents($pipe);
if ($cmd == "state") {
$start = strpos($status, "<state>") + 7;
$len = strpos($status, "</state>", $start) - $start ; // including ""
$state = substr($status, $start, $len);
$status = "<?xml version='1.0'?><camogm_state>\n<state>".$state."</state>\n</camogm_state>";
}
}else{ }else{
$status = "<?xml version='1.0'?><camogm_state>\n<state>".$camogm_running."</state>\n</camogm_state>"; $status = "<?xml version='1.0'?><camogm_state>\n<state>".$camogm_running."</state>\n</camogm_state>";
} }
...@@ -167,6 +173,7 @@ else if ($cmd == "status") ...@@ -167,6 +173,7 @@ else if ($cmd == "status")
// allow CORS: needed for multi cams unified control // allow CORS: needed for multi cams unified control
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
printf("%s", $status); printf("%s", $status);
} }
else if ($cmd == "run_status") else if ($cmd == "run_status")
{ {
...@@ -188,8 +195,11 @@ else if ($cmd=="get_hdd_space"){ ...@@ -188,8 +195,11 @@ else if ($cmd=="get_hdd_space"){
$mountpoint = $_GET['mountpoint']; $mountpoint = $_GET['mountpoint'];
else else
$mountpoint = '/mnt/sda1'; $mountpoint = '/mnt/sda1';
// make sure something is mounted on mountpoint
exec('mount', $arr);
$mounted = implode("", $arr);
if (is_dir($mountpoint)) $res = disk_free_space($mountpoint); if ((strstr($mounted, $mountpoint)) && (is_dir($mountpoint))) $res = disk_free_space($mountpoint);
else $res = 0; else $res = 0;
xml_header(); xml_header();
...@@ -313,12 +323,12 @@ else if ($cmd=="set_skip") { ...@@ -313,12 +323,12 @@ else if ($cmd=="set_skip") {
xml_footer(); xml_footer();
} }
else if ($cmd=="list") { else if ($cmd=="list") {
unset ($message);
if (isset($_GET['path'])) $path = $_GET['path']; if (isset($_GET['path'])) $path = $_GET['path'];
else { else {
$message = "the path is not set"; $message = "the path is not set";
break;
} }
if (!isset($message)) {
if (is_dir($path)) { if (is_dir($path)) {
$files = scandir($path); $files = scandir($path);
foreach ($files as $file){ foreach ($files as $file){
...@@ -326,7 +336,7 @@ else if ($cmd=="list") { ...@@ -326,7 +336,7 @@ else if ($cmd=="list") {
} }
}else{ }else{
$message = "directory not found"; $message = "directory not found";
break; }
} }
xml_header(); xml_header();
echo "<command>".$cmd."</command>"; echo "<command>".$cmd."</command>";
...@@ -337,7 +347,6 @@ else if ($cmd=="list") { ...@@ -337,7 +347,6 @@ else if ($cmd=="list") {
} }
else if ($cmd=="list_raw_devices"){ else if ($cmd=="list_raw_devices"){
$devices = get_raw_dev(); $devices = get_raw_dev();
xml_header(); xml_header();
echo "<command>".$cmd."</command>"; echo "<command>".$cmd."</command>";
echo "<".$cmd.">"; echo "<".$cmd.">";
...@@ -351,6 +360,7 @@ else if ($cmd=="list_raw_devices"){ ...@@ -351,6 +360,7 @@ else if ($cmd=="list_raw_devices"){
xml_footer(); xml_footer();
} }
else if ($cmd=="list_partitions"){ else if ($cmd=="list_partitions"){
xml_header();
$partitions = get_partitions(); $partitions = get_partitions();
foreach ($partitions as $device=>$size) { foreach ($partitions as $device=>$size) {
echo "<item>"; echo "<item>";
...@@ -358,18 +368,26 @@ else if ($cmd=="list_partitions"){ ...@@ -358,18 +368,26 @@ else if ($cmd=="list_partitions"){
echo " <size>" . round($size / 1048576, 2) . "</size>"; echo " <size>" . round($size / 1048576, 2) . "</size>";
echo "</item>"; echo "</item>";
} }
xml_footer();
} }
else else
{ {
$fcmd = fopen($cmd_pipe, "w"); $fcmd = fopen($cmd_pipe, "w");
switch ($cmd) { // cookies have to be set before any output
case "set_prefix":
$prefix = $_GET['prefix'];
setcookie("directory", $prefix);
break;
}
xml_header(); xml_header();
echo "<command>".$cmd."</command>"; echo "<command>".$cmd."</command>";
echo "<".$cmd.">"; echo "<".$cmd.">";
switch ($cmd) switch ($cmd)
{ {
case "start": case "start":
// Camogm starts with all ports disabled
fprintf($fcmd, "port_enable=0;port_enable=1;port_enable=2;port_enable=3;");
fprintf($fcmd,"start;\n"); fprintf($fcmd,"start;\n");
break; break;
case "stop": case "stop":
...@@ -484,7 +502,18 @@ else ...@@ -484,7 +502,18 @@ else
$dir_name = $_GET['name']; $dir_name = $_GET['name'];
if (isset($dir_name) && (($dir_name != "") || ($dir_name != " "))) if (isset($dir_name) && (($dir_name != "") || ($dir_name != " ")))
{ {
exec('mkdir /mnt/sda1/'.$dir_name); exec('mkdir '.SSD_ROOT.$dir_name);
echo "done";
break;
}
else
break;
case "dir_prefix": // combines mkdir with set_prefix define('SSD_ROOT', '/mnt/sda1/');
$dir_name = $_GET['name'];
if (isset($dir_name) && (($dir_name != "") || ($dir_name != " ")))
{
exec('mkdir '.SSD_ROOT.$dir_name);
fprintf($fcmd, "prefix=%s;\n", SSD_ROOT.$prefix.$dir_name.'/');
echo "done"; echo "done";
break; break;
} }
...@@ -591,7 +620,7 @@ else ...@@ -591,7 +620,7 @@ else
case "set_prefix": case "set_prefix":
$prefix = $_GET['prefix']; $prefix = $_GET['prefix'];
fprintf($fcmd, "prefix=%s;\n", $prefix); fprintf($fcmd, "prefix=%s;\n", $prefix);
setcookie("directory", $prefix); // setcookie("directory", $prefix);
break; break;
case "set_debuglev": case "set_debuglev":
......
...@@ -344,15 +344,17 @@ ...@@ -344,15 +344,17 @@
fprintf($fcmd, "prefix=%s;\n", $xml_directory); fprintf($fcmd, "prefix=%s;\n", $xml_directory);
} }
else else
fprintf($fcmd, "prefix=%s;\n", "/var/hdd/"); fprintf($fcmd, "prefix=%s;\n", "/www/pages/hdd/");
} }
} }
if ($xml_format == "'none'") // use quicktime mov as default if no container format has been selected if ($xml_format == "'none'") {// use quicktime mov as default if no container format has been selected
fprintf($fcmd, "format=mov;"); fprintf($fcmd, "format=mov;");
}
// for some reason sometimes camogm was starting with all ports disabled. Temporarily enable them all (add control) // for some reason sometimes camogm was starting with all ports disabled. Temporarily enable them all (add control)
fprintf($fcmd, "port_enable=0;port_enable=1;port_enable=2;port_enable=3;"); // pipe fcmd is closed here!
// fprintf($fcmd, "port_enable=0;port_enable=1;port_enable=2;port_enable=3;");
//Warning: fprintf(): 4 is not a valid stream resource in /www/pages/camogmgui.php on line 355
} }
...@@ -664,7 +666,7 @@ ...@@ -664,7 +666,7 @@
<p style="color:red;">not operational yet!</p> <p style="color:red;">not operational yet!</p>
Detected Audio Hardware: <span id="ajax_detected_audio_hardware">loading...</span> <a href="#" onClick="check_audio_hardware();"><img src="images/reload.png" style="bottom:-2px; position:relative;"></a><br /> Detected Audio Hardware: <span id="ajax_detected_audio_hardware">loading...</span> <a href="#" onClick="check_audio_hardware();"><img src="images/reload.png" style="bottom:-2px; position:relative;"></a><br />
<br /> <br />
Test Audio Playback: <a href="#" onClick="test_audio_playback('/var/hdd/Congas.wav');"><img src="images/play_audio.png" style="position:relative; top:3px;"></a><br /> Test Audio Playback: <a href="#" onClick="test_audio_playback('/www/pages/hdd/Congas.wav');"><img src="images/play_audio.png" style="position:relative; top:3px;"></a><br />
<br /> <br />
<form method="POST" id="audioform"> <form method="POST" id="audioform">
<table cellspacing="5px"> <table cellspacing="5px">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment