mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Add CSRF to hostapd config
And tidy things up a bit
This commit is contained in:
@@ -20,6 +20,35 @@ function CSRFValidate() {
|
||||
return hash_equals($_POST['csrf_token'], $_SESSION['csrf_token']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether array is associative
|
||||
*/
|
||||
function isAssoc($arr) {
|
||||
return array_keys($arr) !== range(0, count($arr) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Display a selector field for a form. Arguments are:
|
||||
* $name: Field name
|
||||
* $options: Array of options
|
||||
* $selected: Selected option (optional)
|
||||
* If $options is an associative array this should be the key
|
||||
*
|
||||
*/
|
||||
function SelectorOptions($name, $options, $selected = null) {
|
||||
echo "<select class=\"form-control\" name=\"$name\">";
|
||||
foreach ( $options as $opt => $label) {
|
||||
$select = '';
|
||||
$key = isAssoc($options) ? $opt : $label;
|
||||
if( $key == $selected ) {
|
||||
$select = " selected";
|
||||
}
|
||||
echo "<option value=\"$key\"$select>$label</options>";
|
||||
}
|
||||
echo "</select>";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $input
|
||||
|
Reference in New Issue
Block a user