24 lines
800 B
PHP
Executable File
24 lines
800 B
PHP
Executable File
|
|
<?php
|
|
header('Content-Type: application/json');
|
|
try {
|
|
$dbfile = '/opt/n8n/.n8n/database.sqlite';
|
|
if (!file_exists($dbfile)) {
|
|
throw new Exception("Database not found");
|
|
}
|
|
|
|
$total = trim(shell_exec("sqlite3 '$dbfile' 'SELECT COUNT(*) FROM workflow_entity;'"));
|
|
$active = trim(shell_exec("sqlite3 '$dbfile' 'SELECT COUNT(*) FROM workflow_entity WHERE active=1;'"));
|
|
$workflows = shell_exec("sqlite3 -json '$dbfile' 'SELECT id, name, active FROM workflow_entity ORDER BY name;'");
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'total' => (int)$total,
|
|
'active' => (int)$active,
|
|
'workflows' => json_decode($workflows) ?: []
|
|
]);
|
|
} catch(Exception $e) {
|
|
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
|
}
|
|
|