| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: FTP.pm,v 1.7 2005/02/18 14:03:39 cmuellermeta Exp $ |
|
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Copyright (C) 2001,2002 Online Office Berlin. All rights reserved. |
|
8
|
|
|
|
|
|
|
# Copyright (c) 2002 Slaven Rezic. All rights reserved. |
|
9
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
|
10
|
|
|
|
|
|
|
# terms of the GNU General Public License, see the file COPYING. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
|
13
|
|
|
|
|
|
|
# WWW: http://we-framework.sourceforge.net |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package WE_Frontend::Publish::FTP; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
856
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
19
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package WE_Frontend::Main; |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
4
|
use Net::FTP; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
5
|
use WE_Frontend::Publish; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
47
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
BEGIN { |
|
30
|
1
|
50
|
|
1
|
|
23
|
if ($] < 5.006) { |
|
31
|
0
|
|
|
|
|
0
|
$INC{"warnings.pm"}++; |
|
32
|
0
|
|
|
|
|
0
|
eval q{ |
|
33
|
|
|
|
|
|
|
package warnings; |
|
34
|
|
|
|
|
|
|
sub unimport { } |
|
35
|
0
|
0
|
|
|
|
0
|
}; die $@ if $@; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
{ |
|
40
|
1
|
|
|
1
|
|
4
|
no warnings 'redefine'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
41
|
1
|
|
|
1
|
|
5
|
use WE::Util::Functions qw(_save_pwd); |
|
|
1
|
|
|
|
|
188
|
|
|
|
1
|
|
|
|
|
610
|
|
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub publish_ftp { |
|
45
|
0
|
|
|
0
|
|
|
my($self, %args) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $v = delete $args{-verbose}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $liveuser = $self->Config->staging->user; |
|
50
|
0
|
|
|
|
|
|
my $livepassword = $self->Config->staging->password; |
|
51
|
0
|
|
|
|
|
|
my $livedirectory = $self->Config->staging->directory; |
|
52
|
0
|
|
|
|
|
|
my $livecgidirectory = $self->Config->staging->cgidirectory; |
|
53
|
0
|
|
|
|
|
|
my $livehost = $self->Config->staging->host; |
|
54
|
0
|
|
|
|
|
|
my $pubhtmldir = $self->Config->paths->pubhtmldir; |
|
55
|
0
|
|
|
|
|
|
my @extracgi = (ref $self->Config->project->stagingextracgi eq 'ARRAY' |
|
56
|
0
|
0
|
|
|
|
|
? @{ $self->Config->project->stagingextracgi } |
|
57
|
|
|
|
|
|
|
: () |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
0
|
|
|
|
if (!defined $liveuser || $liveuser eq '') { |
|
61
|
0
|
|
|
|
|
|
die "The FTP user is missing (config member WEsiteinfo->staging->user)"; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
0
|
0
|
|
|
|
if (!defined $livepassword || $livepassword eq '') { |
|
64
|
0
|
|
|
|
|
|
die "The FTP password is missing (config member WEsiteinfo->staging->password)"; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
0
|
0
|
|
|
|
if (!defined $livehost || $livehost eq '') { |
|
67
|
0
|
|
|
|
|
|
die "The target FTP host is missing (config member WEsiteinfo->staging->host)"; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
0
|
0
|
|
|
|
if (!defined $pubhtmldir || $pubhtmldir eq '') { |
|
70
|
0
|
|
|
|
|
|
die "The publish html directory is missing (config member WEsiteinfo->paths->pubhtmldir)"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
0
|
0
|
0
|
|
|
|
if (@extracgi && (!defined $livecgidirectory || $livecgidirectory eq '')) { |
|
|
|
|
0
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
die "Extra CGI scripts are defined (@extracgi), |
|
74
|
|
|
|
|
|
|
but the WEsiteinfo->staging->cgidirectory config is missing"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if ($v) { |
|
78
|
0
|
|
|
|
|
|
print <
|
|
79
|
|
|
|
|
|
|
Using FTP Protocol. |
|
80
|
0
|
0
|
|
|
|
|
FTP remote host: $livehost |
|
81
|
|
|
|
|
|
|
FTP remote user: $liveuser |
|
82
|
|
|
|
|
|
|
FTP remote directory: $livedirectory |
|
83
|
|
|
|
|
|
|
@{[ @extracgi ? "FTP remote CGI directory: $livecgidirectory" : "" ]} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
EOF |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
my $ftp = Net::FTP->new($livehost, Debug => 0) or die "Can't open FTP connection to $livehost: $@"; |
|
89
|
0
|
0
|
|
|
|
|
$ftp->login($liveuser, $livepassword) or die "Can't login with $liveuser"; |
|
90
|
0
|
|
|
|
|
|
$ftp->pasv(); |
|
91
|
0
|
|
|
|
|
|
$ftp->binary(); |
|
92
|
0
|
0
|
0
|
|
|
|
if (defined $livedirectory && $livedirectory ne '') { |
|
93
|
0
|
0
|
|
|
|
|
$ftp->cwd($livedirectory) or die "Can't remote chdir to $livedirectory"; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $ret = WE_Frontend::Publish::get_files_to_publish($self, %args); |
|
97
|
0
|
|
|
|
|
|
my @directories = @{ $ret->{Directories} }; |
|
|
0
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my @files = @{ $ret->{Files} }; |
|
|
0
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
_save_pwd { |
|
101
|
0
|
0
|
|
0
|
|
|
chdir $pubhtmldir || die "Can't change directory to $pubhtmldir: $!"; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
foreach my $dir (@directories) { |
|
104
|
0
|
0
|
|
|
|
|
if ($v) { print "Create folder $dir\n" } |
|
|
0
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$ftp->mkdir($dir); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
foreach my $file (@files) { |
|
109
|
0
|
0
|
|
|
|
|
if ($v) { print "Create document $file\n" } |
|
|
0
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
if (!-r $file) { warn "The local file $pubhtmldir/$file is not readable" } |
|
|
0
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
$ftp->put($file, $file) or warn "Can't put $pubhtmldir/$file to remote host $livehost"; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
}; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return {Directories => \@directories, |
|
117
|
|
|
|
|
|
|
Files => \@files, |
|
118
|
|
|
|
|
|
|
}; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |