1 |
<?php |
---|
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 |
include_once(dirname(__FILE__)."/../Widget.php"); |
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
class KeepSessionAlive extends CWCWidget |
---|
47 |
{ |
---|
48 |
var $mnTimeout; |
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
function KeepSessionAlive() |
---|
56 |
{ |
---|
57 |
parent::CWCWidget(); |
---|
58 |
|
---|
59 |
$this->maAttributes['TIMEOUT'] = new IntegerAttribute( 'TIMEOUT', false, 0, 1800 ); |
---|
60 |
|
---|
61 |
|
---|
62 |
$this->szWidgetDescription = <<<EOT |
---|
63 |
Allows the current session to be active. |
---|
64 |
EOT; |
---|
65 |
|
---|
66 |
$this->mnMaturityLevel = MATURITY_TECHNICALRELEASE; |
---|
67 |
} |
---|
68 |
|
---|
69 |
function InitDefaults() |
---|
70 |
{ |
---|
71 |
parent::InitDefaults(); |
---|
72 |
if (isset($this->maParams['TIMEOUT'])) |
---|
73 |
{ |
---|
74 |
$nSeconds = $this->maParams['TIMEOUT']; |
---|
75 |
} |
---|
76 |
else |
---|
77 |
$nSeconds = 60 * 10; |
---|
78 |
|
---|
79 |
$this->mnTimeout = 1000 * $nSeconds; |
---|
80 |
} |
---|
81 |
|
---|
82 |
function GetJavascriptOnLoadFunctions() |
---|
83 |
{ |
---|
84 |
$aReturn = array(); |
---|
85 |
|
---|
86 |
$aReturn['Timeout'.$this->mnId] = 'window.setTimeout( "KeepSessionAlive_'.$this->mnId.'()", '. $this->mnTimeout .');'."\n" ; |
---|
87 |
|
---|
88 |
return $aReturn; |
---|
89 |
} |
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 |
function GetJavascriptFunctions() |
---|
98 |
{ |
---|
99 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
100 |
$bCWCJSAPI = 1; |
---|
101 |
else |
---|
102 |
$bCWCJSAPI = 0; |
---|
103 |
|
---|
104 |
$szImageName = 'KeepSessionAliveImage_'.$this->mnId; |
---|
105 |
$nTimeout = $this->mnTimeout; |
---|
106 |
$szURL = $_SESSION['gszCoreWebPath'].'/widgets/KeepSessionAlive/KeepSessionAlive.php?'.SID; |
---|
107 |
$szJsFunctionName = 'KeepSessionAlive_'.$this->mnId; |
---|
108 |
$szFunction = <<<EOT |
---|
109 |
/** |
---|
110 |
* {$szJsFunctionName} |
---|
111 |
* refresh hidden image to prevent session timeouts |
---|
112 |
*/ |
---|
113 |
function {$szJsFunctionName}() |
---|
114 |
{ |
---|
115 |
//copy of cwc_dhtml.js to keep lightweight |
---|
116 |
var CWCIsNav4 = (document.layers) ? 1:0; |
---|
117 |
var CWCIsIE = (document.all) ? 1:0; |
---|
118 |
var CWCIsNav6 = (document.getElementById && !document.all) ? 1:0;var obj = null; |
---|
119 |
var szImage = "{$szImageName}"; |
---|
120 |
if (CWCIsNav4) //Netscape 4.x |
---|
121 |
{ |
---|
122 |
obj = document.images[szImage]; |
---|
123 |
} |
---|
124 |
else |
---|
125 |
{ |
---|
126 |
obj = document.getElementById(szImage); |
---|
127 |
} |
---|
128 |
if (obj != null) |
---|
129 |
{ |
---|
130 |
obj.src = "{$szURL}" + "&rand=" + Math.random(); |
---|
131 |
} |
---|
132 |
window.status = "last update: " + Date(); |
---|
133 |
window.setTimeout( "{$szJsFunctionName}()", {$nTimeout} ); |
---|
134 |
return true; |
---|
135 |
} |
---|
136 |
EOT; |
---|
137 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
138 |
|
---|
139 |
return $aReturn; |
---|
140 |
} |
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 |
function DrawPublish() |
---|
149 |
{ |
---|
150 |
$szResult = '<img name="KeepSessionAliveImage_'.$this->mnId.'" id="KeepSessionAliveImage_'.$this->mnId.'" src="'.$_SESSION['gszCoreWebPath'].'/widgets/KeepSessionAlive/KeepSessionAlive.php?'.SID.'" border="0" width="1" height="1">'; |
---|
151 |
return $szResult; |
---|
152 |
} |
---|
153 |
} |
---|
154 |
?> |
---|
155 |
|
---|