Ich hab mir seiten durchgelesen, um xss, Remote Code Execution, sql-injektion, ... vorzubeugen. Das auf meiner ganzen Homepage zu ändern ist jetz allerdings viel arbeit. Da ich aber sowiso ein neues Projekt beginnen will, werde ich es erst in diesem umsetzen.
hab noch ein paar kleine Fragen, ob das so stimmt:
Remote Code Execution:
PHP Code:
<?php
$allowedPages = array('product', 'contact', 'imprint');
if (in_array($_GET['page'], $allowedPages)) {
include($_GET['page'] . '.php');
} else {
include('startpage.php');
}
?>
XSS:
PHP Code:
<?php
function h($text) {
return htmlentities(strip_tags($text), ENT_QUOTES);
}
?>
[...]
<div class="comment">
<h2><?php echo h($_POST['subject']) ?></h2>
<small><?php echo h($_POST['author']) ?></small>
<p>
<?php echo h($_POST['subject']) ?>
</p>
</div>
[...]
Adrian
SQL-Injektion:
PHP Code:
<?php
$sql = "SELECT FROM
users
WHERE
usename = '". mysql_real_escape_string($_POST['usename']) . "' AND
password = '" . mysql_real_escape_string($_POST['password']) . "'";
mysql_query($sql);
?>