30 lines
1.4 KiB
PHP
30 lines
1.4 KiB
PHP
<?php
|
|
require_once __DIR__ . '/_secrets.php';
|
|
header('Content-Type: application/json');
|
|
$action = $_GET['action'] ?? 'status';
|
|
$token = $_GET['token'] ?? '';
|
|
if ($token !== 'WEVADS2026') die(json_encode(['error'=>'token']));
|
|
|
|
// OVH SMS configuration stored in ethica.sms_providers
|
|
$db = new PDO('pgsql:host=10.1.0.3;port=5432;dbname=adx_system','admin',weval_secret('WEVAL_PG_ADMIN_PASS'));
|
|
$db->exec("SET search_path TO ethica, admin");
|
|
|
|
switch($action) {
|
|
case 'status':
|
|
$providers = [];
|
|
try { foreach ($db->query("SELECT * FROM sms_providers LIMIT 5") as $r) $providers[] = $r; } catch(Exception $e) {}
|
|
echo json_encode(['ok'=>1,'configured'=>count($providers)>0,'providers'=>$providers]);
|
|
break;
|
|
case 'configure':
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') die(json_encode(['error'=>'POST']));
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$ak = $data['app_key'] ?? ''; $as = $data['app_secret'] ?? ''; $ck = $data['consumer_key'] ?? ''; $svc = $data['service_name'] ?? '';
|
|
if (!$ak || !$as || !$ck) die(json_encode(['error'=>'Missing credentials']));
|
|
|
|
$db->prepare("INSERT INTO sms_providers (provider, api_key, api_secret, consumer_key, service_name, status, created_at)
|
|
VALUES ('ovh', ?, ?, ?, ?, 'active', NOW()) ON CONFLICT DO NOTHING")
|
|
->execute([$ak, $as, $ck, $svc]);
|
|
echo json_encode(['ok'=>1,'message'=>'OVH SMS configured']);
|
|
break;
|
|
}
|