Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
timeout_check | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
status | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
42 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\install\controller; |
15 | |
16 | use Symfony\Component\HttpFoundation\JsonResponse; |
17 | |
18 | class timeout_check |
19 | { |
20 | /** |
21 | * @var helper |
22 | */ |
23 | protected $helper; |
24 | |
25 | /** |
26 | * @var string |
27 | */ |
28 | protected $phpbb_root_path; |
29 | |
30 | /** |
31 | * Constructor |
32 | * |
33 | * @param helper $helper |
34 | * @param string $phpbb_root_path |
35 | */ |
36 | public function __construct(helper $helper, $phpbb_root_path) |
37 | { |
38 | $this->helper = $helper; |
39 | $this->phpbb_root_path = $phpbb_root_path; |
40 | } |
41 | |
42 | /** |
43 | * Controller for querying installer status |
44 | */ |
45 | public function status() |
46 | { |
47 | $lock_file = $this->phpbb_root_path . 'store/io_lock.lock'; |
48 | $response = new JsonResponse(); |
49 | |
50 | if (!file_exists($lock_file)) |
51 | { |
52 | $response->setData(array( |
53 | 'status' => 'fail', |
54 | )); |
55 | } |
56 | else |
57 | { |
58 | $fp = @fopen($lock_file, 'r'); |
59 | |
60 | if ($fp && flock($fp, LOCK_EX | LOCK_NB)) |
61 | { |
62 | $status = (filesize($lock_file) >= 2 && fread($fp, 2) === 'ok') ? 'continue' : 'fail'; |
63 | |
64 | $response->setData(array( |
65 | 'status' => $status, |
66 | )); |
67 | flock($fp, LOCK_UN); |
68 | fclose($fp); |
69 | } |
70 | else |
71 | { |
72 | $response->setData(array( |
73 | 'status' => 'running', |
74 | )); |
75 | } |
76 | } |
77 | |
78 | return $response; |
79 | } |
80 | } |