@ 2013-11-08T19:29:24Z <?php
# You must set this correctly to a
# location where you are allowed to
# create a file!
$guestbook = 'guestbook.dat';
# Choose your own password
$adminPassword = '$uP3rDUP3r';
# Hide harmless warning messages that confuse users.
# If you have problems and you don't know why,
# comment this line out for a while to get more
# information from PHP
error_reporting (E_ALL ^ (E_NOTICE | E_WARNING));
# No changes required below here
$admin = 0;
if ($adminPassword == 'Change$') {
die("You need to change \$adminPassword first.");
}
# Undo magic quotes - useless for flat files,
# and inadequate and therefore dangerous for databases. See:
# http://www.boutell.com/newfaq/creating/magicquotes.html
function stripslashes_nested($v)
{
if (is_array($v)) {
return array_map('stripslashes_nested', $v);
} else {
return stripslashes($v);
}
}
if (get_magic_quotes_gpc()) {
$_GET = stripslashes_nested($_GET);
$_POST = stripslashes_nested($_POST);
}
?>
<html>
<head>
<title>Guestbook</title>
</head>
<body>
<h1 align="center">Triumphant Personal Care Guestbook</h1>
<div align="center">
<?php
$password = "";
if ($_POST['password'] == $adminPassword) {
$admin = 1;
$password = $adminPassword;
} else if (strlen($_POST['password'])) {
echo("<h2>Login Failed (Bad Password)</h2>\n");
}
?>
<table border="0" cellpadding="3" cellspacing="3">
<tr><th>Date</th><th>Last Name</th><th>Comment</th>
<?php
if ($admin) {
echo "<th>Controls</th>";
}
?>
</tr>
<?php
if ($_POST['submit']) {
$file = fopen($guestbook, "a");
if (!$file) {
die("Can't write to guestbook file");
}
$date = date('F j, Y, g:i a');
$id = rand();
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$name = clean($name, 40);
$lastname = clean($lastname, 40);
$email = clean($email, 40);
$comment = clean($comment, 40);
fwrite($file,
"$date\t$name\t$lastname\t$email\t$comment\t$id\n");
fclose($file);
}
$file = fopen($guestbook, 'r');
$tfile = null;
$delete = 0;
$deleteId = '';
if ($admin && $_POST['delete']) {
$delete = 1;
$deleteId = $_POST['id'];
$tfile = @fopen("$guestbook.tmp", 'w');
if (!$tfile) {
die("Can't create temporary file for delete operation");
}
}
if ($file) {
while (!feof($file)) {
$line = fgets($file);
$line = trim($line);
list ($date, $name, $lastname, $email, $comment, $id) =
split("\t", $line, 6);
if (!strlen($date)) {
break;
}
if (!strlen($id)) {
// Support my old version
$id = $date;
}
if ($delete) {
if ($id == $deleteId) {
continue;
} else {
fwrite($tfile,
"$date\t$name\t$lastname\t$email\t$comment\t$id\n");
}
}
echo "<tr><td>$date</td><td>$lastname</td><td>$comment</td>";
if ($admin) {
echo "<td>";
echo "<form action=\"keith.php\" " .
"method=\"POST\">";
passwordField();
hiddenField('id', $id);
echo "<input type=\"submit\" " .
"value=\"Delete\" " .
"name=\"delete\">";
echo "</form>";
echo "</td>";
}
echo "</tr>\n";
}
fclose($file);
if ($delete) {
fclose($tfile);
unlink($guestbook);
rename("$guestbook.tmp", $guestbook);
}
}
function clean($name, $max) {
# Turn tabs and CRs into spaces so they can't
# fake other fields or extra entries
$name = ereg_replace("[[:space:]]", ' ', $name);
# Escape < > and and & so they
# can't mess withour HTML markup
$name = ereg_replace('&', '&', $name);
$name = ereg_replace('<', '<', $name);
$name = ereg_replace('>', '>', $name);
# Don't allow excessively long entries
$name = substr($name, 0, $max);
# Undo PHP's "magic quotes" feature, which has
# inserted a \ in front of any " characters.
# We undo this because we're using a file, not a
# database, so we don't want " escaped. Those
# using databases should do the opposite:
# call addslashes if get_magic_quotes_gpc()
# returns false.
return $name;
}
function passwordField() {
global $admin;
global $password;
if (!$admin) {
return;
}
hiddenField('password', $password);
}
function hiddenField($name, $value) {
echo "<input type=\"hidden\" " .
"name=\"$name\" value=\"$value\">";
}
?>
</table>
<?php
if (!$admin) {
?>
<form action="keith.php" method="POST">
<b>Admin Login</b>
<p>
Admin Password: <input type="password" name="password">
<input type="submit" name="login" value="Log In">
</form>
<?php
}
?>
<form action="keith.php" method="POST">
<table border="0" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2">Sign My Guestbook!</td>
</tr>
<tr>
<th>Name</th><td><input name="name" maxlength="40"></td>
</tr>
<tr>
<th>Last Name</th><td><input name="lastname" maxlength="40"></td>
</tr>
<tr>
<th>Email</th><td><input name="email" maxlength="40"></td>
</tr>
<tr>
<th>Comment</th><td><input name="comment" maxlength="40"></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="Sign the Guestbook">
</th>
</tr>
</table>
<?php
passwordField();
?>
</form>
</div>
</body>
</html>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.1.7 0.000 0.008 16.93 7.1.6 0.010 0.013 19.17 7.1.5 0.009 0.012 17.14 7.1.0 0.007 0.030 22.33 7.0.20 0.003 0.006 16.82 7.0.14 0.000 0.080 22.09 7.0.10 0.033 0.070 20.09 7.0.9 0.020 0.080 20.06 7.0.8 0.010 0.083 20.02 7.0.7 0.017 0.080 19.94 7.0.6 0.010 0.070 20.16 7.0.5 0.020 0.083 20.41 7.0.4 0.007 0.047 20.13 7.0.3 0.017 0.053 20.04 7.0.2 0.003 0.083 20.15 7.0.1 0.003 0.093 20.04 7.0.0 0.003 0.090 20.09 5.6.28 0.003 0.073 21.19 5.6.25 0.007 0.087 20.75 5.6.24 0.003 0.067 20.61 5.6.23 0.007 0.050 20.69 5.6.22 0.010 0.077 20.65 5.6.21 0.010 0.080 20.73 5.6.20 0.013 0.073 21.07 5.6.19 0.007 0.083 21.07 5.6.18 0.010 0.077 21.08 5.6.17 0.003 0.047 21.05 5.6.16 0.007 0.050 21.14 5.6.15 0.010 0.073 20.98 5.6.14 0.013 0.077 20.97 5.6.13 0.013 0.043 21.11 5.6.12 0.013 0.080 21.05 5.6.11 0.010 0.033 20.98 5.6.10 0.010 0.080 21.03 5.6.9 0.007 0.083 21.02 5.6.8 0.007 0.077 20.48 5.6.7 0.007 0.073 20.55 5.6.6 0.007 0.050 20.39 5.6.5 0.010 0.063 20.38 5.6.4 0.007 0.043 20.57 5.6.3 0.010 0.033 20.33 5.6.2 0.010 0.070 20.35 5.6.1 0.003 0.043 20.43 5.6.0 0.010 0.077 20.40 5.5.38 0.017 0.070 20.53 5.5.37 0.013 0.077 20.41 5.5.36 0.007 0.077 20.56 5.5.35 0.000 0.063 20.46 5.5.34 0.013 0.050 20.79 5.5.33 0.003 0.087 20.95 5.5.32 0.003 0.080 20.80 5.5.31 0.003 0.043 20.90 5.5.30 0.003 0.050 20.77 5.5.29 0.013 0.067 20.91 5.5.28 0.000 0.047 20.85 5.5.27 0.007 0.080 20.93 5.5.26 0.007 0.077 20.84 5.5.25 0.007 0.070 20.77 5.5.24 0.003 0.077 20.32 5.5.23 0.010 0.063 20.32 5.5.22 0.003 0.050 20.29 5.5.21 0.013 0.067 20.25 5.5.20 0.010 0.040 20.15 5.5.19 0.007 0.083 20.21 5.5.18 0.017 0.040 20.25 5.5.16 0.010 0.070 20.31 5.5.15 0.007 0.083 20.30 5.5.14 0.003 0.067 20.24 5.5.13 0.003 0.080 20.29 5.5.12 0.007 0.083 20.23 5.5.11 0.010 0.080 20.17 5.5.10 0.010 0.073 20.14 5.5.9 0.013 0.057 20.16 5.5.8 0.003 0.073 20.15 5.5.7 0.013 0.077 20.10 5.5.6 0.010 0.050 20.18 5.5.5 0.000 0.043 20.07 5.5.4 0.010 0.073 20.06 5.5.3 0.000 0.090 20.11 5.5.2 0.013 0.067 20.04 5.5.1 0.013 0.067 20.02 5.5.0 0.010 0.073 20.00 5.4.45 0.003 0.087 19.21 5.4.44 0.007 0.067 19.55 5.4.43 0.010 0.073 19.50 5.4.42 0.010 0.037 19.41 5.4.41 0.003 0.047 19.07 5.4.40 0.003 0.073 19.12 5.4.39 0.003 0.080 19.19 5.4.38 0.007 0.073 19.05 5.4.37 0.007 0.073 19.12 5.4.36 0.000 0.057 19.16 5.4.35 0.007 0.067 19.14 5.4.34 0.010 0.067 19.03 5.4.32 0.013 0.073 19.20 5.4.31 0.000 0.073 19.06 5.4.30 0.013 0.063 19.04 5.4.29 0.003 0.077 18.84 5.4.28 0.013 0.053 19.09 5.4.27 0.013 0.073 19.12 5.4.26 0.007 0.077 18.90 5.4.25 0.003 0.063 19.22 5.4.24 0.010 0.077 18.90 5.4.23 0.003 0.073 18.93 5.4.22 0.010 0.057 19.23 5.4.21 0.010 0.067 19.12 5.4.20 0.003 0.077 19.02 5.4.19 0.010 0.070 18.89 5.4.18 0.010 0.070 18.86 5.4.17 0.007 0.057 19.20 5.4.16 0.013 0.073 18.93 5.4.15 0.013 0.073 19.14 5.4.14 0.003 0.087 16.43 5.4.13 0.013 0.057 16.41 5.4.12 0.007 0.073 16.33 5.4.11 0.007 0.057 16.54 5.4.10 0.007 0.070 16.55 5.4.9 0.010 0.067 16.55 5.4.8 0.020 0.060 16.54 5.4.7 0.000 0.077 16.43 5.4.6 0.007 0.073 16.28 5.4.5 0.000 0.040 16.45 5.4.4 0.010 0.067 16.36 5.4.3 0.000 0.060 16.48 5.4.2 0.013 0.063 16.50 5.4.1 0.007 0.073 16.33 5.4.0 0.007 0.057 15.75 5.3.29 0.003 0.070 14.64 5.3.28 0.017 0.060 14.67 5.3.27 0.013 0.067 14.68 5.3.26 0.013 0.070 14.66 5.3.25 0.007 0.047 14.63 5.3.24 0.000 0.083 14.57 5.3.23 0.003 0.077 14.59 5.3.22 0.007 0.077 14.70 5.3.21 0.010 0.067 14.63 5.3.20 0.007 0.077 14.53 5.3.19 0.007 0.053 14.62 5.3.18 0.003 0.080 14.55 5.3.17 0.007 0.070 14.57 5.3.16 0.007 0.077 14.66 5.3.15 0.007 0.063 14.67 5.3.14 0.010 0.070 14.62 5.3.13 0.010 0.067 14.58 5.3.12 0.003 0.087 14.69 5.3.11 0.003 0.067 14.60 5.3.10 0.017 0.063 14.09 5.3.9 0.007 0.077 13.99 5.3.8 0.003 0.060 13.95 5.3.7 0.003 0.067 14.12 5.3.6 0.000 0.083 14.05 5.3.5 0.010 0.040 14.11 5.3.4 0.017 0.033 14.06 5.3.3 0.010 0.057 13.96 5.3.2 0.003 0.070 13.75 5.3.1 0.007 0.073 13.71 5.3.0 0.013 0.067 13.78
preferences:dark mode live preview
34.77 ms | 401 KiB | 5 Q