1212
1313namespace RobiNN \Pca \Dashboards \OPCache ;
1414
15- use RobiNN \Pca \Config ;
1615use RobiNN \Pca \Helpers ;
1716use RobiNN \Pca \Http ;
1817use RobiNN \Pca \Paginator ;
@@ -47,6 +46,13 @@ private function deleteScript(): string {
4746 private function moreInfo (array $ status ): string {
4847 unset($ status ['scripts ' ]);
4948
49+ $ directives = opcache_get_configuration ()['directives ' ];
50+
51+ $ status ['directives ' ] = array_combine (
52+ array_map (static fn ($ key ) => str_replace ('opcache. ' , '' , $ key ), array_keys ($ directives )),
53+ $ directives
54+ );
55+
5056 return $ this ->template ->render ('partials/info_table ' , [
5157 'panel_title ' => 'OPCache Info ' ,
5258 'array ' => Helpers::convertBoolToString ($ status ),
@@ -65,15 +71,21 @@ private function getCachedScripts(array $status): array {
6571
6672 if (isset ($ status ['scripts ' ])) {
6773 foreach ($ status ['scripts ' ] as $ script ) {
68- $ name = explode ('/ ' , str_replace ('\\' , '/ ' , $ script ['full_path ' ]));
74+ $ full_path = str_replace ('\\' , '/ ' , $ script ['full_path ' ]);
75+ $ name = explode ('/ ' , $ full_path );
76+ $ script_name = $ name [array_key_last ($ name )];
77+
78+ if ((isset ($ _GET ['ignore ' ]) && $ _GET ['ignore ' ] === 'yes ' ) && Helpers::str_starts_with ($ full_path , $ _SERVER ['DOCUMENT_ROOT ' ])) {
79+ continue ;
80+ }
6981
7082 $ cached_scripts [] = [
71- 'path ' => $ script [ ' full_path ' ] ,
72- 'name ' => $ name [ array_key_last ( $ name )] ,
73- 'hits ' => $ script ['hits ' ],
83+ 'path ' => $ full_path ,
84+ 'name ' => $ script_name ,
85+ 'hits ' => Helpers:: formatNumber ( $ script ['hits ' ]) ,
7486 'memory ' => Helpers::formatBytes ($ script ['memory_consumption ' ]),
75- 'last_used ' => date (Config:: get ( ' timeformat ' ), $ script ['last_used_timestamp ' ]),
76- 'created ' => date (Config:: get ( ' timeformat ' ), $ script ['timestamp ' ]),
87+ 'last_used ' => Helpers:: formatTime ( $ script ['last_used_timestamp ' ]),
88+ 'created ' => Helpers:: formatTime ( $ script ['timestamp ' ]),
7789 'invalidate_url ' => base64_encode ($ script ['full_path ' ]),
7890 ];
7991 }
@@ -94,9 +106,13 @@ private function mainDashboard(array $status): string {
94106
95107 $ paginator = new Paginator ($ this ->template , $ cached_scripts );
96108
109+ $ is_ignored = isset ($ _GET ['ignore ' ]) && $ _GET ['ignore ' ] === 'yes ' ;
110+
97111 return $ this ->template ->render ('dashboards/opcache ' , [
98112 'cached_scripts ' => $ paginator ->getPaginated (),
99113 'paginator ' => $ paginator ->render (),
114+ 'ignore_url ' => Http::queryString (['pp ' , 'p ' ], ['ignore ' => $ is_ignored ? 'no ' : 'yes ' ]),
115+ 'is_ignored ' => $ is_ignored ,
100116 ]);
101117 }
102118}
0 commit comments