0) { $tmp .= "// name: ".$rowhelper['name']." \n"; $tmp .= "// description: " . $rowhelper['description'] . " \n\n"; $tmp .= preg_replace('/\r\n/', "\n", base64_decode($rowhelper['php'])); $tmp .= "\n"; } } } $tmp .= <<< EOF sleep(1); } ?> EOF; $fout = fopen("/usr/local/pkg/phpservice.php", "w"); fwrite($fout, $tmp); unset($tmp); fclose($fout); phpservice_write_rcfile(); if (is_service_running("phpservice")) { restart_service("phpservice"); } else { start_service("phpservice"); } } else { stop_service("phpservice"); unlink_if_exists("/usr/local/etc/rc.d/phpservice.sh"); } conf_mount_ro(); } function phpservice_write_rcfile() { write_rcfile(array( "file" => "phpservice.sh", "start" => "/usr/local/bin/php -f /usr/local/pkg/phpservice.php >> /var/log/phpservice.log &", "stop" => "/bin/rm -f /tmp/phpmonitor.pid; sleep 3" ) ); } function phpservice_custom_php_service_status_command() { exec("/bin/pgrep -fq phpservice", $output, $retval); return $retval; } function phpservice_deinstall_command() { rmdir_recursive("/usr/local/www/packages/phpservice"); unlink_if_exists("/usr/local/pkg/phpservice.php"); } ?>