2
// ensure this file is being included by a parent file
3
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
5
* @version $Id: ftp_authentication.php 143 2009-04-01 18:48:16Z soeren $
7
* @copyright soeren 2007-2009
8
* @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
9
* @author The The QuiX project (http://quixplorer.sourceforge.net)
12
* The contents of this file are subject to the Mozilla Public License
13
* Version 1.1 (the "License"); you may not use this file except in
14
* compliance with the License. You may obtain a copy of the License at
15
* http://www.mozilla.org/MPL/
17
* Software distributed under the License is distributed on an "AS IS"
18
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
19
* License for the specific language governing rights and limitations
22
* Alternatively, the contents of this file may be used under the terms
23
* of the GNU General Public License Version 2 or later (the "GPL"), in
24
* which case the provisions of the GPL are applicable instead of
25
* those above. If you wish to allow use of your version of this file only
26
* under the terms of the GPL and not to allow others to use
27
* your version of this file under the MPL, indicate your decision by
28
* deleting the provisions above and replace them with the notice and
29
* other provisions required by the GPL. If you do not delete
30
* the provisions above, a recipient may use your version of this file
31
* under either the MPL or the GPL."
36
* This file handles ftp authentication
39
class ext_ftp_authentication {
40
function execAction() {
41
$ftp_login = extGetParam( $_POST, 'ftp_login_name', '' );
42
$ftp_pass = extGetParam( $_POST, 'ftp_login_pass', '' );
43
global $dir, $mosConfig_live_site;
45
if( $ftp_login != '' || $ftp_pass != '' ) {
47
$ftp_host = extGetParam( $_POST, 'ftp_hostname_port', 'localhost:21' );
48
$url = @parse_url( 'ftp://' . $ftp_host);
50
ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21' );
52
$port = empty($url['port']) ? 21 : $url['port'];
53
$ftp = new Net_FTP( $url['host'], $port, 20 );
55
$res = $ftp->connect();
56
if( PEAR::isError( $res )) {
57
ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_connection_failed'].' ('.$url['host'].')' );
60
$res = $ftp->login( $ftp_login, $ftp_pass );
62
if( PEAR::isError( $res )) {
63
ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_login_failed'] );
67
$_SESSION['ftp_login'] = $ftp_login;
68
$_SESSION['ftp_pass'] = $ftp_pass;
69
$_SESSION['ftp_host'] = $ftp_host;
70
$_SESSION['file_mode'] = 'ftp';
72
session_write_close();
74
ext_Result::sendResult('ftp_authentication', true, ext_Lang::msg('actlogin_success') );
84
"url":"<?php echo basename( $GLOBALS['script_name']) ?>",
85
"dialogtitle": "<?php echo $GLOBALS["messages"]["ftp_header"] ?>",
86
"title": "<?php echo $GLOBALS["messages"]["ftp_login_lbl"] ?>",
89
"key": Ext.EventObject.ENTER,
91
if (Ext.getCmp("simpleform").getForm().isValid()) {
92
statusBarMessage( '<?php echo ext_Lang::msg('ftp_login_check', true ) ?>', true );
93
Ext.getCmp("simpleform").getForm().submit({
95
"success": function(form, action) { location.reload() },
96
"failure": function(form, action) {
97
if( !action.result ) return;
98
Ext.Msg.alert('<?php echo ext_Lang::err( 'error', true ) ?>', action.result.error);
99
statusBarMessage( action.result.error, false, false );
101
"scope": Ext.getCmp("simpleform").getForm(),
103
"option": "com_extplorer",
104
"action": "ftp_authentication"
113
"xtype": "textfield",
114
"fieldLabel": "<?php echo ext_Lang::msg('ftp_login_name', true ) ?>",
115
"name": "ftp_login_name",
119
"xtype": "textfield",
120
"fieldLabel": "<?php echo ext_Lang::msg('ftp_login_pass', true ) ?>",
121
"name": "ftp_login_pass",
122
"inputType": "password",
126
"xtype": "textfield",
127
"fieldLabel": "<?php echo ext_Lang::msg('ftp_hostname_port', true ) ?>",
128
"name": "ftp_hostname_port",
129
"value": "<?php echo extGetParam($_SESSION,'ftp_host', 'localhost:21') ?>",
134
"text": "<?php echo ext_Lang::msg( 'btnlogin', true ) ?>",
136
"handler": function() {
137
statusBarMessage( '<?php echo ext_Lang::msg('ftp_login_check', true ) ?>', true );
138
Ext.getCmp("simpleform").getForm().submit({
140
"success": function(form, action) { location.reload() },
141
"failure": function(form, action) {
142
if( !action.result ) return;
143
Ext.Msg.alert('<?php echo ext_Lang::err( 'error', true ) ?>', action.result.error);
144
statusBarMessage( action.result.error, false, false );
146
"scope": Ext.getCmp("simpleform").getForm(),
148
"option": "com_extplorer",
149
"action": "ftp_authentication"
154
"text": "<?php echo ext_Lang::msg( 'btncancel', true ) ?>",
155
"handler": function() { Ext.getCmp("dialog").destroy(); }
162
function ftp_logout() {
163
unset($_SESSION['ftp_login']);
164
unset($_SESSION['ftp_pass']);
165
unset($_SESSION['ftp_host']);
166
session_write_close();
167
extRedirect( make_link(null, null, null, null, null, null, '&file_mode=file') );
b'\\ No newline at end of file'