diff --git a/includes/dhcp.php b/includes/dhcp.php new file mode 100755 index 00000000..48b122b3 --- /dev/null +++ b/includes/dhcp.php @@ -0,0 +1,220 @@ + /tmp/dhcpddata',$temp ); + system( 'sudo cp /tmp/dhcpddata '. RASPI_DNSMASQ_CONFIG, $return ); + + if( $return == 0 ) { + $status->addMessage('Dnsmasq configuration updated successfully', 'success'); + } else { + $status->addMessage('Dnsmasq configuration failed to be updated', 'danger'); + } + } else { + error_log('CSRF violation'); + } + } + + exec( 'pidof dnsmasq | wc -l',$dnsmasq ); + $dnsmasq_state = ($dnsmasq[0] > 0); + + if( isset( $_POST['startdhcpd'] ) ) { + if (CSRFValidate()) { + if ($dnsmasq_state) { + $status->addMessage('dnsmasq already running', 'info'); + } else { + $line = system('sudo /etc/init.d/dnsmasq start',$return); + exec( 'pidof dnsmasq | wc -l',$dnsmasq ); + if ($dnsmasq[0] == 0) { + $status->addMessage('Failed to start dnsmasq', 'danger'); + } else { + $status->addMessage('Successfully started dnsmasq', 'success'); + } + } + } else { + error_log('CSRF violation'); + } + } elseif( isset($_POST['stopdhcpd'] ) ) { + if (CSRFValidate()) { + if ($dnsmasq_state) { + $line = system('sudo /etc/init.d/dnsmasq stop',$return); + exec( 'pidof dnsmasq | wc -l',$dnsmasq ); + if ($dnsmasq[0] == 0) { + $status->addMessage('Successfully stopped dnsmasq', 'success'); + } else { + $status->addMessage('Failed to stop dnsmasq', 'danger'); + } + } else { + $status->addMessage('dnsmasq already stopped', 'info'); + } + } else { + error_log('CSRF violation'); + } + } else { + if( $dnsmasq_state ) { + $status->addMessage('Dnsmasq is running', 'success'); + } else { + $status->addMessage('Dnsmasq is not running', 'warning'); + } + } + + exec( 'cat '. RASPI_DNSMASQ_CONFIG, $return ); + $conf = ParseConfig($return); + $arrRange = explode( ",", $conf['dhcp-range'] ); + $RangeStart = $arrRange[0]; + $RangeEnd = $arrRange[1]; + $RangeMask = $arrRange[2]; + preg_match( '/([0-9]*)([a-z])/i', $arrRange[3], $arrRangeLeaseTime ); + + switch( $arrRangeLeaseTime[2] ) { + case "h": + $hselected = " selected"; + break; + case "m": + $mselected = " selected"; + break; + case "d": + $dselected = " selected"; + break; + } + + ?> +
showMessages(); ?>
+ + + +Expire time | +MAC Address | +IP Address | +Host name | +Client ID | +
---|---|---|---|---|
Expire time | -MAC Address | -IP Address | -Host name | -Client ID | -
---|---|---|---|---|