Remember name

main
Pk11 3 years ago
parent 00724e30ce
commit 8e312fca42

@ -80,6 +80,18 @@
'image/png' => '.png' 'image/png' => '.png'
]; ];
if($save_cookie) {
$uid = $_COOKIE['uid'];
if(empty($uid)) {
$uid = sha1(time() . $img['tmp_name'] . $_SERVER['REMOTE_ADDR'] . UID_SALT);
setcookie('uid', $uid, 0x7FFFFFFF);
$_COOKIE['uid'] = $uid; // so that the checkbox is checked
}
setcookie('name', $name, 0x7FFFFFFF);
$_COOKIE['name'] = $name;
}
// Validate and move the uploaded image file, if necessary // Validate and move the uploaded image file, if necessary
if(!empty($img['tmp_name'])) { if(!empty($img['tmp_name'])) {
if((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg') if((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg')
@ -139,15 +151,6 @@
} }
} }
if($save_cookie) {
$uid = $_COOKIE['uid'];
if(empty($uid)) {
$uid = sha1(time() . $img['tmp_name'] . $_SERVER['REMOTE_ADDR'] . UID_SALT);
setcookie("uid", $uid, 0x7FFFFFFF);
$_COOKIE['uid'] = $uid; // so that the checkbox is checked
}
}
$trip_name = trip_name($name); $trip_name = trip_name($name);
// Add post to database // Add post to database
@ -512,7 +515,7 @@
<?php if($mobile) { ?> <?php if($mobile) { ?>
<label for="name">Name:</label> (Optional) <label for="name">Name:</label> (Optional)
<br /> <br />
<input id="name" name="name" value="<?php if(!empty($err)) echo htmlspecialchars($name); ?>" /> <input id="name" name="name" value="<?php echo htmlspecialchars($name ? : $_COOKIE['name']); ?>" />
<br /> <br />
<br /> <br />
@ -546,7 +549,7 @@
<table> <table>
<tr> <tr>
<td><label for="name">Name:</label></td> <td><label for="name">Name:</label></td>
<td><input id="name" name="name" value="<?php if(!empty($err)) echo htmlspecialchars($name); ?>" /> (Optional)</td> <td><input id="name" name="name" value="<?php echo htmlspecialchars($name ? : $_COOKIE['name']); ?>" /> (Optional)</td>
</tr> </tr>
<tr> <tr>
<td><label for="email">Email:</label></td> <td><label for="email">Email:</label></td>

Loading…
Cancel
Save