This file is indexed.

/usr/share/zabbix/js/class.pmaster.js is in zabbix-frontend-php 1:1.8.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/*
** Copyright (C) 2010 Artem "Aly" Suharev
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
// JavaScript Document

var PMasters = new Array();				// obj instances 
function initPMaster(pmid, args){		// use this function to initialize PMaster
	if(typeof(PMasters[pmid]) == 'undefined'){
		PMasters[pmid] = new CPMaster(pmid,args);
	}
return pmid;
}

// Puppet master Class
// Author: Aly
var CPMaster = Class.create(CDebug,{
pmasterid:			0,				// PMasters reference id
dolls:				new Array(),	// list of updated objects

initialize: function($super, pmid, obj4upd){
	this.pmasterid = pmid;
	$super('CPMaster['+pmid+']');
//--
	
	var doll = new Array();
	for(var id in obj4upd){
		if((typeof(obj4upd[id]) != 'undefined') && (!is_null(obj4upd[id]))){
			doll = obj4upd[id];
			
			if(typeof(doll['frequency']) == 'undefined')	doll['frequency'] = 60;
			if(typeof(doll['url']) == 'undefined') 			doll['url'] = location.href;
			if(typeof(doll['counter']) == 'undefined') 		doll['counter'] = 0;
			if(typeof(doll['darken']) == 'undefined') 		doll['darken'] = 0;
			if(typeof(doll['params']) == 'undefined') 		doll['params'] = new Array();
			
			this.addStartDoll(id, doll.frequency, doll.url, doll.counter, doll.darken, doll.params);
		}
	}
},

addStartDoll: function(domid,frequency,url,counter,darken,params){
	this.addDoll(domid,frequency,url,counter,darken,params);
	this.dolls[domid].startDoll();
	
return this.dolls[domid];
},

addDoll: function(domid,frequency,url,counter,darken,params){
	this.debug('addDoll', domid);
	
	var obj = document.getElementById(domid);
	if((typeof(obj) == 'undefined')) return false; 

	if(typeof(this.dolls[domid]) != 'undefined'){ 
		return this.dolls[domid];
	}
	
	var obj4update = {
		'domid': 		domid,
		'url': 			url,
		'params': 		params,
		'frequency': 	frequency,
		'darken':		darken,
		'lastupdate': 	0,
		'counter': 		0,
		'ready': 		true
	}

	this.dolls[domid] = new CDoll(obj4update);
	this.dolls[domid]._pmasterid = this.pmasterid;
	
return this.dolls[domid];
},

rmvDoll: function(domid){
	this.debug('rmvDoll', domid);
	
	if((typeof(this.dolls[domid]) != 'undefined') && (!is_null(this.dolls[domid]))){
		this.dolls[domid].pexec.stop();
		this.dolls[domid].pexec = null;
		
		this.dolls[domid].rmvDarken();
		
		try{ delete(this.dolls[domid]); } catch(e){ this.dolls[domid] = null; }
	}
},

startAllDolls: function(){
	this.debug('startAllDolls');
	
	for(domid in this.dolls){
		if((typeof(this.dolls[domid]) != 'undefined') && (!is_null(this.dolls[domid]))){
			this.dolls[domid].startDoll();
		}
	}
},

stopAllDolls: function(){
	this.debug('stopAllDolls');
	
	for(domid in this.dolls){
		if((typeof(this.dolls[domid]) != 'undefined') && (!is_null(this.dolls[domid]))){
			this.dolls[domid].stopDoll();
		}
	}
},

clear: function(){
	this.debug('clear');
	
	for(domid in this.dolls){
		this.rmvDoll(domid);
	}
	this.dolls = new Array();
}
});

// JavaScript Document
// DOM obj light loader (DOLL)
// Author: Aly
var CDoll = Class.create(CDebug,{
_pmasterid:		0,			// PMasters id to which doll belongs
_domobj:		null,		// DOM obj for update
_domid:			null,		// DOM obj id
_domdark:		null,		// DOM div for darken updated obj
_url:			'',
_frequency:		60,			// min 5 sec
_darken:		0,			// make updated object darken - 1
_lastupdate:	0,
_counter:		0,			// how many times do update, 0 - infinite
_params:		'',
_status:		false,
_ready:			false,

pexec:			null,		// PeriodicalExecuter object
min_freq:		5,			// seconds

initialize: function($super, obj4update){
	this._domid = obj4update.domid;
	$super('CDoll['+this._domid+']');
//--

	this._domobj = $(this._domid);
	this.url(obj4update.url);
	this.frequency(obj4update.frequency);
	this.lastupdate(obj4update.lastupdate);
	this.darken(obj4update.darken);
	this.counter(obj4update.counter);
	this.params(obj4update.params);
	this.ready(obj4update.ready);
},

startDoll: function(){
	this.debug('startDoll');

	if(is_null(this.pexec)){
		this.lastupdate(0);
		this.pexec = new PeriodicalExecuter(this.check4Update.bind(this), this._frequency);
		this.check4Update();
	}
},

restartDoll: function(){
	this.debug('restartDoll');	
	if(!is_null(this.pexec)){
		this.pexec.stop();		
		try{ delete(this.pexec); } catch(e){ this.pexec = null; }
		this.pexec = null;
	}

	this.pexec = new PeriodicalExecuter(this.check4Update.bind(this), this._frequency);
},

stopDoll: function(){
	this.debug('stopDoll');
	
	if(!is_null(this.pexec)){
		this.pexec.stop();		
		try{ delete(this.pexec); } catch(e){ this.pexec = null; }
		this.pexec = null;
	}
},

pmasterid: function(){
	return this._pmasterid;
},

domid: function(){
	return this._domid;
},

domobj: function(){
	return this._domobj;
},

url: function(url_){
	if('undefined'==typeof(url_)) return this._url;
	else this._url=url_;
},

frequency: function(frequency_){
	if('undefined'==typeof(frequency_)){
		return this._frequency;
	}
	else{
		if(frequency_ < this.min_freq) frequency_ = this.min_freq;
		this._frequency=parseInt(frequency_);
	}
},

lastupdate: function(lastupdate_){
	if('undefined'==typeof(lastupdate_)) return this._lastupdate;
	else this._lastupdate=lastupdate_;
},

darken:	function(darken_){
	if('undefined'==typeof(darken_)) return this._darken;
	else this._darken=darken_;
},

counter: function(counter_){
	if('undefined'==typeof(counter_)) return Math.abs(this._counter);
	else this._counter=counter_;
},

ready: function(ready_){
	if('undefined'==typeof(ready_)) return this._ready;
	else this._ready=ready_;
},

params: function(params_){
	if('undefined'==typeof(params_)) return this._params;
	else this._params=params_;
},

check4Update: function(){
	this.debug('check4Update');
	
	var now = parseInt(new Date().getTime()/1000);

//SDI((this._lastupdate + this._frequency)+' < '+(now + this.min_freq));
	if(this._ready && ((this._lastupdate + this._frequency) < (now + this.min_freq))){ //
		this.update();
		this._lastupdate = now; 
	}
},

update: function(){
	this.debug('update');

	this._ready = false;
	
	if(this._counter == 1) this.pexec.stop();
	if(this._darken) this.setDarken();
	
	var url = new Curl(this._url);
	url.setArgument('upd_counter', this.counter());
	url.setArgument('pmasterid', this.pmasterid());

	new Ajax.Request(url.getUrl(),
					{
						'method': 'post',
						'parameters': this._params,
						'onSuccess': this.onSuccess.bind(this),
						'onFailure': this.onFailure.bind(this)
					}
	);

	this._counter--;
},

onSuccess: function(resp){
	this.debug('onSuccess');
	this.rmwDarken();

	var headers = resp.getAllResponseHeaders(); 
//alert(headers);
	if(headers.indexOf('Ajax-response: false') > -1){
		return false;
	}
	else{
		this._domobj.update(resp.responseText);
	}
//SDI(resp.responseText);

	this._ready = true;
	this.notify(true, this._pmasterid, this._domid, this._lastupdate, this.counter());
},

onFailure: function(resp){
	this.debug('onFailure');
	
	this.rmwDarken();
	this._ready = true;
	this.notify(false, this._pmasterid, this._domid, this._lastupdate, this.counter());
},

setDarken: function(){
	this.debug('setDarken');
	
	if(is_null(this._domobj)) return false;
	
	if(is_null(this._domdark)){
		this._domdark = document.createElement('div');		
		document.body.appendChild(this._domdark);
		this._domdark.className = 'onajaxload';
	}
	
	var obj_params = getPosition(this._domobj);
	obj_params.height = this._domobj.offsetHeight;
	obj_params.width = this._domobj.offsetWidth;
	
	Element.extend(this._domdark);
	this._domdark.setStyle({ 'top': obj_params.top+'px', 
							'left': obj_params.left+'px',
							'width': obj_params.width+'px',
							'height': obj_params.height+'px'
							});
},

rmwDarken: function(){
	this.debug('rmvDarken');
	
	if(!is_null(this._domdark)){
		this._domdark.style.cursor = 'auto';
		
		document.body.removeChild(this._domdark);
		this._domdark = null;
	}
}
});