hesabixWCPlugin/includes/hesabix-webhook.php

34 lines
826 B
PHP
Raw Normal View History

2025-08-05 17:24:52 +03:30
<?php
/**
* Hesabix Webhook Endpoint
*
* @package Hesabix
* @author Mohammad Rezai
* @author URI https://pirouz.xyz
* @since 1.0.0
*/
if (
!(defined('STDIN') || (strtolower(php_sapi_name()) == 'cli' && (!isset($_SERVER['REMOTE_ADDR'])
|| empty($_SERVER['REMOTE_ADDR']))))
) {
if (substr(wp_hash(AUTH_KEY . 'hesabix/webhook'), 0, 10) != $_GET['token']) {
die('Bad token');
}
}
$post = file_get_contents('php://input');
$result = json_decode($post);
if (!is_object($result)) {
die('Invalid request.');
}
if ($result->Password != get_option('hesabix_webhook_password')) {
die('Invalid password.');
}
include(dirname(__FILE__) . '/class-hesabix-webhook.php');
HesabixLogService::writeLogStr("Hesabix Webhook Called");
new Hesabix_Webhook();