Bearsampp 2026.7.28
Loading...
Searching...
No Matches
ajax.reload.status.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2025 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Website: https://bearsampp.com
6 * Github: https://github.com/Bearsampp
7 */
8
19
20header('Content-Type: application/json');
21
22$response = array();
23
24try {
25 $reloadStatusFile = Path::getLogsPath() . '/reload-status.json';
26
27 if (file_exists($reloadStatusFile)) {
28 $statusContent = file_get_contents($reloadStatusFile);
29 $status = json_decode($statusContent, true);
30
31 if ($status !== null) {
32 $response = array(
33 'completed' => true,
34 'status' => $status
35 );
36
37 Log::debug('Reload status retrieved: ' . json_encode($status));
38 } elseif (json_last_error() !== JSON_ERROR_NONE) {
39 // Invalid JSON detected (likely from concurrent partial write)
40 Log::warning('Reload status file has invalid JSON: ' . json_last_error_msg());
41 $response = array(
42 'completed' => false,
43 'message' => 'Status file being updated'
44 );
45 } else {
46 $response = array(
47 'completed' => false,
48 'message' => 'Reload in progress'
49 );
50 }
51 } else {
52 $response = array(
53 'completed' => false,
54 'message' => 'Reload in progress'
55 );
56 }
57} catch (Exception $e) {
58 Log::error('Error checking reload status: ' . $e->getMessage());
59 $response = array(
60 'error' => 'Failed to check reload status: ' . $e->getMessage(),
61 'completed' => false
62 );
63}
64
65echo json_encode($response);
static debug($data, $file=null)
static warning($data, $file=null)
static error($data, $file=null)
static getLogsPath($aetrayPath=false)