403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.217.105
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : root ( 0)
PHP Version : 8.2.28
Disable Function : 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,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/wp.10/wp-content/plugins/clarity-seo/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.10/wp-content/plugins/clarity-seo/includes/tracking.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}
// Keyword Tracking: Via GSC Search Analytics API, position history, reports
function clarity_seo_track_keywords() {
    $gsc_access_token = get_option('clarity_seo_gsc_access_token', '');
    $gsc_site_url = get_option('clarity_seo_gsc_site_url', '');
    if (empty($gsc_access_token) || empty($gsc_site_url)) {
        return; // Skip if not configured; no mock in production
    }
    $keywords = get_option('clarity_seo_tracked_keywords', []); // Array from settings, e.g., ['keyword1', 'keyword2']
    $history = get_option('clarity_seo_keyword_history', []);
    $end_date = gmdate('Y-m-d', strtotime('-1 day')); // Yesterday
    $start_date = gmdate('Y-m-d', strtotime('-7 days')); // Last 7 days for average
    foreach ($keywords as $kw) {
        $api_url = "https://www.googleapis.com/webmasters/v3/sites/" . urlencode($gsc_site_url) . "/searchAnalytics/query";
        $body = json_encode([
            'startDate' => $start_date,
            'endDate' => $end_date,
            'dimensions' => ['query'],
            'dimensionFilterGroups' => [
                [
                    'filters' => [
                        [
                            'dimension' => 'query',
                            'operator' => 'equals',
                            'expression' => $kw
                        ]
                    ]
                ]
            ],
            'rowLimit' => 1,
            'aggregationType' => 'byProperty'
        ]);
        $response = wp_remote_post($api_url, [
            'headers' => [
                'Authorization' => 'Bearer ' . $gsc_access_token,
                'Content-Type' => 'application/json'
            ],
            'body' => $body
        ]);
        if (is_wp_error($response)) {
            continue;
        }
        $body = wp_remote_retrieve_body($response);
        $data = json_decode($body, true);
        if (isset($data['error'])) {
            continue;
        }
        $row = $data['rows'][0] ?? null;
        $position = $row ? round($row['position'], 1) : 0;
        $impressions = $row ? $row['impressions'] : 0;
        $clicks = $row ? $row['clicks'] : 0;
        $history[$kw][] = [
            'date' => gmdate('Y-m-d'),
            'position' => $position,
            'impressions' => $impressions,
            'clicks' => $clicks
        ];
    }
    update_option('clarity_seo_keyword_history', $history);
}
add_action('clarity_seo_email_reports', 'clarity_seo_track_keywords');

// Send reports
function clarity_seo_send_email_reports() {
    $history = get_option('clarity_seo_keyword_history', []);
    if (empty($history)) return;
    $email = get_option('admin_email');
    $subject = __('Weekly SEO Report', 'clarity-seo');
    $message = __('Keyword Positions:', 'clarity-seo') . "\n";
    foreach ($history as $kw => $data) {
        $last = end($data);
        $message .= $kw . ': Position ' . $last['position'] . ', Impressions ' . $last['impressions'] . ', Clicks ' . $last['clicks'] . "\n";
    }
    wp_mail($email, $subject, $message);
}
// Add tracked keywords to settings (add field in settings.php)
?>

Youez - 2016 - github.com/yon3zu
LinuXploit