Lines 1-2622
Link Here
|
1 |
Index: frontends/php/include/perm.inc.php |
|
|
2 |
=================================================================== |
3 |
--- frontends/php/include/perm.inc.php (revision 6620) |
4 |
+++ frontends/php/include/perm.inc.php (revision 6621) |
5 |
@@ -44,7 +44,7 @@ |
6 |
$USER_DETAILS = NULL; |
7 |
$login = FALSE; |
8 |
|
9 |
- $sessionid = get_cookie('zbx_sessionid'); |
10 |
+ $sessionid = get_request('sessionid',get_cookie('zbx_sessionid')); |
11 |
|
12 |
if(!is_null($sessionid)){ |
13 |
$sql = 'SELECT u.*,s.* '. |
14 |
Index: frontends/php/include/validate.inc.php |
15 |
=================================================================== |
16 |
--- frontends/php/include/validate.inc.php (revision 6620) |
17 |
+++ frontends/php/include/validate.inc.php (revision 6621) |
18 |
@@ -428,8 +429,12 @@ |
19 |
} |
20 |
} |
21 |
else if($opt == O_OPT){ |
22 |
- if(!isset($_REQUEST[$field])) |
23 |
+ if(!isset($_REQUEST[$field])){ |
24 |
return ZBX_VALID_OK; |
25 |
+ } |
26 |
+ else if(($flags&P_ACT) && !isset($_REQUEST['zbx_form'])){ |
27 |
+ return ZBX_VALID_ERROR; |
28 |
+ } |
29 |
} |
30 |
|
31 |
check_trim($_REQUEST[$field]); |
32 |
@@ -458,17 +463,21 @@ |
33 |
return ZBX_VALID_OK; |
34 |
} |
35 |
|
36 |
-// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION |
37 |
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION |
38 |
$system_fields=array( |
39 |
- "sessionid"=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(),NULL), |
40 |
- "switch_node"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL), |
41 |
- "triggers_hash"=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL), |
42 |
- 'print'=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1"),NULL), |
43 |
+ 'sessionid'=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(), 'isset({zbx_form})'), |
44 |
+ 'zbx_form'=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY, NULL), |
45 |
+// |
46 |
+ 'switch_node'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL), |
47 |
+ 'triggers_hash'=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL), |
48 |
+ 'print'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('1'),NULL), |
49 |
+ |
50 |
+// table sorting |
51 |
'sort'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL,NULL), |
52 |
'sortorder'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL,NULL) |
53 |
); |
54 |
|
55 |
- function invalid_url(){ |
56 |
+ function invalid_url(){ |
57 |
include_once "include/page_header.php"; |
58 |
unset_all(); |
59 |
show_error_message(S_INVALID_URL); |
60 |
Index: frontends/php/include/classes/cform.inc.php |
61 |
=================================================================== |
62 |
--- frontends/php/include/classes/cform.inc.php (revision 6620) |
63 |
+++ frontends/php/include/classes/cform.inc.php (revision 6621) |
64 |
@@ -22,46 +22,44 @@ |
65 |
class CForm extends CTag{ |
66 |
/* public */ |
67 |
function CForm($action=NULL, $method='post', $enctype=NULL){ |
68 |
- parent::CTag("form","yes"); |
69 |
- $this->SetMethod($method); |
70 |
- $this->SetAction($action); |
71 |
- $this->SetEnctype($enctype); |
72 |
+ parent::CTag('form','yes'); |
73 |
+ $this->setMethod($method); |
74 |
+ $this->setAction($action); |
75 |
+ $this->setEnctype($enctype); |
76 |
+ |
77 |
+ $this->addVar('zbx_form', 'action'); |
78 |
+ $this->addVar('sessionid', $_COOKIE['zbx_sessionid']); |
79 |
} |
80 |
|
81 |
- function SetMethod($value='post'){ |
82 |
+ function setMethod($value='post'){ |
83 |
return $this->options['method'] = $value; |
84 |
} |
85 |
|
86 |
- function SetAction($value){ |
87 |
+ function setAction($value){ |
88 |
global $page; |
89 |
|
90 |
if(is_null($value)){ |
91 |
- if(isset($page['file'])){ |
92 |
- $value = $page['file']; |
93 |
- } |
94 |
- else{ |
95 |
- $value = "#"; |
96 |
- } |
97 |
+ $value = isset($page['file'])?$page['file']:'#'; |
98 |
} |
99 |
|
100 |
return $this->options['action'] = $value; |
101 |
} |
102 |
|
103 |
- function SetEnctype($value=NULL){ |
104 |
+ function setEnctype($value=NULL){ |
105 |
if(is_null($value)){ |
106 |
- return $this->DelOption("enctype"); |
107 |
+ return $this->DelOption('enctype'); |
108 |
} |
109 |
else if(!is_string($value)){ |
110 |
return $this->error("Incorrect value for SetEnctype [$value]"); |
111 |
} |
112 |
|
113 |
- return $this->AddOption("enctype",$value); |
114 |
+ return $this->addOption('enctype',$value); |
115 |
} |
116 |
|
117 |
- function AddVar($name, $value){ |
118 |
+ function addVar($name, $value){ |
119 |
if(empty($value) && $value != 0) return $value; |
120 |
|
121 |
- return $this->AddItem(new CVar($name, $value)); |
122 |
+ return $this->addItem(new CVar($name, $value)); |
123 |
} |
124 |
} |
125 |
?> |
126 |
Index: frontends/php/include/classes/cformtable.inc.php |
127 |
=================================================================== |
128 |
--- frontends/php/include/classes/cformtable.inc.php (revision 6620) |
129 |
+++ frontends/php/include/classes/cformtable.inc.php (revision 6621) |
130 |
@@ -46,48 +46,48 @@ |
131 |
} |
132 |
|
133 |
parent::CForm($action,$method,$enctype); |
134 |
- $this->SetTitle($title); |
135 |
- $this->SetAlign('center'); |
136 |
- $this->SetHelp(); |
137 |
+ $this->setTitle($title); |
138 |
+ $this->setAlign('center'); |
139 |
+ $this->setHelp(); |
140 |
|
141 |
// $frm_link = new CLink(); |
142 |
-// $frm_link->SetName("formtable"); |
143 |
-// $this->AddItemToTopRow($frm_link); |
144 |
+// $frm_link->setName("formtable"); |
145 |
+// $this->addItemToTopRow($frm_link); |
146 |
|
147 |
- $this->AddVar($form_variable, get_request($form_variable, 1)); |
148 |
- $this->AddVar('form_refresh',get_request('form_refresh',0)+1); |
149 |
+ $this->addVar($form_variable, get_request($form_variable, 1)); |
150 |
+ $this->addVar('form_refresh',get_request('form_refresh',0)+1); |
151 |
|
152 |
$this->bottom_items = new CCol(SPACE,'form_row_last'); |
153 |
- $this->bottom_items->SetColSpan(2); |
154 |
+ $this->bottom_items->setColSpan(2); |
155 |
} |
156 |
|
157 |
- function SetAction($value){ |
158 |
+ function setAction($value){ |
159 |
|
160 |
if(is_string($value)) |
161 |
- return parent::SetAction($value); |
162 |
+ return parent::setAction($value); |
163 |
elseif(is_null($value)) |
164 |
- return parent::SetAction($value); |
165 |
+ return parent::setAction($value); |
166 |
else |
167 |
return $this->error("Incorrect value for SetAction [$value]"); |
168 |
} |
169 |
|
170 |
- function SetName($value){ |
171 |
+ function setName($value){ |
172 |
if(!is_string($value)){ |
173 |
return $this->error("Incorrect value for SetAlign [$value]"); |
174 |
} |
175 |
- $this->AddOption('name',$value); |
176 |
- $this->AddOption('id',$value); |
177 |
+ $this->addOption('name',$value); |
178 |
+ $this->addOption('id',$value); |
179 |
return true; |
180 |
} |
181 |
|
182 |
- function SetAlign($value){ |
183 |
+ function setAlign($value){ |
184 |
if(!is_string($value)){ |
185 |
return $this->error("Incorrect value for SetAlign [$value]"); |
186 |
} |
187 |
return $this->align = $value; |
188 |
} |
189 |
|
190 |
- function SetTitle($value=NULL){ |
191 |
+ function setTitle($value=NULL){ |
192 |
if(is_null($value)){ |
193 |
unset($this->title); |
194 |
return 0; |
195 |
@@ -101,7 +101,7 @@ |
196 |
$this->title = unpack_object($value); |
197 |
} |
198 |
|
199 |
- function SetHelp($value=NULL){ |
200 |
+ function setHelp($value=NULL){ |
201 |
if(is_null($value)) { |
202 |
$this->help = new CHelp(); |
203 |
} |
204 |
@@ -110,8 +110,8 @@ |
205 |
} |
206 |
else if(is_string($value)) { |
207 |
$this->help = new CHelp($value); |
208 |
- if($this->GetName()==NULL) |
209 |
- $this->SetName($value); |
210 |
+ if($this->getName()==NULL) |
211 |
+ $this->setName($value); |
212 |
} |
213 |
else { |
214 |
return $this->error("Incorrect value for SetHelp [$value]"); |
215 |
@@ -119,21 +119,21 @@ |
216 |
return 0; |
217 |
} |
218 |
|
219 |
- function AddVar($name, $value){ |
220 |
- $this->AddItemToTopRow(new CVar($name, $value)); |
221 |
+ function addVar($name, $value){ |
222 |
+ $this->addItemToTopRow(new CVar($name, $value)); |
223 |
} |
224 |
|
225 |
- function AddItemToTopRow($value){ |
226 |
+ function addItemToTopRow($value){ |
227 |
array_push($this->top_items, $value); |
228 |
} |
229 |
|
230 |
- function AddRow($item1, $item2=NULL, $class=NULL){ |
231 |
+ function addRow($item1, $item2=NULL, $class=NULL){ |
232 |
if(strtolower(get_class($item1)) == 'crow'){ |
233 |
|
234 |
} |
235 |
else if(strtolower(get_class($item1)) == 'ctable'){ |
236 |
$td = new CCol($item1,'form_row_c'); |
237 |
- $td->SetColSpan(2); |
238 |
+ $td->setColSpan(2); |
239 |
|
240 |
$item1 = new CRow($td); |
241 |
} |
242 |
@@ -157,7 +157,7 @@ |
243 |
array_push($this->center_items, $item1); |
244 |
} |
245 |
|
246 |
- function AddSpanRow($value, $class=NULL){ |
247 |
+ function addSpanRow($value, $class=NULL){ |
248 |
if(is_string($value)) |
249 |
$item1=nbsp($value); |
250 |
|
251 |
@@ -165,16 +165,16 @@ |
252 |
if(is_null($class)) $class = 'form_row_c'; |
253 |
|
254 |
$col = new CCol($value,$class); |
255 |
- $col->SetColSpan(2); |
256 |
+ $col->setColSpan(2); |
257 |
array_push($this->center_items,new CRow($col)); |
258 |
} |
259 |
|
260 |
|
261 |
- function AddItemToBottomRow($value){ |
262 |
- $this->bottom_items->AddItem($value); |
263 |
+ function addItemToBottomRow($value){ |
264 |
+ $this->bottom_items->addItem($value); |
265 |
} |
266 |
|
267 |
- function SetTableClass($class){ |
268 |
+ function setTableClass($class){ |
269 |
if(is_string($class)){ |
270 |
$this->tableclass = $class; |
271 |
} |
272 |
@@ -186,25 +186,25 @@ |
273 |
|
274 |
$tbl = new CTable(NULL,$this->tableclass); |
275 |
|
276 |
- $tbl->SetOddRowClass('form_odd_row'); |
277 |
- $tbl->SetEvenRowClass('form_even_row'); |
278 |
- $tbl->SetCellSpacing(0); |
279 |
- $tbl->SetCellPadding(1); |
280 |
- $tbl->SetAlign($this->align); |
281 |
+ $tbl->setOddRowClass('form_odd_row'); |
282 |
+ $tbl->setEvenRowClass('form_even_row'); |
283 |
+ $tbl->setCellSpacing(0); |
284 |
+ $tbl->setCellPadding(1); |
285 |
+ $tbl->setAlign($this->align); |
286 |
# add first row |
287 |
$col = new CCol(NULL,'form_row_first'); |
288 |
- $col->SetColSpan(2); |
289 |
+ $col->setColSpan(2); |
290 |
|
291 |
- if(isset($this->help)) $col->AddItem($this->help); |
292 |
- if(isset($this->title)) $col->AddItem($this->title); |
293 |
- foreach($this->top_items as $item) $col->AddItem($item); |
294 |
+ if(isset($this->help)) $col->addItem($this->help); |
295 |
+ if(isset($this->title)) $col->addItem($this->title); |
296 |
+ foreach($this->top_items as $item) $col->addItem($item); |
297 |
|
298 |
- $tbl->SetHeader($col); |
299 |
+ $tbl->setHeader($col); |
300 |
# add last row |
301 |
- $tbl->SetFooter($this->bottom_items); |
302 |
+ $tbl->setFooter($this->bottom_items); |
303 |
# add center rows |
304 |
foreach($this->center_items as $item){ |
305 |
- $tbl->AddRow($item); |
306 |
+ $tbl->addRow($item); |
307 |
} |
308 |
return $tbl->ToString(); |
309 |
} |
310 |
|
311 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
312 |
Obtained from svn://svn.zabbix.com/branches/1.6/frontends/php/ |
313 |
|
314 |
This hunk adds session identifier transmission during Ajax requests. |
315 |
It also reshuffles some JavaScript functions and adds many whitespace |
316 |
changes. |
317 |
|
318 |
Index: frontends/php/js/cookies.js |
319 |
=================================================================== |
320 |
--- frontends/php/js/cookies.js (revision 6622) |
321 |
+++ frontends/php/js/cookies.js (revision 6623) |
322 |
@@ -1,78 +0,0 @@ |
323 |
-//Javascript document |
324 |
-/* |
325 |
-** ZABBIX |
326 |
-** Copyright (C) 2000-2005 SIA Zabbix |
327 |
-** |
328 |
-** This program is free software; you can redistribute it and/or modify |
329 |
-** it under the terms of the GNU General Public License as published by |
330 |
-** the Free Software Foundation; either version 2 of the License, or |
331 |
-** (at your option) any later version. |
332 |
-** |
333 |
-** This program is distributed in the hope that it will be useful, |
334 |
-** but WITHOUT ANY WARRANTY; without even the implied warranty of |
335 |
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
336 |
-** GNU General Public License for more details. |
337 |
-** |
338 |
-** You should have received a copy of the GNU General Public License |
339 |
-** along with this program; if not, write to the Free Software |
340 |
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
341 |
-**/ |
342 |
-// Title: cookies class |
343 |
-// Description: to manipulate cookies on client side |
344 |
-// Author: Aly |
345 |
- |
346 |
-var cookie ={ |
347 |
-cookies: new Array(), |
348 |
- |
349 |
-init: function () { |
350 |
- var allCookies = document.cookie.split('; '); |
351 |
- for (var i=0;i<allCookies.length;i++) { |
352 |
- var cookiePair = allCookies[i].split('='); |
353 |
- this.cookies[cookiePair[0]] = cookiePair[1]; |
354 |
- } |
355 |
-}, |
356 |
- |
357 |
-create: function (name,value,days) { |
358 |
- if(days) { |
359 |
- var date = new Date(); |
360 |
- date.setTime(date.getTime()+(days*24*60*60*1000)); |
361 |
- var expires = "; expires="+date.toGMTString(); |
362 |
- }else{ |
363 |
- var expires = ""; |
364 |
- } |
365 |
- |
366 |
- document.cookie = name+"="+value+expires+"; path=/"; |
367 |
- this.cookies[name] = value; |
368 |
-}, |
369 |
- |
370 |
-read : function(name){ |
371 |
- if(typeof(this.cookies[name]) != 'undefined'){ |
372 |
- return this.cookies[name]; |
373 |
- } else { |
374 |
- var nameEQ = name + "="; |
375 |
- var ca = document.cookie.split(';'); |
376 |
- for(var i=0;i < ca.length;i++) { |
377 |
- var c = ca[i]; |
378 |
- while (c.charAt(0)==' ') c = c.substring(1,c.length); |
379 |
- if(c.indexOf(nameEQ) == 0) return this.cookies[name] = c.substring(nameEQ.length,c.length); |
380 |
- } |
381 |
- } |
382 |
- return null; |
383 |
-}, |
384 |
- |
385 |
-printall: function() { |
386 |
- var allCookies = document.cookie.split('; '); |
387 |
- for (var i=0;i<allCookies.length;i++) { |
388 |
- var cookiePair = allCookies[i].split('='); |
389 |
- |
390 |
- alert("[" + cookiePair[0] + "] is " + cookiePair[1]); // assumes print is already defined |
391 |
- } |
392 |
-}, |
393 |
- |
394 |
-erase: function (name) { |
395 |
- this.create(name,'',-1); |
396 |
- this.cookies[name] = undefined; |
397 |
-} |
398 |
-} |
399 |
- |
400 |
-cookie.init(); |
401 |
\ No newline at end of file |
402 |
Index: frontends/php/js/url.js |
403 |
=================================================================== |
404 |
--- frontends/php/js/url.js (revision 6622) |
405 |
+++ frontends/php/js/url.js (revision 6623) |
406 |
@@ -1,256 +0,0 @@ |
407 |
-// JavaScript Document |
408 |
-/* |
409 |
-** ZABBIX |
410 |
-** Copyright (C) 2000-2007 SIA Zabbix |
411 |
-** |
412 |
-** This program is free software; you can redistribute it and/or modify |
413 |
-** it under the terms of the GNU General Public License as published by |
414 |
-** the Free Software Foundation; either version 2 of the License, or |
415 |
-** (at your option) any later version. |
416 |
-** |
417 |
-** This program is distributed in the hope that it will be useful, |
418 |
-** but WITHOUT ANY WARRANTY; without even the implied warranty of |
419 |
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
420 |
-** GNU General Public License for more details. |
421 |
-** |
422 |
-** You should have received a copy of the GNU General Public License |
423 |
-** along with this program; if not, write to the Free Software |
424 |
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
425 |
-** |
426 |
-*/ |
427 |
- |
428 |
-// Title: url manipulation class |
429 |
-// Author: Aly |
430 |
- |
431 |
- |
432 |
-var url = Class.create(); |
433 |
- |
434 |
-url.prototype = { |
435 |
-url: '', // actually, it's depricated/private variable |
436 |
-port: -1, |
437 |
-host: '', |
438 |
-protocol: '', |
439 |
-username: '', |
440 |
-password: '', |
441 |
-filr: '', |
442 |
-reference: '', |
443 |
-path: '', |
444 |
-query: '', |
445 |
-arguments: new Array(), |
446 |
- |
447 |
-initialize: function(url){ |
448 |
- this.url=unescape(url); |
449 |
- |
450 |
- this.query=(this.url.indexOf('?')>=0)?this.url.substring(this.url.indexOf('?')+1):''; |
451 |
- if(this.query.indexOf('#')>=0) this.query=this.query.substring(0,this.query.indexOf('#')); |
452 |
- |
453 |
- var protocolSepIndex=this.url.indexOf('://'); |
454 |
- if(protocolSepIndex>=0){ |
455 |
- this.protocol=this.url.substring(0,protocolSepIndex).toLowerCase(); |
456 |
- this.host=this.url.substring(protocolSepIndex+3); |
457 |
- if(this.host.indexOf('/')>=0) this.host=this.host.substring(0,this.host.indexOf('/')); |
458 |
- var atIndex=this.host.indexOf('@'); |
459 |
- if(atIndex>=0){ |
460 |
- var credentials=this.host.substring(0,atIndex); |
461 |
- var colonIndex=credentials.indexOf(':'); |
462 |
- if(colonIndex>=0){ |
463 |
- this.username=credentials.substring(0,colonIndex); |
464 |
- this.password=credentials.substring(colonIndex); |
465 |
- }else{ |
466 |
- this.username=credentials; |
467 |
- } |
468 |
- this.host=this.host.substring(atIndex+1); |
469 |
- } |
470 |
- |
471 |
- var host_ipv6 = this.host.indexOf(']'); |
472 |
- if(host_ipv6>=0){ |
473 |
- if(host_ipv6 < (this.host.length-1)){ |
474 |
- host_ipv6++; |
475 |
- var host_less = this.host.substring(host_ipv6); |
476 |
- |
477 |
- var portColonIndex=host_less.indexOf(':'); |
478 |
- if(portColonIndex>=0){ |
479 |
- this.port=host_less.substring(portColonIndex+1); |
480 |
- this.host=this.host.substring(0,host_ipv6); |
481 |
- } |
482 |
- } |
483 |
- } |
484 |
- else{ |
485 |
- var portColonIndex=this.host.indexOf(':'); |
486 |
- if(portColonIndex>=0){ |
487 |
- this.port=this.host.substring(portColonIndex+1); |
488 |
- this.host=this.host.substring(0,portColonIndex); |
489 |
- } |
490 |
- } |
491 |
- this.file=this.url.substring(protocolSepIndex+3); |
492 |
- this.file=this.file.substring(this.file.indexOf('/')); |
493 |
- }else{ |
494 |
- this.file=this.url; |
495 |
- } |
496 |
- if(this.file.indexOf('?')>=0) this.file=this.file.substring(0, this.file.indexOf('?')); |
497 |
- |
498 |
- var refSepIndex=url.indexOf('#'); |
499 |
- if(refSepIndex>=0){ |
500 |
- this.file=this.file.substring(0,refSepIndex); |
501 |
- this.reference=this.url.substring(this.url.indexOf('#')); |
502 |
- } |
503 |
- this.path=this.file; |
504 |
- if(this.query.length>0) this.file+='?'+this.query; |
505 |
- if(this.reference.length>0) this.file+='#'+this.reference; |
506 |
- if(this.query.length > 0) this.getArguments(); |
507 |
-}, |
508 |
- |
509 |
-getArguments: function(){ |
510 |
- var args=this.query.split('&'); |
511 |
- var keyval=''; |
512 |
- |
513 |
- if(args.length<1) return; |
514 |
- |
515 |
- for(i=0;i<args.length;i++){ |
516 |
- keyval=args[i].split('='); |
517 |
- this.arguments[i] = new Array(keyval[0],(keyval.length==1)?keyval[0]:keyval[1]); |
518 |
- } |
519 |
-}, |
520 |
- |
521 |
-getArgumentValue: function(key){ |
522 |
- if(key.length<1) return ''; |
523 |
- for(i=0; i < this.arguments.length; i++){ |
524 |
- if(this.arguments[i][0] == key) return this.arguments[i][1]; |
525 |
- } |
526 |
- |
527 |
-return ''; |
528 |
-}, |
529 |
- |
530 |
-getArgumentValues: function(){ |
531 |
- var a=new Array(); |
532 |
- var b=this.query.split('&'); |
533 |
- var c=''; |
534 |
- if(b.length<1) return a; |
535 |
- for(i=0;i<b.length;i++){ |
536 |
- c=b[i].split('='); |
537 |
- a[i]=new Array(c[0],((c.length==1)?c[0]:c[1])); |
538 |
- } |
539 |
-return a; |
540 |
-}, |
541 |
- |
542 |
-getUrl: function(){ |
543 |
- var uri = (this.protocol.length > 0)?(this.protocol+'://'):''; |
544 |
- uri += encodeURI((this.username.length > 0)?(this.username):''); |
545 |
- uri += encodeURI((this.password.length > 0)?(':'+this.password):''); |
546 |
- uri += (this.host.length > 0)?(this.host):''; |
547 |
- uri += (this.port.length > 0)?(':'+this.port):''; |
548 |
- uri += encodeURI((this.path.length > 0)?(this.path):''); |
549 |
- uri += encodeURI((this.query.length > 0)?('?'+this.query):''); |
550 |
- uri += encodeURI((this.reference.length > 0)?('#'+this.reference):''); |
551 |
-// alert(uri.getProtocol()+' : '+uri.getHost()+' : '+uri.getPort()+' : '+uri.getPath()+' : '+uri.getQuery()); |
552 |
-return uri; |
553 |
-}, |
554 |
- |
555 |
-setArgument: function(key,value){ |
556 |
- |
557 |
- var valueisset = false; |
558 |
- if(typeof(key) == 'undefined') throw 'Invalid argument past for setArgument'; |
559 |
- |
560 |
- value =('undefined' != typeof(value))?value:''; |
561 |
- |
562 |
- for(i=0; i < this.arguments.length; i++){ |
563 |
- if(this.arguments[i][0] == key){ |
564 |
- valueisset = true; |
565 |
- this.arguments[i][1] = value; |
566 |
- } |
567 |
- } |
568 |
- if(!valueisset) this.arguments[this.arguments.length] = new Array(key,value); |
569 |
- this.formatQuery(); |
570 |
-}, |
571 |
- |
572 |
-formatQuery: function(){ |
573 |
- if(this.arguments.lenght < 1) return; |
574 |
- |
575 |
- var query = ''; |
576 |
- for(i=0; i < this.arguments.length; i++){ |
577 |
- query+=this.arguments[i][0]+'='+this.arguments[i][1]+'&'; |
578 |
- } |
579 |
- this.query = query.substring(0,query.length-1); |
580 |
-}, |
581 |
- |
582 |
-getPort: function(){ |
583 |
- return this.port; |
584 |
-}, |
585 |
- |
586 |
-setPort: function(port){ |
587 |
- this.port = port; |
588 |
-}, |
589 |
- |
590 |
-getQuery: function(){ |
591 |
- return this.query; |
592 |
-}, |
593 |
- |
594 |
-setQuery: function(query){ |
595 |
- this.query = query; |
596 |
- this.getArgumentValues(); |
597 |
- this.formatQuery(); |
598 |
-}, |
599 |
- |
600 |
-/* Returns the protocol of this URL, i.e. 'http' in the url 'http://server/' */ |
601 |
-getProtocol: function(){ |
602 |
- return this.protocol; |
603 |
-}, |
604 |
- |
605 |
-setProtocol: function(protocol){ |
606 |
- this.protocol = protocol; |
607 |
-}, |
608 |
-/* Returns the host name of this URL, i.e. 'server.com' in the url 'http://server.com/' */ |
609 |
-getHost: function(){ |
610 |
- return this.host; |
611 |
-}, |
612 |
- |
613 |
-setHost: function(set){ |
614 |
- this.host = host; |
615 |
-}, |
616 |
- |
617 |
-/* Returns the user name part of this URL, i.e. 'joe' in the url 'http://joe@server.com/' */ |
618 |
-getUserName: function(){ |
619 |
- return this.username; |
620 |
-}, |
621 |
- |
622 |
-setUserName: function(username){ |
623 |
- this.username = username; |
624 |
-}, |
625 |
- |
626 |
-/* Returns the password part of this url, i.e. 'secret' in the url 'http://joe:secret@server.com/' */ |
627 |
-getPassword: function(){ |
628 |
- return this.password; |
629 |
-}, |
630 |
- |
631 |
-setPassword: function(password){ |
632 |
- this.password = password; |
633 |
-}, |
634 |
- |
635 |
-/* Returns the file part of this url, i.e. everything after the host name. */ |
636 |
-getFile: function(){ |
637 |
- return this.file = file; |
638 |
-}, |
639 |
- |
640 |
-setFile: function(file){ |
641 |
- this.file = file; |
642 |
-}, |
643 |
- |
644 |
-/* Returns the reference of this url, i.e. 'bookmark' in the url 'http://server/file.html#bookmark' */ |
645 |
-getReference: function(){ |
646 |
- return this.reference; |
647 |
-}, |
648 |
- |
649 |
-setReference: function(reference){ |
650 |
- this.reference = reference; |
651 |
-}, |
652 |
- |
653 |
-/* Returns the file path of this url, i.e. '/dir/file.html' in the url 'http://server/dir/file.html' */ |
654 |
-getPath: function(){ |
655 |
- return this.path; |
656 |
-}, |
657 |
- |
658 |
-setPath: function(path){ |
659 |
- this.path = path; |
660 |
-} |
661 |
- |
662 |
-} |
663 |
\ No newline at end of file |
664 |
Index: frontends/php/js/updater.js |
665 |
=================================================================== |
666 |
--- frontends/php/js/updater.js (revision 6622) |
667 |
+++ frontends/php/js/updater.js (revision 6623) |
668 |
@@ -27,7 +27,7 @@ |
669 |
|
670 |
setObj4Update: function(id,frequency,url,params){ |
671 |
var obj = document.getElementById(id); |
672 |
- if((typeof(obj) == 'undefined')) return false; |
673 |
+ if(typeof(obj) == 'undefined') return false; |
674 |
|
675 |
var obj4update = { |
676 |
'id': id, |
677 |
@@ -65,7 +65,9 @@ |
678 |
obj4update.ready = false; |
679 |
|
680 |
var uri = new url(obj4update.url); |
681 |
- new Ajax.Updater(obj4update.id, obj4update.url, |
682 |
+ uri.setArgument('sessionid', cookie.read('zbx_sessionid')); |
683 |
+ |
684 |
+ new Ajax.Updater(obj4update.id, uri.getUrl(),//obj4update.url, |
685 |
{ |
686 |
method: 'post', |
687 |
'parameters': obj4update.params, |
688 |
Index: frontends/php/js/gpc.js |
689 |
=================================================================== |
690 |
--- frontends/php/js/gpc.js (revision 0) |
691 |
+++ frontends/php/js/gpc.js (revision 6623) |
692 |
@@ -0,0 +1,315 @@ |
693 |
+//Javascript document |
694 |
+/* |
695 |
+** ZABBIX |
696 |
+** Copyright (C) 2000-2009 SIA Zabbix |
697 |
+** |
698 |
+** This program is free software; you can redistribute it and/or modify |
699 |
+** it under the terms of the GNU General Public License as published by |
700 |
+** the Free Software Foundation; either version 2 of the License, or |
701 |
+** (at your option) any later version. |
702 |
+** |
703 |
+** This program is distributed in the hope that it will be useful, |
704 |
+** but WITHOUT ANY WARRANTY; without even the implied warranty of |
705 |
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
706 |
+** GNU General Public License for more details. |
707 |
+** |
708 |
+** You should have received a copy of the GNU General Public License |
709 |
+** along with this program; if not, write to the Free Software |
710 |
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
711 |
+**/ |
712 |
+ |
713 |
+// Title: cookies class |
714 |
+// Description: to manipulate cookies on client side |
715 |
+// Author: Aly |
716 |
+var cookie ={ |
717 |
+cookies: new Array(), |
718 |
+ |
719 |
+init: function () { |
720 |
+ var allCookies = document.cookie.split('; '); |
721 |
+ for (var i=0;i<allCookies.length;i++) { |
722 |
+ var cookiePair = allCookies[i].split('='); |
723 |
+ this.cookies[cookiePair[0]] = cookiePair[1]; |
724 |
+ } |
725 |
+}, |
726 |
+ |
727 |
+create: function (name,value,days) { |
728 |
+ if(days) { |
729 |
+ var date = new Date(); |
730 |
+ date.setTime(date.getTime()+(days*24*60*60*1000)); |
731 |
+ var expires = "; expires="+date.toGMTString(); |
732 |
+ } |
733 |
+ else{ |
734 |
+ var expires = ""; |
735 |
+ } |
736 |
+ |
737 |
+ document.cookie = name+"="+value+expires+"; path=/"; |
738 |
+ this.cookies[name] = value; |
739 |
+}, |
740 |
+ |
741 |
+read : function(name){ |
742 |
+ if(typeof(this.cookies[name]) != 'undefined'){ |
743 |
+ return this.cookies[name]; |
744 |
+ } |
745 |
+ else { |
746 |
+ var nameEQ = name + "="; |
747 |
+ var ca = document.cookie.split(';'); |
748 |
+ for(var i=0;i < ca.length;i++) { |
749 |
+ var c = ca[i]; |
750 |
+ while (c.charAt(0)==' ') c = c.substring(1,c.length); |
751 |
+ if(c.indexOf(nameEQ) == 0) return this.cookies[name] = c.substring(nameEQ.length,c.length); |
752 |
+ } |
753 |
+ } |
754 |
+ return null; |
755 |
+}, |
756 |
+ |
757 |
+printall: function() { |
758 |
+ var allCookies = document.cookie.split('; '); |
759 |
+ for(var i=0;i<allCookies.length;i++){ |
760 |
+ var cookiePair = allCookies[i].split('='); |
761 |
+ |
762 |
+ alert("[" + cookiePair[0] + "] is " + cookiePair[1]); // assumes print is already defined |
763 |
+ } |
764 |
+}, |
765 |
+ |
766 |
+erase: function (name) { |
767 |
+ this.create(name,'',-1); |
768 |
+ this.cookies[name] = undefined; |
769 |
+} |
770 |
+} |
771 |
+ |
772 |
+cookie.init(); |
773 |
+ |
774 |
+ |
775 |
+ |
776 |
+// Title: url manipulation class |
777 |
+// Author: Aly |
778 |
+var url = Class.create(); |
779 |
+ |
780 |
+url.prototype = { |
781 |
+url: '', // actually, it's depricated/private variable |
782 |
+port: -1, |
783 |
+host: '', |
784 |
+protocol: '', |
785 |
+username: '', |
786 |
+password: '', |
787 |
+filr: '', |
788 |
+reference: '', |
789 |
+path: '', |
790 |
+query: '', |
791 |
+arguments: new Array(), |
792 |
+ |
793 |
+initialize: function(url){ |
794 |
+ this.url=unescape(url); |
795 |
+ |
796 |
+ this.query=(this.url.indexOf('?')>=0)?this.url.substring(this.url.indexOf('?')+1):''; |
797 |
+ if(this.query.indexOf('#')>=0) this.query=this.query.substring(0,this.query.indexOf('#')); |
798 |
+ |
799 |
+ var protocolSepIndex=this.url.indexOf('://'); |
800 |
+ if(protocolSepIndex>=0){ |
801 |
+ this.protocol=this.url.substring(0,protocolSepIndex).toLowerCase(); |
802 |
+ this.host=this.url.substring(protocolSepIndex+3); |
803 |
+ if(this.host.indexOf('/')>=0) this.host=this.host.substring(0,this.host.indexOf('/')); |
804 |
+ var atIndex=this.host.indexOf('@'); |
805 |
+ if(atIndex>=0){ |
806 |
+ var credentials=this.host.substring(0,atIndex); |
807 |
+ var colonIndex=credentials.indexOf(':'); |
808 |
+ if(colonIndex>=0){ |
809 |
+ this.username=credentials.substring(0,colonIndex); |
810 |
+ this.password=credentials.substring(colonIndex); |
811 |
+ }else{ |
812 |
+ this.username=credentials; |
813 |
+ } |
814 |
+ this.host=this.host.substring(atIndex+1); |
815 |
+ } |
816 |
+ |
817 |
+ var host_ipv6 = this.host.indexOf(']'); |
818 |
+ if(host_ipv6>=0){ |
819 |
+ if(host_ipv6 < (this.host.length-1)){ |
820 |
+ host_ipv6++; |
821 |
+ var host_less = this.host.substring(host_ipv6); |
822 |
+ |
823 |
+ var portColonIndex=host_less.indexOf(':'); |
824 |
+ if(portColonIndex>=0){ |
825 |
+ this.port=host_less.substring(portColonIndex+1); |
826 |
+ this.host=this.host.substring(0,host_ipv6); |
827 |
+ } |
828 |
+ } |
829 |
+ } |
830 |
+ else{ |
831 |
+ var portColonIndex=this.host.indexOf(':'); |
832 |
+ if(portColonIndex>=0){ |
833 |
+ this.port=this.host.substring(portColonIndex+1); |
834 |
+ this.host=this.host.substring(0,portColonIndex); |
835 |
+ } |
836 |
+ } |
837 |
+ this.file=this.url.substring(protocolSepIndex+3); |
838 |
+ this.file=this.file.substring(this.file.indexOf('/')); |
839 |
+ }else{ |
840 |
+ this.file=this.url; |
841 |
+ } |
842 |
+ if(this.file.indexOf('?')>=0) this.file=this.file.substring(0, this.file.indexOf('?')); |
843 |
+ |
844 |
+ var refSepIndex=url.indexOf('#'); |
845 |
+ if(refSepIndex>=0){ |
846 |
+ this.file=this.file.substring(0,refSepIndex); |
847 |
+ this.reference=this.url.substring(this.url.indexOf('#')); |
848 |
+ } |
849 |
+ this.path=this.file; |
850 |
+ if(this.query.length>0) this.file+='?'+this.query; |
851 |
+ if(this.reference.length>0) this.file+='#'+this.reference; |
852 |
+ if(this.query.length > 0) this.getArguments(); |
853 |
+}, |
854 |
+ |
855 |
+getArguments: function(){ |
856 |
+ var args=this.query.split('&'); |
857 |
+ var keyval=''; |
858 |
+ |
859 |
+ if(args.length<1) return; |
860 |
+ |
861 |
+ for(i=0;i<args.length;i++){ |
862 |
+ keyval=args[i].split('='); |
863 |
+ this.arguments[i] = new Array(keyval[0],(keyval.length==1)?keyval[0]:keyval[1]); |
864 |
+ } |
865 |
+}, |
866 |
+ |
867 |
+getArgumentValue: function(key){ |
868 |
+ if(key.length<1) return ''; |
869 |
+ for(i=0; i < this.arguments.length; i++){ |
870 |
+ if(this.arguments[i][0] == key) return this.arguments[i][1]; |
871 |
+ } |
872 |
+ |
873 |
+return ''; |
874 |
+}, |
875 |
+ |
876 |
+getArgumentValues: function(){ |
877 |
+ var a=new Array(); |
878 |
+ var b=this.query.split('&'); |
879 |
+ var c=''; |
880 |
+ if(b.length<1) return a; |
881 |
+ for(i=0;i<b.length;i++){ |
882 |
+ c=b[i].split('='); |
883 |
+ a[i]=new Array(c[0],((c.length==1)?c[0]:c[1])); |
884 |
+ } |
885 |
+return a; |
886 |
+}, |
887 |
+ |
888 |
+getUrl: function(){ |
889 |
+ var uri = (this.protocol.length > 0)?(this.protocol+'://'):''; |
890 |
+ uri += encodeURI((this.username.length > 0)?(this.username):''); |
891 |
+ uri += encodeURI((this.password.length > 0)?(':'+this.password):''); |
892 |
+ uri += (this.host.length > 0)?(this.host):''; |
893 |
+ uri += (this.port.length > 0)?(':'+this.port):''; |
894 |
+ uri += encodeURI((this.path.length > 0)?(this.path):''); |
895 |
+ uri += encodeURI((this.query.length > 0)?('?'+this.query):''); |
896 |
+ uri += encodeURI((this.reference.length > 0)?('#'+this.reference):''); |
897 |
+// alert(uri.getProtocol()+' : '+uri.getHost()+' : '+uri.getPort()+' : '+uri.getPath()+' : '+uri.getQuery()); |
898 |
+return uri; |
899 |
+}, |
900 |
+ |
901 |
+setArgument: function(key,value){ |
902 |
+ |
903 |
+ var valueisset = false; |
904 |
+ if(typeof(key) == 'undefined') throw 'Invalid argument past for setArgument'; |
905 |
+ |
906 |
+ value =('undefined' != typeof(value))?value:''; |
907 |
+ |
908 |
+ for(i=0; i < this.arguments.length; i++){ |
909 |
+ if(this.arguments[i][0] == key){ |
910 |
+ valueisset = true; |
911 |
+ this.arguments[i][1] = value; |
912 |
+ } |
913 |
+ } |
914 |
+ if(!valueisset) this.arguments[this.arguments.length] = new Array(key,value); |
915 |
+ this.formatQuery(); |
916 |
+}, |
917 |
+ |
918 |
+formatQuery: function(){ |
919 |
+ if(this.arguments.lenght < 1) return; |
920 |
+ |
921 |
+ var query = ''; |
922 |
+ for(i=0; i < this.arguments.length; i++){ |
923 |
+ query+=this.arguments[i][0]+'='+this.arguments[i][1]+'&'; |
924 |
+ } |
925 |
+ this.query = query.substring(0,query.length-1); |
926 |
+}, |
927 |
+ |
928 |
+getPort: function(){ |
929 |
+ return this.port; |
930 |
+}, |
931 |
+ |
932 |
+setPort: function(port){ |
933 |
+ this.port = port; |
934 |
+}, |
935 |
+ |
936 |
+getQuery: function(){ |
937 |
+ return this.query; |
938 |
+}, |
939 |
+ |
940 |
+setQuery: function(query){ |
941 |
+ this.query = query; |
942 |
+ this.getArgumentValues(); |
943 |
+ this.formatQuery(); |
944 |
+}, |
945 |
+ |
946 |
+/* Returns the protocol of this URL, i.e. 'http' in the url 'http://server/' */ |
947 |
+getProtocol: function(){ |
948 |
+ return this.protocol; |
949 |
+}, |
950 |
+ |
951 |
+setProtocol: function(protocol){ |
952 |
+ this.protocol = protocol; |
953 |
+}, |
954 |
+/* Returns the host name of this URL, i.e. 'server.com' in the url 'http://server.com/' */ |
955 |
+getHost: function(){ |
956 |
+ return this.host; |
957 |
+}, |
958 |
+ |
959 |
+setHost: function(set){ |
960 |
+ this.host = host; |
961 |
+}, |
962 |
+ |
963 |
+/* Returns the user name part of this URL, i.e. 'joe' in the url 'http://joe@server.com/' */ |
964 |
+getUserName: function(){ |
965 |
+ return this.username; |
966 |
+}, |
967 |
+ |
968 |
+setUserName: function(username){ |
969 |
+ this.username = username; |
970 |
+}, |
971 |
+ |
972 |
+/* Returns the password part of this url, i.e. 'secret' in the url 'http://joe:secret@server.com/' */ |
973 |
+getPassword: function(){ |
974 |
+ return this.password; |
975 |
+}, |
976 |
+ |
977 |
+setPassword: function(password){ |
978 |
+ this.password = password; |
979 |
+}, |
980 |
+ |
981 |
+/* Returns the file part of this url, i.e. everything after the host name. */ |
982 |
+getFile: function(){ |
983 |
+ return this.file = file; |
984 |
+}, |
985 |
+ |
986 |
+setFile: function(file){ |
987 |
+ this.file = file; |
988 |
+}, |
989 |
+ |
990 |
+/* Returns the reference of this url, i.e. 'bookmark' in the url 'http://server/file.html#bookmark' */ |
991 |
+getReference: function(){ |
992 |
+ return this.reference; |
993 |
+}, |
994 |
+ |
995 |
+setReference: function(reference){ |
996 |
+ this.reference = reference; |
997 |
+}, |
998 |
+ |
999 |
+/* Returns the file path of this url, i.e. '/dir/file.html' in the url 'http://server/dir/file.html' */ |
1000 |
+getPath: function(){ |
1001 |
+ return this.path; |
1002 |
+}, |
1003 |
+ |
1004 |
+setPath: function(path){ |
1005 |
+ this.path = path; |
1006 |
+} |
1007 |
+} |
1008 |
\ No newline at end of file |
1009 |
Index: frontends/php/js/ajax_req.js |
1010 |
=================================================================== |
1011 |
--- frontends/php/js/ajax_req.js (revision 6622) |
1012 |
+++ frontends/php/js/ajax_req.js (revision 6623) |
1013 |
@@ -19,6 +19,8 @@ |
1014 |
**/ |
1015 |
|
1016 |
function send_params(params){ |
1017 |
+ if(typeof(params) == 'undefined') var params = new Array(); |
1018 |
+ params['sessionid'] = cookie.read('zbx_sessionid'); |
1019 |
|
1020 |
var uri = new url(location.href); |
1021 |
new Ajax.Request(uri.getPath()+"?output=ajax", |
1022 |
Index: frontends/php/dashboard.php |
1023 |
=================================================================== |
1024 |
--- frontends/php/dashboard.php (revision 6622) |
1025 |
+++ frontends/php/dashboard.php (revision 6623) |
1026 |
@@ -42,8 +42,8 @@ |
1027 |
'view_style'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), |
1028 |
'type'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), |
1029 |
|
1030 |
- 'output'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL), |
1031 |
- 'jsscriptid'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL), |
1032 |
+ 'output'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), |
1033 |
+ 'jsscriptid'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), |
1034 |
'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), |
1035 |
|
1036 |
//ajax |
1037 |
@@ -56,7 +56,7 @@ |
1038 |
); |
1039 |
|
1040 |
check_fields($fields); |
1041 |
- |
1042 |
+ |
1043 |
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_RES_IDS_ARRAY); |
1044 |
// ACTION ///////////////////////////////////////////////////////////////////////////// |
1045 |
if(isset($_REQUEST['favobj'])){ |
1046 |
Index: frontends/php/include/page_header.php |
1047 |
=================================================================== |
1048 |
--- frontends/php/include/page_header.php (revision 6622) |
1049 |
+++ frontends/php/include/page_header.php (revision 6623) |
1050 |
@@ -428,8 +428,8 @@ |
1051 |
|
1052 |
<script type="text/javascript" src="js/prototype.js"></script> |
1053 |
<script type="text/javascript" src="js/common.js"></script> |
1054 |
+<script type="text/javascript" src="js/gpc.js"></script> |
1055 |
<script type="text/javascript" src="js/ajax_req.js"></script> |
1056 |
-<script type="text/javascript" src="js/url.js"></script> |
1057 |
<script type="text/javascript" src="js/chkbxrange.js"></script> |
1058 |
<?php |
1059 |
if(isset($page['scripts']) && is_array($page['scripts'])){ |
1060 |
Index: frontends/php/include/validate.inc.php |
1061 |
=================================================================== |
1062 |
--- frontends/php/include/validate.inc.php (revision 6622) |
1063 |
+++ frontends/php/include/validate.inc.php (revision 6623) |
1064 |
@@ -432,7 +432,7 @@ |
1065 |
if(!isset($_REQUEST[$field])){ |
1066 |
return ZBX_VALID_OK; |
1067 |
} |
1068 |
- else if(($flags&P_ACT) && !isset($_REQUEST['zbx_form'])){ |
1069 |
+ else if(($flags&P_ACT) && !isset($_REQUEST['sessionid'])){ |
1070 |
return ZBX_VALID_ERROR; |
1071 |
} |
1072 |
} |
1073 |
@@ -465,8 +465,7 @@ |
1074 |
|
1075 |
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION |
1076 |
$system_fields=array( |
1077 |
- 'sessionid'=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(), 'isset({zbx_form})'), |
1078 |
- 'zbx_form'=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY, NULL), |
1079 |
+ 'sessionid'=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(), NULL), |
1080 |
// |
1081 |
'switch_node'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL), |
1082 |
'triggers_hash'=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL), |
1083 |
Index: frontends/php/include/classes/ctree.inc.php |
1084 |
=================================================================== |
1085 |
--- frontends/php/include/classes/ctree.inc.php (revision 6622) |
1086 |
+++ frontends/php/include/classes/ctree.inc.php (revision 6623) |
1087 |
@@ -214,7 +214,6 @@ |
1088 |
global $page; |
1089 |
$js = ' |
1090 |
<script src="js/tree.js" type="text/javascript"></script> |
1091 |
- <script src="js/cookies.js" type="text/javascript"></script> |
1092 |
<script type="text/javascript"> |
1093 |
var treenode = new Array(0); |
1094 |
var tree_name = "tree_'.$this->getUserAlias().'_'.$page["file"].'"; |
1095 |
Index: frontends/php/include/classes/cform.inc.php |
1096 |
=================================================================== |
1097 |
--- frontends/php/include/classes/cform.inc.php (revision 6622) |
1098 |
+++ frontends/php/include/classes/cform.inc.php (revision 6623) |
1099 |
@@ -27,7 +27,6 @@ |
1100 |
$this->setAction($action); |
1101 |
$this->setEnctype($enctype); |
1102 |
|
1103 |
- $this->addVar('zbx_form', 'action'); |
1104 |
$this->addVar('sessionid', $_COOKIE['zbx_sessionid']); |
1105 |
} |
1106 |
|
1107 |
Index: frontends/php/index.php |
1108 |
=================================================================== |
1109 |
--- frontends/php/index.php (revision 6622) |
1110 |
+++ frontends/php/index.php (revision 6623) |
1111 |
@@ -33,8 +33,8 @@ |
1112 |
"password"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({enter})'), |
1113 |
"sessionid"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), |
1114 |
"message"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), |
1115 |
- "reconnect"=> array(T_ZBX_INT, O_OPT, P_ACT, BETWEEN(0,65535),NULL), |
1116 |
- "enter"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), |
1117 |
+ "reconnect"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),NULL), |
1118 |
+ "enter"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), |
1119 |
"form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), |
1120 |
"form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL) |
1121 |
); |
1122 |
|
1123 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1124 |
Obtained from svn://svn.zabbix.com/branches/1.6/frontends/php/ |
1125 |
|
1126 |
Checks if 'zbx_sessionid' cookie is really here before setting |
1127 |
'sessionid' variable. |
1128 |
|
1129 |
Index: frontends/php/include/classes/cform.inc.php |
1130 |
=================================================================== |
1131 |
--- frontends/php/include/classes/cform.inc.php (revision 6624) |
1132 |
+++ frontends/php/include/classes/cform.inc.php (revision 6625) |
1133 |
@@ -27,7 +27,8 @@ |
1134 |
$this->setAction($action); |
1135 |
$this->setEnctype($enctype); |
1136 |
|
1137 |
- $this->addVar('sessionid', $_COOKIE['zbx_sessionid']); |
1138 |
+ if(isset($_COOKIE['zbx_sessionid'])) |
1139 |
+ $this->addVar('sessionid', $_COOKIE['zbx_sessionid']); |
1140 |
} |
1141 |
|
1142 |
function setMethod($value='post'){ |
1143 |
|
1144 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1145 |
Obtained from svn://svn.zabbix.com/branches/1.6/frontends/php/ |
1146 |
|
1147 |
This hunk basically trades the name 'sessionid' for 'sid'. It also |
1148 |
reshuffles many functions, adds many whitespace changes and implants |
1149 |
URL manipulation tools for JavaScript. |
1150 |
|
1151 |
Index: frontends/php/users.php |
1152 |
=================================================================== |
1153 |
--- frontends/php/users.php (revision 6643) |
1154 |
+++ frontends/php/users.php (revision 6644) |
1155 |
@@ -1,7 +1,7 @@ |
1156 |
<?php |
1157 |
/* |
1158 |
** ZABBIX |
1159 |
-** Copyright (C) 2000-2005 SIA Zabbix |
1160 |
+** Copyright (C) 2000-2009 SIA Zabbix |
1161 |
** |
1162 |
** This program is free software; you can redistribute it and/or modify |
1163 |
** it under the terms of the GNU General Public License as published by |
1164 |
@@ -24,6 +24,7 @@ |
1165 |
require_once('include/media.inc.php'); |
1166 |
require_once('include/users.inc.php'); |
1167 |
require_once('include/forms.inc.php'); |
1168 |
+ require_once('include/classes/curl.inc.php'); |
1169 |
require_once('include/js.inc.php'); |
1170 |
|
1171 |
$page['title'] = 'S_USERS'; |
1172 |
@@ -32,7 +33,6 @@ |
1173 |
$page['scripts'] = array('menu_scripts.js'); |
1174 |
|
1175 |
include_once('include/page_header.php'); |
1176 |
- |
1177 |
?> |
1178 |
<?php |
1179 |
$_REQUEST['config']=get_request('config',get_profile('web.users.config',0)); |
1180 |
Index: frontends/php/js/menu.js |
1181 |
=================================================================== |
1182 |
--- frontends/php/js/menu.js (revision 6643) |
1183 |
+++ frontends/php/js/menu.js (revision 6644) |
1184 |
@@ -386,8 +386,13 @@ |
1185 |
this.n_y -= this.getprop('height') * (o_parent.a_config.length - item_offset); |
1186 |
} |
1187 |
|
1188 |
+ if(!is_null(this.a_config[1]) && (this.a_config[1].indexOf('javascript') == -1)){ |
1189 |
+ var uri = new url(this.a_config[1]); |
1190 |
+ this.a_config[1] = uri.getUrl(); |
1191 |
+ } |
1192 |
+ |
1193 |
// generate item's HMTL |
1194 |
- var el = document.createElement("a"); |
1195 |
+ var el = document.createElement('a'); |
1196 |
el.setAttribute('id', 'e' + o_root.n_id + '_' + this.n_id + 'o'); |
1197 |
el.setAttribute('href', this.a_config[1]); |
1198 |
|
1199 |
Index: frontends/php/js/updater.js |
1200 |
=================================================================== |
1201 |
--- frontends/php/js/updater.js (revision 6643) |
1202 |
+++ frontends/php/js/updater.js (revision 6644) |
1203 |
@@ -65,8 +65,6 @@ |
1204 |
obj4update.ready = false; |
1205 |
|
1206 |
var uri = new url(obj4update.url); |
1207 |
- uri.setArgument('sessionid', cookie.read('zbx_sessionid')); |
1208 |
- |
1209 |
new Ajax.Updater(obj4update.id, uri.getUrl(),//obj4update.url, |
1210 |
{ |
1211 |
method: 'post', |
1212 |
Index: frontends/php/js/gpc.js |
1213 |
=================================================================== |
1214 |
--- frontends/php/js/gpc.js (revision 6643) |
1215 |
+++ frontends/php/js/gpc.js (revision 6644) |
1216 |
@@ -96,7 +96,7 @@ |
1217 |
reference: '', |
1218 |
path: '', |
1219 |
query: '', |
1220 |
-arguments: new Array(), |
1221 |
+arguments: {}, |
1222 |
|
1223 |
initialize: function(url){ |
1224 |
this.url=unescape(url); |
1225 |
@@ -116,7 +116,8 @@ |
1226 |
if(colonIndex>=0){ |
1227 |
this.username=credentials.substring(0,colonIndex); |
1228 |
this.password=credentials.substring(colonIndex); |
1229 |
- }else{ |
1230 |
+ } |
1231 |
+ else{ |
1232 |
this.username=credentials; |
1233 |
} |
1234 |
this.host=this.host.substring(atIndex+1); |
1235 |
@@ -144,9 +145,11 @@ |
1236 |
} |
1237 |
this.file=this.url.substring(protocolSepIndex+3); |
1238 |
this.file=this.file.substring(this.file.indexOf('/')); |
1239 |
- }else{ |
1240 |
+ } |
1241 |
+ else{ |
1242 |
this.file=this.url; |
1243 |
} |
1244 |
+ |
1245 |
if(this.file.indexOf('?')>=0) this.file=this.file.substring(0, this.file.indexOf('?')); |
1246 |
|
1247 |
var refSepIndex=url.indexOf('#'); |
1248 |
@@ -157,42 +160,51 @@ |
1249 |
this.path=this.file; |
1250 |
if(this.query.length>0) this.file+='?'+this.query; |
1251 |
if(this.reference.length>0) this.file+='#'+this.reference; |
1252 |
- if(this.query.length > 0) this.getArguments(); |
1253 |
+ if(this.query.length > 0) this.formatArguments(); |
1254 |
+ |
1255 |
+ var sid = cookie.read('zbx_sessionid'); |
1256 |
+ this.setArgument('sid', sid.substring(16)); |
1257 |
}, |
1258 |
|
1259 |
-getArguments: function(){ |
1260 |
+ |
1261 |
+formatQuery: function(){ |
1262 |
+ if(this.arguments.lenght < 1) return; |
1263 |
+ |
1264 |
+ var query = ''; |
1265 |
+ for(var key in this.arguments){ |
1266 |
+ if(typeof(this.arguments[key]) != 'undefined'){ |
1267 |
+ query+=key+'='+this.arguments[key]+'&'; |
1268 |
+ } |
1269 |
+ } |
1270 |
+ this.query = query.substring(0,query.length-1); |
1271 |
+}, |
1272 |
+ |
1273 |
+formatArguments: function(){ |
1274 |
var args=this.query.split('&'); |
1275 |
var keyval=''; |
1276 |
- |
1277 |
+ |
1278 |
if(args.length<1) return; |
1279 |
|
1280 |
- for(i=0;i<args.length;i++){ |
1281 |
- keyval=args[i].split('='); |
1282 |
- this.arguments[i] = new Array(keyval[0],(keyval.length==1)?keyval[0]:keyval[1]); |
1283 |
+ for(i=0; i<args.length; i++){ |
1284 |
+ keyval = args[i].split('='); |
1285 |
+ this.arguments[keyval[0]] = (keyval.length>1)?keyval[1]:''; |
1286 |
} |
1287 |
}, |
1288 |
|
1289 |
-getArgumentValue: function(key){ |
1290 |
- if(key.length<1) return ''; |
1291 |
- for(i=0; i < this.arguments.length; i++){ |
1292 |
- if(this.arguments[i][0] == key) return this.arguments[i][1]; |
1293 |
- } |
1294 |
- |
1295 |
-return ''; |
1296 |
+setArgument: function(key,value){ |
1297 |
+ this.arguments[key] = value; |
1298 |
+ this.formatQuery(); |
1299 |
}, |
1300 |
|
1301 |
-getArgumentValues: function(){ |
1302 |
- var a=new Array(); |
1303 |
- var b=this.query.split('&'); |
1304 |
- var c=''; |
1305 |
- if(b.length<1) return a; |
1306 |
- for(i=0;i<b.length;i++){ |
1307 |
- c=b[i].split('='); |
1308 |
- a[i]=new Array(c[0],((c.length==1)?c[0]:c[1])); |
1309 |
- } |
1310 |
-return a; |
1311 |
+getArgument: function(key){ |
1312 |
+ if(typeof(this.arguments[key]) != 'undefined') return this.arguments[key]; |
1313 |
+ else return null; |
1314 |
}, |
1315 |
|
1316 |
+getArguments: function(){ |
1317 |
+ return this.arguments; |
1318 |
+}, |
1319 |
+ |
1320 |
getUrl: function(){ |
1321 |
var uri = (this.protocol.length > 0)?(this.protocol+'://'):''; |
1322 |
uri += encodeURI((this.username.length > 0)?(this.username):''); |
1323 |
@@ -206,51 +218,30 @@ |
1324 |
return uri; |
1325 |
}, |
1326 |
|
1327 |
-setArgument: function(key,value){ |
1328 |
- |
1329 |
- var valueisset = false; |
1330 |
- if(typeof(key) == 'undefined') throw 'Invalid argument past for setArgument'; |
1331 |
- |
1332 |
- value =('undefined' != typeof(value))?value:''; |
1333 |
- |
1334 |
- for(i=0; i < this.arguments.length; i++){ |
1335 |
- if(this.arguments[i][0] == key){ |
1336 |
- valueisset = true; |
1337 |
- this.arguments[i][1] = value; |
1338 |
- } |
1339 |
- } |
1340 |
- if(!valueisset) this.arguments[this.arguments.length] = new Array(key,value); |
1341 |
- this.formatQuery(); |
1342 |
+setPort: function(port){ |
1343 |
+ this.port = port; |
1344 |
}, |
1345 |
|
1346 |
-formatQuery: function(){ |
1347 |
- if(this.arguments.lenght < 1) return; |
1348 |
- |
1349 |
- var query = ''; |
1350 |
- for(i=0; i < this.arguments.length; i++){ |
1351 |
- query+=this.arguments[i][0]+'='+this.arguments[i][1]+'&'; |
1352 |
- } |
1353 |
- this.query = query.substring(0,query.length-1); |
1354 |
-}, |
1355 |
- |
1356 |
getPort: function(){ |
1357 |
return this.port; |
1358 |
}, |
1359 |
|
1360 |
-setPort: function(port){ |
1361 |
- this.port = port; |
1362 |
+setQuery: function(query){ |
1363 |
+ this.query = query; |
1364 |
+ if(this.query.indexOf('?')>=0){ |
1365 |
+ this.query= this.query.substring(this.query.indexOf('?')+1); |
1366 |
+ } |
1367 |
+ |
1368 |
+ this.formatArguments(); |
1369 |
+ |
1370 |
+ var sid = cookie.read('zbx_sessionid'); |
1371 |
+ this.setArgument('sid', sid.substring(16)); |
1372 |
}, |
1373 |
|
1374 |
getQuery: function(){ |
1375 |
return this.query; |
1376 |
}, |
1377 |
|
1378 |
-setQuery: function(query){ |
1379 |
- this.query = query; |
1380 |
- this.getArgumentValues(); |
1381 |
- this.formatQuery(); |
1382 |
-}, |
1383 |
- |
1384 |
/* Returns the protocol of this URL, i.e. 'http' in the url 'http://server/' */ |
1385 |
getProtocol: function(){ |
1386 |
return this.protocol; |
1387 |
@@ -264,7 +255,7 @@ |
1388 |
return this.host; |
1389 |
}, |
1390 |
|
1391 |
-setHost: function(set){ |
1392 |
+setHost: function(host){ |
1393 |
this.host = host; |
1394 |
}, |
1395 |
|
1396 |
@@ -288,7 +279,7 @@ |
1397 |
|
1398 |
/* Returns the file part of this url, i.e. everything after the host name. */ |
1399 |
getFile: function(){ |
1400 |
- return this.file = file; |
1401 |
+ return this.file; |
1402 |
}, |
1403 |
|
1404 |
setFile: function(file){ |
1405 |
Index: frontends/php/js/menu_scripts.js |
1406 |
=================================================================== |
1407 |
--- frontends/php/js/menu_scripts.js (revision 6643) |
1408 |
+++ frontends/php/js/menu_scripts.js (revision 6644) |
1409 |
@@ -64,7 +64,7 @@ |
1410 |
for(var i=0; i < menu_usrgrp_gui.length; i++){ |
1411 |
if((typeof(menu_usrgrp_gui[i]) != 'undefined') && !empty(menu_usrgrp_gui[i])){ |
1412 |
var row = menu_usrgrp_gui[i]; |
1413 |
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid); |
1414 |
+ var menu_row = new Array(row.name,'users.php?config=0&form=update&grpaction=1&userid='+userid+'&usrgrpid='+row.usrgrpid); |
1415 |
grp_gui_add_to.push(menu_row); |
1416 |
} |
1417 |
} |
1418 |
@@ -73,7 +73,7 @@ |
1419 |
for(var i=0; i < usr_grp_gui_in.length; i++){ |
1420 |
if((typeof(usr_grp_all_in[i]) != 'undefined') && !empty(usr_grp_gui_in[i])){ |
1421 |
var row = usr_grp_gui_in[i]; |
1422 |
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid); |
1423 |
+ var menu_row = new Array(row.name,'users.php?config=0&form=update&grpaction=0&userid='+userid+'&usrgrpid='+row.usrgrpid); |
1424 |
grp_gui_rmv_frm.push(menu_row); |
1425 |
} |
1426 |
} |
1427 |
@@ -89,7 +89,7 @@ |
1428 |
for(var i=0; i < menu_usrgrp_status.length; i++){ |
1429 |
if((typeof(menu_usrgrp_status[i]) != 'undefined') && !empty(menu_usrgrp_status[i])){ |
1430 |
var row = menu_usrgrp_status[i]; |
1431 |
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=1&userid="+userid+"&usrgrpid="+row.usrgrpid); |
1432 |
+ var menu_row = new Array(row.name,'users.php?config=0&form=update&grpaction=1&userid='+userid+'&usrgrpid='+row.usrgrpid); |
1433 |
grp_status_add_to.push(menu_row); |
1434 |
} |
1435 |
} |
1436 |
@@ -98,7 +98,7 @@ |
1437 |
for(var i=0; i < usr_grp_status_in.length; i++){ |
1438 |
if((typeof(usr_grp_status_in[i]) != 'undefined') && !empty(usr_grp_status_in[i])){ |
1439 |
var row = usr_grp_status_in[i]; |
1440 |
- var menu_row = new Array(row.name,"users.php?config=0&form=update&grpaction=0&userid="+userid+"&usrgrpid="+row.usrgrpid); |
1441 |
+ var menu_row = new Array(row.name,'users.php?config=0&form=update&grpaction=0&userid='+userid+'&usrgrpid='+row.usrgrpid); |
1442 |
grp_status_rmv_frm.push(menu_row); |
1443 |
} |
1444 |
} |
1445 |
Index: frontends/php/js/common.js |
1446 |
=================================================================== |
1447 |
--- frontends/php/js/common.js (revision 6643) |
1448 |
+++ frontends/php/js/common.js (revision 6644) |
1449 |
@@ -82,6 +82,16 @@ |
1450 |
div_help.appendChild(document.createElement("br")); |
1451 |
} |
1452 |
|
1453 |
+function SDJ(obj){ |
1454 |
+ var debug = ''; |
1455 |
+ for(var key in obj) { |
1456 |
+ var value = obj[key]; |
1457 |
+ debug+=key+': '+value+'\n'; |
1458 |
+ } |
1459 |
+ SDI('\n'+debug); |
1460 |
+} |
1461 |
+ |
1462 |
+ |
1463 |
/// Alpha-Betic sorting |
1464 |
|
1465 |
function addListener(element, eventname, expression, bubbling){ |
1466 |
Index: frontends/php/js/ajax_req.js |
1467 |
=================================================================== |
1468 |
--- frontends/php/js/ajax_req.js (revision 6643) |
1469 |
+++ frontends/php/js/ajax_req.js (revision 6644) |
1470 |
@@ -20,14 +20,16 @@ |
1471 |
|
1472 |
function send_params(params){ |
1473 |
if(typeof(params) == 'undefined') var params = new Array(); |
1474 |
- params['sessionid'] = cookie.read('zbx_sessionid'); |
1475 |
|
1476 |
var uri = new url(location.href); |
1477 |
- new Ajax.Request(uri.getPath()+"?output=ajax", |
1478 |
+ uri.setQuery('?output=ajax'); |
1479 |
+ |
1480 |
+ new Ajax.Request(uri.getUrl(), |
1481 |
{ |
1482 |
'method': 'post', |
1483 |
'parameters':params, |
1484 |
- 'onSuccess': function(resp){ },//alert(resp.responseText); |
1485 |
+ 'onSuccess': function(resp){ }, |
1486 |
+// 'onSuccess': function(resp){ alert(resp.responseText); }, |
1487 |
'onFailure': function(){ document.location = uri.getPath()+'?'+Object.toQueryString(params); } |
1488 |
} |
1489 |
); |
1490 |
Index: frontends/php/dashboard.php |
1491 |
=================================================================== |
1492 |
--- frontends/php/dashboard.php (revision 6643) |
1493 |
+++ frontends/php/dashboard.php (revision 6644) |
1494 |
@@ -54,7 +54,7 @@ |
1495 |
'action'=> array(T_ZBX_STR, O_OPT, P_ACT, IN("'add','remove'"),NULL), |
1496 |
'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj}) && ("hat"=={favobj})'), |
1497 |
); |
1498 |
- |
1499 |
+ |
1500 |
check_fields($fields); |
1501 |
|
1502 |
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_RES_IDS_ARRAY); |
1503 |
@@ -179,11 +179,11 @@ |
1504 |
$p_elements = array(); |
1505 |
// Header |
1506 |
|
1507 |
- $url = '?fullscreen='.($_REQUEST['fullscreen']?'0':'1'); |
1508 |
+ $url = new Curl('?fullscreen='.($_REQUEST['fullscreen']?'0':'1')); |
1509 |
|
1510 |
$fs_icon = new CDiv(SPACE,'fullscreen'); |
1511 |
$fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); |
1512 |
- $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); |
1513 |
+ $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url->getUrl()."';")); |
1514 |
//------------- |
1515 |
|
1516 |
$left_tab = new CTable(); |
1517 |
Index: frontends/php/include/func.inc.php |
1518 |
=================================================================== |
1519 |
--- frontends/php/include/func.inc.php (revision 6643) |
1520 |
+++ frontends/php/include/func.inc.php (revision 6644) |
1521 |
@@ -344,6 +344,18 @@ |
1522 |
return $pos; |
1523 |
} |
1524 |
|
1525 |
+function zbx_substring($haystack, $start, $end=null){ |
1526 |
+ if($end < $start) return ''; |
1527 |
+ |
1528 |
+ $len = zbx_strlen($haystack); |
1529 |
+ if(is_null($end)) |
1530 |
+ $result = substr($haystack, $start); |
1531 |
+ else |
1532 |
+ $result = substr($haystack, $start, ($end - $start)); |
1533 |
+ |
1534 |
+return $result; |
1535 |
+} |
1536 |
+ |
1537 |
function uint_in_array($needle,$haystack){ |
1538 |
foreach($haystack as $id => $value) |
1539 |
if(bccomp($needle,$value) == 0) return true; |
1540 |
Index: frontends/php/include/screens.inc.php |
1541 |
=================================================================== |
1542 |
--- frontends/php/include/screens.inc.php (revision 6643) |
1543 |
+++ frontends/php/include/screens.inc.php (revision 6644) |
1544 |
@@ -886,7 +886,7 @@ |
1545 |
$action = 'screenedit.php?form=update'.url_param('screenid').'&x='.$c.'&y='.$r.'#form'; |
1546 |
else |
1547 |
$action = NULL; |
1548 |
- |
1549 |
+ |
1550 |
if($editmode == 1 && isset($_REQUEST["form"]) && |
1551 |
isset($_REQUEST["x"]) && $_REQUEST["x"]==$c && |
1552 |
isset($_REQUEST["y"]) && $_REQUEST["y"]==$r) |
1553 |
Index: frontends/php/include/perm.inc.php |
1554 |
=================================================================== |
1555 |
--- frontends/php/include/perm.inc.php (revision 6643) |
1556 |
+++ frontends/php/include/perm.inc.php (revision 6644) |
1557 |
@@ -44,7 +44,7 @@ |
1558 |
$USER_DETAILS = NULL; |
1559 |
$login = FALSE; |
1560 |
|
1561 |
- $sessionid = get_request('sessionid',get_cookie('zbx_sessionid')); |
1562 |
+ $sessionid = get_cookie('zbx_sessionid'); |
1563 |
|
1564 |
if(!is_null($sessionid)){ |
1565 |
$sql = 'SELECT u.*,s.* '. |
1566 |
Index: frontends/php/include/config.inc.php |
1567 |
=================================================================== |
1568 |
--- frontends/php/include/config.inc.php (revision 6643) |
1569 |
+++ frontends/php/include/config.inc.php (revision 6644) |
1570 |
@@ -65,6 +65,7 @@ |
1571 |
require_once('include/classes/cpumenu.inc.php'); |
1572 |
require_once('include/classes/graph.inc.php'); |
1573 |
require_once('include/classes/cscript.inc.php'); |
1574 |
+ require_once('include/classes/curl.inc.php'); |
1575 |
|
1576 |
// Include Tactical Overview modules |
1577 |
|
1578 |
Index: frontends/php/include/validate.inc.php |
1579 |
=================================================================== |
1580 |
--- frontends/php/include/validate.inc.php (revision 6643) |
1581 |
+++ frontends/php/include/validate.inc.php (revision 6644) |
1582 |
@@ -432,8 +432,13 @@ |
1583 |
if(!isset($_REQUEST[$field])){ |
1584 |
return ZBX_VALID_OK; |
1585 |
} |
1586 |
- else if(($flags&P_ACT) && !isset($_REQUEST['sessionid'])){ |
1587 |
- return ZBX_VALID_ERROR; |
1588 |
+ else if($flags&P_ACT){ |
1589 |
+ if(!isset($_REQUEST['sid'])){ |
1590 |
+ return ZBX_VALID_ERROR; |
1591 |
+ } |
1592 |
+ else if(isset($_COOKIE['zbx_sessionid']) && ($_REQUEST['sid'] != substr($_COOKIE['zbx_sessionid'],16,16))){ |
1593 |
+ return ZBX_VALID_ERROR; |
1594 |
+ } |
1595 |
} |
1596 |
} |
1597 |
|
1598 |
@@ -465,7 +470,7 @@ |
1599 |
|
1600 |
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION |
1601 |
$system_fields=array( |
1602 |
- 'sessionid'=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(), NULL), |
1603 |
+ 'sid'=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(), NULL), |
1604 |
// |
1605 |
'switch_node'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL), |
1606 |
'triggers_hash'=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL), |
1607 |
Index: frontends/php/include/classes/clink.inc.php |
1608 |
=================================================================== |
1609 |
--- frontends/php/include/classes/clink.inc.php (revision 6643) |
1610 |
+++ frontends/php/include/classes/clink.inc.php (revision 6644) |
1611 |
@@ -19,12 +19,14 @@ |
1612 |
**/ |
1613 |
?> |
1614 |
<?php |
1615 |
- class CLink extends CTag |
1616 |
- { |
1617 |
+ class CLink extends CTag{ |
1618 |
/* public */ |
1619 |
function CLink($item=NULL,$url=NULL,$class=NULL,$action=NULL){ |
1620 |
parent::CTag('a','yes'); |
1621 |
- |
1622 |
+ |
1623 |
+ $uri = new Curl($url); |
1624 |
+ $url = $uri->getUrl(); |
1625 |
+ |
1626 |
$this->tag_start= ''; |
1627 |
$this->tag_end = ''; |
1628 |
$this->tag_body_start = ''; |
1629 |
@@ -36,14 +38,14 @@ |
1630 |
if(!is_null($action)) $this->SetAction($action); |
1631 |
} |
1632 |
|
1633 |
- function SetAction($value=NULL){ |
1634 |
+ function setAction($value=NULL){ |
1635 |
if(is_null($value)) |
1636 |
return $this->options['action'] = $page['file']; |
1637 |
|
1638 |
return parent::AddAction('onclick', $value); |
1639 |
} |
1640 |
|
1641 |
- function SetUrl($value){ |
1642 |
+ function setUrl($value){ |
1643 |
$this->AddOption('href', $value); |
1644 |
} |
1645 |
|
1646 |
@@ -54,7 +56,7 @@ |
1647 |
return null; |
1648 |
} |
1649 |
|
1650 |
- function SetTarget($value=NULL){ |
1651 |
+ function setTarget($value=NULL){ |
1652 |
if(is_null($value)){ |
1653 |
unset($this->options['target']); |
1654 |
} |
1655 |
Index: frontends/php/include/classes/curl.inc.php |
1656 |
=================================================================== |
1657 |
--- frontends/php/include/classes/curl.inc.php (revision 0) |
1658 |
+++ frontends/php/include/classes/curl.inc.php (revision 6644) |
1659 |
@@ -0,0 +1,273 @@ |
1660 |
+<?php |
1661 |
+/* |
1662 |
+** ZABBIX |
1663 |
+** Copyright (C) 2000-2005 SIA Zabbix |
1664 |
+** |
1665 |
+** $this program is free software; you can redistribute it and/or modify |
1666 |
+** it under the terms of the GNU General Public License as published by |
1667 |
+** the Free Software Foundation; either version 2 of the License, or |
1668 |
+** (at your option) any later version. |
1669 |
+** |
1670 |
+** $this program is distributed in the hope that it will be useful, |
1671 |
+** but WITHOUT ANY WARRANTY; without even the implied warranty of |
1672 |
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1673 |
+** GNU General Public License for more details. |
1674 |
+** |
1675 |
+** You should have received a copy of the GNU General Public License |
1676 |
+** along with $this program; if not, write to the Free Software |
1677 |
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
1678 |
+**/ |
1679 |
+?> |
1680 |
+<?php |
1681 |
+// Title: url manipulation class |
1682 |
+// Author: Aly |
1683 |
+ |
1684 |
+class Curl{ |
1685 |
+/* |
1686 |
+private $url = ''; // actually, it's depricated/private variable |
1687 |
+private $port = false; |
1688 |
+private $host = ''; |
1689 |
+private $protocol = ''; |
1690 |
+private $username = ''; |
1691 |
+private $password = ''; |
1692 |
+private $filr = ''; |
1693 |
+private $reference = ''; |
1694 |
+private $path = ''; |
1695 |
+private $query = ''; |
1696 |
+private $arguments = array(); |
1697 |
+//*/ |
1698 |
+ |
1699 |
+function curl($url=null){ |
1700 |
+ global $USER_DETAILS; |
1701 |
+ |
1702 |
+ $this->url = ''; // actually, it's depricated/private variable |
1703 |
+ $this->port = false; |
1704 |
+ $this->host = ''; |
1705 |
+ $this->protocol = ''; |
1706 |
+ $this->username = ''; |
1707 |
+ $this->password = ''; |
1708 |
+ $this->filr = ''; |
1709 |
+ $this->reference = ''; |
1710 |
+ $this->path = ''; |
1711 |
+ $this->query = ''; |
1712 |
+ $this->arguments = array(); |
1713 |
+ |
1714 |
+ if(empty($url)){ |
1715 |
+ $this->formatArguments(); |
1716 |
+ $this->url = $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'].'?'.$this->getQuery(); |
1717 |
+ } |
1718 |
+ else{ |
1719 |
+ $this->url=urldecode($url); |
1720 |
+ |
1721 |
+ $tmp_pos = strpos($this->url,'?'); |
1722 |
+ $this->query=($tmp_pos!==false)?(substr($this->url,$tmp_pos+1)):''; |
1723 |
+ |
1724 |
+ $tmp_pos = strpos($this->query,'#'); |
1725 |
+ if($tmp_pos!==false) $this->query=zbx_substring($this->query,0,$tmp_pos); |
1726 |
+ |
1727 |
+ $this->formatArguments($this->query); |
1728 |
+ } |
1729 |
+ |
1730 |
+ $protocolSepIndex=strpos($this->url,'://'); |
1731 |
+ if($protocolSepIndex!==false){ |
1732 |
+ $this->protocol= strtolower(zbx_substring($this->url,0,$protocolSepIndex)); |
1733 |
+ |
1734 |
+ $this->host=substr($this->url, $protocolSepIndex+3); |
1735 |
+ |
1736 |
+ $tmp_pos = strpos($this->host,'/'); |
1737 |
+ if($tmp_pos!==false) $this->host=zbx_substring($this->host,0,$tmp_pos); |
1738 |
+ |
1739 |
+ $atIndex=strpos($this->host,'@'); |
1740 |
+ if($atIndex!==false){ |
1741 |
+ $credentials=zbx_substring($this->host,0,$atIndex); |
1742 |
+ |
1743 |
+ $colonIndex=strpos(credentials,':'); |
1744 |
+ if($colonIndex!==false){ |
1745 |
+ $this->username=zbx_substring($credentials,0,$colonIndex); |
1746 |
+ $this->password=substr($credentials,$colonIndex); |
1747 |
+ } |
1748 |
+ else{ |
1749 |
+ $this->username=$credentials; |
1750 |
+ } |
1751 |
+ $this->host=substr($this->host,$atIndex+1); |
1752 |
+ } |
1753 |
+ |
1754 |
+ $host_ipv6 = strpos($this->host,']'); |
1755 |
+ if($host_ipv6!==false){ |
1756 |
+ if($host_ipv6 < (zbx_strlen($this->host)-1)){ |
1757 |
+ $host_ipv6++; |
1758 |
+ $host_less = substr($this->host,$host_ipv6); |
1759 |
+ |
1760 |
+ $portColonIndex=strpos($host_less,':'); |
1761 |
+ if($portColonIndex!==false){ |
1762 |
+ $this->host=zbx_substring($this->host,0,$host_ipv6); |
1763 |
+ $this->port=substr($host_less,$portColonIndex+1); |
1764 |
+ } |
1765 |
+ } |
1766 |
+ } |
1767 |
+ else{ |
1768 |
+ $portColonIndex=strpos($this->host,':'); |
1769 |
+ if($portColonIndex!==false){ |
1770 |
+ $this->host=zbx_substring($this->host,0,$portColonIndex); |
1771 |
+ $this->port=substr($this->host,$portColonIndex+1); |
1772 |
+ } |
1773 |
+ } |
1774 |
+ |
1775 |
+ $this->file = substr($this->url,$protocolSepIndex+3); |
1776 |
+ $this->file = substr($this->file, strpos($this->file,'/')); |
1777 |
+ } |
1778 |
+ else{ |
1779 |
+ $this->file = $this->url; |
1780 |
+ } |
1781 |
+ |
1782 |
+ $tmp_pos = strpos($this->file,'?'); |
1783 |
+ if($tmp_pos!==false) $this->file=zbx_substring($this->file, 0, $tmp_pos); |
1784 |
+ |
1785 |
+ $refSepIndex=strpos($url,'#'); |
1786 |
+ if($refSepIndex!==false){ |
1787 |
+ $this->file = zbx_substring($this->file,0,$refSepIndex); |
1788 |
+ $this->reference = substr($url,strpos($url,'#')+1); |
1789 |
+ } |
1790 |
+ |
1791 |
+ $this->path=$this->file; |
1792 |
+ if(zbx_strlen($this->query)>0) $this->file.='?'.$this->query; |
1793 |
+ if(zbx_strlen($this->reference)>0) $this->file.='#'.$this->reference; |
1794 |
+ |
1795 |
+ if(isset($_COOKIE['zbx_sessionid'])) |
1796 |
+ $this->setArgument('sid', substr($_COOKIE['zbx_sessionid'],16,16)); |
1797 |
+} |
1798 |
+ |
1799 |
+function formatQuery(){ |
1800 |
+ $query = ''; |
1801 |
+ foreach($this->arguments as $key => $value){ |
1802 |
+ $query.= $key.'='.$value.'&'; |
1803 |
+ } |
1804 |
+ $this->query = rtrim($query,'&'); |
1805 |
+} |
1806 |
+ |
1807 |
+function formatArguments($query=null){ |
1808 |
+ if(is_null($query)){ |
1809 |
+ $this->arguments = $_REQUEST; |
1810 |
+ } |
1811 |
+ else{ |
1812 |
+ $query=ltrim($query,'?'); |
1813 |
+ $args = explode('&',$query); |
1814 |
+ foreach($args as $id => $arg){ |
1815 |
+ if(empty($arg)) continue; |
1816 |
+ |
1817 |
+ $tmp = explode('=',$arg); |
1818 |
+ $this->arguments[$tmp[0]] = isset($tmp[1])?$tmp[1]:''; |
1819 |
+ } |
1820 |
+ } |
1821 |
+ $this->formatQuery(); |
1822 |
+} |
1823 |
+ |
1824 |
+function getUrl(){ |
1825 |
+ $url = (zbx_strlen($this->protocol) > 0)?($this->protocol.'://'):''; |
1826 |
+ $url .= (zbx_strlen($this->username) > 0)?$this->username:''; |
1827 |
+ $url .= (zbx_strlen($this->password) > 0)?':'.$this->password:''; |
1828 |
+ $url .= (zbx_strlen($this->host) > 0)?$this->host:''; |
1829 |
+ $url .= $this->port?(':'.$this->port):''; |
1830 |
+ $url .= (zbx_strlen($this->path) > 0)?$this->path:''; |
1831 |
+ $url .= (zbx_strlen($this->query) > 0)?('?'.$this->query):''; |
1832 |
+ $url .= (zbx_strlen($this->reference) > 0)?('#'.urlencode($this->reference)):''; |
1833 |
+ |
1834 |
+//SDI($this->getProtocol().' : '.$this->getHost().' : '.$this->getPort().' : '.$this->getPath().' : '.$this->getQuery()); |
1835 |
+return $url; |
1836 |
+} |
1837 |
+ |
1838 |
+function setPort($port){ |
1839 |
+ $this->port = $port; |
1840 |
+} |
1841 |
+ |
1842 |
+function getPort(){ |
1843 |
+ return $this->port; |
1844 |
+} |
1845 |
+ |
1846 |
+function setArgument($key,$value=''){ |
1847 |
+ $this->arguments[$key] = $value; |
1848 |
+ $this->formatQuery(); |
1849 |
+} |
1850 |
+ |
1851 |
+function getArgument($key){ |
1852 |
+ if(isset($this->arguments[$key])) return $this->arguments[$key]; |
1853 |
+ else return NULL; |
1854 |
+} |
1855 |
+ |
1856 |
+function setQuery($query){ |
1857 |
+ $this->query = $query; |
1858 |
+ $this->formatArguments(); |
1859 |
+ $this->formatQuery(); |
1860 |
+} |
1861 |
+ |
1862 |
+function getQuery(){ |
1863 |
+ return $this->query; |
1864 |
+} |
1865 |
+ |
1866 |
+function setProtocol($protocol){ |
1867 |
+ $this->protocol = $protocol; |
1868 |
+} |
1869 |
+ |
1870 |
+/* Returns the protocol of $this URL, i.e. 'http' in the url 'http://server/' */ |
1871 |
+function getProtocol(){ |
1872 |
+ return $this->protocol; |
1873 |
+} |
1874 |
+ |
1875 |
+function setHost($host){ |
1876 |
+ $this->host = $host; |
1877 |
+} |
1878 |
+ |
1879 |
+/* Returns the host name of $this URL, i.e. 'server.com' in the url 'http://server.com/' */ |
1880 |
+function getHost(){ |
1881 |
+ return $this->host; |
1882 |
+} |
1883 |
+ |
1884 |
+function setUserName($username){ |
1885 |
+ $this->username = $username; |
1886 |
+} |
1887 |
+ |
1888 |
+/* Returns the user name part of $this URL, i.e. 'joe' in the url 'http://joe@server.com/' */ |
1889 |
+function getUserName(){ |
1890 |
+ return $this->username; |
1891 |
+} |
1892 |
+ |
1893 |
+function setPassword($password){ |
1894 |
+ $this->password = $password; |
1895 |
+} |
1896 |
+ |
1897 |
+/* Returns the password part of $this url, i.e. 'secret' in the url 'http://joe:secret@server.com/' */ |
1898 |
+function getPassword(){ |
1899 |
+ return $this->password; |
1900 |
+} |
1901 |
+ |
1902 |
+function setFile($file){ |
1903 |
+ $this->file = $file; |
1904 |
+} |
1905 |
+ |
1906 |
+/* Returns the file part of $this url, i.e. everything after the host name. */ |
1907 |
+function getFile(){ |
1908 |
+ return $this->file; |
1909 |
+} |
1910 |
+ |
1911 |
+function setReference($reference){ |
1912 |
+ $this->reference = $reference; |
1913 |
+} |
1914 |
+ |
1915 |
+/* Returns the reference of $this url, i.e. 'bookmark' in the url 'http://server/file.html#bookmark' */ |
1916 |
+function getReference(){ |
1917 |
+ return $this->reference; |
1918 |
+} |
1919 |
+ |
1920 |
+function setPath($path){ |
1921 |
+ $this->path = $path; |
1922 |
+} |
1923 |
+ |
1924 |
+/* Returns the file path of $this url, i.e. '/dir/file.html' in the url 'http://server/dir/file.html' */ |
1925 |
+function getPath(){ |
1926 |
+ return $this->path; |
1927 |
+} |
1928 |
+ |
1929 |
+function toString(){ |
1930 |
+ return $this->getUrl(); |
1931 |
+} |
1932 |
+} |
1933 |
\ No newline at end of file |
1934 |
Index: frontends/php/include/classes/cform.inc.php |
1935 |
=================================================================== |
1936 |
--- frontends/php/include/classes/cform.inc.php (revision 6643) |
1937 |
+++ frontends/php/include/classes/cform.inc.php (revision 6644) |
1938 |
@@ -28,7 +28,7 @@ |
1939 |
$this->setEnctype($enctype); |
1940 |
|
1941 |
if(isset($_COOKIE['zbx_sessionid'])) |
1942 |
- $this->addVar('sessionid', $_COOKIE['zbx_sessionid']); |
1943 |
+ $this->addVar('sid', substr($_COOKIE['zbx_sessionid'],16,16)); |
1944 |
} |
1945 |
|
1946 |
function setMethod($value='post'){ |
1947 |
Index: frontends/php/include/classes/ctag.inc.php |
1948 |
=================================================================== |
1949 |
--- frontends/php/include/classes/ctag.inc.php (revision 6643) |
1950 |
+++ frontends/php/include/classes/ctag.inc.php (revision 6644) |
1951 |
@@ -1,7 +1,7 @@ |
1952 |
<?php |
1953 |
/* |
1954 |
** ZABBIX |
1955 |
-** Copyright (C) 2000-2005 SIA Zabbix |
1956 |
+** Copyright (C) 2000-2009 SIA Zabbix |
1957 |
** |
1958 |
** This program is free software; you can redistribute it and/or modify |
1959 |
** it under the terms of the GNU General Public License as published by |
1960 |
@@ -19,272 +19,258 @@ |
1961 |
**/ |
1962 |
?> |
1963 |
<?php |
1964 |
- function destroy_objects() |
1965 |
- { |
1966 |
- global $GLOBALS; |
1967 |
- |
1968 |
- if(isset($GLOBALS)) foreach($GLOBALS as $name => $value) |
1969 |
- { |
1970 |
- if(!is_object($GLOBALS[$name])) continue; |
1971 |
- unset($GLOBALS[$name]); |
1972 |
- } |
1973 |
+function destroy_objects(){ |
1974 |
+ if(isset($GLOBALS)) foreach($GLOBALS as $name => $value){ |
1975 |
+ if(!is_object($GLOBALS[$name])) continue; |
1976 |
+ unset($GLOBALS[$name]); |
1977 |
} |
1978 |
- |
1979 |
- function unpack_object(&$item) |
1980 |
- { |
1981 |
- $res = ""; |
1982 |
+} |
1983 |
|
1984 |
- if(is_object($item)) |
1985 |
- { |
1986 |
- $res = $item->ToString(false); |
1987 |
- } |
1988 |
- elseif(is_array($item)) |
1989 |
- { |
1990 |
- foreach($item as $id => $dat) |
1991 |
- $res .= unpack_object($item[$id]); // Attention, recursion !!! |
1992 |
- } |
1993 |
- elseif(!is_null($item)) |
1994 |
- { |
1995 |
- $res = strval($item); |
1996 |
- unset($item); |
1997 |
- } |
1998 |
- return $res; |
1999 |
+function unpack_object(&$item){ |
2000 |
+ $res = ''; |
2001 |
+ |
2002 |
+ if(is_object($item)){ |
2003 |
+ $res = $item->toString(false); |
2004 |
} |
2005 |
+ else if(is_array($item)){ |
2006 |
+ foreach($item as $id => $dat) |
2007 |
+ $res .= unpack_object($item[$id]); // Attention, recursion !!! |
2008 |
+ } |
2009 |
+ else if(!is_null($item)){ |
2010 |
+ $res = strval($item); |
2011 |
+ unset($item); |
2012 |
+ } |
2013 |
+return $res; |
2014 |
+} |
2015 |
|
2016 |
- function implode_objects($glue, &$pieces) |
2017 |
- { |
2018 |
- if( !is_array($pieces) ) return unpack_object($pieces); |
2019 |
+function implode_objects($glue, &$pieces){ |
2020 |
+ if( !is_array($pieces) ) return unpack_object($pieces); |
2021 |
|
2022 |
- foreach($pieces as $id => $piece) |
2023 |
- $pieces[$id] = unpack_object($piece); |
2024 |
+ foreach($pieces as $id => $piece) |
2025 |
+ $pieces[$id] = unpack_object($piece); |
2026 |
|
2027 |
- return implode($glue, $pieces); |
2028 |
- } |
2029 |
+return implode($glue, $pieces); |
2030 |
+} |
2031 |
|
2032 |
- class CObject |
2033 |
- { |
2034 |
- function CObject($items=null) |
2035 |
- { |
2036 |
- $this->items = array(); |
2037 |
- if(isset($items)) |
2038 |
- { |
2039 |
- $this->AddItem($items); |
2040 |
- } |
2041 |
+class CObject{ |
2042 |
+ function CObject($items=null){ |
2043 |
+ $this->items = array(); |
2044 |
+ if(isset($items)){ |
2045 |
+ $this->addItem($items); |
2046 |
} |
2047 |
- |
2048 |
- function ToString($destroy=true) |
2049 |
- { |
2050 |
- $res = implode('',$this->items); |
2051 |
- if($destroy) $this->Destroy(); |
2052 |
- return $res; |
2053 |
- } |
2054 |
+ } |
2055 |
+ |
2056 |
+ function toString($destroy=true){ |
2057 |
+ $res = implode('',$this->items); |
2058 |
+ if($destroy) $this->destroy(); |
2059 |
+ return $res; |
2060 |
+ } |
2061 |
|
2062 |
- function Show($destroy=true){ |
2063 |
- echo $this->ToString($destroy); |
2064 |
- } |
2065 |
+ function show($destroy=true){ |
2066 |
+ echo $this->toString($destroy); |
2067 |
+ } |
2068 |
|
2069 |
- function Destroy() |
2070 |
- { |
2071 |
+ function destroy(){ |
2072 |
// TODO Problem under PHP 5.0 "Fatal error: Cannot re-assign $this in ..." |
2073 |
// $this = null; |
2074 |
- $this->CleanItems(); |
2075 |
- } |
2076 |
+ $this->cleanItems(); |
2077 |
+ } |
2078 |
|
2079 |
- function CleanItems(){ |
2080 |
- $this->items = array(); |
2081 |
+ function cleanItems(){ |
2082 |
+ $this->items = array(); |
2083 |
+ } |
2084 |
+ |
2085 |
+ function itemsCount(){ |
2086 |
+ return count($this->items); |
2087 |
+ } |
2088 |
+ |
2089 |
+ function addItem($value){ |
2090 |
+ |
2091 |
+ if(is_object($value)){ |
2092 |
+ array_push($this->items,unpack_object($value)); |
2093 |
} |
2094 |
- |
2095 |
- function ItemsCount(){ |
2096 |
- return count($this->items); |
2097 |
+ else if(is_string($value)){ |
2098 |
+ array_push($this->items,str_replace(array('<','>','"'),array('<','>','"'),$value)); |
2099 |
+// array_push($this->items,htmlspecialchars($value)); |
2100 |
} |
2101 |
- |
2102 |
- function AddItem($value){ |
2103 |
- |
2104 |
- if(is_object($value)){ |
2105 |
- array_push($this->items,unpack_object($value)); |
2106 |
+ else if(is_array($value)){ |
2107 |
+ foreach($value as $item){ |
2108 |
+ $this->addItem($item); // Attention, recursion !!! |
2109 |
} |
2110 |
- else if(is_string($value)){ |
2111 |
- array_push($this->items,str_replace(array('<','>','"'),array('<','>','"'),$value)); |
2112 |
-// array_push($this->items,htmlspecialchars($value)); |
2113 |
- } |
2114 |
- else if(is_array($value)){ |
2115 |
- foreach($value as $item){ |
2116 |
- $this->AddItem($item); // Attention, recursion !!! |
2117 |
- } |
2118 |
- } |
2119 |
- else if(!is_null($value)){ |
2120 |
- array_push($this->items,unpack_object($value)); |
2121 |
- } |
2122 |
} |
2123 |
+ else if(!is_null($value)){ |
2124 |
+ array_push($this->items,unpack_object($value)); |
2125 |
+ } |
2126 |
} |
2127 |
+} |
2128 |
|
2129 |
- class CTag extends CObject{ |
2130 |
+class CTag extends CObject{ |
2131 |
/* private *//* |
2132 |
- var $tagname; |
2133 |
- var $options = array(); |
2134 |
- var $paired;*/ |
2135 |
+ var $tagname; |
2136 |
+ var $options = array(); |
2137 |
+ var $paired;*/ |
2138 |
/* protected *//* |
2139 |
- var $items = array(); |
2140 |
+ var $items = array(); |
2141 |
|
2142 |
- var $tag_body_start; |
2143 |
- var $tag_body_end; |
2144 |
- var $tag_start; |
2145 |
- var $tag_end;*/ |
2146 |
+ var $tag_body_start; |
2147 |
+ var $tag_body_end; |
2148 |
+ var $tag_start; |
2149 |
+ var $tag_end;*/ |
2150 |
|
2151 |
/* public */ |
2152 |
- function CTag($tagname=NULL, $paired='no', $body=NULL, $class=null){ |
2153 |
- parent::CObject(); |
2154 |
+ function CTag($tagname=NULL, $paired='no', $body=NULL, $class=null){ |
2155 |
+ parent::CObject(); |
2156 |
|
2157 |
- $this->options = array(); |
2158 |
+ $this->options = array(); |
2159 |
|
2160 |
- if(!is_string($tagname)){ |
2161 |
- return $this->error('Incorrect tagname for CTag ['.$tagname.']'); |
2162 |
- } |
2163 |
- |
2164 |
- $this->tagname = $tagname; |
2165 |
- $this->paired = $paired; |
2166 |
- |
2167 |
- $this->tag_start = $this->tag_end = $this->tag_body_start = $this->tag_body_end = ''; |
2168 |
- |
2169 |
- if(is_null($body)){ |
2170 |
- $this->tag_end = $this->tag_body_start = "\n"; |
2171 |
- } |
2172 |
- else{ |
2173 |
- CTag::AddItem($body); |
2174 |
- } |
2175 |
- |
2176 |
- $this->SetClass($class); |
2177 |
+ if(!is_string($tagname)){ |
2178 |
+ return $this->error('Incorrect tagname for CTag ['.$tagname.']'); |
2179 |
} |
2180 |
|
2181 |
- function ShowStart() { echo $this->StartToString(); } |
2182 |
- function ShowBody() { echo $this->BodyToString(); } |
2183 |
- function ShowEnd() { echo $this->EndToString(); } |
2184 |
+ $this->tagname = $tagname; |
2185 |
+ $this->paired = $paired; |
2186 |
|
2187 |
- function StartToString(){ |
2188 |
- $res = $this->tag_start.'<'.$this->tagname; |
2189 |
- foreach($this->options as $key => $value){ |
2190 |
- $res .= ' '.$key.'="'.$value.'"'; |
2191 |
- } |
2192 |
- $res .= ($this->paired=='yes')?'>':' />'; |
2193 |
- return $res; |
2194 |
- } |
2195 |
+ $this->tag_start = $this->tag_end = $this->tag_body_start = $this->tag_body_end = ''; |
2196 |
|
2197 |
- function BodyToString(){ |
2198 |
- $res = $this->tag_body_start; |
2199 |
- return $res.parent::ToString(false); |
2200 |
- |
2201 |
- /*foreach($this->items as $item) |
2202 |
- $res .= $item; |
2203 |
- return $res;*/ |
2204 |
+ if(is_null($body)){ |
2205 |
+ $this->tag_end = $this->tag_body_start = "\n"; |
2206 |
} |
2207 |
- |
2208 |
- function EndToString(){ |
2209 |
- $res = ($this->paired=='yes') ? $this->tag_body_end.'</'.$this->tagname.'>' : ''; |
2210 |
- $res .= $this->tag_end; |
2211 |
- return $res; |
2212 |
+ else{ |
2213 |
+ CTag::addItem($body); |
2214 |
} |
2215 |
- |
2216 |
- function ToString($destroy=true){ |
2217 |
- $res = $this->StartToString(); |
2218 |
- $res .= $this->BodyToString(); |
2219 |
- $res .= $this->EndToString(); |
2220 |
|
2221 |
- if($destroy) $this->Destroy(); |
2222 |
+ $this->setClass($class); |
2223 |
+ } |
2224 |
+ |
2225 |
+ function showStart() { echo $this->startToString(); } |
2226 |
+ function showBody() { echo $this->bodyToString(); } |
2227 |
+ function showEnd() { echo $this->endToString(); } |
2228 |
|
2229 |
- return $res; |
2230 |
+ function startToString(){ |
2231 |
+ $res = $this->tag_start.'<'.$this->tagname; |
2232 |
+ foreach($this->options as $key => $value){ |
2233 |
+ $res .= ' '.$key.'="'.$value.'"'; |
2234 |
} |
2235 |
- |
2236 |
- function SetName($value){ |
2237 |
- if(is_null($value)) return $value; |
2238 |
+ $res .= ($this->paired=='yes')?'>':' />'; |
2239 |
+ return $res; |
2240 |
+ } |
2241 |
|
2242 |
- if(!is_string($value)){ |
2243 |
- return $this->error("Incorrect value for SetName [$value]"); |
2244 |
- } |
2245 |
- return $this->AddOption("name",$value); |
2246 |
- } |
2247 |
+ function bodyToString(){ |
2248 |
+ $res = $this->tag_body_start; |
2249 |
+ return $res.parent::ToString(false); |
2250 |
|
2251 |
- function GetName(){ |
2252 |
- if(isset($this->options['name'])) |
2253 |
- return $this->options['name']; |
2254 |
- return NULL; |
2255 |
- } |
2256 |
- |
2257 |
- function SetClass($value){ |
2258 |
- if(isset($value)) |
2259 |
- $this->options['class'] = $value; |
2260 |
- else |
2261 |
- unset($this->options['class']); |
2262 |
+ /*foreach($this->items as $item) |
2263 |
+ $res .= $item; |
2264 |
+ return $res;*/ |
2265 |
+ } |
2266 |
+ |
2267 |
+ function endToString(){ |
2268 |
+ $res = ($this->paired=='yes') ? $this->tag_body_end.'</'.$this->tagname.'>' : ''; |
2269 |
+ $res .= $this->tag_end; |
2270 |
+ return $res; |
2271 |
+ } |
2272 |
+ |
2273 |
+ function toString($destroy=true){ |
2274 |
+ $res = $this->startToString(); |
2275 |
+ $res .= $this->bodyToString(); |
2276 |
+ $res .= $this->endToString(); |
2277 |
|
2278 |
- return $value; |
2279 |
+ if($destroy) $this->Destroy(); |
2280 |
+ |
2281 |
+ return $res; |
2282 |
+ } |
2283 |
+ |
2284 |
+ function setName($value){ |
2285 |
+ if(is_null($value)) return $value; |
2286 |
+ |
2287 |
+ if(!is_string($value)){ |
2288 |
+ return $this->error("Incorrect value for setName [$value]"); |
2289 |
} |
2290 |
- |
2291 |
- function DelOption($name){ |
2292 |
- unset($this->options[$name]); |
2293 |
- } |
2294 |
- |
2295 |
- function GetOption($name){ |
2296 |
- $ret = NULL; |
2297 |
- if(isset($this->options[$name])) |
2298 |
- $ret =& $this->options[$name]; |
2299 |
- return $ret; |
2300 |
- } |
2301 |
+ return $this->addOption("name",$value); |
2302 |
+ } |
2303 |
+ |
2304 |
+ function getName(){ |
2305 |
+ if(isset($this->options['name'])) |
2306 |
+ return $this->options['name']; |
2307 |
+ return NULL; |
2308 |
+ } |
2309 |
+ |
2310 |
+ function setClass($value){ |
2311 |
+ if(isset($value)) |
2312 |
+ $this->options['class'] = $value; |
2313 |
+ else |
2314 |
+ unset($this->options['class']); |
2315 |
|
2316 |
- function SetHint($text, $width='', $class=''){ |
2317 |
- if(empty($text)) return false; |
2318 |
+ return $value; |
2319 |
+ } |
2320 |
+ |
2321 |
+ function DelOption($name){ |
2322 |
+ unset($this->options[$name]); |
2323 |
+ } |
2324 |
+ |
2325 |
+ function getOption($name){ |
2326 |
+ $ret = NULL; |
2327 |
+ if(isset($this->options[$name])) |
2328 |
+ $ret =& $this->options[$name]; |
2329 |
+ return $ret; |
2330 |
+ } |
2331 |
|
2332 |
- insert_showhint_javascript(); |
2333 |
+ function setHint($text, $width='', $class=''){ |
2334 |
+ if(empty($text)) return false; |
2335 |
|
2336 |
- $text = unpack_object($text); |
2337 |
- if($width != '' || $class != ''){ |
2338 |
- $code = "show_hint_ext(this,event,'".$text."','".$width."','".$class."');"; |
2339 |
- } |
2340 |
- else{ |
2341 |
- $code = "show_hint(this,event,'".$text."');"; |
2342 |
- } |
2343 |
+ insert_showhint_javascript(); |
2344 |
|
2345 |
- $this->AddAction('onMouseOver', $code); |
2346 |
- $this->AddAction('onMouseMove', 'update_hint(this,event);'); |
2347 |
+ $text = unpack_object($text); |
2348 |
+ if($width != '' || $class != ''){ |
2349 |
+ $code = "show_hint_ext(this,event,'".$text."','".$width."','".$class."');"; |
2350 |
} |
2351 |
- |
2352 |
- function OnClick($handle_code){ |
2353 |
- $this->AddAction('onclick', $handle_code); |
2354 |
+ else{ |
2355 |
+ $code = "show_hint(this,event,'".$text."');"; |
2356 |
} |
2357 |
|
2358 |
- function AddAction($name, $value){ |
2359 |
- if(is_object($value)){ |
2360 |
- $this->options[$name] = unpack_object($value); |
2361 |
- } |
2362 |
- else if(!empty($value)){ |
2363 |
- $this->options[$name] = htmlentities(str_replace(array("\r", "\n"), '', strval($value)),ENT_COMPAT,S_HTML_CHARSET); |
2364 |
- } |
2365 |
+ $this->addAction('onMouseOver', $code); |
2366 |
+ $this->addAction('onMouseMove', 'update_hint(this,event);'); |
2367 |
+ } |
2368 |
+ |
2369 |
+ function onClick($handle_code){ |
2370 |
+ $this->addAction('onclick', $handle_code); |
2371 |
+ } |
2372 |
+ |
2373 |
+ function addAction($name, $value){ |
2374 |
+ if(is_object($value)){ |
2375 |
+ $this->options[$name] = unpack_object($value); |
2376 |
} |
2377 |
+ else if(!empty($value)){ |
2378 |
+ $this->options[$name] = htmlentities(str_replace(array("\r", "\n"), '', strval($value)),ENT_COMPAT,S_HTML_CHARSET); |
2379 |
+ } |
2380 |
+ } |
2381 |
|
2382 |
- function AddOption($name, $value){ |
2383 |
- if(is_object($value)){ |
2384 |
- $this->options[$name] = unpack_object($value); |
2385 |
- } |
2386 |
- else if(isset($value)) |
2387 |
- $this->options[$name] = htmlspecialchars(strval($value)); |
2388 |
- else |
2389 |
- unset($this->options[$name]); |
2390 |
+ function addOption($name, $value){ |
2391 |
+ if(is_object($value)){ |
2392 |
+ $this->options[$name] = unpack_object($value); |
2393 |
} |
2394 |
+ else if(isset($value)) |
2395 |
+ $this->options[$name] = htmlspecialchars(strval($value)); |
2396 |
+ else |
2397 |
+ unset($this->options[$name]); |
2398 |
+ } |
2399 |
|
2400 |
- function SetEnabled($value='yes'){ |
2401 |
- if((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1') |
2402 |
- || (is_int($value) && $value<>0)) |
2403 |
- { |
2404 |
- unset($this->options['disabled']); |
2405 |
- } |
2406 |
- else if((is_string($value) && ($value == 'no' || $value == 'disabled' || $value=='off') || $value=='0') |
2407 |
- || (is_int($value) && $value==0)) |
2408 |
- { |
2409 |
- $this->options['disabled'] = 'disabled'; |
2410 |
- } |
2411 |
+ function setEnabled($value='yes'){ |
2412 |
+ if((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1') |
2413 |
+ || (is_int($value) && $value<>0)) |
2414 |
+ { |
2415 |
+ unset($this->options['disabled']); |
2416 |
} |
2417 |
- |
2418 |
- function error($value){ |
2419 |
- error('class('.get_class($this).') - '.$value); |
2420 |
- return 1; |
2421 |
+ else if((is_string($value) && ($value == 'no' || $value == 'disabled' || $value=='off') || $value=='0') |
2422 |
+ || (is_int($value) && $value==0)) |
2423 |
+ { |
2424 |
+ $this->options['disabled'] = 'disabled'; |
2425 |
} |
2426 |
} |
2427 |
-?> |
2428 |
+ |
2429 |
+ function error($value){ |
2430 |
+ error('class('.get_class($this).') - '.$value); |
2431 |
+ return 1; |
2432 |
+ } |
2433 |
+} |
2434 |
+?> |
2435 |
\ No newline at end of file |
2436 |
Index: frontends/php/include/classes/cmap.inc.php |
2437 |
=================================================================== |
2438 |
--- frontends/php/include/classes/cmap.inc.php (revision 6643) |
2439 |
+++ frontends/php/include/classes/cmap.inc.php (revision 6644) |
2440 |
@@ -19,78 +19,75 @@ |
2441 |
**/ |
2442 |
?> |
2443 |
<?php |
2444 |
- class CMap extends CTag |
2445 |
- { |
2446 |
+class CMap extends CTag{ |
2447 |
/* public */ |
2448 |
- function CMap($name="") |
2449 |
- { |
2450 |
- parent::CTag("map","yes"); |
2451 |
- $this->SetName($name); |
2452 |
- } |
2453 |
- function AddRectArea($x1,$y1,$x2,$y2,$href,$alt) |
2454 |
- { |
2455 |
- return $this->AddArea(array($x1,$y1,$x2,$y2),$href,$alt,'rect'); |
2456 |
- } |
2457 |
- function AddArea($coords,$href,$alt,$shape) |
2458 |
- { |
2459 |
- return $this->AddItem(new CArea($coords,$href,$alt,$shape)); |
2460 |
- } |
2461 |
- function AddItem($value) |
2462 |
- { |
2463 |
- if(strtolower(get_class($value)) != 'carea') |
2464 |
- return $this->error("Incorrect value for AddItem [$value]"); |
2465 |
+ function CMap($name=''){ |
2466 |
+ parent::CTag('map','yes'); |
2467 |
+ $this->setName($name); |
2468 |
+ } |
2469 |
+ |
2470 |
+ function addRectArea($x1,$y1,$x2,$y2,$href,$alt){ |
2471 |
+ return $this->addArea(array($x1,$y1,$x2,$y2),$href,$alt,'rect'); |
2472 |
+ } |
2473 |
+ |
2474 |
+ function addArea($coords,$href,$alt,$shape){ |
2475 |
+ return $this->addItem(new CArea($coords,$href,$alt,$shape)); |
2476 |
+ } |
2477 |
+ |
2478 |
+ function addItem($value){ |
2479 |
+ if(strtolower(get_class($value)) != 'carea') |
2480 |
+ return $this->error('Incorrect value for addItem ['.$value.']'); |
2481 |
|
2482 |
- return parent::AddItem($value); |
2483 |
- } |
2484 |
+ return parent::addItem($value); |
2485 |
} |
2486 |
+} |
2487 |
|
2488 |
- class CArea extends CTag |
2489 |
- { |
2490 |
- function CArea($coords,$href,$alt,$shape) |
2491 |
- { |
2492 |
- parent::CTag("area","no"); |
2493 |
- $this->SetCoords($coords); |
2494 |
- $this->SetShape($shape); |
2495 |
- $this->SetHref($href); |
2496 |
- $this->SetAlt($alt); |
2497 |
- } |
2498 |
- function SetCoords($value) |
2499 |
- { |
2500 |
- if(!is_array($value)) |
2501 |
- return $this->error("Incorrect value for SetCoords [$value]"); |
2502 |
- if(count($value)<3) |
2503 |
- return $this->error("Incorrect values count for SetCoords [".count($value)."]"); |
2504 |
+class CArea extends CTag{ |
2505 |
+ function CArea($coords,$href,$alt,$shape){ |
2506 |
+ parent::CTag('area','no'); |
2507 |
+ $this->setCoords($coords); |
2508 |
+ $this->setShape($shape); |
2509 |
+ $this->setHref($href); |
2510 |
+ $this->setAlt($alt); |
2511 |
+ } |
2512 |
+ |
2513 |
+ function setCoords($value){ |
2514 |
+ if(!is_array($value)) |
2515 |
+ return $this->error('Incorrect value for setCoords ['.$value.']'); |
2516 |
+ if(count($value)<3) |
2517 |
+ return $this->error('Incorrect values count for setCoords ['.count($value).']'); |
2518 |
|
2519 |
- $str_val = ""; |
2520 |
- foreach($value as $val) |
2521 |
- { |
2522 |
- if(!is_numeric($val)) |
2523 |
- return $this->error("Incorrect value for SetCoords [$val]"); |
2524 |
+ $str_val = ''; |
2525 |
+ foreach($value as $val){ |
2526 |
+ if(!is_numeric($val)) |
2527 |
+ return $this->error('Incorrect value for setCoords ['.$val.']'); |
2528 |
|
2529 |
- $str_val .= $val.","; |
2530 |
- } |
2531 |
- $this->AddOption("coords",trim($str_val,',')); |
2532 |
+ $str_val .= $val.','; |
2533 |
} |
2534 |
- function SetShape($value) |
2535 |
- { |
2536 |
- if(!is_string($value)) |
2537 |
- return $this->error("Incorrect value for SetShape [$value]"); |
2538 |
+ $this->addOption('coords',trim($str_val,',')); |
2539 |
+ } |
2540 |
|
2541 |
- $this->AddOption("shape",$value); |
2542 |
- } |
2543 |
- function SetHref($value) |
2544 |
- { |
2545 |
- if(!is_string($value)) |
2546 |
- return $this->error("Incorrect value for SetHref [$value]"); |
2547 |
+ function setShape($value){ |
2548 |
+ if(!is_string($value)) |
2549 |
+ return $this->error('Incorrect value for setShape ['.$value.']'); |
2550 |
|
2551 |
- $this->AddOption("href",$value); |
2552 |
- } |
2553 |
- function SetAlt($value) |
2554 |
- { |
2555 |
- if(!is_string($value)) |
2556 |
- return $this->error("Incorrect value for SetAlt [$value]"); |
2557 |
+ $this->addOption('shape',$value); |
2558 |
+ } |
2559 |
|
2560 |
- $this->AddOption("alt",$value); |
2561 |
- } |
2562 |
+ function setHref($value){ |
2563 |
+ if(!is_string($value)) |
2564 |
+ return $this->error('Incorrect value for setHref ['.$value.']'); |
2565 |
+ $url = new Curl($value); |
2566 |
+ $value = $url->getUrl(); |
2567 |
+ |
2568 |
+ $this->addOption('href',$value); |
2569 |
} |
2570 |
-?> |
2571 |
+ |
2572 |
+ function setAlt($value){ |
2573 |
+ if(!is_string($value)) |
2574 |
+ return $this->error('Incorrect value for setAlt ['.$value.']'); |
2575 |
+ |
2576 |
+ $this->addOption('alt',$value); |
2577 |
+ } |
2578 |
+} |
2579 |
+?> |
2580 |
\ No newline at end of file |
2581 |
Index: frontends/php/include/html.inc.php |
2582 |
=================================================================== |
2583 |
--- frontends/php/include/html.inc.php (revision 6643) |
2584 |
+++ frontends/php/include/html.inc.php (revision 6644) |
2585 |
@@ -58,7 +58,7 @@ |
2586 |
} |
2587 |
|
2588 |
function prepare_url(&$var, $varname=null){ |
2589 |
- $result = ""; |
2590 |
+ $result = ''; |
2591 |
|
2592 |
if(is_array($var)){ |
2593 |
foreach($var as $id => $par) |
2594 |
Index: frontends/php/items.php |
2595 |
=================================================================== |
2596 |
--- frontends/php/items.php (revision 6643) |
2597 |
+++ frontends/php/items.php (revision 6644) |
2598 |
@@ -944,16 +944,17 @@ |
2599 |
// url_param('groupid'), |
2600 |
'action')); |
2601 |
|
2602 |
- $status=new CCol(new CLink(item_status2str($db_item["status"]), |
2603 |
- "?group_itemid%5B%5D=".$db_item["itemid"]. |
2604 |
- "&group_task=".($db_item["status"] ? "Activate+selected" : "Disable+selected"), |
2605 |
- item_status2style($db_item["status"]))); |
2606 |
+ $status=new CCol(new CLink(item_status2str($db_item['status']), |
2607 |
+// '?sessionid='.$USER_DETAILS['sessionid']. |
2608 |
+ '?group_itemid%5B%5D='.$db_item['itemid']. |
2609 |
+ '&group_task='.($db_item['status']?'Activate+selected':'Disable+selected'), |
2610 |
+ item_status2style($db_item['status']))); |
2611 |
|
2612 |
- if($db_item["error"] == ''){ |
2613 |
- $error=new CCol('-',"off"); |
2614 |
+ if($db_item['error'] == ''){ |
2615 |
+ $error=new CCol('-','off'); |
2616 |
} |
2617 |
else{ |
2618 |
- $error=new CCol($db_item["error"],"on"); |
2619 |
+ $error=new CCol($db_item['error'],'on'); |
2620 |
} |
2621 |
|
2622 |
$applications = $show_applications ? implode(', ', get_applications_by_itemid($db_item["itemid"], 'name')) : null; |