Poprawki bezpieczeństwa formularza i panelu ustawień
- wp_unslash dla pól formularza i opcji (koniec z \' w mailach) - panel: wymagany nonce i manage_options, sanityzacja, esc_attr - reCAPTCHA: oczekiwana akcja i próg wyniku 0.5 - From z domeny strony, adres nadawcy tylko w Reply-To - honeypot bez die(), walidacja JS nie jest omijana - komunikat o nieudanej wysyłce, zachowanie wpisanych pól - nowy wygląd formularza (klasy ic-*) i szablon maila Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -39,49 +39,35 @@ class AdminMenu
|
||||
|
||||
public function InContactSettings()
|
||||
{
|
||||
$updated = isset($_POST["updated"]) ? $_POST["updated"] : "";
|
||||
$incontactconfig = isset($_REQUEST["incontact-config"])
|
||||
? $_REQUEST["incontact-config"]
|
||||
$nonce = isset($_POST["incontact-config"])
|
||||
? sanitize_text_field(wp_unslash($_POST["incontact-config"]))
|
||||
: "";
|
||||
if (
|
||||
$updated === "true" ||
|
||||
wp_verify_nonce($incontactconfig, "incontact-update")
|
||||
$_SERVER["REQUEST_METHOD"] === "POST" &&
|
||||
current_user_can("manage_options") &&
|
||||
wp_verify_nonce($nonce, "incontact-update")
|
||||
) {
|
||||
|
||||
update_option("incontact-site-key", $_POST["incontact-site-key"]);
|
||||
update_option(
|
||||
"incontact-secret-key",
|
||||
$_POST["incontact-secret-key"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-target-mail",
|
||||
$_POST["incontact-target-mail"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-ph-name",
|
||||
$_POST["incontact-form-ph-name"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-ph-email",
|
||||
$_POST["incontact-form-ph-email"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-ph-message",
|
||||
$_POST["incontact-form-ph-message"],
|
||||
);
|
||||
update_option("incontact-form-name", $_POST["incontact-form-name"]);
|
||||
update_option(
|
||||
"incontact-form-email",
|
||||
$_POST["incontact-form-email"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-message",
|
||||
$_POST["incontact-form-message"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-snd-ok",
|
||||
$_POST["incontact-form-snd-ok"],
|
||||
);
|
||||
$fields = [
|
||||
"incontact-site-key" => "sanitize_text_field",
|
||||
"incontact-secret-key" => "sanitize_text_field",
|
||||
"incontact-target-mail" => "sanitize_email",
|
||||
"incontact-form-ph-name" => "sanitize_text_field",
|
||||
"incontact-form-ph-email" => "sanitize_text_field",
|
||||
"incontact-form-ph-message" => "sanitize_text_field",
|
||||
"incontact-form-name" => "sanitize_text_field",
|
||||
"incontact-form-email" => "sanitize_text_field",
|
||||
"incontact-form-message" => "sanitize_text_field",
|
||||
"incontact-form-snd-ok" => "sanitize_text_field",
|
||||
];
|
||||
foreach ($fields as $option => $sanitize) {
|
||||
if (!isset($_POST[$option])) {
|
||||
continue;
|
||||
}
|
||||
update_option(
|
||||
$option,
|
||||
$sanitize(wp_unslash($_POST[$option])),
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="updated">
|
||||
@@ -108,9 +94,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-site-key" id="incontact-site-key" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-site-key",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-site-key")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-secret-key"><?php echo esc_html__(
|
||||
@@ -118,9 +102,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-secret-key" id="incontact-secret-key" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-secret-key",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-secret-key")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-target-mail"><?php echo esc_html__(
|
||||
@@ -128,9 +110,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-target-mail" id="incontact-target-mail" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-target-mail",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-target-mail")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -139,9 +119,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-ph-name" id="incontact-form-ph-name" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-ph-name",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-ph-name")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-ph-email"><?php echo esc_html__(
|
||||
@@ -149,9 +127,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-ph-email" id="incontact-form-ph-email" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-ph-email",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-ph-email")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-ph-message"><?php echo esc_html__(
|
||||
@@ -159,9 +135,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-ph-message" id="incontact-form-ph-message" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-ph-message",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-ph-message")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -170,9 +144,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-name" id="incontact-form-name" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-name",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-name")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-email"><?php echo esc_html__(
|
||||
@@ -180,9 +152,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-email" id="incontact-form-email" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-email",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-email")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-message"><?php echo esc_html__(
|
||||
@@ -190,9 +160,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-message" id="incontact-form-message" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-message",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-message")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -201,9 +169,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-snd-ok" id="incontact-form-snd-ok" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-snd-ok",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-snd-ok")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user