1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8require_once('tiki-setup.php');
9//TODO Use a pref to handle the list
10if (! empty($tikiMonitorRestriction)) {
11	if (is_array($tikiMonitorRestriction)) {
12		if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
13			$aListIp = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
14			$sIpToCheck = $aListIp[0];
15		} elseif (isset($_SERVER['REMOTE_ADDR']) && ! empty($_SERVER['REMOTE_ADDR'])) {
16			$sIpToCheck = $_SERVER['REMOTE_ADDR'];
17		} else {
18			$sIpToCheck = null;
19		}
20		if (in_array($sIpToCheck, $tikiMonitorRestriction) === false) {
21			header('location: index.php');
22		}
23	} else {
24		echo tra("\$tikiMonitorRestriction need to be an array");
25		exit;
26	}
27}
28$opcode_stats = TikiLib::lib('admin')->getOpcodeCacheStatus();
29
30# TODO: The results will be wrong for WinCache
31# The following is the relevant snippet from
32# admin/include_performance.php
33$txtUsed = tr('Used');
34$txtAvailable = tr('Available');
35if ($opcode_cache == 'WinCache') {
36	// Somehow WinCache seems to flip the representations
37	$txtAvailable = tr('Used');
38	$txtUsed = tr('Available');
39}
40
41$result = [];
42$result['OPCodeCache'] = $opcode_stats['opcode_cache'];
43$result['OpCodeStats'] = $opcode_stats;
44
45include_once('installer/installlib.php');
46$installer = Installer::getInstance();
47$result['DbRequiresUpdate'] = $installer->requiresUpdate();
48
49$result['SearchIndexRebuildLast'] = $tikilib->get_preference('unified_last_rebuild');
50
51$display = json_encode($result);
52echo $display;
53