</div> <h1><?php echo $res->title; ?> </h1> <?php if (empty($res->source) == false) { echo "<span class=\"label label-info\">Source : " . $res->source . "</span>"; } ?> <hr/> <?php echo $res->spj == 1 ? infoBox('<b>Notice!</b> Submissions on this problem will be special judged') : ""; ?> <?php echo $res->defunct == 'Y' ? errorBox('<b>Notice!</b> This Problem is not available') : ""; ?> <h5>Description</h5> <p><?php echo $res->description; ?> </p> <hr/> <h5>Input</h5> <p><?php echo $res->input; ?> </p><br/> <h5>Output</h5> <p><?php echo $res->output;
/** * parsePerfdata() parses a Nagios performance data string to an array * * Function adapted from PNP process_perfdata.pl. Thanks to Jörg Linge. * The function is originally taken from Nagios::Plugin::Performance * Thanks to Gavin Carr and Ton Voon * * @param String Nagios performance data * @return Array Array which contains parsed performance data information * @author Lars Michelsen <*****@*****.**> */ function parsePerfdata($sPerfdata) { $aMatches = array(); $aPerfdata = array(); // Cleanup $sPerfdata = str_replace(',', '.', $sPerfdata); $sPerfdata = preg_replace('/\\s*=\\s*/', '=', $sPerfdata); // Nagios::Plugin::Performance $sTmpPerfdata = $sPerfdata; // Parse perfdata // We are trying to match the following string: // temp=78.8F;55:93;50:98;0;100; // metric current unit warning critical min max preg_match_all('/([^=]+)=([\\d\\.\\-]+)([\\w%\\/]*);?([\\d\\.\\-:~@]+)?;?([\\d\\.\\-:~@]+)?;?([\\d\\.\\-]+)?;?([\\d\\.\\-]+)?\\s*/', $sPerfdata, $aMatches, PREG_SET_ORDER); // When no match found if (!isset($aMatches[0])) { errorBox('ERROR: Found no valid performance data in string'); } for ($i = 0, $len = sizeof($aMatches); $i < $len; $i++) { $aTmp = $aMatches[$i]; // Save needed values $aSet = array('label' => $aTmp[1], 'value' => $aTmp[2]); // Save optional values if (isset($aTmp[3])) { $aSet['uom'] = $aTmp[3]; } else { $aSet['uom'] = null; } if (isset($aTmp[4])) { $aSet['warning'] = $aTmp[4]; preg_match_all('/([\\d\\.]+):([\\d\\.]+)/', $aTmp[4], $matches); if (isset($matches[0]) && isset($matches[0][0])) { $aSet['warning_min'] = $matches[1][0]; $aSet['warning_max'] = $matches[2][0]; } } else { $aSet['warning'] = null; } if (isset($aTmp[5])) { $aSet['critical'] = $aTmp[5]; preg_match_all('/([\\d\\.]+):([\\d\\.]+)/', $aTmp[5], $matches); if (isset($matches[0]) && isset($matches[0][0])) { $aSet['critical_min'] = $matches[1][0]; $aSet['critical_max'] = $matches[2][0]; } } else { $aSet['critical'] = null; } if (isset($aTmp[6])) { $aSet['min'] = $aTmp[6]; } else { $aSet['min'] = null; } if (isset($aTmp[7])) { $aSet['max'] = $aTmp[7]; } else { $aSet['max'] = null; } $aPerfdata[] = $aSet; } return $aPerfdata; }