Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
324 richard 1
<?php
2
# change user password on Alcasar captive Portal
3
# Copyright (C) 2003, 2004 Mondru AB.
4
# Copyright (C) 2008-2009 ANGEL95 & REXY
5
 
6
require('/etc/freeradius-web/config.php');
7
require('../lib/functions.php');
8
require('../lib/defaults.php');
9
 
10
$current_page = $_SERVER['PHP_SELF'];
11
 
12
# Choice of language
13
$Language = 'fr';
14
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
15
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
16
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
17
if($Language == 'es'){
18
$R_title = "User password change";
19
$R_form_l1 = "User";
20
$R_form_l2 = "Old password";
21
$R_form_l3 = "New password";
22
$R_form_l4 = "New password (confirmation)";
23
$R_form_button = "Modify";
24
$R_form_result1 = "Your password has been successfuly changed";
25
$R_form_result2 = "Error when trying to change password";
26
}
27
if($Language == 'de'){
28
$R_title = "User password change";
29
$R_form_l1 = "User";
30
$R_form_l2 = "Old password";
31
$R_form_l3 = "New password";
32
$R_form_l4 = "New password (confirmation)";
33
$R_form_button = "Modify";
34
$R_form_result1 = "Your password has been successfuly changed";
35
$R_form_result2 = "Error when trying to change password";
36
}
37
if($Language == 'nl'){
38
$R_title = "User password change";
39
$R_form_l1 = "User";
40
$R_form_l2 = "Old password";
41
$R_form_l3 = "New password";
42
$R_form_l4 = "New password (confirmation)";
43
$R_form_button = "Modify";
44
$R_form_result1 = "Your password has been successfuly changed";
45
$R_form_result2 = "Error when trying to change password";
46
}
47
if($Language == 'en'){
48
$R_title = "User password change";
49
$R_form_l1 = "User";
50
$R_form_l2 = "Old password";
51
$R_form_l3 = "New password";
52
$R_form_l4 = "New password (confirmation)";
53
$R_form_button = "Modify";
54
$R_form_result1 = "Your password has been successfuly changed";
55
$R_form_result2 = "Error when trying to change password";
56
}
57
if($Language == 'fr'){
58
$R_title = "Changement de mot de passe utilisateur";
59
$R_form_l1 = "Utilisateur";
60
$R_form_l2 = "Ancien mot de passe";
61
$R_form_l3 = "nouveau mot de passe";
62
$R_form_l4 = "nouveau mot de passe (confirmation)";
63
$R_form_button = "Modifier";
64
$R_form_result1 = "Votre mot de passe a &eacute;t&eacute; modifi&eacute; avec succ&egrave;s";
65
$R_form_result2 = "Erreur de changement de mot de passe";
66
}
67
echo "
68
<html>
69
<head>
70
  <title>$R_title</title>
71
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
72
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
73
<link rel=\"stylesheet\" href=\"/css/style.css\" type=\"text/css\">
74
</head>
75
<body>
76
<center>
77
<table border=0 width=400 cellpadding=0 cellspacing=2>
78
<tr>
79
<td>
80
<form name=\"master\" action=\"$current_page\" method=\"post\">
81
<input type=hidden name=action value=checkpass>
82
<br>
83
<table border=0 width=540 cellpadding=1 cellspacing=1>
84
<tr valign=top>
85
<td width=340></td>
86
<td bgcolor=\"black\" width=200>
87
	<table border=0 width=100% cellpadding=2 cellspacing=0>
88
	<tr bgcolor=\"#907030\" align=right valign=top><th>
89
	<font color=\"white\">$R_title</font>&nbsp;
90
	</th></tr>
91
	</table>
92
</td></tr>
93
<tr bgcolor=\"black\" valign=top><td colspan=2>
94
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor=\"#ffffd0\" valign=top>
95
	<tr><td>
96
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor=\"#ffffe0\" valign=top>
97
	<tr><td align=center bgcolor=\"#d0ddb0\">$R_form_l1</td><td><input type=\"text\" name=\"login\" value=\"\"></td></tr>	
98
	<tr><td align=center bgcolor=\"#d0ddb0\">$R_form_l2</td><td><input type=\"password\" name=\"passwd\" value=\"\"></td></tr>	
99
	<tr><td align=center bgcolor=\"#d0ddb0\">$R_form_l3</td><td><input type=\"password\" name=\"newpasswd\" value=\"\"></td></tr>	
100
	<tr><td align=center bgcolor=\"#d0ddb0\">$R_form_l4</td><td><input type=\"password\" name=\"newpasswd2\" value=\"\">&nbsp;<input type=\"submit\" class=button value=\"$R_form_button\"></td></tr>	
101
	</table>
102
	</table>
103
</table>";
104
 
105
#if (is_file("../lib/$config[general_lib_type]/password_check.php"))
106
#	include("../lib/$config[general_lib_type]/password_check.php");
107
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
108
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
109
else{
110
	echo "<b>Could not include SQL library</b><br>\n";
111
	exit();
112
}
113
if ($action == 'checkpass'){
114
	$link = @da_sql_pconnect($config);
115
	if ($link){
116
		$res = @da_sql_query($link,$config,
117
			"SELECT attribute,value FROM $config[sql_check_table] WHERE username = '$login'
118
			AND attribute = '$config[sql_password_attribute]';");
119
		if ($res){
120
			$row = @da_sql_fetch_array($res,$config);
121
			if (is_file("../lib/crypt/$config[general_encryption_method].php")){
122
				include("../lib/crypt/$config[general_encryption_method].php");
123
				$enc_passwd = $row[value];
124
				$passwd = da_encrypt($passwd,$enc_passwd);
125
				$newpasswd = da_encrypt($newpasswd,$enc_passwd);
126
				$newpasswd2 = da_encrypt($newpasswd2,$enc_passwd);
127
				if (($passwd == $enc_passwd) and ($newpasswd == $newpasswd2)){
128
					$msg = '<font color=blue><b>'.$R_form_result1.'</b></font>';
129
					$res2 = @da_sql_query($link,$config,
130
						"UPDATE $config[sql_check_table] set value='$newpasswd' WHERE username = '$login'
131
						AND attribute = '$config[sql_password_attribute]';");}
132
				else
133
					$msg = '<font color=red><b>'.$R_form_result2.'</b></font>';
134
			}
135
			else
136
				echo "<b>Could not open encryption library file</b><br>\n";
137
		}
138
	}
139
	echo "<tr><td colspan=3 align=center>$msg</td></tr>\n";
140
}
141
?>
142
</body>
143
</html>