1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php
$filename = 'conf.txt';
if (!file_exists($filename)) die('Fichier'.$filename.'inexistant');
if (isset($_POST['submit'])) {
unset($_POST['submit']);
$filecontent = '';
foreach($_POST as $k => $v) {
$filecontent .= $k . ':' . implode(' ', $v) . PHP_EOL;
}
file_put_contents($filename, $filecontent);
echo 'File updated';
}
$filetoarray = file($filename);
foreach ($filetoarray as $line) {
$config[] = explode(':', $line);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php foreach ($config as $value) :?>
<br>
<?php $ips = explode(' ', $value[1]); ?>
<?php foreach ($ips as $ip) :?>
<?php if (empty($ip)) continue; ?>
<?php echo $value[0], ' '; ?>
<input type="text" name="<?php echo $value[0]; ?>[]" value="<?php echo $ip; ?>"><br>
<?php endforeach; ?>
<?php endforeach; ?>
<br/><input type="submit" name="submit" value="Valider" align="right" style="margin-left: 80px; width: 60px";>
<br/><a href=""><input type="button" name="Reset" value="Reset" align="right" style="margin-left: 80px; width: 60px";></a>
</form> |
Partager