-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathkeepalive.php
More file actions
46 lines (41 loc) · 1.22 KB
/
keepalive.php
File metadata and controls
46 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
// preload/keepalive.php
defined("ICMS_ROOT_PATH") || die("ImpressCMS root path not defined");
class IcmsPreloadKeepalive extends icms_preload_Item
{
public function eventBeforeFooter()
{
global $xoTheme;
/* ------------------------------------------------------------------
* Make sure a user object exists and is not a guest.
* ------------------------------------------------------------------*/
// The core may still be booting, so icms::$user can be null.
// We guard against that before calling isGuest().
if (
!isset(icms::$user) || // no user object yet
!is_object(icms::$user) || // defensive – just in case
icms::$user->isGuest() // guest users are ignored
) {
return;
}
/* ------------------------------------------------------------------
* Register the external script, attaching a unique id
* and the keep‑alive endpoint as a data attribute.
*/
$keepaliveUrl = ICMS_URL . "/keepalive.php";
$xoTheme->addScript(
"assets/js/keepalive.js",
[
"id" => "keepalive-script",
"data-keepalive-url" => $keepaliveUrl,
],
"", // no inline content
"module",
0, // default weight
);
}
public function eventAdminHeader()
{
$this->eventBeforeFooter();
}
}