| Server IP : 91.240.85.141 / Your IP : 216.73.216.223 Web Server : nginx/1.28.0 System : Linux nuevo.ru 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : ( 1029) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wpface_ru_usr/data/www/wpface.ru/wp-content/plugins/plh/inc/ |
Upload File : |
<?php
if (!defined('ABSPATH')) exit;
new ScotSetup;
class ScotSetup
{
function __construct()
{
add_action('wp_ajax_scot_action_with_rest_url', [$this, 'register_webhook']);
add_action('rest_api_init', [$this, 'register_route']);
}
public function register_route(): void
{
$webhookPath = scot_get_option('webhook_path', 'scot');
register_rest_route($webhookPath . '/v1', '/main/', [
'methods' => ['GET', 'POST'],
'permission_callback' => '__return_true',
'callback' => [$this, 'get_tg_data'],
]);
}
public function get_tg_data(): void
{
$input_data = sanitize_text_field(file_get_contents('php://input'));
$tg_data = json_decode($input_data, true, 100, JSON_UNESCAPED_UNICODE);
do_action('scot_receive_data', $tg_data);
}
function register_webhook(): void
{
check_ajax_referer('register_webhook', 'security');
$webHookAction = (!empty($_POST['btn_action']) && $_POST['btn_action'] == 'activate') ? 'setWebhook'
: 'deleteWebhook';
$webhookPath = scot_get_option('webhook_path', 'scot');
$url = get_site_url() . '/wp-json/' . $webhookPath . '/v1/main/';
$api_url = scot_get_option('telegram_server_url', 'https://api.telegram.org/bot');
$result = wp_remote_get($api_url . scot_get_option('bot_api_token') . '/' . $webHookAction . '?url=' . $url,
[
'headers' => ["Content-Type: application/json"],
]
);
wp_send_json(['message' => json_decode($result['body'])]);
}
}