Subversion Repositories ALCASAR

Rev

Rev 1835 | Rev 2415 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1835 Rev 2414
Line 56... Line 56...
56
  $l_out_title = "   ---  Internet access via ALCASAR  ---  ";
56
  $l_out_title = "   ---  Internet access via ALCASAR  ---  ";
57
  $l_out_login = "Login :";
57
  $l_out_login = "Login :";
58
  $l_out_passwd = "Password :";
58
  $l_out_passwd = "Password :";
59
  $l_out_mind = "Don't forget to change your password (a link is on the authentication window)";
59
  $l_out_mind = "Don't forget to change your password (a link is on the authentication window)";
60
}
60
}
-
 
61
 
-
 
62
require('/etc/freeradius-web/config.php');
-
 
63
 
61
function getImportFileList(){
64
function getImportFileList(){
62
	$importFile = array();
65
	$importFile = array();
63
	if ($handle = opendir('/tmp')) {
66
	if ($handle = opendir('/tmp')) {
64
		while (false !== ($file = readdir($handle))) {
67
		while (false !== ($file = readdir($handle))) {
65
			if ($file != "." && $file != "..") {
68
			if ($file != "." && $file != "..") {
Line 72... Line 75...
72
		}
75
		}
73
		closedir($handle);
76
		closedir($handle);
74
	}
77
	}
75
	return $importFile;
78
	return $importFile;
76
}
79
}
-
 
80
 
77
function GenPassword($nb_car="8")
81
function GenPassword($nb_car="8")
78
	{
82
{
79
// Random password
83
// Random password
80
	$password = "";
84
	$password = "";
81
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
85
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
82
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
86
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
83
	while($nb_car != 0)
87
	while($nb_car != 0) {
84
		{
-
 
85
		$i = rand(0,71);
88
		$i = rand(0,71);
86
		$password .= $chaine[$i];
89
		$password .= $chaine[$i];
87
		$nb_car --;
90
		$nb_car--;
88
		}
-
 
89
	return $password ;
-
 
90
	}
91
	}
-
 
92
	return $password;
-
 
93
}
-
 
94
 
-
 
95
function freeradiusweb_removeDisallowedChars($login)
-
 
96
{
-
 
97
	if ($login != '')
-
 
98
	{
-
 
99
		$accent = "âêôûéàèùîáâãäçèéêëìíîïñòóôõöùúûü";
-
 
100
		$login = preg_replace("/[^\w$accent\.\/\@\:\-]/",'',$login);
-
 
101
	}
-
 
102
	if ($login != '' && $config['general_strip_realms'] == 'yes'){
-
 
103
		$realm_del = ($config['general_realm_delimiter'] != '') ? $config['general_realm_delimiter'] : '@';
-
 
104
		$realm_for = ($config['general_realm_format'] != '') ? $config['general_realm_format'] : 'suffix';
-
 
105
		$new = explode($realm_del,$login,2);
-
 
106
		if (count($new) == 2)
-
 
107
			$login = ($realm_for == 'suffix') ? $new[0] : $new[1];
-
 
108
	}
-
 
109
 
-
 
110
	return $login;
-
 
111
}
-
 
112
 
91
?>
113
?>
92
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
114
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
93
<tr><th><? echo "$l_title"; ?></th></tr>
115
<tr><th><? echo "$l_title"; ?></th></tr>
94
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
116
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
95
</TABLE>
117
</TABLE>
Line 98... Line 120...
98
<CENTER><H3> 
120
<CENTER><H3> 
99
<?php
121
<?php
100
echo "$l_database_state";
122
echo "$l_database_state";
101
 
123
 
102
$LIBpath = "../lib/";
124
$LIBpath = "../lib/";
103
require('/etc/freeradius-web/config.php');
-
 
104
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
125
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
105
	{
126
	{
106
	include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
127
	include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
107
	}
128
	}
108
else
129
else
Line 161... Line 182...
161
						if ($login != '')
182
						if ($login != '')
162
							{
183
							{
163
							if ($password == "")
184
							if ($password == "")
164
								{
185
								{
165
								$password = GenPassword();
186
								$password = GenPassword();
166
								}	
187
								}
-
 
188
							$login = freeradiusweb_removeDisallowedChars($login);
167
							$login = da_sql_escape_string($link,$login);
189
							$login = da_sql_escape_string($link,$login);
168
							$passwd = da_sql_escape_string($link,$passwd);
190
							$passwd = da_sql_escape_string($link,$passwd);
169
							$passwd = da_encrypt($password);
191
							$passwd = da_encrypt($password);
170
// insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe)
192
// insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe)
171
							$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_check_table] (attribute,value,username $text) VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
193
							$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_check_table] (attribute,value,username $text) VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");