From 3e1caa8078443999129e65936f3a2062526ab1ef Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Thu, 22 Jan 2009 18:45:56 +0000 Subject: New package PHPService --- packages/phpservice/phpservice.inc | 225 ++++++++++++++++++++++++++++ packages/phpservice/phpservice.xml | 121 +++++++++++++++ packages/phpservice/phpservice_php.tmp | 186 +++++++++++++++++++++++ packages/phpservice/phpservice_php_edit.tmp | 187 +++++++++++++++++++++++ 4 files changed, 719 insertions(+) create mode 100644 packages/phpservice/phpservice.inc create mode 100644 packages/phpservice/phpservice.xml create mode 100644 packages/phpservice/phpservice_php.tmp create mode 100644 packages/phpservice/phpservice_php_edit.tmp (limited to 'packages/phpservice') diff --git a/packages/phpservice/phpservice.inc b/packages/phpservice/phpservice.inc new file mode 100644 index 00000000..bed136b2 --- /dev/null +++ b/packages/phpservice/phpservice.inc @@ -0,0 +1,225 @@ +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 sync_package_phpservice() +{ + + 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) { + + $tmp .= base64_decode($rowhelper['php']); + $tmp .= "\n"; + $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 sync_package() +{ + + global $config; + sync_package_phpservice(); + + //if (!is_dir('/usr/local/www/phpservice/')) { + //exec("mkdir /usr/local/www/phpservice/"); + //} + +} + + +function php_install_command() +{ + + global $config; + conf_mount_rw(); + config_lock(); + + //if (!is_dir('/usr/local/www/phpservice/')) { + //exec("mkdir /usr/local/www/phpservice/"); + //} + + + //rename PHP files from .tmp to .php + exec("cp /tmp/phpservice_php.tmp /usr/local/www/phpservice_php.php"); + unlink_if_exists("/tmp/phpservice_php.tmp"); + + exec("cp /tmp/phpservice.tmp /usr/local/pkg/phpservice.php"); + unlink_if_exists("/tmp/phpservice.tmp"); + + + //write_config(); + + + write_rcfile(array( + "file" => "phpservice.sh", + "start" => "/usr/local/bin/php /usr/local/pkg/phpservice.php", + "stop" => "rm /tmp/phpmonitor.pid" + ) + ); + + 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/packages/phpservice/phpservice.xml b/packages/phpservice/phpservice.xml new file mode 100644 index 00000000..03e51d26 --- /dev/null +++ b/packages/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.1 + Settings + /usr/local/pkg/phpservice.inc + + PHPService + PHP Service settings. +
Services
+ phpservice.xml + /phpservice.php +
+ + PHPService + phpservice.sh + phpservice + PHP Service + + + + Settings + /pkg_edit.php?xml=phpservice.xml&id=0 + + + + Settings + /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 + + + /usr/local/www/ + 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 + + + + + + sync_package_phpservice_settings(); + + + sync_package_phpservice_settings(); + + + php_install_command(); + + + deinstall_command(); + +
\ No newline at end of file diff --git a/packages/phpservice/phpservice_php.tmp b/packages/phpservice/phpservice_php.tmp new file mode 100644 index 00000000..2e054a18 --- /dev/null +++ b/packages/phpservice/phpservice_php.tmp @@ -0,0 +1,186 @@ + + + + + +

PHP Service:

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

PHP Service
+
+ PHP Service is an easy way to monitor Memory, CPU, and files and send events to the system log. +

+
+ + + + + + + + + + 0) { + + foreach ($a_phpservice as $ent) { + + ?> + + + + + + + + + + + + + + + + + +
NameDescription + + + + + + +
+ +
+   + +   + + + + + + +
+
+ + + + + +
+
+ +
+ + +
+
+
+
+
+
+
+
+ +
+ +
+ + + + + diff --git a/packages/phpservice/phpservice_php_edit.tmp b/packages/phpservice/phpservice_php_edit.tmp new file mode 100644 index 00000000..0e03131f --- /dev/null +++ b/packages/phpservice/phpservice_php_edit.tmp @@ -0,0 +1,187 @@ + + + + + + +

PHP Service: Edit

+ + + +
+ + +
+ +
+ + + + +
+ + + + + + +

PHP
+
+

+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Name + +
PHP + \n"; + ?> + +
Description + +
Enter the description here.
+
  + + + + +
+
+ +
+
+
+
+
+
+ +
+ +
+ + + + -- cgit v1.2.3