| Server IP : 172.173.179.141 / Your IP : 216.73.216.196 Web Server : Apache System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.2.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/dev/htdocs/custom/.ecommerceng442/ |
Upload File : |
<?php
/* Copyright (C) 2010 Franck Charpentier - Auguria <franck.charpentier@auguria.net>
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
// Change this following line to use the correct relative path (../, ../../, etc)
$res=0;
if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
dol_include_once("/ecommerceng/class/business/eCommercePendingWebHook.class.php");
/*dol_syslog('_SERVER : ' . json_encode($_SERVER), LOG_ERR);
dol_syslog('_REQUEST : ' . json_encode($_REQUEST), LOG_ERR);
dol_syslog('_POST : ' . json_encode($_POST), LOG_ERR);
dol_syslog('_GET : ' . json_encode($_GET), LOG_ERR);
dol_syslog('HTTP_RAW_POST_DATA : ' . json_encode($HTTP_RAW_POST_DATA), LOG_ERR);
$postdata = file_get_contents("php://input");
dol_syslog('postdata : ' . json_encode($postdata), LOG_ERR);
dol_syslog('_FILES : ' . json_encode($_FILES), LOG_ERR);*/
$langs->load("ecommerce@ecommerceng");
$site_id = GETPOST('ecommerce_id', 'int');
if (!($site_id > 0)) {
// Bad values
dol_syslog("webhooks.php - Error bad values: ecommerce_id", LOG_ERR);
http_response_code(400);
die();
}
if (GETPOST('webhook_id', 'int') > 0) {
// Test webhook links
http_response_code(200);
die();
}
$webhook = new eCommercePendingWebHook($db);
// Set values
$webhook->site_id = $site_id;
$webhook->delivery_id = $_SERVER['HTTP_X_WC_WEBHOOK_DELIVERY_ID'];
$webhook->webhook_id = $_SERVER['HTTP_X_WC_WEBHOOK_ID'];
$webhook->webhook_topic = $_SERVER['HTTP_X_WC_WEBHOOK_TOPIC'];
$webhook->webhook_event = $_SERVER['HTTP_X_WC_WEBHOOK_EVENT'];
$webhook->webhook_resource = $_SERVER['HTTP_X_WC_WEBHOOK_RESOURCE'];
$webhook->webhook_signature = $_SERVER['HTTP_X_WC_WEBHOOK_SIGNATURE'];
$webhook->webhook_source = $_SERVER['HTTP_X_WC_WEBHOOK_SOURCE'];
$webhook->webhook_data = file_get_contents("php://input");
// Check values
$result = $webhook->check();
if ($result == -1) {
// Bad values
dol_syslog("webhooks.php - Error bad values: " . $webhook->errorsToString(), LOG_ERR);
http_response_code(400);
die();
} elseif ($result == -2) {
// Unauthorized
dol_syslog("webhooks.php - Error check signature failed", LOG_ERR);
http_response_code(401);
die();
}
$result = $webhook->create();
if ($result < 0) {
// Error
dol_syslog("webhooks.php - Error create webhook: " . $webhook->errorsToString(), LOG_ERR);
http_response_code(500);
die();
}
http_response_code(200);
$db->close();