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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<?php
ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('max_execution_time', 0);
require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Sftp\Sftp as Sftp;
$FtpServer = 'mwas.mjsoft.co'; $FtpPort = 6422; $FtpUser = 'mwas'; $FtpPass = 'mj8901.23-'; $FtpPath = '/var/www/mwas_html/android_login/_emergency/jego1s_XPDA/Debug';
# Scan Directory $test = Sftp::scandir($FtpServer, $FtpUser, $FtpPass, $FtpPath, $FtpPort); echo "scandir"; var_dump($test);
exit;
# Test connection $test = Sftp::test($FtpServer, $FtpUser, $FtpPass, $FtpPort); echo "test"; var_dump($test);
# Check Login Directory PWD $test = Sftp::pwd($FtpServer, $FtpUser, $FtpPass, $FtpPort); echo "pwd"; var_dump($test);
# Upload File $local_file = __DIR__ . '/test.txt'; $remote_file = $FtpPath . '/test.txt'; $test = Sftp::upload($FtpServer, $FtpUser, $FtpPass, $local_file, $remote_file, $FtpPort); echo "upload"; var_dump($test);
# Download File $local_file = __DIR__ . '/test-download.txt'; $remote_file = $FtpPath . '/test.txt'; $test = Sftp::download($FtpServer, $FtpUser, $FtpPass, $remote_file, $local_file, $FtpPort); echo "download"; var_dump($test); unlink($local_file);
# Rename File $old_file = $FtpPath . '/test.txt'; $new_file = $FtpPath . '/test-renamed.txt'; $test = Sftp::rename($FtpServer, $FtpUser, $FtpPass, $old_file, $new_file, $FtpPort); echo "rename file"; var_dump($test);
# Test file exist $remote_file = $FtpPath . '/test-renamed.txt'; $test = Sftp::is_file($FtpServer, $FtpUser, $FtpPass, $remote_file, $FtpPort); echo "is_file"; var_dump($test);
# Delete File $remote_file = $FtpPath . '/test-renamed.txt'; $test = Sftp::delete($FtpServer, $FtpUser, $FtpPass, $remote_file, $FtpPort); echo "delete file"; var_dump($test);
# Upload Folder // if ends with a slash upload content // if no slash end upload dir itself $local_path = __DIR__ . '/../src'; $remote_path = $FtpPath; $test = Sftp::upload_dir($FtpServer, $FtpUser, $FtpPass, $local_path, $remote_path, $FtpPort); echo "upload_dir"; var_dump($test);
# Download Folder // if ends with a slash download content // if no slash end download dir itself $remote_dir = $FtpPath . '/src'; $local_dir = __DIR__; $test = Sftp::download_dir($FtpServer, $FtpUser, $FtpPass, $remote_dir, $local_dir, $FtpPort); var_dump($test);
# Delete Folder // if ends with a slash delete content // if no slash delete dir itself $remote_path = $FtpPath . '/src'; $test = Sftp::rmdir($FtpServer, $FtpUser, $FtpPass, $remote_path, $FtpPort); var_dump($test);
# Create File $file_name = $FtpPath . '/test.txt'; $file_content = 'Love it !'; $test = Sftp::touch($FtpServer, $FtpUser, $FtpPass, $file_name, $file_content, $FtpPort); echo "touch"; var_dump($test);
# Delete File $remote_file = $FtpPath . '/test.txt'; $test = Sftp::delete($FtpServer, $FtpUser, $FtpPass, $remote_file, $FtpPort); echo "delete file"; var_dump($test);
# Create Folder $directory = $FtpPath . '/coucou'; $test = Sftp::mkdir($FtpServer, $FtpUser, $FtpPass, $directory, $FtpPort); echo "mkdir"; var_dump($test);
# Rename Folder $old_file = $FtpPath . '/coucou'; $new_file = $FtpPath . '/coco'; $test = Sftp::rename($FtpServer, $FtpUser, $FtpPass, $old_file, $new_file, $FtpPort); echo "rename dir"; var_dump($test);
# Delete Folder $remote_path = $FtpPath . '/coco'; $test = Sftp::rmdir($FtpServer, $FtpUser, $FtpPass, $remote_path, $FtpPort); echo "rmdir"; var_dump($test);
# Scan directory again $test = Sftp::scandir($FtpServer, $FtpUser, $FtpPass, $FtpPath, $FtpPort); echo "scandir"; var_dump($test);
?>
|