| Current Path : /home/seto/888mirror.pm/ |
| Current File : /home/seto/888mirror.pm/postback.php |
<?php
require_once __DIR__ . '/includes/db.php';
// Принимаем параметры
$subid = trim($_GET['subid'] ?? '');
$event = strtolower(trim($_GET['event'] ?? 'fd'));
$payout = (float)($_GET['payout'] ?? $_GET['cpapayout'] ?? 0);
$ms_id = trim($_GET['ms_id'] ?? $_GET['MS_ID'] ?? '');
$customer_id = trim($_GET['customer_id'] ?? $_GET['Customer_ID'] ?? '');
$dynamic = trim($_GET['dynamic'] ?? '');
$dynamic2 = trim($_GET['dynamic2'] ?? '');
$tid = trim($_GET['tid'] ?? $_GET['TID'] ?? '');
$country = strtolower(trim($_GET['country'] ?? ''));
$dep_sum = trim($_GET['dep_sum'] ?? $_GET['Dep_Sum_EUR'] ?? '');
// Валидация subid
if (!$subid) {
http_response_code(400);
exit('missing subid');
}
// Допустимые типы событий
if (!in_array($event, ['fd', 'reg', 'anydep'])) {
$event = 'fd';
}
// Найти бренд по subid из таблицы stats
$click = db()->prepare("SELECT brand_id, country, landing_id FROM stats WHERE subid = ? AND event_type = 'click' LIMIT 1");
$click->execute([$subid]);
$click = $click->fetch();
$brand_id = $click ? (int)$click['brand_id'] : null;
if (!$country && $click) $country = $click['country'] ?? '';
// Сохранить все входящие параметры как JSON
$raw = json_encode($_GET, JSON_UNESCAPED_UNICODE);
// Записать конверсию
db()->prepare("
INSERT INTO conversions (subid, brand_id, event_type, payout, ms_id, customer_id, dynamic, dynamic2, tid, country, dep_sum, raw_params)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
")->execute([$subid, $brand_id, $event, $payout, $ms_id, $customer_id, $dynamic, $dynamic2, $tid, $country, $dep_sum, $raw]);
echo 'OK';