Repository navigation
Expand file tree
/
Copy pathFTP_Test.php
More file actions
executable file
·71 lines (68 loc) · 1.84 KB
/
Copy pathFTP_Test.php
File metadata and controls
executable file
·71 lines (68 loc) · 1.84 KB
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
<?php
# This script will try to log into a server with the supplied FTP credentials.
# If Up/Down & filename are supplied, then it will attempt to Upload/Download the file.
if(is_null($argv[3]))
{
echo "Usage: $argv[0] Server Username Password [Up/Down Filename]\n";
return;
}else{
if(strtoupper($argv[4]) == 'UP' || strtoupper($argv[4]) == 'DOWN')
{
if(is_null($argv[5]))
{
echo "Missing Filename\n";
echo "Usage: $argv[0] IP Username Password [Up/Down Filename]\n";
return;
}else{
$Move = $argv[4];
$File = $argv[5];
}
}
$IP = $argv[1];
$Username = $argv[2];
$Password = $argv[3];
$FTP = ftp_connect($IP);
if($FTP)
{
echo "Connected to the Server\n";
}else{
echo "Could not connect to the Server\n";
}
$Login = ftp_login($FTP,$Username,$Password);
if(!$Login)
{
echo "Login Failed!\n";
}else{
echo "Login Success!\n";
}
if(!is_null($File))
{
if(!is_null($Move))
{
echo "We're going to move ".$File."\n";
if (strtoupper($Move) == 'UP')
{
echo "Attempting to upload ".$File."\n";
if(!$Move = FTP_Put($FTP,$File,$File,FTP_BINARY))
{
echo "Can't Push ".$File."\n";
}
}elseif(strtoupper($Move) == 'DOWN')
{
echo "Attempting to download ".$File."\n";
if(!$Move = FTP_Get($FTP,$File,$File,FTP_BINARY))
{
echo "Can't Pull ".$File."\n";
}
}else{
echo "Couldn't find which direction we're going to move\n";
echo "Move = ".$Move."\n";
echo "strtoupper(Move) = ".strtoupper($Move)."\n";
echo "File = ".$File."\n";
}
}else{
echo "Not Moving any Files\n";
}
}
}
?>