Subversion Repositories ALCASAR

Rev

Rev 2817 | Rev 2853 | 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
}
81
else {
82
	$l_title = "Welcome in ACC (ALCASAR Control Center)";
2823 rexy 83
	$l_internet_link = "Internet connection";
84
	$l_enable = "Enabled";
85
	$l_disable = "Disabled";
2815 rexy 86
	$l_version = "Installed version";
87
	$l_available = "Available version";
88
	$l_users = "Number of users / connected.";
89
	$l_groups = "Number of groups";
90
	$l_bl_version = "Blacklist date";
91
}
92
?>
93
<!DOCTYPE html>
94
<html>
2823 rexy 95
<head>
96
	<link rel="stylesheet" href="/css/acc.css">
97
</head>
98
<body>	
99
	<div class="panel">
100
		<div class="panel-header"><?= $l_title ?></div>
101
		<div class ="panel-row">
102
			<div class="panel-cell">
2815 rexy 103
<?
104
// Read CONF_FILE
105
define ('CONF_FILE', '/usr/local/etc/alcasar.conf');
106
$file_conf = fopen(CONF_FILE, 'r');
107
if (!$file_conf) {
108
	exit('Error opening the file '.CONF_FILE);}
109
while (!feof($file_conf)) {
110
	$buffer = fgets($file_conf, 4096);
111
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
112
		$tmp = explode('=', $buffer, 2);
113
		$conf[trim($tmp[0])] = trim($tmp[1]);
114
	}
115
}
116
fclose($file_conf);
117
// Get current version
118
$INSTALLEDVERSION = $conf['VERSION'];
119
$VERSIONBL = date ("F d Y", filemtime ('/etc/e2guardian/lists/blacklists/README'));
120
$nb_users = request ('user');
121
$nb_groups  = request ('group');
122
$nb_online_users = exec ("sudo /usr/sbin/chilli_query list | cut -d\" \" -f5 | grep \"1\" | wc -l");
123
if ((filtrageTest("/var/www/html/index.php","/network_pb = false/")) && (internetTest())) {
2823 rexy 124
	$internet_status =  "<img src='/images/state_ok.gif'>".$l_enable;
2815 rexy 125
	$version = dns_get_record("version.alcasar.net",DNS_TXT);
126
	$AVAILABLEDVERSION = $version[0]['txt'];
127
} else {
2823 rexy 128
	$internet_status =  "<img src='/images/state_error.gif'>".$l_disable;
2815 rexy 129
	$AVAILABLEDVERSION = "-";
130
}
131
echo $l_internet_link."	: ".$internet_status."<br>\n";
132
echo $l_version."	: ".$INSTALLEDVERSION."<br>\n";
133
echo $l_available."	: ".$AVAILABLEDVERSION."<br>\n";
134
echo "</div><div class=\"panel-cell\">";
135
echo $l_users."		: ".$nb_users." / ".$nb_online_users."<br>\n";
136
echo $l_groups."	: ".$nb_groups."<br>\n";
137
echo $l_bl_version."	: ".$VERSIONBL."<br>\n";
138
?>
139
			</div>
140
		</div>
2823 rexy 141
	</div>
142
	<div class="panel">
143
		<iframe class="panel-iframe" src="phpsysinfo/">
144
		</iframe>
145
	</div>
146
</body>
2815 rexy 147
</html>