diff --git a/index.php b/index.php index 1c77fdb..a4958c3 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,8 @@ Network -> SNMPv3: user profiles -> choose profile from list -> Authentication Protocol $apcPDUs['001']['privacyPassphrase'] = ''; // Administration -> Network -> SNMPv3: user profiles -> choose profile from list -> Privacy Passphrase | NOTE: The password must be 15-32 ASCII characters long. ⚠️ Special characters not allowed. $apcPDUs['001']['privacyProtocol'] = 'DES'; // Administration -> Network -> SNMPv3: user profiles -> choose profile from list -> Privacy Protocol -$apcPDUs['001']['securityLevel'] = 'noAuthNoPriv'; // Set desired security level: noAuthNoPriv | authNoPriv | authPriv | More detail: https://www.php.net/manual/en/function.snmp3-get.php +$apcPDUs['001']['securityLevel'] = 'authPriv'; // Set desired security level: noAuthNoPriv | authNoPriv | authPriv | More detail: https://www.php.net/manual/en/function.snmp3-get.php $apcPDUs['002']['active'] = false; // Set to "false", if you don't own or want to monitor more than one APC PDU @@ -56,6 +56,7 @@ $apcPDUs['002']['privacyProtocol'] = 'DES'; // Administration -> Network -> SNMPv3: user profiles -> choose profile from list -> Privacy Protocol $apcPDUs['002']['securityLevel'] = 'noAuthNoPriv'; // Set desired security level: noAuthNoPriv | authNoPriv | authPriv | More detail: https://www.php.net/manual/en/function.snmp3-get.php +#################################################### ### No further editing is needed below this line ### #################################################### @@ -78,29 +79,12 @@ $rPDUOutletStatusOutletState = '1.3.6.1.4.1.318.1.1.12.3.5.1.1.4'; -if (isset($_POST["PORT"])) { - $port = $_POST["PORT"]; -} - -if (isset($_POST["IP"])) { - $ip = $_POST["IP"]; +if (isset($_REQUEST["PORT"])) { + $port = $_REQUEST["PORT"]; } -if (isset($_POST["STATE"])) { - switch (strtoupper($_POST["STATE"])) { - case 'ON': - // If submitted state is ON (1), change to OFF (2) - $state = 2; - break; - case 'OFF': - // If submitted state is OFF (2), change to ON (1) - $state = 1; - break; - case 'REBOOT': - // If submitted state is REBOOT (3), perform reboot - $state = 3; - break; - } +if (isset($_REQUEST["IP"])) { + $ip = $_REQUEST["IP"]; } ################################################ @@ -112,25 +96,68 @@ $anytrue = false; $alltrue = true; -function errorMsg($errorType) { +function errorMsg($errorType, $erroMsgString, $affectedPDU) { + + switch ($erroMsgString) { + case 'Timeout': + $errorMsg['en']['connection']['head'] = $erroMsgString; + $errorMsg['en']['connection']['body'] = '
A '.strtolower($erroMsgString).' has occurred on the PDU with the IP address '.$affectedPDU.'. Possible reasons:
+An '.strtolower($erroMsgString).' was used to log into the PDU with the IP address '.$affectedPDU.'. Possible reasons:
+No user name has been specified for the PDU with the IP address '.$affectedPDU.'.'; + $errorMsg['en']['connection']['footer'] = 'Please consult README.md for more informations.'; + break; - $errorMsg['en']['connection']['head'] = 'Connection error'; - $errorMsg['en']['connection']['body'] = '
A connection error with the PDU under the IP address '.$apcPDU['ipAddress'].' has occurred. Possible reasons:
-A '.strtolower($erroMsgString).' has occurred on the PDU with the IP address '.$affectedPDU.'. Possible reasons:
A connection error with the error message "'.$erroMsgString.'" has occurred on the PDU with the IP address '.$affectedPDU.'.
'; + $errorMsg['en']['connection']['footer'] = 'Please consult '.explode('/', $_SERVER['SERVER_SOFTWARE'])[0].' error log for more informations.'; + } + $errorMsg['en']['invalidIP']['head'] = 'Invalid IP address'; - $errorMsg['en']['invalidIP']['body'] = 'Invalid IP address detected. Check entries on line 41, 51, etc.
'; + $errorMsg['en']['invalidIP']['body'] = 'Invalid IP address ("'.$affectedPDU.'") detected. Check entries on line 41, 51, etc.
'; $errorMsg['en']['invalidIP']['footer'] = 'Set a valid IP address to establish a connection.'; $errorMsg['en']['configuration']['head'] = 'Configuration error'; @@ -155,8 +182,25 @@ function errorMsg($errorType) { '; + } +################################################ +############### Stylesheet mgmt ################ +################################################ + +function stylesheetSource() { + + $file = 'assets/vendor/bootstrap/5.1.3/css/bootstrap.min.css'; + $local = ''; + $cloud = ''; + + if (file_exists($file)) { + echo $local; + } else { + echo $cloud; + } +} ?> @@ -169,7 +213,7 @@ function errorMsg($errorType) {