-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvfs-ftp.php
executable file
·126 lines (105 loc) · 2.84 KB
/
vfs-ftp.php
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
<?php
/*
* $Id: vfs-ftp.php 18 2010-04-30 19:12:36Z veghead $
*/
require_once('vfs.php');
class oliver_vfs_ftp extends oliver_vfs {
function __construct($conf)
{
parent::__construct($conf);
$this->conf=$conf;
$this->cid=@ftp_connect($this->conf['ftp_server'],
$this->conf['ftp_server_port'],
$this->conf['ftp_timeout']);
}
function login($user,$pass)
{
if (! ($res=@ftp_login($this->cid,$user,$pass))) {
return($res);
}
@ftp_pasv($this->cid,$this->conf['ftp_passive']);
$this->user = $user;
$this->pass = $pass;
return($res);
}
function get_pwd()
{
return(@ftp_pwd($this->cid));
}
function chmod($file,$mode)
{
return(@ftp_site($this->cid,"chmod $mode ".$file));
}
function chdir($pwd)
{
return(@ftp_chdir($this->cid,$pwd));
}
function rmdir($todel)
{
return(@ftp_rmdir($this->cid,$todel));
}
function cdup()
{
return(@ftp_cdup($this->cid));
}
function get($local_file,$file,$fl)
{
return(@ftp_get($this->cid,$local_file,$file,$fl));
}
function makeurl($file)
{
$url = 'ftp://'.$this->user.':'.$this->pass.'@';
$url .= $this->conf['ftp_server'].':'.$this->conf['ftp_server_port'].'/';
// The trailing slash above tell curl to use an absolute url.
$url .= $this->get_pwd().'/'.$file;
return $url;
}
function getPipe($file)
{
if (! $this->conf['hascurl']) {
return false;
}
$url = $this->makeurl($file);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_BINARYTRANSFER => true,
CURLOPT_URL => $url));
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
function put($local_file,$file,$fl)
{
return(@ftp_put($this->cid,$local_file,$file,$fl));
}
function delete($todel)
{
return(@ftp_delete($this->cid,$todel));
}
function ls($dir)
{
$f = empty($this->conf['ls_flags']) ? '' : $this->conf['ls_flags'].' ';
if (isset($this->conf['space_in_filename_workaround']) && $this->conf['space_in_filename_workaround']) {
$pwd = @ftp_pwd($this->cid);
@ftp_chdir($this->cid,$dir);
$list = @ftp_rawlist($this->cid,$f.'.');
@ftp_chdir($this->cid,$pwd);
} else {
$list=ftp_rawlist($this->cid,$f.$dir);
}
return($list);
}
function size($name)
{
return(@ftp_size($this->cid,$name));
}
function mkdir($name)
{
return(@ftp_mkdir($this->cid,$name));
}
function quit()
{
return(@ftp_quit($this->cid));
}
}
?>