' . str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
if (file_exists(str_replace("sass_watchdog.php", "swjunk.jnk", $fn))) {
$tlout=file_get_contents(str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
unlink(str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
if (strpos($tlout, ' ' . $tpid . ' ') !== false) {
$trunning = true;
}
}
} else {
$trunning = posix_kill($tpid,0);
}
if ($trunning) {
return null;
} else {
$swis=str_replace("," . $tpid . "|" . str_replace(" ",";",explode($sasswitch[0], $command)[1]), '', $swis);
$upd=true;
}
}
$cwords=explode(' ', $command);
if (sizeof($cwords) >= $four) {
if (!file_exists($cwords[-2 + $four])) { // not good
$isthere=false;
}
} else {
$isthere=false;
}
}
$descriptorspec = array(
1 => is_string($redirectStdout) ? array('file', $redirectStdout, 'w') : array('pipe', 'w'),
2 => is_string($redirectStderr) ? array('file', $redirectStderr, 'w') : array('pipe', 'w'),
);
if (is_string($stdin)) {
$descriptorspec[0] = array('pipe', 'r');
}
//if ($iswatchdog) { file_put_contents("zz.5",""); }
if ($isthere) {
//if ($iswatchdog) { file_put_contents("zz.6",""); }
$proc = proc_open($command, $descriptorspec, $pipes, $cwd, $env, $other_options);
}
if (!is_resource($proc)) {
//throw new \Exception("Failed to start background process by command: $command");
$proc=null;
} else {
$etat=proc_get_status($proc);
if ($etat['running'] == FALSE) {
proc_close($proc);
$proc=null;
return null;
} else if ($iswatchdog) {
//if ($iswatchdog) { file_put_contents("zz.7",""); }
$swis=str_replace("," . ",", "," . $etat['pid'] . "|" . str_replace(" ",";",explode("php ", $commandin)[1]) . "," . ",", $swis);
//if ($iswatchdog) { file_put_contents("zz.8",""); }
$upd=true;
if ($upd) { file_put_contents($fn, $swis); $upd=false; }
//if ($iswatchdog) { file_put_contents("zz.9",""); }
} else {
$swis=str_replace("," . ",", "," . $etat['pid'] . "|" . $cwords[-2 + $four] . ";" . $cwords[-1 + $four] . "," . ",", $swis);
$upd=true;
$swis=str_replace('["' . ' ' . ' ' . '"]', '["' . $cwords[-2 + $four] . '","' . ' ' . ' ' . '"]', str_replace(',"' . ' ' . ' ' . '"]', ',"' . $cwords[-2 + $four] . '","' . ' ' . ' ' . '"]', $swis));
$swis=str_replace('["' . ' ' . ' ' . ' ' . '"]', '["' . $cwords[-1 + $four] . '","' . ' ' . ' ' . ' ' . '"]', str_replace(',"' . ' ' . ' ' . ' ' . '"]', ',"' . $cwords[-1 + $four] . '","' . ' ' . ' ' . ' ' . '"]', $swis));
}
}
if (is_string($stdin)) {
fwrite($pipes[0], $stdin);
fclose($pipes[0]);
}
if (!is_string($redirectStdout)) {
fclose($pipes[1]);
}
if (!is_string($redirectStderr)) {
fclose($pipes[2]);
}
return $proc;
}
if (!function_exists("readline")) { // thanks to https://stackoverflow.com/questions/23238378/call-to-undefined-function-readline
function readline($prompt = null) {
if ($prompt) {
echo $prompt;
}
$fp = fopen("php://stdin","r");
$line = rtrim(fgets($fp, 1024));
return $line;
}
}
if (!isset($argc)) { // surfing the net
if (isset($_GET['check'])) { // done via curl
dochecks(); //passthru("date");
} else if (isset($_POST['unoop'])) { // done via surfing the net
echo "";
exit;
} else if (isset($_POST['uncheck'])) { // done via surfing the net
undochecks(); //passthru("date");
} else if (isset($_GET['sanitycheck']) && isset($_GET['in1']) && isset($_GET['out1'])) { // done via surfing the net
$cmds='/usr/local/Cellar/sass/1.22.12/bin/sass';
if (isset($_GET['sasexe'])) {
if (strlen(trim($_GET['sasexe'])) != 0) {
if (realpath(str_replace('+',' ',urldecode($_GET['sasexe']))) != '') {
$cmds=realpath(str_replace('+',' ',urldecode($_GET['sasexe'])));
} else {
$cmds=str_replace('+',' ',urldecode($_GET['sasexe']));
}
} else {
$cmds="sass";
}
}
$cmdsw=' --watch ';
if (isset($_GET['sasswitch'])) {
if (strlen(trim($_GET['sasswitch'])) != 0) {
$cmdsw=str_replace('+',' ',urldecode($_GET['sasswitch']));
}
}
if (PHP_OS=='WINNT' || PHP_OS=='WIN32' || PHP_OS=='Windows') {
$lfil='nul';
$errlfil='&1';
} else {
$lfil='/dev/null';
$errlfil='/dev/null';
}
if (isset($_GET['errlogfiles'])) {
if (strlen(trim($_GET['errlogfiles'])) != 0) {
if (ourrealpath(str_replace('+',' ',urldecode($_GET['errlogfiles']))) == '') {
$errlfil=str_replace('+',' ',urldecode($_GET['errlogfiles']));
} else {
$errlfil=ourrealpath(str_replace('+',' ',urldecode($_GET['errlogfiles'])));
}
}
}
if (isset($_GET['logfiles'])) {
if (strlen(trim($_GET['logfiles'])) != 0) {
if (ourrealpath(str_replace('+',' ',urldecode($_GET['logfiles']))) == '') {
$lfil=str_replace('+',' ',urldecode($_GET['logfiles']));
} else {
$lfil=ourrealpath(str_replace('+',' ',urldecode($_GET['logfiles'])));
}
}
}
//file_put_contents('zq.1',$cmds);
//if (strpos($swis, "," . urldecode($_GET['sanitycheck']) . "|" . $phppath[0] . ";check") !== false) {
if (trim(str_replace('+',' ',urldecode($_GET['sanitycheck']))) == trim($oop[0])) {
//file_put_contents('zq.2',$cmdsw);
$one=1;
if (PHP_OS=='WINNT' || PHP_OS=='WIN32' || PHP_OS=='Windows') {
if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") === false) {
if (!startBackgroundProcess($cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil)) {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Errors calling ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Successfully called ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Would have tried to call ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
} else {
//file_put_contents('zq.3','');
if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") === false) {
//file_put_contents('zq.4',$htmlis);
if (!startBackgroundProcess($cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil)) {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Errors calling ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Successfully called ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Would have tried to call ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_GET['in' . $one] . ';' . $_GET['out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
}
//file_put_contents('zq.5',$htmlis);
}
if ($upd) { file_put_contents($fn, $swis); }
exit;
} else if (isset($_POST['in1out1']) && !isset($_POST['check'])) { // done via surfing the net
$cmds='/usr/local/Cellar/sass/1.22.12/bin/sass';
if (isset($_POST['sasexe'])) {
if (strlen(trim($_POST['sasexe'])) != 0) {
if (realpath(str_replace('+',' ',urldecode($_POST['sasexe']))) != '') {
$cmds=realpath(str_replace('+',' ',urldecode($_POST['sasexe'])));
} else {
$cmds=str_replace('+',' ',urldecode($_POST['sasexe']));
}
} else {
$cmds="sass";
}
}
$cmdsw=' --watch ';
if (isset($_POST['sasswitch'])) {
if (strlen(trim($_POST['sasswitch'])) != 0) {
$cmdsw=str_replace('+',' ',urldecode($_POST['sasswitch']));
}
}
if (PHP_OS=='WINNT' || PHP_OS=='WIN32' || PHP_OS=='Windows') {
$lfil='nul';
$errlfil='&1';
} else {
$lfil='/dev/null';
$errlfil='/dev/null';
}
if (isset($_POST['errlogfiles'])) {
if (strlen(trim($_POST['errlogfiles'])) != 0) {
if (ourrealpath(str_replace('+',' ',urldecode($_POST['errlogfiles']))) == '') {
$errlfil=str_replace('+',' ',urldecode($_POST['errlogfiles']));
} else {
$errlfil=ourrealpath(str_replace('+',' ',urldecode($_POST['errlogfiles'])));
}
}
}
if (isset($_POST['logfiles'])) {
if (strlen(trim($_POST['logfiles'])) != 0) {
if (ourrealpath(str_replace('+',' ',urldecode($_POST['logfiles']))) == '') {
$lfil=str_replace('+',' ',urldecode($_POST['logfiles']));
} else {
$lfil=ourrealpath(str_replace('+',' ',urldecode($_POST['logfiles'])));
}
}
}
$one=$preone;
while (isset($_POST['in' . $one . 'out' . $one])) {
if (strlen($_POST['in' . $one . 'out' . $one]) > 0) {
//if (sizeof($incssfiles) > $one) {
if (PHP_OS=='WINNT' || PHP_OS=='WIN32' || PHP_OS=='Windows') {
if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") === false) {
if (!startBackgroundProcess($cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil)) {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Errors calling ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Successfully called ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Would have tried to call ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
} else {
if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") === false) {
if (!startBackgroundProcess($cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil)) {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Errors calling ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Successfully called ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
} else {
ourecho(str_replace("\n","
",str_replace(">",">",str_replace("<","<","Would have tried to call ... startBackgroundProcess('" . $cmds . ' ' . $cmdsw . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[0] . ' ' . explode(' ',str_replace(';', ' ',str_replace('+',' ',urldecode($_POST['in' . $one . 'out' . $one]))))[1] . ' >> ' . $lfil . ' 2>> ' . $errlfil . "');\n"))));
}
}
//}
}
$one++;
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$swis=str_replace(' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', '' . rand(0,9) . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . '"]', $swis);
$upd=true;
}
if ($upd) { file_put_contents($fn, $swis); if ($setoffphp) { $iswatchdog=true; if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") === false) { startBackgroundProcess("php " . $phppath[0] . ";check"); } } }
if (strpos($htmlis, "uccess") !== false) {
if (PHP_OS=='WINNT' || PHP_OS=='WIN32' || PHP_OS=='Windows') {
echo "" . $htmlis . "
";
} else {
//echo "" . $htmlis . "
" . str_replace(" sh ","
sh ",str_replace(" php ","
php ",str_replace("\r","
",str_replace("\n","
",(passthru("ps -ef | grep 'sass_watchdog'") . passthru("ps -ef | grep '/sass '")))))) . "
";
if (file_exists(str_replace("sass_watchdog.php", "swjunk.jnk", $fn))) {
unlink(str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
}
exec("ps -ef | grep 'sass' | grep -v 'grep' > " . str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
$pt=file_get_contents(str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
if (file_exists(str_replace("sass_watchdog.php", "swjunk.jnk", $fn))) {
unlink(str_replace("sass_watchdog.php", "swjunk.jnk", $fn));
}
echo "" . str_replace("\r","
",str_replace("\n","
",$pt)) . "
" . $htmlis . "
";
}
exit;
} else {
echo $htmlis;
}
} else { // done via surfing the net
echo "
Sass CSS Preprocesor Supervisor and Watchdog ... RJM Programming ... September,2019 ... Optionally helps out sass --watch [inputSassSCSS] [outputCSS]
Sass 'sass --watch [inputSassSCSS] [outputCSS]' Supervisor and Watchdog
RJM Programming
September, 2019
";
}
} else { // done via command line
if ($argc > 1) {
if (strpos(strtolower($argv[1]), "check") !== false) {
$iji=$argc;
//$curlurl[0]="http://localhost:8888/sass_watchdog.php";
while ($iji == $argc) {
if (PHP_OS=='WINNT' || PHP_OS=='WIN32' || PHP_OS=='Windows') {
exec('curl "' . $curlurl[0] . '?check=' . rand(0, 198766700) . '" 2>nul');
} else {
exec('curl "' . $curlurl[0] . '?check=' . rand(0, 198766700) . '" 2> /dev/null');
}
sleep(60);
}
} else if (strpos(strtolower($argv[1]), "killall") !== false) {
undochecks();
}
}
}
// Logging information below
// ,,
?>