Server IP : 104.21.14.103 / Your IP : 18.117.154.217 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Form/Util/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Form\Util; if (!defined('ABSPATH')) exit; use MailPoet\WP\Functions as WPFunctions; class FieldNameObfuscator { const OBFUSCATED_FIELD_PREFIX = 'form_field_'; const HASH_LENGTH = 12; /** @var WPFunctions */ private $wp; public function __construct( WPFunctions $wp ) { $this->wp = $wp; } public function obfuscate($name) { $authKey = defined('AUTH_KEY') ? AUTH_KEY : ''; $hash = substr(md5($authKey . $this->wp->homeUrl() . $name), 0, self::HASH_LENGTH); return self::OBFUSCATED_FIELD_PREFIX . base64_encode($hash . '_' . $name); } public function deobfuscate($name) { $decoded = base64_decode(substr($name, strlen(self::OBFUSCATED_FIELD_PREFIX))); return substr($decoded, self::HASH_LENGTH + 1); } public function deobfuscateFormPayload($data) { $result = []; foreach ($data as $key => $value) { $result[$this->deobfuscateField($key)] = $value; } return $result; } private function deobfuscateField($name) { if ($this->wasFieldObfuscated($name)) { return $this->deobfuscate($name); } else { return $name; } } private function wasFieldObfuscated($name) { return strpos($name, FieldNameObfuscator::OBFUSCATED_FIELD_PREFIX) === 0; } }