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/wpmuhibbah_err/wp-content/plugins/give/src/Tracking/Repositories/TrackEvents.php
<?php

namespace Give\Tracking\Repositories;

use Give\Tracking\TrackingData\WebsiteInfoData;
use Give\Tracking\TrackRegisterer;

/**
 * Class EventRecord
 * @package Give\Tracking\Repositories
 *
 * @since 2.10.0
 */
class TrackEvents
{
    const TELEMETRY_REQUEST_TIME_OPTION_KEY = 'give_telemetry_usage_tracking_last_request';
    const TRACKING_EVENTS_RECORD_OPTION_KEY = 'give_telemetry_records';
    const RECENTLY_EDITED_DONATION_FORM_OPTION_KEY = 'give_telemetry_recently_edited_donation_form';

    /**
     * Remove tracks.
     *
     * @since 2.10.0
     */
    public function removeTrackList()
    {
        delete_option(self::TRACKING_EVENTS_RECORD_OPTION_KEY);
    }

    /**
     * Remove list of recently edited donation forms.
     *
     * @since 2.10.2
     */
    public function removeRecentlyEditedDonationFormList()
    {
        delete_option(self::RECENTLY_EDITED_DONATION_FORM_OPTION_KEY);
    }

    /**
     * Save tracks.
     *
     * @since 2.10.0
     */
    public function saveTrackList()
    {
        /* @var TrackRegisterer $trackRegisterer */
        $trackRegisterer = give(TrackRegisterer::class);
        update_option(self::TRACKING_EVENTS_RECORD_OPTION_KEY, $trackRegisterer->getTrackList(), false);
    }

    /**
     * Save recently edited donation form.
     *
     * @since 2.10.2
     */
    public function saveRecentlyEditedDonationForm($formId)
    {
        $formIds = $this->getRecentlyEditedDonationFormsList();
        $formIds[] = $formId;

        $formIds = array_unique($formIds);
        update_option(self::RECENTLY_EDITED_DONATION_FORM_OPTION_KEY, $formIds, false);
    }

    /**
     * Get recently edited donation form list.
     *
     * @since 2.10.2
     */
    public function getRecentlyEditedDonationFormsList()
    {
        return get_option(self::RECENTLY_EDITED_DONATION_FORM_OPTION_KEY, []);
    }

    /**
     * Get tracks list.
     *
     * @since 2.10.0
     */
    public function getTrackList()
    {
        return get_option(self::TRACKING_EVENTS_RECORD_OPTION_KEY, []);
    }

    /**
     * Save request time.
     *
     * @since 2.10.0
     */
    public function saveRequestTime()
    {
        update_option(self::TELEMETRY_REQUEST_TIME_OPTION_KEY, strtotime('- 1 hour', current_time('timestamp')), false);
    }

    /**
     * Get request time.
     *
     * @since 2.10.0
     *
     * @return false|string
     */
    public function getRequestTime()
    {
        $today = strtotime('today', current_time('timestamp'));

        return date('Y-m-d H:i:s', get_option(self::TELEMETRY_REQUEST_TIME_OPTION_KEY, $today));
    }

    /**
     * Store website tracking event.
     *
     * @since 2.10.0
     */
    public function storeWebsiteTrackingEvent()
    {
        /* @var WebsiteInfoData $dataClass */
        $dataClass = give(WebsiteInfoData::class);
        $optionName = 'give_telemetry_website_data_checksum';
        $previousChecksum = get_option($optionName, '');
        $checksum = substr(md5(serialize($dataClass->get())), 0, 32);

        if ($previousChecksum === $checksum) {
            return false;
        }

        update_option($optionName, $checksum, false);

        return true;
    }
}