From 55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Fri, 6 Feb 2009 19:18:00 -0600 Subject: mv packages to config dir to match web layout --- config/phpservice/phpservice.inc | 229 ++++++++++++++++++++++++++++++ config/phpservice/phpservice.xml | 121 ++++++++++++++++ config/phpservice/phpservice_php.tmp | 192 +++++++++++++++++++++++++ config/phpservice/phpservice_php_edit.tmp | 213 +++++++++++++++++++++++++++ 4 files changed, 755 insertions(+) create mode 100644 config/phpservice/phpservice.inc create mode 100644 config/phpservice/phpservice.xml create mode 100644 config/phpservice/phpservice_php.tmp create mode 100644 config/phpservice/phpservice_php_edit.tmp (limited to 'config/phpservice') diff --git a/config/phpservice/phpservice.inc b/config/phpservice/phpservice.inc new file mode 100644 index 00000000..041dfafc --- /dev/null +++ b/config/phpservice/phpservice.inc @@ -0,0 +1,229 @@ +10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; +} + + +function phpservice_sync_package_php() +{ + + global $config; + if($config['installedpackages']['phpservice']['config'] != "") { + + conf_mount_rw(); + config_unlock(); + + + $tmp = "\\n\";\n"; + $tmp .= " } else {\n"; + $tmp .= " fwrite(\$fp, \$syslogmsg);\n"; + $tmp .= " fclose(\$fp);\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "//\$msg = \"1.begin loop. \".date('r').\"\\n\";\n"; + $tmp .= "//\$fp = fopen('/tmp/phpmonitor.txt', 'a');\n"; + $tmp .= "//fwrite(\$fp, \$msg.\"\\n\");\n"; + $tmp .= "//fclose(\$fp);\n"; + $tmp .= "\n"; + $tmp .= "\$x = 0;\n"; + $tmp .= "while(\$x == 0) {\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " if(!file_exists('/tmp/phpmonitor.pid')) {\n"; + $tmp .= " //if the file does not exist then close the program.\n"; + $tmp .= " echo \"program closing\\n\";\n"; + $tmp .= " return;\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + + foreach($config['installedpackages']['phpservice']['config'] as $rowhelper) { + if ($rowhelper['enabled'] != "false") { + $tmp_php = base64_decode($rowhelper['php']); + if (strlen($tmp_php) > 0) { + $tmp .= "// name: ".$rowhelper['name']." \n"; + $tmp .= "// description: ".$rowhelper['description']." \n\n"; + $tmp .= base64_decode($rowhelper['php']); + $tmp .= "\n"; + } + } + + } + + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " //usleep(100000); //micro seconds //2 seconds 2000000\n"; + $tmp .= " sleep(1); //in seconds\n"; + $tmp .= " //if (\$x > 60){ exit; } //exit after 60 seconds for testing\n"; + $tmp .= "} //emd while\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "?>"; + + $fout = fopen("/usr/local/pkg/phpservice.php","w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + + conf_mount_ro(); + + } +} + + +function php_sync_package() +{ + + global $config; + phpservice_sync_package_php(); + +} + + +function php_install_command() +{ + + global $config; + conf_mount_rw(); + config_lock(); + + if (!is_dir('/usr/local/www/packages/')) { + exec("mkdir /usr/local/www/packages/"); + } + + if (!is_dir('/usr/local/www/packages/phpservice/')) { + exec("mkdir /usr/local/www/packages/phpservice/"); + } + + + //rename PHP files from .tmp to .php + exec("cp /tmp/phpservice_php.tmp /usr/local/www/packages/phpservice/phpservice_php.php"); + unlink_if_exists("/tmp/phpservice_php.tmp"); + + exec("cp /tmp/phpservice_php_edit.tmp /usr/local/www/packages/phpservice/phpservice_php_edit.php"); + unlink_if_exists("/tmp/phpservice_php_edit.tmp"); + + + //write_config(); + + + write_rcfile(array( + "file" => "phpservice.sh", + "start" => "/usr/local/bin/php /usr/local/pkg/phpservice.php", + "stop" => "rm /tmp/phpmonitor.pid" + ) + ); + + php_sync_package(); + //$handle = popen("/usr/local/etc/rc.d/phpservice.sh start", "r"); + //pclose($handle); + + //if (pkg_is_service_running('phpservice')) { + //documentation purposes + //} + + conf_mount_ro(); + config_unlock(); + +} + + +function deinstall_command() +{ + + conf_mount_rw(); + config_lock(); + $handle = popen("/usr/local/etc/rc.d/phpservice.sh stop", "r"); + unlink_if_exists("/usr/local/pkg/phpservice.xml"); + unlink_if_exists("/usr/local/pkg/phpservice.inc"); + unlink_if_exists("/usr/local/www/phpservice.inc"); + unlink_if_exists("/usr/local/etc/rc.d/phpservice.sh"); + conf_mount_ro(); + config_unlock(); + +} + +?> \ No newline at end of file diff --git a/config/phpservice/phpservice.xml b/config/phpservice/phpservice.xml new file mode 100644 index 00000000..e4cff8bc --- /dev/null +++ b/config/phpservice/phpservice.xml @@ -0,0 +1,121 @@ + + + + + + + + PHP Service + Describe your package requirements here + Currently there are no FAQ items provided. + PHP Service Settings + 0.3 + Settings + /usr/local/pkg/phpservice.inc + + PHPService + PHP Service settings. +
Services
+ phpservice.xml + /packages/phpservice/phpservice_php.php +
+ + phpservice + phpservice.sh + phpservice + PHP run from a command line as a service. + + + + Settings + /pkg_edit.php?xml=phpservice.xml&id=0 + + + + Settings + /packages/phpservice_php.php + + + + installedpackages->package->$packagename->configuration->phpservice + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/phpservice/phpservice.xml + + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/phpservice/phpservice.inc + + + /tmp/ + 0755 + http://www.pfsense.com/packages/config/phpservice/phpservice_php.tmp + + + /tmp/ + 0755 + http://www.pfsense.com/packages/config/phpservice/phpservice_php_edit.tmp + + + + Variable One + var1 + Enter the variable one here. + input + + + Variable Two + var1 + Enter the variable one here. + input + + + + + + php_sync_package(); + + + php_sync_package(); + + + php_install_command(); + + + deinstall_command(); + +
\ No newline at end of file diff --git a/config/phpservice/phpservice_php.tmp b/config/phpservice/phpservice_php.tmp new file mode 100644 index 00000000..45ecf425 --- /dev/null +++ b/config/phpservice/phpservice_php.tmp @@ -0,0 +1,192 @@ + + + + + +

PHP Service:

+ +
+ + +
+ +
+ + + + + +
+ +
+"; +//print_info_box_np("This is an info box."); +//echo"
"; +//endif; + +?> + + + + +

+ Is command line PHP designed to run PHP as a Service. The custom PHP code that is defined below is run over and over again inside a continuous loop. There are many possible uses such as monitoring CPU, Memory, File System Space, interacting with Snort, and many others uses that are yet to be discovered. + It can send events to the sylog that will can be viewed from the system log or remote syslog server. example: exec("logger This is a test"); +

+ For more information see: http://doc.pfsense.org/index.php/PHPService +

+
+ + + + + + + + + + + 0) { + + foreach ($a_phpservice as $ent) { + + ?> + + + + + + + + + + + + + + + + + + +
NameEnabledDescription + + + + + + +
+ +
+   + +   + +   + + + + + + +
+
+ + + + + +
+
+ +
+ + +
+
+
+
+
+
+
+
+ +
+ +
+ + + + + diff --git a/config/phpservice/phpservice_php_edit.tmp b/config/phpservice/phpservice_php_edit.tmp new file mode 100644 index 00000000..070c87d1 --- /dev/null +++ b/config/phpservice/phpservice_php_edit.tmp @@ -0,0 +1,213 @@ + + + + + + +

PHP Service: Edit

+ + + +
+ + +
+ +
+ + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Name + +
PHP + ".htmlspecialchars($pconfig['php'])."\n"; + ?> + +
Enabled + \n"; + echo " \n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " \n"; + echo " \n"; + break; + case "false": + echo " \n"; + echo " \n"; + + break; + default: + echo " \n"; + echo " \n"; + } + echo " \n"; + ?> +
Description + +
Enter the description here.
+
  + + + + +
+
+ +
+
+
+
+
+
+ +
+ +
+ + + + -- cgit v1.2.3