This file is indexed.

/usr/share/zabbix/js/class.cdate.js is in zabbix-frontend-php 1:2.4.7+dfsg-2ubuntu2.

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
/*
** Zabbix
** Copyright (C) 2001-2015 Zabbix SIA
**
** 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/

var CDate = Class.create();

CDate.prototype = {
	server:		0,			// getTime uses clients :0, or servers time :1
	tzDiff:		0,			// server and client TZ diff
	clientDate:	null,	// clients(JS, Browser) date object
	serverDate:	null,	// servers(PHP, Unix) date object
	tmpDate:	null,		// inner usage

	initialize: function() {
		this.tmpDate = new Date();

		this.clientDate = (arguments.length > 0)
			? new Date(arguments[0])
			: new Date();
		this.calcTZdiff(this.clientDate.getTime());
		this.serverDate = new Date(this.clientDate.getTime() - this.tzDiff * 1000);
	},

	calcTZdiff: function(time) {
		var ddTZOffset;

		if (typeof(time) != 'undefined') {
			this.tmpDate.setTime(time);
			ddTZOffset = this.tmpDate.getTimezoneOffset() * -60;
		}
		else {
			ddTZOffset = this.serverDate.getTimezoneOffset() * -60;
		}

		this.tzDiff = ddTZOffset - PHP_TZ_OFFSET;
	},

	/**
	* Formats date according given format. Uses server timezone.
	* Supported formats:	'd M Y H:i', 'j. M Y G:i', 'Y/m/d H:i', 'Y-m-d H:i', 'Y-m-d H:i:s', 'Y-m-d', 'H:i:s', 'H:i',
	*						'M jS, Y h:i A', 'Y M d H:i', 'd.m.Y H:i' and 'd m Y H i'
	*						Format 'd m Y H i' is also accepted but used internally for date input fields.
	*
	* @param format PHP style date format limited to supported formats
	*
	* @return string|bool human readable date or false if unsupported format given
	*/
	format: function(format) {
		var shortMn = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

		var dt = this.getDate(),
			mnth = this.getMonth(),
			yr = this.getFullYear(),
			hrs = this.getHours(),
			mnts = this.getMinutes(),
			sec = this.getSeconds();

		/**
		 * Transform datetime parts to two digits e.g., 2 becomes 02
		 * @param int val
		 * @return string
		 */
		var appZr = function(val) {
			return val < 10 ? '0' + val : val;
		}

		/**
		 * Append date suffix according to English rules e.g., 3 becomes 3rd
		 * @param int date
		 * @return string
		 */
		var appSfx = function(date) {
			if (date % 10 == 1 && date != 11) {
				return date + 'st';
			}
			if (date % 10 == 2 && date != 12) {
				return date + 'nd';
			}
			if (date % 10 == 3 && date != 13) {
				return date + 'rd';
			}
			return date + 'th';
		}

		switch(format) {
			case 'd M Y H:i':
				return appZr(dt) + ' ' + shortMn[mnth] + ' ' + yr + ' ' + appZr(hrs) + ':' + appZr(mnts);
			case 'j. M Y G:i':
				return dt + '. ' + shortMn[mnth] + ' ' + yr + ' ' + hrs + ':' + appZr(mnts);
			case 'Y/m/d H:i':
				return yr + '/' + appZr(mnth + 1) + '/' + appZr(dt) + ' ' + appZr(hrs) + ':' + appZr(mnts);
			case 'Y-m-d H:i':
				return yr + '-' + appZr(mnth + 1) + '-' + appZr(dt) + ' ' + appZr(hrs) + ':' + appZr(mnts);
			case 'Y-m-d':
				return yr + '-' + appZr(mnth + 1) + '-' + appZr(dt);
			case 'H:i:s':
				return  appZr(hrs) + ':' + appZr(mnts) + ':' + appZr(sec);
			case 'H:i':
				return  appZr(hrs) + ':' + appZr(mnts);
			case 'M jS, Y h:i A':
				var ampm = (hrs < 12) ? 'AM' : 'PM';
				hrs = appZr((hrs + 11) % 12 + 1);
				return shortMn[mnth] + ' ' + appSfx(dt) + ', ' + yr + ' ' + hrs + ':' + appZr(mnts) + ' ' + ampm;
			case 'Y M d H:i':
				return  yr + ' ' + shortMn[mnth] + ' ' +appZr(dt) + ' ' + appZr(hrs) + ':' + appZr(mnts);
			case 'd.m.Y H:i':
				return appZr(dt) + '.' + appZr(mnth + 1) + '.' + yr + ' ' + appZr(hrs) + ':' + appZr(mnts);
			case 'd. m. Y H:i':
				return appZr(dt) + '. ' + appZr(mnth + 1) + '. ' + yr + ' ' + appZr(hrs) + ':' + appZr(mnts);
			// date format used for date input fields
			case 'd m Y H i':
				return appZr(dt) + ' ' + appZr(mnth + 1) + ' ' + yr + ' ' + appZr(hrs) + ' ' + appZr(mnts);
			default:
				// defaults to Y-m-d H:i:s
				return yr + '-' + appZr(mnth + 1) + '-' + appZr(dt) + ' ' + appZr(hrs) + ':' + appZr(mnts) +
					':' + appZr(sec);
		}
	},

	getZBXDate: function() {
		var thedate = [];
		thedate[0] = this.serverDate.getDate();
		thedate[1] = this.serverDate.getMonth() + 1;
		thedate[2] = this.serverDate.getFullYear();
		thedate[3] = this.serverDate.getHours();
		thedate[4] = this.serverDate.getMinutes();
		thedate[5] = this.serverDate.getSeconds();

		for (var i = 0; i < thedate.length; i++) {
			if ((thedate[i] + '').length < 2) {
				thedate[i] = '0' + thedate[i];
			}
		}

		return '' + thedate[2] + thedate[1] + thedate[0] + thedate[3] + thedate[4] + thedate[5];
	},

	setZBXDate: function(strdate) {
		this.server = 1;

		var theDate = {
			Y: strdate.toString().substr(0, 4),
			m: strdate.toString().substr(4, 2),
			d: strdate.toString().substr(6, 2),
			H: strdate.toString().substr(8, 2),
			i: strdate.toString().substr(10, 2),
			s: strdate.toString().substr(12, 2)
		};

		this.serverDate.setFullYear(theDate.Y);
		this.serverDate.setMonth(theDate.m - 1);
		this.serverDate.setDate(theDate.d);
		this.serverDate.setHours(theDate.H);
		this.serverDate.setMinutes(theDate.i);
		this.serverDate.setSeconds(theDate.s);
		this.serverDate.setMilliseconds(0);
		this.calcTZdiff();

		return this.getTime();
	},

	getFormattedDate: function() {
		var fDate = this.getFullYear() + '-' + (this.getMonth() + 1) + '-' + this.getDate();
		fDate += ' ' + this.getHours() + ':' + this.getMinutes() + ':' + this.getSeconds();
		fDate += ' ' + tzOffsetHours + ':' + this.tzOffset / 3600;

		return fDate;
	},

	toString: function() {
		return this.serverDate.toString();
	},

	parse: function(arg) {
		this.server = 1;
		this.serverDate.setTime(Date.parse(arg));
		this.calcTZdiff();

		return this.getTime();
	},

	getTimezoneOffset: function() {
		return parseInt(-PHP_TZ_OFFSET / 60);
	},

	getMilliseconds: function() {
		return this.serverDate.getMilliseconds();
	},

	getSeconds: function() {
		return this.serverDate.getSeconds();
	},

	getMinutes: function() {
		return this.serverDate.getMinutes();
	},

	getHours: function() {
		return this.serverDate.getHours();
	},

	getDay: function() {
		return this.serverDate.getDay();
	},

	getMonth: function() {
		return this.serverDate.getMonth();
	},

	getYear: function() {
		return this.serverDate.getYear();
	},

	getFullYear: function() {
		return this.serverDate.getFullYear();
	},

	getDate: function() {
		return this.serverDate.getDate();
	},

	getTime: function() {
		if (this.server == 1) {
			return this.serverDate.getTime() + this.tzDiff * 1000;
		}
		else {
			return this.clientDate.getTime();
		}
	},

	setMilliseconds: function(arg) {
		this.server = 1;
		this.serverDate.setMilliseconds(arg);
		this.calcTZdiff();
	},

	setSeconds: function(arg) {
		this.server = 1;
		this.serverDate.setSeconds(arg);
		this.calcTZdiff();
	},

	setMinutes: function(arg) {
		this.server = 1;
		this.serverDate.setMinutes(arg);
		this.calcTZdiff();
	},

	setHours: function(arg) {
		this.server = 1;
		this.serverDate.setHours(arg);
		this.calcTZdiff();
	},

	setDate: function(arg) {
		this.server = 1;
		this.serverDate.setDate(arg);
		this.calcTZdiff();
	},

	setMonth: function(arg) {
		this.server = 1;
		this.serverDate.setMonth(arg);
		this.calcTZdiff();
	},

	setFullYear: function(arg) {
		this.server = 1;
		this.serverDate.setFullYear(arg);
		this.calcTZdiff();
	},

	setTime: function(arg) {
		arg = parseInt(arg, 10);

		this.server = 0;
		this.calcTZdiff(arg);
		this.serverDate.setTime(arg - this.tzDiff * 1000);
		this.clientDate.setTime(arg);
	}
}