Hallo, ich wollte mal fragen ob Ihr mal auf mein Script schauen könnt und mir sagt, ob ich noch irgendwo eine gravierende Sicherheitslücke habe:
PHP-Code:
//**********************************************
// Abhängigkeiten einbinden
//**********************************************
// escape
function e($s) { return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); }
// abhängige Dateien
include('../Connections/astro_error_report.php');
include('../Connections/astro_dbconnect.php');
//**********************************************
// Initialisierung
//**********************************************
mysqli_select_db($verbindung, $datenbank) or die ("Die Datenbank existiert nicht");
//**********************************************
// Standardwerte für Templatevariablen
//**********************************************
$id = '';
$errors = array();
$formSent = false;
// Verarbeitungslogik
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$formSent = true;
$id = (isset($_POST['id']))
? $_POST['id']
//? (int) $_POST['id']
: $id;
}
if (!ctype_digit($id)){
$errors[] = 'Keine bzw. ungültige ID angegeben';
}
if (count($errors) === 0) {
$sql = "
DELETE FROM
benutzer
WHERE intID = $id
";
$abfrage = mysqli_query($verbindung, $sql);
}
}
?>
<?php if (count($errors) > 0): ?>
<h2>Fehler</h2>
<ol>
<?php foreach ($errors as $message) : ?>
<li><?php echo e($message) ?></li>
<?php endforeach; ?>
</ol>
<p>Bitte überprüfen Sie Ihre Eingaben.</p>
<?php endif; ?>
<?php if (count($errors) === 0 && $formSent) : ?>
<p>Daten gelöscht.</p>
<pre><?php echo e(print_r($_POST, true)) ?></pre>
<?php else : ?>
<form method="post" action="<?php echo e($_SERVER['SCRIPT_NAME']) ?>">
<table>
<tbody>
<tr>
<td>intID</td>
<td><input type="text" name="id" value="<?php echo e($id) ?>" /></td>
</tr>
</tbody>
</table>
<br />
<input type="submit" name="loeschen" value="Löschen" />
</form>
<?php
$selectsql = "SELECT * FROM benutzer";
$abfrage = mysqli_query($verbindung, $selectsql);
echo '<h3>Es gibt ' . mysqli_num_rows($abfrage) . ' User</h3>';
echo "<table class='daten' >";
echo "<thead>";
echo "<th class='daten'>". 'ID' . "</th>";
echo "<th class='daten'>". 'Vorname' . "</th>";
echo "<th class='daten'>". 'Nachname' . "</th>";
echo "<th class='daten'>". 'Anlagedatum' . "</th>";
echo "</thead>";
while($userdaten = mysqli_fetch_assoc($abfrage))
{
echo "<tr>";
echo "<td class='daten'>". $userdaten['intID'] . "</td>";
echo "<td class='daten'>". $userdaten['strVorname'] . "</td>";
echo "<td class='daten'>". $userdaten['strNachname'] . "</td>";
echo "<td class='daten'>". $userdaten['dtmAnlage'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
<?php endif; ?>
Kommentar