A Moodle-modified WebDAV client, based on webdav_client v0.1.5, a php based webdav client class.
More...
|
| __construct ($server='', $user='', $pass='', $auth=false, $socket='', $oauthtoken='') |
| #-
|
|
| __set ($key, $value) |
|
| check_webdav () |
| Check's if server is a webdav compliant server.
|
|
| close () |
| Closes an open socket.
|
|
| copy_coll ($src_path, $dst_path, $overwrite) |
| Public method copy_coll.
|
|
| copy_file ($src_path, $dst_path, $overwrite) |
| Public method copy_file.
|
|
| delete ($path) |
| Public method delete.
|
|
| get ($path, &$buffer, $fp=null) |
| Public method get.
|
|
| get_file ($srcpath, $localpath) |
| Public method get_file.
|
|
| gpi ($path) |
| Public method gpi.
|
|
| is_dir ($path) |
| Public method is_dir.
|
|
| is_file ($path) |
| Public method is_file.
|
|
| lock ($path) |
| Public method lock.
|
|
| ls ($path) |
| Public method ls.
|
|
| mget ($filelist) |
| Public method mget.
|
|
| mkcol ($path) |
| Public method mkcol.
|
|
| move ($src_path, $dst_path, $overwrite) |
| Public method move.
|
|
| mput ($filelist) |
| Public method mput.
|
|
| open () |
| Open's a socket to a webdav server.
|
|
| options () |
| Get options from webdav server.
|
|
| put ($path, $data) |
| Public method put.
|
|
| put_file ($path, $filename) |
| Public method put_file.
|
|
| set_protocol ($version) |
| Set which HTTP protocol will be used.
|
|
| unlock ($path, $locktoken) |
| Public method unlock.
|
|
A Moodle-modified WebDAV client, based on webdav_client v0.1.5, a php based webdav client class.
class webdav client. a php based nearly RFC 2518 conforming client.
This class implements methods to get access to an webdav server. Most of the methods are returning boolean false on error, an integer status (http response status) on success or an array in case of a multistatus response (207) from the webdav server. Look at the code which keys are used in arrays. It's your responsibility to handle the webdav server responses in an proper manner. Please notice that all Filenames coming from or going to the webdav server should be UTF-8 encoded (see RFC 2518). This class tries to convert all you filenames into utf-8 when it's needed.
Moodle modifications:
- Moodle 3.4: Add support for OAuth 2 bearer token-based authentication
- Author
- Christian Juerges chris.nosp@m.tian.nosp@m..juer.nosp@m.ges@.nosp@m.xwave.nosp@m..ch, Xwave GmbH, Josefstr. 92, 8005 Zuerich - Switzerland
- Copyright
- (C) 2003/2004, Christian Juerges
- License
- http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
◆ __construct()
webdav_client::__construct |
( |
| $server = '', |
|
|
| $user = '', |
|
|
| $pass = '', |
|
|
| $auth = false, |
|
|
| $socket = '', |
|
|
| $oauthtoken = '' ) |
#-
Constructor - Initialise class variables
- Parameters
-
string | $server | Hostname of the server to connect to |
string | $user | Username (for basic/digest auth, see $auth) |
string | $pass | Password (for basic/digest auth, see $auth) |
bool | $auth | Authentication type; one of ['basic', 'digest', 'bearer'] |
string | $socket | Used protocol for fsockopen, usually: '' (empty) or 'ssl://' |
string | $oauthtoken | OAuth 2 bearer token (for bearer auth, see $auth) |
◆ check_webdav()
webdav_client::check_webdav |
( |
| ) |
|
Check's if server is a webdav compliant server.
True if server returns a DAV Element in Header and when schema 1,2 is supported.
- Return values
-
bool | true if server is webdav server. Otherwise false. |
◆ copy_coll()
webdav_client::copy_coll |
( |
| $src_path, |
|
|
| $dst_path, |
|
|
| $overwrite ) |
Public method copy_coll.
Copies a collection on a webdav server
Duplicates a collection on the webdav server (serverside). All work is done on the webdav server. If you set param overwrite as true, the target will be overwritten.
- Parameters
-
string | src_path, string dest_path, bool overwrite |
- Return values
-
int | status code (look at rfc 2518). false on error. |
◆ copy_file()
webdav_client::copy_file |
( |
| $src_path, |
|
|
| $dst_path, |
|
|
| $overwrite ) |
Public method copy_file.
Copies a file on a webdav server
Duplicates a file on the webdav server (serverside). All work is done on the webdav server. If you set param overwrite as true, the target will be overwritten.
- Parameters
-
string | src_path, string dest_path, bool overwrite |
- Return values
-
int | status code (look at rfc 2518). false on error. |
◆ delete()
webdav_client::delete |
( |
| $path | ) |
|
Public method delete.
deletes a collection/directory on a webdav server
- Parameters
-
- Return values
-
int | status code (look at rfc 2518). false on error. |
◆ get()
webdav_client::get |
( |
| $path, |
|
|
& | $buffer, |
|
|
| $fp = null ) |
Public method get.
Gets a file from a webdav collection.
- Parameters
-
string | $path | the path to the file on the webdav server |
string | &$buffer | the buffer to store the data in |
resource | $fp | optional if included, the data is written directly to this resource and not to the buffer |
- Return values
-
string|bool | status code and &$buffer (by reference) with response data from server on success. False on error. |
◆ get_file()
webdav_client::get_file |
( |
| $srcpath, |
|
|
| $localpath ) |
Public method get_file.
Gets a file from a collection into local filesystem.
fopen() is used.
- Parameters
-
string | $srcpath | |
string | $localpath | |
- Return values
-
bool | true on success. false on error. |
◆ gpi()
webdav_client::gpi |
( |
| $path | ) |
|
Public method gpi.
Get's path information from webdav server for one element.
- Parameters
-
- Return values
-
array | dirinfo. false on error |
◆ is_dir()
webdav_client::is_dir |
( |
| $path | ) |
|
Public method is_dir.
Gather whether a path points to a directory
- Parameters
-
string | path return bool true or false |
◆ is_file()
webdav_client::is_file |
( |
| $path | ) |
|
Public method is_file.
Gathers whether a path points to a file or not.
- Parameters
-
- Return values
-
◆ lock()
webdav_client::lock |
( |
| $path | ) |
|
Public method lock.
Locks a file or collection.
Lock uses this->_user as lock owner.
- Parameters
-
- Return values
-
int | status code (look at rfc 2518). false on error. |
◆ ls()
webdav_client::ls |
( |
| $path | ) |
|
Public method ls.
Get's directory information from webdav server into flat a array using PROPFIND
All filenames are UTF-8 encoded. Have a look at _propfind_startElement what keys are used in array returned.
- Parameters
-
- Return values
-
array | dirinfo, false on error |
◆ mget()
webdav_client::mget |
( |
| $filelist | ) |
|
Public method mget.
Gets multiple files and directories.
FileList must be in format array("remotepath" => "localpath"). Filenames are UTF-8 encoded.
- Parameters
-
- Return values
-
bool | true on succes, other int status code on error |
◆ mkcol()
webdav_client::mkcol |
( |
| $path | ) |
|
Public method mkcol.
Creates a new collection/directory on a webdav server
- Parameters
-
- Return values
-
int | status code received as response from webdav server (see rfc 2518) |
◆ move()
webdav_client::move |
( |
| $src_path, |
|
|
| $dst_path, |
|
|
| $overwrite ) |
Public method move.
Moves a file or collection on webdav server (serverside)
If you set param overwrite as true, the target will be overwritten.
- Parameters
-
string | src_path, string dest_path, bool overwrite |
- Return values
-
int | status code (look at rfc 2518). false on error. |
◆ mput()
webdav_client::mput |
( |
| $filelist | ) |
|
Public method mput.
Puts multiple files and/or directories onto a webdav server.
Filenames should be allready UTF-8 encoded. Param fileList must be in format array("localpath" => "destpath").
- Parameters
-
- Return values
-
bool | true on success. otherwise int status code on error |
◆ open()
Open's a socket to a webdav server.
- Return values
-
bool | true on success. Otherwise false. |
◆ options()
webdav_client::options |
( |
| ) |
|
Get options from webdav server.
- Return values
-
array | with all header fields returned from webdav server. false if server does not speak http. |
◆ put()
webdav_client::put |
( |
| $path, |
|
|
| $data ) |
Public method put.
Puts a file into a collection. Data is putted as one chunk!
- Parameters
-
- Return values
-
int | status-code read from webdavserver. False on error. |
◆ put_file()
webdav_client::put_file |
( |
| $path, |
|
|
| $filename ) |
Public method put_file.
Read a file as stream and puts it chunk by chunk into webdav server collection.
Look at php documenation for legal filenames with fopen(); The filename will be translated into utf-8 if not allready in utf-8.
- Parameters
-
string | targetpath, string filename |
- Return values
-
int | status code. False on error. |
◆ set_protocol()
webdav_client::set_protocol |
( |
| $version | ) |
|
Set which HTTP protocol will be used.
Value 1 defines that HTTP/1.1 should be used (Keeps Connection to webdav server alive). Otherwise HTTP/1.0 will be used.
- Parameters
-
◆ unlock()
webdav_client::unlock |
( |
| $path, |
|
|
| $locktoken ) |
Public method unlock.
Unlocks a file or collection.
- Parameters
-
string | path, string locktoken |
- Return values
-
int | status code (look at rfc 2518). false on error. |
The documentation for this class was generated from the following file: