mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 11:44:31 +00:00
0.9.7.23: Verbindungsbezogenen Live-Status bereitstellen
This commit is contained in:
@@ -24,6 +24,7 @@ if (!function_exists('is_admin') || !is_admin())
|
||||
exit;
|
||||
}
|
||||
|
||||
$requested_connection_id = isset($_GET['connection_id']) ? max(0, (int)$_GET['connection_id']) : 0;
|
||||
$dir = PHPWG_ROOT_PATH.'_data/bratonien-tools/nc-connector-status';
|
||||
$latest = array(
|
||||
'state'=>'idle',
|
||||
@@ -41,11 +42,16 @@ $latest = array(
|
||||
'route_timestamp'=>0,
|
||||
'route_time_label'=>'Nicht verfügbar',
|
||||
'route_detail'=>'',
|
||||
'connection_id'=>$requested_connection_id,
|
||||
);
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
foreach (glob($dir.'/connection-*.json') ?: array() as $file)
|
||||
$files = $requested_connection_id > 0
|
||||
? array($dir.'/connection-'.$requested_connection_id.'.json')
|
||||
: (glob($dir.'/connection-*.json') ?: array());
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (!is_readable($file))
|
||||
{
|
||||
@@ -63,6 +69,8 @@ if (is_dir($dir))
|
||||
}
|
||||
}
|
||||
|
||||
if ($requested_connection_id === 0)
|
||||
{
|
||||
$route_file = $dir.'/route-status.json';
|
||||
if (is_readable($route_file))
|
||||
{
|
||||
@@ -111,10 +119,6 @@ if (is_dir($dir))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)$latest['timestamp'] > 0)
|
||||
{
|
||||
$latest['last_run_label'] = date('d.m.Y H:i:s', (int)$latest['timestamp']);
|
||||
}
|
||||
|
||||
$system_file = BRATONIEN_TOOLS_PATH.'include/nc_connector_system.inc.php';
|
||||
@@ -129,4 +133,27 @@ if (is_readable($system_file))
|
||||
}
|
||||
}
|
||||
|
||||
$scheduler_file = PHPWG_ROOT_PATH.'_data/bratonien-tools/nc-connector-scheduler/state.json';
|
||||
if ($requested_connection_id > 0 && is_readable($scheduler_file))
|
||||
{
|
||||
$scheduler = json_decode((string)@file_get_contents($scheduler_file), true);
|
||||
if (
|
||||
is_array($scheduler)
|
||||
&& (int)($scheduler['connection_id'] ?? 0) === $requested_connection_id
|
||||
&& in_array((string)($scheduler['state'] ?? ''), array('queued','running'), true)
|
||||
&& (int)($scheduler['timestamp'] ?? 0) >= (int)($latest['timestamp'] ?? 0)
|
||||
)
|
||||
{
|
||||
$latest['state'] = (string)$scheduler['state'];
|
||||
$latest['message'] = (string)($scheduler['message'] ?? 'NC-Abgleich läuft.');
|
||||
$latest['timestamp'] = (int)($scheduler['timestamp'] ?? time());
|
||||
$latest['error_detail'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)$latest['timestamp'] > 0)
|
||||
{
|
||||
$latest['last_run_label'] = date('d.m.Y H:i:s', (int)$latest['timestamp']);
|
||||
}
|
||||
|
||||
echo json_encode($latest, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
Reference in New Issue
Block a user