1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<?LassoScript
//
// [FTP_MkDir]
//
// Based on FTP_DeleteFile by Gary Sprague Jun 18, 2008
// gary.s@gareworks.com
//
//
// Compatible with Lasso 8.5.2 or higher
//
define_tag('MkDir',
-namespace = '_global_FTP_',
-priority = 'Replace',
-required = 'URL',
-required = 'DIR',
-optional = 'Username',
-optional = 'Password');
error_push;
local(
'_ua'=(String_FindRegExp:#URL,-find='^(ftp://)([a-zA-Z0-9\\-\\.]*)(\\/{0,1}.*)/{0,1}$'),
'_read'= '',
'_error'='',
'_resp'= '');
protect;
fail_if((#_ua->size) == 0, -9960, 'FTP_MkDir: -URL parameter requires full URL including ftp://');
local(
'_serv' = #_ua->(get:3),
'_dirs' = (#_ua->(get:4) + '/')
);
local('_ftp'= (net));
#_ftp->(settype:Net_TypeTCP);
#_resp = #_ftp->(Connect: #_serv, 21);
#_read = #_ftp->(Read:1024);
if(local_defined('Username') == true && #Username != '');
#_resp = #_ftp->(Write:'USER ' + #Username + '\n');
#_read = #_ftp->(Read:1024);
fail_if( string( #_read )->beginswith( '500' ), -9960, 'No username provided.' );
if(local_defined('Password') == true && #Password != '');
#_resp = #_ftp->(Write:'PASS ' + #Password + '\n');
#_read = #_ftp->(Read:1024);
fail_if( string( #_read )->beginswith( '530' ), -9960, 'Invalid username or password.' );
/if;
/if;
#_resp = #_ftp->(Write:'CWD ' + #_dirs + '\n');
#_read = #_ftp->(Read:1024);
fail_if( string( #_read )->beginswith( '550' ), -9984, 'Remote directory not found.' );
fail_if( string( #_read )->beginswith( '530' ), -9960, 'Access Denied. Login required.' );
#_resp = #_ftp->(Write:'mkd ' + #DIR + '\n');
#_read = #_ftp->(Read:1024);
fail_if( string( #_read )->beginswith( '550' ), -9984, 'Remote file not found.' );
fail_if( string( #_read )->beginswith( '530' ), -9960, 'Access Denied. Login required.' );
#_resp = #_ftp->(Write:'QUIT\n');
#_read = #_ftp->(Read:1024);
#_ftp->close;
handle_error;
error_push;
#_ftp->close;
/handle_error;
/protect;
error_pop;
/define_tag;
?>
|