Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | List of all members
webdav_client Class Reference

Public Member Functions

 __construct ($server='', $user='', $pass='', $auth=false, $socket='', $oauthtoken='')
 #- More...
 
 __set ($key, $value)
 
 check_webdav ()
 Check's if server is a webdav compliant server. More...
 
 close ()
 Closes an open socket.
 
 copy_coll ($src_path, $dst_path, $overwrite)
 Public method copy_coll. More...
 
 copy_file ($src_path, $dst_path, $overwrite)
 Public method copy_file. More...
 
 delete ($path)
 Public method delete. More...
 
 get ($path, &$buffer, $fp=null)
 Public method get. More...
 
 get_file ($srcpath, $localpath)
 Public method get_file. More...
 
 gpi ($path)
 Public method gpi. More...
 
 is_dir ($path)
 Public method is_dir. More...
 
 is_file ($path)
 Public method is_file. More...
 
 lock ($path)
 Public method lock. More...
 
 ls ($path)
 Public method ls. More...
 
 mget ($filelist)
 Public method mget. More...
 
 mkcol ($path)
 Public method mkcol. More...
 
 move ($src_path, $dst_path, $overwrite)
 Public method move. More...
 
 mput ($filelist)
 Public method mput. More...
 
 open ()
 Open's a socket to a webdav server. More...
 
 options ()
 Get options from webdav server. More...
 
 put ($path, $data)
 Public method put. More...
 
 put_file ($path, $filename)
 Public method put_file. More...
 
 set_protocol ($version)
 Set which HTTP protocol will be used. More...
 
 unlock ($path, $locktoken)
 Public method unlock. More...
 

Constructor & Destructor Documentation

◆ __construct()

webdav_client::__construct (   $server = '',
  $user = '',
  $pass = '',
  $auth = false,
  $socket = '',
  $oauthtoken = '' 
)

#-

Constructor - Initialise class variables

Parameters
string$serverHostname of the server to connect to
string$userUsername (for basic/digest auth, see $auth)
string$passPassword (for basic/digest auth, see $auth)
bool$authAuthentication type; one of ['basic', 'digest', 'bearer']
string$socketUsed protocol for fsockopen, usually: '' (empty) or 'ssl://'
string$oauthtokenOAuth 2 bearer token (for bearer auth, see $auth)

Member Function Documentation

◆ 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
booltrue 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
stringsrc_path, string dest_path, bool overwrite
Return values
intstatus 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
stringsrc_path, string dest_path, bool overwrite
Return values
intstatus 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
stringpath
Return values
intstatus 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$paththe path to the file on the webdav server
string&$bufferthe buffer to store the data in
resource$fpoptional if included, the data is written directly to this resource and not to the buffer
Return values
string|boolstatus 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
booltrue on success. false on error.

◆ gpi()

webdav_client::gpi (   $path)

Public method gpi.

Get's path information from webdav server for one element.

Parameters
stringpath
Return values
arraydirinfo. false on error

◆ is_dir()

webdav_client::is_dir (   $path)

Public method is_dir.

Gather whether a path points to a directory

Parameters
stringpath 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
stringpath
Return values
booltrue or false

◆ lock()

webdav_client::lock (   $path)

Public method lock.

Locks a file or collection.

Lock uses this->_user as lock owner.

Parameters
stringpath
Return values
intstatus 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
stringpath
Return values
arraydirinfo, 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
arrayfilelist
Return values
booltrue 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
stringpath
Return values
intstatus 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
stringsrc_path, string dest_path, bool overwrite
Return values
intstatus 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
arrayfilelist
Return values
booltrue on success. otherwise int status code on error

◆ open()

webdav_client::open ( )

Open's a socket to a webdav server.

Return values
booltrue on success. Otherwise false.

◆ options()

webdav_client::options ( )

Get options from webdav server.

Return values
arraywith 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
stringpath, string data
Return values
intstatus-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
stringtargetpath, string filename
Return values
intstatus 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
intversion

◆ unlock()

webdav_client::unlock (   $path,
  $locktoken 
)

Public method unlock.

Unlocks a file or collection.

Parameters
stringpath, string locktoken
Return values
intstatus code (look at rfc 2518). false on error.

The documentation for this class was generated from the following file: