getBrowser(); $file = fopen($path."/smartfact.log", "a"); fwrite($file, date("Y-m-d H:i:s\t").$addr. "\t".$info->Platform. "\t".$info->Browser. "\t".$info->Version. "\t".($info->isMobileDevice?"mobile":""). "\t".$user. "\t".$dns."\n"); fclose($file); // http://ip-address-lookup-v4.com/ip/92.205.118.219 print($user); return; } if (isset($_GET['sourcelist'])) { $server = mysql_connect($dbhost, $dbuser, $dbpass); if (!$server) die(mysql_error()); if (!mysql_select_db($dbname, $server)) die(mysql_error()); $result = mysql_query("SELECT fSourceName AS name FROM source", $server); if (!$result) die(mysql_error()); // var res = db.query("SELECT fSourceName, fRightAscension, fDeclination ", // "FROM source"); // store the record of the "example" table into $row // Print out the contents of the entry while ($row=mysql_fetch_array($result, MYSQL_NUM)) print("'".$row[0]."'\n"); mysql_close($server); return; } if (isset($_GET['source']) && isset($_GET['time'])) { // $args = "filename":label --arg:"key1=value" --arg:"key2=value" $cmd = $path.'/makedata '.escapeshellarg($_GET['source']).' '.escapeshellarg($_GET['time']); // Execute passthru($cmd, $str); // Logging (mainly for debugging) $d = date("Y/m"); $path = "log/".$d; if (!file_exists($path)) mkdir($path, 0777, true); $file = fopen($path."/exec.log", "a"); fwrite($file, $cmd."\n".$str."\n\n"); fclose($file); print_r($str); return; } if (isset($_GET['logout'])) { if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) return; return header('HTTP/1.0 401 Successfull logout!'); } // -------------------------------------------------------------------- if (!isset($_GET['start']) && !isset($_GET['stop'])) return header('HTTP/1.0 400 Command not supported'); // -------------------------------------------------------------------- if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { header('WWW-Authenticate: Basic realm="SmartFACT++"'); header('HTTP/1.0 401 Unauthorized'); return; } $rc = login(); if ($rc!="") return header('HTTP/1.0 401 '.$rc); // -------------------------------------------------------------------- $out = array(); if (isset($_GET['stop'])) $str = exec($path."/dimctrl --user '".$_SERVER['PHP_AUTH_USER']."' --stop", $out, $rc); if (isset($_GET['start'])) { // Filename $script = '"scripts/'.$_GET['start'].'"'; unset($_GET['start']); /* $args = ""; foreach ($_GET as $key => $value) $args .= " --arg:".$key."=".$value; $str = exec($path."/dimctrl --exec ".$args, $out, $rc); */ // Label if (isset($_GET['label'])) { if ($_GET['label']>=0) $script .= ":".$_GET['label']; unset($_GET['label']); } $msg = ""; if (isset($_GET['msg'])) { if ($_GET['msg']>=0) $msg = $_GET['msg']; unset($_GET['msg']); } // Arguments if (!empty($script) && empty($msg)) { //foreach ($_GET as $key => $value) // $args .= ' --arg:"'.$key.'='.escape($value).'"'; $args = ""; foreach ($_GET as $key => $value) $args .= ' "'.$key.'"="'.$value.'"'; // $args = "filename":label --arg:"key1=value" --arg:"key2=value" $cmd = $path.'/dimctrl --user "'.$_SERVER['PHP_AUTH_USER'].'" --start '.escapeshellarg($script.$args); // Execute $str = exec($cmd, $out, $rc); // Logging (mainly for debugging) $d = date("Y/m"); $path = "log/".$d; if (!file_exists($path)) mkdir($path, 0777, true); $file = fopen($path."/exec.log", "a"); fwrite($file, $cmd."\n".$str."\n\n"); fclose($file); } if (!empty($msg)) { $msg = escape($msg); // $args = "filename":label --arg:"key1=value" --arg:"key2=value" $cmd = $path.'/dimctrl --user "'.$_SERVER['PHP_AUTH_USER'].'" --msg '.escapeshellarg($msg); // Execute $str = exec($cmd, $out, $rc); // Logging (mainly for debugging) $d = date("Y/m"); $path = "log/".$d; if (!file_exists($path)) mkdir($path, 0777, true); $file = fopen($path."/exec.log", "a"); fwrite($file, $cmd."\n".$str."\n\n"); fclose($file); } // ------------------------------------------- } if ($rc>1) return header('HTTP/1.0 500 Execution failed [rc='.$rc."]"); if ($rc==1) return header('HTTP/1.0 500 Sending command failed.'); print($_SERVER['PHP_AUTH_USER']); if (isset($_GET['debug'])) { print("\n"); print_r($out); } ?>