diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/vhosts/lighty-vhosts.conf | 179 | ||||
-rw-r--r-- | config/vhosts/vhosts.inc | 228 | ||||
-rw-r--r-- | config/vhosts/vhosts.xml | 132 | ||||
-rw-r--r-- | config/vhosts/vhosts_php.tmp | 191 | ||||
-rw-r--r-- | config/vhosts/vhosts_php_edit.tmp | 231 |
5 files changed, 961 insertions, 0 deletions
diff --git a/config/vhosts/lighty-vhosts.conf b/config/vhosts/lighty-vhosts.conf new file mode 100644 index 00000000..b3178771 --- /dev/null +++ b/config/vhosts/lighty-vhosts.conf @@ -0,0 +1,179 @@ +# +# lighttpd configuration file +# +# use a it as base for lighttpd 1.0.0 and above +# +############ Options you really have to take care of #################### + +## FreeBSD! +server.event-handler = "freebsd-kqueue" +server.network-backend = "writev" ## Fixes 7.x upload issues + + + +## modules to load +server.modules = ( + "mod_accesslog", + "mod_access", "mod_accesslog", + "mod_fastcgi", "mod_cgi","mod_rewrite" + ) + +## Unused modules +# "mod_setenv", +# "mod_compress" +# "mod_redirect", +# "mod_rewrite", +# "mod_ssi", +# "mod_usertrack", +# "mod_expire", +# "mod_secdownload", +# "mod_rrdtool", +# "mod_auth", +# "mod_status", +# "mod_alias", +# "mod_proxy", +# "mod_simple_vhost", +# "mod_evhost", +# "mod_userdir", +# "mod_cgi", +# "mod_accesslog" + +## a static document-root, for virtual-hosting take look at the +## server.virtual-* options +server.document-root = "/usr/local/vhosts/" + + +# Maximum idle time with nothing being written (php downloading) +server.max-write-idle = 999 + +## where to send error-messages to +server.errorlog = "/var/log/lighttpd.error.log" + +# files to check for if .../ is requested +server.indexfiles = ( "index.php", "index.html", + "index.htm", "default.htm" ) + +# mimetype mapping +mimetype.assign = ( + ".pdf" => "application/pdf", + ".sig" => "application/pgp-signature", + ".spl" => "application/futuresplash", + ".class" => "application/octet-stream", + ".ps" => "application/postscript", + ".torrent" => "application/x-bittorrent", + ".dvi" => "application/x-dvi", + ".gz" => "application/x-gzip", + ".pac" => "application/x-ns-proxy-autoconfig", + ".swf" => "application/x-shockwave-flash", + ".tar.gz" => "application/x-tgz", + ".tgz" => "application/x-tgz", + ".tar" => "application/x-tar", + ".zip" => "application/zip", + ".mp3" => "audio/mpeg", + ".m3u" => "audio/x-mpegurl", + ".wma" => "audio/x-ms-wma", + ".wax" => "audio/x-ms-wax", + ".ogg" => "audio/x-wav", + ".wav" => "audio/x-wav", + ".gif" => "image/gif", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".xbm" => "image/x-xbitmap", + ".xpm" => "image/x-xpixmap", + ".xwd" => "image/x-xwindowdump", + ".css" => "text/css", + ".html" => "text/html", + ".htm" => "text/html", + ".js" => "text/javascript", + ".asc" => "text/plain", + ".c" => "text/plain", + ".conf" => "text/plain", + ".text" => "text/plain", + ".txt" => "text/plain", + ".dtd" => "text/xml", + ".xml" => "text/xml", + ".mpeg" => "video/mpeg", + ".mpg" => "video/mpeg", + ".mov" => "video/quicktime", + ".qt" => "video/quicktime", + ".avi" => "video/x-msvideo", + ".asf" => "video/x-ms-asf", + ".asx" => "video/x-ms-asf", + ".wmv" => "video/x-ms-wmv", + ".bz2" => "application/x-bzip", + ".tbz" => "application/x-bzip-compressed-tar", + ".tar.bz2" => "application/x-bzip-compressed-tar" + ) + +# Use the "Content-Type" extended attribute to obtain mime type if possible +#mimetypes.use-xattr = "enable" + +#### accesslog module +#accesslog.filename = "/dev/null" + +## deny access the file-extensions +# +# ~ is for backupfiles from vi, emacs, joe, ... +# .inc is often used for code includes which should in general not be part +# of the document-root +url.access-deny = ( "~", ".db" ) + + +######### Options that are good to be but not neccesary to be changed ####### + +## bind to port (default: 80) +server.port = 8001 + +## error-handler for status 404 +#server.error-handler-404 = "/error-handler.html" +#server.error-handler-404 = "/error-handler.php" + +## to help the rc.scripts +server.pid-file = "/var/run/lighty-vhosts.pid" + +## virtual directory listings +server.dir-listing = "disable" + +## enable debugging +debug.log-request-header = "disable" +debug.log-response-header = "disable" +debug.log-request-handling = "disable" +debug.log-file-not-found = "disable" + +#### compress module +#compress.cache-dir = "/tmp/lighttpd/cache/compress/" +#compress.filetype = ("text/plain", "text/html") + +#server.network-backend = "writev" + +server.upload-dirs = ( "/root/", "/tmp/", "/var/" ) + + +server.max-request-size = 2097152 + +#### fastcgi module +## read fastcgi.txt for more info +fastcgi.server = ( ".php" => + ( "localhost" => + ( + "socket" => "/tmp/php5-fastcgi.socket", + "min-procs" => 1, + "max-procs" => 1, + "idle-timeout" => 0, + "bin-environment" => ( + "PHP_FCGI_MAX_REQUESTS" => "500", + "PHP_FCGI_CHILDREN" => "1" + ), + "bin-path" => "/usr/local/php5/php-cgi" + ) + ) +) + +#### CGI module +cgi.assign = ( ".cgi" => "" ) + + + + + diff --git a/config/vhosts/vhosts.inc b/config/vhosts/vhosts.inc new file mode 100644 index 00000000..0cb88064 --- /dev/null +++ b/config/vhosts/vhosts.inc @@ -0,0 +1,228 @@ +<?php +/* $Id$ */ +/* +/* ========================================================================== */ +/* + vhosts.inc + Copyright (C) 2008 Mark J Crane + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +function pkg_is_service_running($servicename) +{ + exec("/bin/ps ax | awk '{ print $5 }'", $psout); + array_shift($psout); + foreach($psout as $line) { + $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); + } + if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { + return true; + } + else { + return false; + } +} + +function byte_convert( $bytes ) { + + if ($bytes<=0) + return '0 Byte'; + + $convention=1000; //[1000->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 vhosts_sync_package_php() +{ + + global $config; + if($config['installedpackages']['vhosts']['config'] != "") { + + conf_mount_rw(); + config_unlock(); + + $tmp = "<?php\n"; + $tmp .= "\n"; + $tmp .= "// Set time limit to indefinite execution\n"; + $tmp .= "set_time_limit (0);\n"; + $tmp .= "\n"; + $tmp .= "//run this program as long as the pid file exists\n"; + $tmp .= "\$filename = '/tmp/phpmonitor.pid';\n"; + $tmp .= "\$fp = fopen(\$filename, 'w');\n"; + $tmp .= "fwrite(\$fp, \"If this file is deleted then phpmonitor will stop.\");\n"; + $tmp .= "fclose(\$fp);\n"; + $tmp .= "unset(\$filename);\n"; + $tmp .= "\n"; + $tmp .= "//require_once(\"config.inc\");\n"; + $tmp .= "//global \$config;\n"; + $tmp .= "//\$syslogaddress = \$config['syslog']['remoteserver'];\n"; + $tmp .= "\$syslogaddress = \"127.0.0.1\";\n"; + $tmp .= "\$syslogport = 514;\n"; + $tmp .= "echo \"syslog server: \".\$syslogaddress.\"\\n\";\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "function send_to_syslog(\$syslogaddress, \$syslogport, \$syslogmsg) {\n"; + $tmp .= "\n"; + $tmp .= " \$fp = fsockopen(\"udp://\".\$syslogaddress, \$syslogport, \$errno, \$errstr);\n"; + $tmp .= " if (!\$fp) {\n"; + $tmp .= " //echo \"ERROR: \$errno - \$errstr<br />\\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']['vhosts']['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/vhosts.php","w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + + conf_mount_ro(); + + } +} + + +function php_sync_package() +{ + + global $config; + vhosts_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/vhosts/')) { + exec("mkdir /usr/local/www/packages/vhosts/"); + } + + //rename PHP files from .tmp to .php + exec("cp /tmp/vhosts_php.tmp /usr/local/www/packages/vhosts/vhosts_php.php"); + unlink_if_exists("/tmp/vhosts_php.tmp"); + + exec("cp /tmp/vhosts_php_edit.tmp /usr/local/www/packages/vhosts/vhosts_php_edit.php"); + unlink_if_exists("/tmp/vhosts_php_edit.tmp"); + + //extract php5 + exec("cp /tmp/vhosts_php_edit.tmp /usr/local/www/packages/vhosts/vhosts_php_edit.php"); + unlink_if_exists("/tmp/php5.tar.gz"); + + //write_config(); + + write_rcfile(array( + "file" => "vhosts.sh", + "start" => "/usr/local/sbin/lighttpd -f /var/etc/lighty-vhosts.conf", + "stop" => "rm /tmp/phpmonitor.pid" + ) + ); + + php_sync_package(); + //$handle = popen("/usr/local/etc/rc.d/vhosts.sh start", "r"); + //pclose($handle); + + //if (pkg_is_service_running('vhosts')) { + //documentation purposes + //} + + conf_mount_ro(); + config_unlock(); + +} + + +function deinstall_command() +{ + conf_mount_rw(); + config_lock(); + $handle = popen("/usr/local/etc/rc.d/vhosts.sh stop", "r"); + unlink_if_exists("/usr/local/pkg/vhosts.xml"); + unlink_if_exists("/usr/local/pkg/vhosts.inc"); + unlink_if_exists("/usr/local/www/vhosts.inc"); + unlink_if_exists("/usr/local/etc/rc.d/vhosts.sh"); + exec("rm -R /usr/local/php5"); + conf_mount_ro(); + config_unlock(); +} + +?>
\ No newline at end of file diff --git a/config/vhosts/vhosts.xml b/config/vhosts/vhosts.xml new file mode 100644 index 00000000..cbb01582 --- /dev/null +++ b/config/vhosts/vhosts.xml @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ========================================================================== */ +/* + vhosts.xml + Copyright (C) 2008 Mark J Crane + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + ]]> + </copyright> + <description>PHP Service</description> + <requirements>Describe your package requirements here</requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>vHosts Settings</name> + <version>0.1</version> + <title>Settings</title> + <include_file>/usr/local/pkg/vhosts.inc</include_file> + <menu> + <name>vhosts</name> + <tooltiptext>vHosts Service settings.</tooltiptext> + <section>Services</section> + <configfile>vhosts.xml</configfile> + <url>/packages/vhosts/vhosts_php.php</url> + </menu> + <service> + <name>vhosts</name> + <rcfile>vhosts.sh</rcfile> + <executable>vhosts</executable> + <description>Lighttpd web server service.</description> + </service> + <tabs> + <tab> + <text>Settings</text> + <url>/pkg_edit.php?xml=vhosts.xml&id=0</url> + <active/> + </tab> + <tab> + <text>Settings</text> + <url>/packages/vhosts_php.php</url> + <active/> + </tab> + </tabs> + <configpath>installedpackages->package->$packagename->configuration->vhosts</configpath> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/vhosts/vhosts.xml</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/vhosts/vhosts.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/tmp/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/vhosts/vhosts_php.tmp</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/tmp/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/vhosts/vhosts_php_edit.tmp</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/var/etc/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/vhosts/lighty-vhosts.conf</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/tmp/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/vhosts/php5.tar.gz</item> + </additional_files_needed> + + <fields> + <field> + <fielddescr>Variable One</fielddescr> + <fieldname>var1</fieldname> + <description>Enter the variable one here.</description> + <type>input</type> + </field> + <field> + <fielddescr>Variable Two</fielddescr> + <fieldname>var1</fieldname> + <description>Enter the variable one here.</description> + <type>input</type> + </field> + </fields> + <custom_add_php_command> + </custom_add_php_command> + <custom_php_resync_config_command> + php_sync_package(); + </custom_php_resync_config_command> + <custom_delete_php_command> + php_sync_package(); + </custom_delete_php_command> + <custom_php_install_command> + php_install_command(); + </custom_php_install_command> + <custom_php_deinstall_command> + deinstall_command(); + </custom_php_deinstall_command> +</packagegui>
\ No newline at end of file diff --git a/config/vhosts/vhosts_php.tmp b/config/vhosts/vhosts_php.tmp new file mode 100644 index 00000000..c77d50a3 --- /dev/null +++ b/config/vhosts/vhosts_php.tmp @@ -0,0 +1,191 @@ +<?php +/* $Id$ */ +/* + vhosts_php.php + Copyright (C) 2008 Mark J Crane + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.inc"); +require("/usr/local/pkg/vhosts.inc"); + +$a_vhosts = &$config['installedpackages']['vhosts']['config']; + + +if ($_GET['act'] == "del") { + if ($_GET['type'] == 'php') { + if ($a_vhosts[$_GET['id']]) { + unset($a_vhosts[$_GET['id']]); + write_config(); + header("Location: vhosts_php.php"); + exit; + } + } +} + +include("head.inc"); + +?> + + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle">vHosts Service:</p> + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/packages/vhosts/vhosts_php.php"); + display_top_tabs($tab_array); + +?> +</td></tr> +</table> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr> +<td class="tabcont" > + + <form action="vhosts_php.php" method="post" name="iform" id="iform"> + <?php + + if ($config_change == 1) { + write_config(); + $config_change = 0; + } + + //if ($savemsg) print_info_box($savemsg); + //if (file_exists($d_hostsdirty_path)): echo"<p>"; + //print_info_box_np("This is an info box."); + //echo"<br />"; + //endif; + + ?> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td><p><!--<span class="vexpl"><span class="red"><strong>PHP Service<br></strong></span>--> + 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"); + <br /><br /> + For more information see: <a href='http://doc.pfsense.org/index.php/vhosts'>http://doc.pfsense.org/index.php/vhosts</a> + </p></td> + </tr> + </table> + <br /> + + <table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="30%" class="listhdrr">Name</td> + <td width="20%" class="listhdrr">Enabled</td> + <td width="40%" class="listhdr">Description</td> + <td width="10%" class="list"> + + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="vhosts_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + + </td> + </tr> + + + <?php + + $i = 0; + if (count($a_vhosts) > 0) { + + foreach ($a_vhosts as $ent) { + + ?> + <tr> + <td class="listr" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> + <?=$ent['name'];?> + </td> + <td class="listr" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> + <?=$ent['enabled'];?> + </td> + <td class="listbg" ondblclick="document.location='vhosts_php_edit.php?id=<?=$i;?>';"> + <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?> + </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td valign="middle"><a href="vhosts_php_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> + <td><a href="vhosts_php_edit.php?type=php&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + <?php + + $i++; + } + } + ?> + + <tr> + <td class="list" colspan="3"></td> + <td class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="vhosts_php_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + + <tr> + <td class="list" colspan="3"></td> + <td class="list"></td> + </tr> + </table> + + </form> + + + <br> + <br> + <br> + <br> + <br> + <br> + <br> + <br> + +</td> +</tr> +</table> + +</div> + + +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/vhosts/vhosts_php_edit.tmp b/config/vhosts/vhosts_php_edit.tmp new file mode 100644 index 00000000..db3235d6 --- /dev/null +++ b/config/vhosts/vhosts_php_edit.tmp @@ -0,0 +1,231 @@ +<?php +/* $Id$ */ +/* + + vhosts_php_edit.php + Copyright (C) 2008 Mark J Crane + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.inc"); +require("/usr/local/pkg/vhosts.inc"); + + +$a_vhosts = &$config['installedpackages']['vhosts']['config']; + +$id = $_GET['id']; +if (isset($_POST['id'])) { + $id = $_POST['id']; +} + +if ($_GET['act'] == "del") { + if ($_GET['type'] == 'php') { + if ($a_vhosts[$_GET['id']]) { + unset($a_vhosts[$_GET['id']]); + write_config(); + php_sync_package(); + header("Location: vhosts_php.php"); + exit; + } + } +} + +if (isset($id) && $a_vhosts[$id]) { + $pconfig['name'] = $a_vhosts[$id]['name']; + $pconfig['host'] = $a_vhosts[$id]['host']; + $pconfig['ipaddress'] = $a_vhosts[$id]['ipaddress']; + $pconfig['port'] = $a_vhosts[$id]['port']; + $pconfig['enabled'] = $a_vhosts[$id]['enabled']; + $pconfig['description'] = $a_vhosts[$id]['description']; + +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + if (!$input_errors) { + + $ent = array(); + $ent['name'] = $_POST['name']; + $ent['host'] = $_POST['host']; + $ent['ipaddress'] = $_POST['ipaddress']; + $ent['port'] = $_POST['port']; + $ent['enabled'] = $_POST['enabled']; + $ent['description'] = $_POST['description']; + + if (isset($id) && $a_vhosts[$id]) { + //update + $a_vhosts[$id] = $ent; + } + else { + //add + $a_vhosts[] = $ent; + } + + write_config(); + php_sync_package(); + + header("Location: vhosts_php.php"); + exit; + } +} + +include("head.inc"); + +?> + +<script type="text/javascript" language="JavaScript"> + +function show_advanced_config() { + document.getElementById("showadvancedbox").innerHTML=''; + aodiv = document.getElementById('showadvanced'); + aodiv.style.display = "block"; +</script> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle">PHP Service: Edit</p> +<?php if ($input_errors) print_input_errors($input_errors); ?> + + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/packages/vhosts/vhosts_php.php"); + display_top_tabs($tab_array); + +?> +</td></tr> +</table> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabcont" > + + <!-- + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td><p><span class="vexpl"><span class="red"><strong>PHP<br> + </strong></span> + </p></td> + </tr> + </table> + --> + <br /> + + <form action="vhosts_php_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + + <tr> + <td width="25%" valign="top" class="vncellreq">Name</td> + <td width="75%" class="vtable"> + <input name="name" type="text" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>"> + </td> + </tr> + + <tr> + <td width="25%" valign="top" class="vncellreq">Host</td> + <td width="75%" class="vtable"> + <input name="name" type="text" class="formfld" id="host" size="40" value="<?=htmlspecialchars($pconfig['host']);?>"> + </td> + </tr> + + <tr> + <td width="25%" valign="top" class="vncellreq">IP Address</td> + <td width="75%" class="vtable"> + <input name="name" type="text" class="formfld" id="ipaddress" size="40" value="<?=htmlspecialchars($pconfig['ipaddress']);?>"> + </td> + </tr> + + <tr> + <td width="25%" valign="top" class="vncellreq">Port</td> + <td width="75%" class="vtable"> + <input name="name" type="text" class="formfld" id="port" size="40" value="<?=htmlspecialchars($pconfig['port']);?>"> + Example: 8001 + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncellreq">Enabled</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='enabled' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + break; + default: + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">Description</td> + <td width="75%" class="vtable"> + <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> + <br><span class="vexpl">Enter the description here.<br></span> + </td> + </tr> + + <tr> + <td valign="top"> </td> + <td> + <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> + <?php if (isset($id) && $a_vhosts[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>"> + <?php endif; ?> + </td> + </tr> + </table> + </form> + + <br> + <br> + <br> + <br> + <br> + <br> + + </td> + </tr> +</table> + +</div> + +<?php include("fend.inc"); ?> +</body> +</html> |