Subversion Repositories ALCASAR

Rev

Rev 2817 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2815 rexy 1
<?php
2
# Welcome page (sysinfo)
3
# by Rexy
4
// request database
5
function request ($texte) {
6
		$strResult = 0;
7
		// Déclaration des paramètres de connexion
8
		$host = "localhost";
9
		$DB_USER = "radius";
10
		$DB_RADIUS = "radius";
11
		$radiuspwd = "";
12
		// Connexion au serveur
13
		$mysqli = new mysqli($host, $DB_USER, $radiuspwd, $DB_RADIUS);
14
		if ($texte == 'user') {$query = "SELECT UserName FROM userinfo";}
15
		else { $query = "SELECT GroupName FROM radusergroup GROUP BY GroupName";}
16
		$result = $mysqli->query($query);
17
		// Recuperation des resultats
18
		$strResult = $result->num_rows;
19
		// Deconnexion de la base de donnees
20
		$mysqli->close();
21
		return $strResult;
22
 }
23
 
24
// Internet test
25
function internetTest() {
26
	$host  = 'www.google.com';
27
	$host2 = 'www.alcasar.net';
28
	$port = 80;
29
 
30
	$sock = @fsockopen($host, $port, $errno, $errstr, 2);
31
	if ($sock) {
32
		fclose($sock);
33
		return true;
34
	}
35
 
36
	$sock = @fsockopen($host2, $port, $errno, $errstr, 2);
37
	if ($sock) {
38
		fclose($sock);
39
		return true;
40
	}
41
 
42
	return false;
43
}
44
 
45
// filtering test
46
function filtrageTest($file, $search_regex){
47
	$pointeur = fopen($file,"r");
48
	$result = false;
49
	if ($pointeur)
50
		{
51
		while (!feof($pointeur))
52
			{
53
				$ligne = fgets($pointeur);
54
				if (preg_match($search_regex, $ligne, $r))
55
				{
56
				$result = true;
57
				break;
58
				}
59
			}
60
		}
61
	fclose($pointeur);
62
	return $result;
63
}
64
 
65
$Language = 'en';
66
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
67
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
68
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
69
	}
70
if ($Language === 'fr') {
71
	$l_title = "Bienvenue dans l'ACC (ALCASAR Control Center)";
72
	$l_internet_link = "Connexion Internet";
73
	$l_version = "Version instalée";
74
	$l_available = "Version disponible";
75
	$l_users = "Nombre d'utilisateurs / connectés";
76
	$l_groups = "Nombre de groupes";
77
	$l_bl_version = "Date de la blacklist";
78
}
79
else {
80
	$l_title = "Welcome in ACC (ALCASAR Control Center)";
81
	$l_internet_link = "Connexion Internet";
82
	$l_version = "Installed version";
83
	$l_available = "Available version";
84
	$l_users = "Number of users / connected.";
85
	$l_groups = "Number of groups";
86
	$l_bl_version = "Blacklist date";
87
}
88
?>
89
<!DOCTYPE html>
90
<html>
91
		<head>
92
			<link rel="stylesheet" href="/css/style.css">
93
		</head>
94
	<body>	
95
		<div class="panel">
96
			<div class="panel-header"><?= $l_title ?></div>
97
			<div class ="panel-row">
98
				<div class="panel-cell">
99
<?
100
// Read CONF_FILE
101
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
102
$file_conf = fopen(CONF_FILE, 'r');
103
if (!$file_conf) {
104
	exit('Error opening the file '.CONF_FILE);}
105
while (!feof($file_conf)) {
106
	$buffer = fgets($file_conf, 4096);
107
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
108
		$tmp = explode('=', $buffer, 2);
109
		$conf[trim($tmp[0])] = trim($tmp[1]);
110
	}
111
}
112
fclose($file_conf);
113
// Get current version
114
$INSTALLEDVERSION = $conf['VERSION'];
115
$VERSIONBL = date ("F d Y", filemtime ('/etc/e2guardian/lists/blacklists/README'));
116
$nb_users = request ('user');
117
$nb_groups  = request ('group');
118
$nb_online_users = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
119
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
120
	$internet_status =  "<img src='/images/state_ok.gif'>".$text['enable'];
121
	$version = dns_get_record("version.alcasar.net",DNS_TXT);
122
	$AVAILABLEDVERSION = $version[0]['txt'];
123
} else {
124
	$internet_status =  "<img src='/images/state_error.gif'>".$text['disable'];
125
	$AVAILABLEDVERSION = "-";
126
}
127
echo $l_internet_link."	: ".$internet_status."<br>\n";
128
echo $l_version."	: ".$INSTALLEDVERSION."<br>\n";
129
echo $l_available."	: ".$AVAILABLEDVERSION."<br>\n";
130
echo "</div><div class=\"panel-cell\">";
131
echo $l_users."		: ".$nb_users." / ".$nb_online_users."<br>\n";
132
echo $l_groups."	: ".$nb_groups."<br>\n";
133
echo $l_bl_version."	: ".$VERSIONBL."<br>\n";
134
?>
135
				</div>
136
			</div>
137
		</div>
138
		<div class="panel">
139
			<iframe class="panel-iframe" src="phpsysinfo/">
140
			</iframe>
141
		</div>
142
	</body>
143
</html>