[Additional chknet code tony@tonywhitmore.co.uk**20041018212239] { addfile ./chknet/settings.php hunk ./CHANGELOG 1 +Development - 18/10/2004 +======================== +* Added further functionality to chknet + hunk ./CHANGELOG 8 +* Added start of ChkNet code hunk ./TODO 54 -* Change to "Get help with MODULE" +* Change to "Get help with MODULE" - done with chknet hunk ./TODO 56 +* Move module settings to inside the module - probably keep table though - DONE with chknet +* Add default values to ChkNet settings table hunk ./chknet/intro.php 44 - function produce_cell($name) + function produce_cell($array) hunk ./chknet/intro.php 47 - echo "fetchRow(); - $pingpath = $row['value']; - $query = "SELECT value FROM settings WHERE function = 'pingoptions'"; - $result = $db->query($query); - if (DB::isError($db)) {die($db->getMessage());} - $row = $result->fetchRow(); - $pingoptions = $row['value']; + while ( $row = $result->fetchRow() ) + { + $$row['function'] = $row['value']; + } + hunk ./chknet/intro.php 58 - $return = "alive"; - if ( $return == "alive" ) + $output = shell_exec($pingpath . ' ' . $pingoptions . ' ' . $array['hostname']); + echo "(" . $array['hostname'] . ")\n"; hunk ./chknet/intro.php 73 + hunk ./chknet/intro.php 81 - echo "\n"; + echo "
\n"; hunk ./chknet/intro.php 90 - if ( $j = 0 ) + if ( $j == 0 ) hunk ./chknet/intro.php 98 - produce_cell($row2['name']); + produce_cell($row2); hunk ./chknet/intro.php 111 - hunk ./chknet/intro.php 125 - that a device on a hostname or IP address has responded to an ICMP request. + that a device on a hostname or IP address has responded to an ICMP echo request. hunk ./chknet/settings.php 1 - +\n"; + +$query = "SELECT * FROM chknet_settings"; + +if ( isset($_POST['not_new']) ) + { + // Pull all the current settings from the database + $result = $db->query($query); + if (DB::isError($db)) {die($db->getMessage());} + while ( $row = $result->fetchRow() ) + { // for each row in the settings table + if ( $row['function'] != "chunksperday" ) + { // Don't update the chunksperday setting, but all others + $query1 = "UPDATE chknet_settings SET value='" . $_POST[$row['function']] . "' WHERE function='" . $row['function'] . "'"; + $result1 = $db->query($query1); + if (DB::isError($db)) {die($db->getMessage());} + } + } + // Closing comment and navbutton + echo "

Settings updated!

\n"; + navbutton("intro.php","OK"); + } +else + { + // Start the form that holds the data. + echo "\n"; + // Start the table that holds the data table for formatting purposes. + echo "
\n + \n"; + echo "\n"; + echo "
\n"; + // Start the table that holds the data. + echo "\n"; + // Table title bar + echo "\n"; + echo "\n"; + echo "\n"; + + // Fetch the information from the table + $result = $db->query($query); + if (DB::isError($db)) {die($db->getMessage());} + while ( $row = $result->fetchRow() ) + { + extract ($row); + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + // Close the table + echo "\n"; + echo "
\n"; + echo "System settings for the ChkNet module\n"; + echo "
\n"; + echo ""; + // Small if loop that presents a nice version of the variable name + if ( $function == "pingpath" ) + { + echo "Full path to ping executable"; + } + elseif ( $function == "pingoptions" ) + { + echo "Options to be passed to ping before list of hostname"; + } + elseif ( $function == "refresh" ) + { + echo "Automatic refresh period for ChkNet status page (in seconds)
Default: 60"; + } + elseif ( $function == "okcolour" ) + { + echo "Colour for alive devices (in HTML hex colour format)
Default: #33FF33"; + } + elseif ( $function == "failcolour" ) + { + echo "Colour for failed devices (in HTML hex colour format)
Default: #FF0000"; + } + else + { + echo $function; + } + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + + // Close the table used for formatting purposes. + echo "
\n"; + + // Submittal button + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + } + +?> hunk ./includes/STORM/chknet/html/admin_nav.inc 54 + echo "\n"; + echo "Edit ChkNet Settings\n"; + echo "\n"; + echo "\n"; + +// Start and end the spacer cell between navigation elements. + echo "\n"; + +// Start the cell for the navigation element. + echo "\n"; hunk ./includes/STORM/chknet/misc/functions.inc 196 - $query = "SELECT value FROM settings WHERE function='chknetrefresh'"; + $query = "SELECT value FROM chknet_settings WHERE function='refresh'"; }