Subversion Repositories ALCASAR

Rev

Rev 2823 | Rev 2887 | Go to most recent revision | Details | Compare with Previous | 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";
2823 rexy 73
	$l_enable = "Active";
74
	$l_disable = "Désactivée";
2815 rexy 75
	$l_version = "Version instalée";
76
	$l_available = "Version disponible";
77
	$l_users = "Nombre d'utilisateurs / connectés";
78
	$l_groups = "Nombre de groupes";
79
	$l_bl_version = "Date de la blacklist";
80
}
2853 rexy 81
else if ($Language === 'es') {
82
	$l_title = "Bienvenido al ACC (Centro de Control de ALCASAR)";
83
	$l_internet_link = "Conexión a Internet";
84
	$l_enable = "Activo";
85
	$l_disable = "Desactivado";
86
	$l_version = "Versión instalada";
87
	$l_available = "Versión disponible";
88
	$l_users = "Número de usuarios / conectados";
89
	$l_groups = "Número de grupos";
90
	$l_bl_version = "Fecha de la lista negra";
91
}
2815 rexy 92
else {
93
	$l_title = "Welcome in ACC (ALCASAR Control Center)";
2823 rexy 94
	$l_internet_link = "Internet connection";
95
	$l_enable = "Enabled";
96
	$l_disable = "Disabled";
2815 rexy 97
	$l_version = "Installed version";
98
	$l_available = "Available version";
99
	$l_users = "Number of users / connected.";
100
	$l_groups = "Number of groups";
101
	$l_bl_version = "Blacklist date";
102
}
103
?>
104
<!DOCTYPE html>
105
<html>
2823 rexy 106
<head>
107
	<link rel="stylesheet" href="/css/acc.css">
108
</head>
109
<body>	
110
	<div class="panel">
111
		<div class="panel-header"><?= $l_title ?></div>
112
		<div class ="panel-row">
113
			<div class="panel-cell">
2815 rexy 114
<?
115
// Read CONF_FILE
116
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
117
$file_conf = fopen(CONF_FILE, 'r');
118
if (!$file_conf) {
119
	exit('Error opening the file '.CONF_FILE);}
120
while (!feof($file_conf)) {
121
	$buffer = fgets($file_conf, 4096);
122
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
123
		$tmp = explode('=', $buffer, 2);
124
		$conf[trim($tmp[0])] = trim($tmp[1]);
125
	}
126
}
127
fclose($file_conf);
128
// Get current version
129
$INSTALLEDVERSION = $conf['VERSION'];
130
$VERSIONBL = date ("F d Y", filemtime ('/etc/e2guardian/lists/blacklists/README'));
131
$nb_users = request ('user');
132
$nb_groups  = request ('group');
133
$nb_online_users = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
134
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
2823 rexy 135
	$internet_status =  "<img src='/images/state_ok.gif'>".$l_enable;
2815 rexy 136
	$version = dns_get_record("version.alcasar.net",DNS_TXT);
2853 rexy 137
	if (!empty($version)) {
138
		$AVAILABLEDVERSION = $version[0]['txt'];
139
	} else {
140
		$AVAILABLEDVERSION = "-";
141
	}
2815 rexy 142
} else {
2823 rexy 143
	$internet_status =  "<img src='/images/state_error.gif'>".$l_disable;
2815 rexy 144
	$AVAILABLEDVERSION = "-";
145
}
146
echo $l_internet_link."	: ".$internet_status."<br>\n";
147
echo $l_version."	: ".$INSTALLEDVERSION."<br>\n";
148
echo $l_available."	: ".$AVAILABLEDVERSION."<br>\n";
149
echo "</div><div class=\"panel-cell\">";
150
echo $l_users."		: ".$nb_users." / ".$nb_online_users."<br>\n";
151
echo $l_groups."	: ".$nb_groups."<br>\n";
152
echo $l_bl_version."	: ".$VERSIONBL."<br>\n";
153
?>
154
			</div>
155
		</div>
2823 rexy 156
	</div>
157
	<div class="panel">
158
		<iframe class="panel-iframe" src="phpsysinfo/">
159
		</iframe>
160
	</div>
161
</body>
2815 rexy 162
</html>