1 |
dpavlin |
1.1 |
<? |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
Document manager auth_ftp.php module |
5 |
|
|
|
6 |
|
|
WARNING: this modules uses e-mail address to check |
7 |
|
|
login and password against ftp server! e-mail must be |
8 |
|
|
in following form: |
9 |
|
|
|
10 |
|
|
login_on_ftp_server@ftp_server.domain |
11 |
|
|
|
12 |
|
|
That has a side-effect that e-mail address in htusers file |
13 |
|
|
may not be valid (if your ftp server is not e-mail server |
14 |
|
|
also!) |
15 |
|
|
|
16 |
|
|
*/ |
17 |
|
|
|
18 |
|
|
function auth_ftp($user) { |
19 |
|
|
$email = explode("@",$user[3]); |
20 |
|
|
|
21 |
|
|
// set up basic connection |
22 |
|
|
$conn_id = ftp_connect($email[1]); |
23 |
|
|
|
24 |
|
|
if (! $conn_id) { |
25 |
|
|
return false; |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
// login with username and password |
29 |
|
|
$login_result = @ftp_login($conn_id,$email[0],stripslashes($GLOBALS[PHP_AUTH_PW])); |
30 |
|
|
|
31 |
|
|
if ($login_result) { |
32 |
|
|
if (function_exists('ftp_close')) ftp_close($conn_id); |
33 |
|
|
return true; |
34 |
|
|
} |
35 |
|
|
if (function_exists('ftp_close')) ftp_close($conn_id); |
36 |
|
|
return false; |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
?> |