HEX
Server: nginx/1.18.0
System: Linux iZj6c1ieg2jrpk1z5tzi19Z 6.3.9-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 21 22:18:40 EDT 2023 x86_64
User: www (1001)
PHP: 8.2.4
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.cytocare.cn/wp-content/plugins/mailpoet/lib/Captcha/CaptchaSession.php
<?php declare(strict_types = 1);

namespace MailPoet\Captcha;

if (!defined('ABSPATH')) exit;


use MailPoet\Util\Security;
use MailPoet\WP\Functions as WPFunctions;

class CaptchaSession {
  const EXPIRATION = 1800; // 30 minutes
  const ID_LENGTH = 32;

  const SESSION_HASH_KEY = 'hash';
  const SESSION_FORM_KEY = 'form';

  private WPFunctions $wp;

  public function __construct(
    WPFunctions $wp
  ) {
    $this->wp = $wp;
  }

  public function generateSessionId(): string {
    return Security::generateRandomString(self::ID_LENGTH);
  }

  public function reset(string $sessionId): void {
    $formKey = $this->getKey($sessionId, self::SESSION_FORM_KEY);
    $hashKey = $this->getKey($sessionId, self::SESSION_HASH_KEY);
    $this->wp->deleteTransient($formKey);
    $this->wp->deleteTransient($hashKey);
  }

  public function setFormData(string $sessionId, array $data): void {
    $key = $this->getKey($sessionId, self::SESSION_FORM_KEY);
    $this->wp->setTransient($key, $data, self::EXPIRATION);
  }

  public function getFormData(string $sessionId) {
    $key = $this->getKey($sessionId, self::SESSION_FORM_KEY);
    return $this->wp->getTransient($key);
  }

  public function setCaptchaHash(string $sessionId, $hash): void {
    $key = $this->getKey($sessionId, self::SESSION_HASH_KEY);
    $this->wp->setTransient($key, $hash, self::EXPIRATION);
  }

  public function getCaptchaHash(string $sessionId) {
    $key = $this->getKey($sessionId, self::SESSION_HASH_KEY);
    return $this->wp->getTransient($key);
  }

  private function getKey(string $sessionId, string $type): string {
    return implode('_', ['MAILPOET', $sessionId, $type]);
  }
}