aboutsummaryrefslogtreecommitdiffstats
path: root/config/apcupsd/apcupsd_status.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/apcupsd/apcupsd_status.php')
-rwxr-xr-xconfig/apcupsd/apcupsd_status.php130
1 files changed, 50 insertions, 80 deletions
diff --git a/config/apcupsd/apcupsd_status.php b/config/apcupsd/apcupsd_status.php
index a8d3776d..04736c65 100755
--- a/config/apcupsd/apcupsd_status.php
+++ b/config/apcupsd/apcupsd_status.php
@@ -1,8 +1,9 @@
<?php
/*
apcupsd_status.php
- part of pfSense (https://www.pfsense.org/)
- Copyright (C) 2013 Danilo G. Baio <dbaio@bsd.com.br>
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2013-2015 Danilo G. Baio <dbaio@bsd.com.br>
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -26,66 +27,26 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-
require("guiconfig.inc");
require_once("apcupsd.inc");
+global $pfs_version;
+$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-if ($pf_version < 2.0)
- $one_two = true;
-
$pgtitle = "Services: Apcupsd (Status)";
include("head.inc");
-function puts( $arg ) { echo "$arg\n"; }
-
-if (isset($_GET['strapcaccess']))
- $strapcaccess = trim($_GET['strapcaccess']);
-
-?>
-
-<style>
-<!--
-
-input {
- font-family: courier new, courier;
- font-weight: normal;
- font-size: 9pt;
+function puts($arg) {
+ echo "$arg\n";
}
-pre {
- border: 2px solid #435370;
- background: #F0F0F0;
- padding: 1em;
- font-family: courier new, courier;
- white-space: pre;
- line-height: 10pt;
- font-size: 10pt;
+if (isset($_GET['strapcaccess'])) {
+ $strapcaccess = trim($_GET['strapcaccess']);
}
-.label {
- font-family: tahoma, verdana, arial, helvetica;
- font-size: 11px;
- font-weight: bold;
-}
-
-.button {
- font-family: tahoma, verdana, arial, helvetica;
- font-weight: bold;
- font-size: 11px;
-}
+?>
--->
-</style>
-</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-
- <?php include("fbegin.inc"); ?>
-
- <?php if($one_two): ?>
- <p class="pgtitle"><?=$pgtitle?></font></p>
- <?php endif; ?>
-
+<?php include("fbegin.inc"); ?>
<div id="mainlevel">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -101,70 +62,79 @@ pre {
</div>
<div id="mainarea" style="padding-top: 0px; padding-bottom: 0px; ">
- <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
- <form name="frm_apcupsd_status" method="GET">
+ <form name="frm_apcupsd_status" method="get" action="">
+ <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="14%" valign="top" class="vncellreq">Host:</td>
<td width="86%" class="vtable">
- <input name="strapcaccess" type="text" class="formfld unknown" id="strapcaccess" size="22" value="<? echo "{$strapcaccess}"; ?>">
- <br/>
+ <input name="strapcaccess" type="text" class="formfld unknown" id="strapcaccess" size="22" value="<? echo "{$strapcaccess}"; ?>" />
+ <br />
<span class="vexpl">
- Default: <b>localhost</b><br/>
- apcaccess uses apcupsd's inbuilt Network Information Server (NIS) to obtain the current status information <br/>
- from the UPS on the local or remote computer. It is therefore necessary to have the following configuration directives: <br/>
- NETSERVER on<br/>
- NISPORT 3551<br/>
- <br/>
- <?php if ($pf_version < 2.2): ?>
- <input type="Submit" value="Execute" class="formbtn" disabled/>
+ Default: <strong>localhost</strong><br /><br />
+ Note: apcaccess uses apcupsd's inbuilt Network Information Server (NIS) to obtain the current status information<br />
+ from the UPS on the local or remote computer. It is therefore necessary to have the following configuration directives: <br />
+ NETSERVER on<br />
+ NISPORT 3551<br />
+ <br />
+ <?php if ($pfs_version < 2.2): ?>
+ <input type="submit" value="Execute" class="formbtn" disabled="disabled" />
<?php else: ?>
- <input type="Submit" value="Execute" class="formbtn"/>
+ <input type="submit" value="Execute" class="formbtn" />
<?php endif; ?>
</span>
</td>
+
</tr>
- </form>
<tr><td colspan="2">
<?php
$nis_server = check_nis_running_apcupsd();
- if ($pf_version >= 2.2){
- if($strapcaccess) {
+ if ($pfs_version >= 2.2) {
+ if ($strapcaccess) {
echo "Running: apcaccess -h {$strapcaccess} <br/>";
puts("<pre>");
putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
$ph = popen("apcaccess -h {$strapcaccess} 2>&1", "r" );
- while ($line = fgets($ph)) echo htmlspecialchars($line);
+ while ($line = fgets($ph)) {
+ echo htmlspecialchars($line);
+ }
pclose($ph);
puts("</pre>");
- }elseif($nis_server){
- $nisip=(check_nis_ip_apcupsd() != ''? check_nis_ip_apcupsd() : "0.0.0.0");
- $nisport=(check_nis_port_apcupsd() != ''? check_nis_port_apcupsd() : "3551");
+ } elseif ($nis_server) {
+ $nisip = (check_nis_ip_apcupsd() != ''? check_nis_ip_apcupsd() : "0.0.0.0");
+ $nisport = (check_nis_port_apcupsd() != '' ? check_nis_port_apcupsd() : "3551");
echo "Running: apcaccess -h {$nisip}:{$nisport} <br/>";
puts("<pre>");
putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
$ph = popen("apcaccess -h localhost 2>&1", "r" );
- while ($line = fgets($ph)) echo htmlspecialchars($line);
+ while ($line = fgets($ph)) {
+ echo htmlspecialchars($line);
+ }
pclose($ph);
puts("</pre>");
- }else
- echo "Network Information Server (NIS) not running, in order to run apcaccess on localhost, you need to enable it on APCupsd General settings. <br/>";
- }else{
- echo "pfSense version prior to 2.2 runs APCupsd 3.14.10 and apcaccess doesn't accept host parameter. <br/>";
- if ($nis_server){
+ } else {
+ echo "Network Information Server (NIS) not running; in order to run apcaccess on localhost, you need to enable it on APCupsd General settings. <br />";
+ }
+ } else {
+ echo "pfSense version prior to 2.2 runs APCupsd 3.14.10 and apcaccess doesn't accept host parameter. <br />";
+ if ($nis_server) {
puts("<pre>");
putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
$ph = popen("apcaccess 2>&1", "r" );
- while ($line = fgets($ph)) echo htmlspecialchars($line);
+ while ($line = fgets($ph)) {
+ echo htmlspecialchars($line);
+ }
pclose($ph);
puts("</pre>");
- }else
- echo "Network Information Server (NIS) not running, in order to run apcaccess on localhost, you need to enable it on APCupsd General settings. <br/>";
- }
+ } else {
+ echo "Network Information Server (NIS) not running, in order to run apcaccess on localhost, you need to enable it on APCupsd General settings. <br />";
+ }
+ }
?>
</td></tr>
</table>
+ </form>
</div>
<?php
include("fend.inc");