HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpprm/wp-content/themes/ronneby/inc/user_form/vendor/AkismetManager.php
<?php

class Dfd_Akismet_Manager {

    /**
     *
     * @var Dfd_Akismet_Manager $_instance 
     */
    private static $_instance = null;

    /**
     *
     * @var Dfd_Akismet $akismet 
     */
    private $akismet;

    public static function instance() {
        if (is_null(self::$_instance)) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    public function setAkisment() {
        if ($this->getApiKey()) {
            $this->akismet = new Dfd_Akismet(get_site_url(), $this->getApiKey());
        }
    }

    public function validate($arr_params) {
        if (isset($_SERVER['REMOTE_ADDR'])) {
            $userip = $_SERVER['REMOTE_ADDR'];
            $this->akismet->setUserIP($userip);
        }
        $this->akismet->setCommentType("contact-form");
        if (!empty($arr_params)) {
            foreach ($arr_params as $type => $value) {
                $this->addField($type, $value);
            }
        }
//        print_r($_SERVER);
        $objDateTime = new DateTime('NOW');
        $date = $objDateTime->format(DateTime::ISO8601);
        $this->akismet->setCommentDateGmt($date);
//        print_r($arr_params);
//        print_r($this->akismet->getAllFields());
        return $this->akismet->isCommentSpam();
    }

    public function addField($type, $value) {
        switch ($type) {
            case "comment_content":
                $this->akismet->setCommentContent($value);
                break;
            case "comment_author":
                $this->akismet->setCommentAuthor($value);
                break;
            case "comment_author_email":
                $this->akismet->setCommentAuthorEmail($value);
                break;
            case "comment_type":
                $this->akismet->setCommentType($value);
                break;
            case "permalink":
                $this->akismet->setPermalink($value);
                break;
            case "comment_author_url":
                $this->akismet->setCommentAuthorURL($value);
                break;

            default:
                break;
        }
    }

    public function getApiKey() {
        $api_key = "";
        if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+
            $api_key = Akismet::get_api_key();
        } else {
            if (function_exists('akismet_get_key')) {
                $api_key = akismet_get_key();
            } else {
                return false;
            }
        }
        return $api_key;
    }

    function __construct() {
        $this->setAkisment();
    }

}