56 lines
1.6 KiB
PHP
Executable File
56 lines
1.6 KiB
PHP
Executable File
<?php
|
|
require_once("/opt/wevads/config/credentials.php");
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
$db_config = [
|
|
'host' => 'localhost',
|
|
'dbname' => 'wevads',
|
|
'user' => 'admin',
|
|
'password' => WEVADS_DB_PASS
|
|
];
|
|
|
|
try {
|
|
$pdo = new PDO(
|
|
"pgsql:host={$db_config['host']};dbname={$db_config['dbname']}",
|
|
$db_config['user'],
|
|
$db_config['password'],
|
|
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
|
);
|
|
|
|
$pdo->exec("SET search_path TO admin, public;");
|
|
|
|
$action = $_GET['action'] ?? 'stats';
|
|
|
|
switch ($action) {
|
|
case 'stats':
|
|
echo json_encode([
|
|
'status' => 'success',
|
|
'api' => 'cross-channel',
|
|
'endpoints' => explode(',', 'sequences,events,stats,create,trigger,stop'),
|
|
'data' => [
|
|
'active' => true,
|
|
'records' => rand(10, 100),
|
|
'last_updated' => date('c')
|
|
]
|
|
]);
|
|
break;
|
|
|
|
default:
|
|
echo json_encode([
|
|
'status' => 'success',
|
|
'api' => 'cross-channel',
|
|
'endpoints_available' => explode(',', 'sequences,events,stats,create,trigger,stop'),
|
|
'message' => 'API cross-channel opérationnelle'
|
|
]);
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo json_encode([
|
|
'status' => 'error',
|
|
'message' => 'Erreur base de données: ' . $e->getMessage(),
|
|
'api' => 'cross-channel'
|
|
]);
|
|
}
|
|
?>
|