<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <TITLE>phpgwapi - VFS Class: Function reference</TITLE> <LINK HREF="vfs-6.html" REL=next> <LINK HREF="vfs-4.html" REL=previous> <LINK HREF="vfs.html#toc5" REL=contents> </HEAD> <BODY> <A HREF="vfs-6.html">Next</A> <A HREF="vfs-4.html">Previous</A> <A HREF="vfs.html#toc5">Contents</A> <HR> <H2><A NAME="sec:function_reference"></A> <A NAME="s5">5.</A> <A HREF="vfs.html#toc5">Function reference</A></H2> <H2><A NAME="sec:function_reference_about"></A> <A NAME="ss5.1">5.1</A> <A HREF="vfs.html#toc5.1">About</A> </H2> <P>This function reference is periodically auto-generated from the inline comments in phpgwapi/inc/class.vfs.inc.php. For the most up-to-date (and nicer looking) reference, see class.vfs.inc.php. This reference is created as a separate DocBook document (using the inline2lyx.pl script), so it might look a bit out of place.</P> <H2><A NAME="sec: class vfs"></A> <A NAME="ss5.2">5.2</A> <A HREF="vfs.html#toc5.2">class vfs</A> </H2> <P>abstract: virtual file system</P> <P>description: Authors: Zone, Seek3r</P> <H2><A NAME="sec: class path_class"></A> <A NAME="ss5.3">5.3</A> <A HREF="vfs.html#toc5.3">class path_class</A> </H2> <P>abstract: helper class for path_parts</P> <H2><A NAME="sec: vfs"></A> <A NAME="ss5.4">5.4</A> <A HREF="vfs.html#toc5.4">vfs</A> </H2> <P>abstract: constructor, sets up variables</P> <P> <PRE> function vfs () </PRE> </P> <H2><A NAME="sec: set_relative"></A> <A NAME="ss5.5">5.5</A> <A HREF="vfs.html#toc5.5">set_relative</A> </H2> <P>abstract: Set path relativity</P> <P>param: $mask Relative bitmask (see RELATIVE_ defines)</P> <P> <PRE> function set_relative ($mask) </PRE> </P> <H2><A NAME="sec: get_relative"></A> <A NAME="ss5.6">5.6</A> <A HREF="vfs.html#toc5.6">get_relative</A> </H2> <P>abstract: Return relativity bitmask</P> <P>discussion: Returns relativity bitmask, or the default of "completely relative" if unset</P> <P> <PRE> function get_relative () </PRE> </P> <H2><A NAME="sec: sanitize"></A> <A NAME="ss5.7">5.7</A> <A HREF="vfs.html#toc5.7">sanitize</A> </H2> <P>abstract: Removes leading .'s from $string</P> <P>discussion: You should not pass all filenames through sanitize () unless you plan on rejecting</P> <P>.files. Instead, pass the name through securitycheck () first, and if it fails,</P> <P>pass it through sanitize</P> <P>param: $string string to sanitize</P> <P>result: $string without it's leading .'s</P> <P> <PRE> function sanitize ($string) </PRE> </P> <H2><A NAME="sec: securitycheck"></A> <A NAME="ss5.8">5.8</A> <A HREF="vfs.html#toc5.8">securitycheck</A> </H2> <P>abstract: Security check function</P> <P>discussion: Checks for basic violations such as ..</P> <P>If securitycheck () fails, run your string through vfs->sanitize ()</P> <P>param: $string string to check security of</P> <P>result: Boolean True/False. True means secure, False means insecure</P> <P> <PRE> function securitycheck ($string) </PRE> </P> <H2><A NAME="sec: db_clean"></A> <A NAME="ss5.9">5.9</A> <A HREF="vfs.html#toc5.9">db_clean</A> </H2> <P>abstract: Clean $string for use in database queries</P> <P>param: $string String to clean</P> <P>result: Cleaned version of $string</P> <P> <PRE> function db_clean ($string) </PRE> </P> <H2><A NAME="sec: path_parts"></A> <A NAME="ss5.10">5.10</A> <A HREF="vfs.html#toc5.10">path_parts</A> </H2> <P>abstract: take a real or fake pathname and return an array of its component parts</P> <P>param: $string full real or fake path</P> <P>param: $relatives Relativity array</P> <P>param: $object True returns an object instead of an array</P> <P>result: $rarray/$robject Array or object containing the fake and real component parts of the path</P> <P>discussion: Returned values are:</P> <P>mask</P> <P>outside</P> <P>fake_full_path</P> <P>fake_leading_dirs</P> <P>fake_extra_path</P> <P>fake_name</P> <P>real_full_path</P> <P>real_leading_dirs</P> <P>real_extra_path</P> <P>real_name</P> <P>fake_full_path_clean</P> <P>fake_leading_dirs_clean</P> <P>fake_extra_path_clean</P> <P>fake_name_clean</P> <P>real_full_path_clean</P> <P>real_leading_dirs_clean</P> <P>real_extra_path_clean</P> <P>real_name_clean</P> <P>"clean" values are run through vfs->db_clean () and</P> <P>are safe for use in SQL queries that use key='value'</P> <P>They should be used ONLY for SQL queries, so are used</P> <P>mostly internally</P> <P>mask is either RELATIVE_NONE or RELATIVE_NONE|VFS_REAL,</P> <P>and is used internally</P> <P>outside is boolean, True if $relatives contains VFS_REAL</P> <P> <PRE> function path_parts ($string, $relatives = array (RELATIVE_CURRENT), $object = True) </PRE> </P> <H2><A NAME="sec: getabsolutepath"></A> <A NAME="ss5.11">5.11</A> <A HREF="vfs.html#toc5.11">getabsolutepath</A> </H2> <P>abstract: get the absolute path</P> <P>param: $target defaults to False, directory/file to get path of, relative to $relatives[0]</P> <P>param: $mask Relativity bitmask (see RELATIVE_ defines). RELATIVE_CURRENT means use $this->relative</P> <P>param: $fake Returns the "fake" path, ie /home/user/dir/file (not always possible. use path_parts () instead)</P> <P>result: $basedir Full fake or real path</P> <P> <PRE> function getabsolutepath ($target = False, $relatives = array (RELATIVE_CURRENT), $fake = True) </PRE> </P> <H2><A NAME="sec: cd"></A> <A NAME="ss5.12">5.12</A> <A HREF="vfs.html#toc5.12">cd</A> </H2> <P>abstract: Change directory</P> <P>discussion: To cd to the files root "/", use cd ("/", False, array (RELATIVE_NONE));</P> <P>param: $target default "/". directory to cd into. if "/" and $relative is True, uses "/home/<working_lid>";</P> <P>param: $relative default True/relative means add target to current path, else pass $relative as mask to getabsolutepath()</P> <P> <PRE> function cd ($target = "/", $relative = True, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: pwd"></A> <A NAME="ss5.13">5.13</A> <A HREF="vfs.html#toc5.13">pwd</A> </H2> <P>abstract: current working dir</P> <P>param: $full default True returns full fake path, else just the extra dirs (false strips the leading /)</P> <P>result: $currentdir currentdir</P> <P> <PRE> function pwd ($full = True) </PRE> </P> <H2><A NAME="sec: read"></A> <A NAME="ss5.14">5.14</A> <A HREF="vfs.html#toc5.14">read</A> </H2> <P>abstract: return file contents</P> <P>param: $file filename</P> <P>param: $relatives Relativity array</P> <P>result: $contents Contents of $file, or False if file cannot be read</P> <P> <PRE> function read ($file, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: write"></A> <A NAME="ss5.15">5.15</A> <A HREF="vfs.html#toc5.15">write</A> </H2> <P>abstract: write to a file</P> <P>param: $file file name</P> <P>param: $relatives Relativity array</P> <P>param: $contents contents</P> <P>result: Boolean True/False</P> <P> <PRE> function write ($file, $relatives = array (RELATIVE_CURRENT), $contents) </PRE> </P> <H2><A NAME="sec: touch"></A> <A NAME="ss5.16">5.16</A> <A HREF="vfs.html#toc5.16">touch</A> </H2> <P>abstract: Create blank file $file or set the modification time and modified by of $file to current time and user</P> <P>param: $file File to touch or set modifies</P> <P>param: $relatives Relativity array</P> <P>result: Boolean True/False</P> <P> <PRE> function touch ($file, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: cp"></A> <A NAME="ss5.17">5.17</A> <A HREF="vfs.html#toc5.17">cp</A> </H2> <P>abstract: copy file</P> <P>param: $from from file/directory</P> <P>param: $to to file/directory</P> <P>param: $relatives Relativity array</P> <P>result: boolean True/False</P> <P> <PRE> function cp ($from, $to, $relatives = array (RELATIVE_CURRENT, RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: mv"></A> <A NAME="ss5.18">5.18</A> <A HREF="vfs.html#toc5.18">mv</A> </H2> <P>abstract: move file/directory</P> <P>param: $from from file/directory</P> <P>param: $to to file/directory</P> <P>param: $relatives Relativity array</P> <P>result: boolean True/False</P> <P> <PRE> function mv ($from, $to, $relatives = array (RELATIVE_CURRENT, RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: move"></A> <A NAME="ss5.19">5.19</A> <A HREF="vfs.html#toc5.19">move</A> </H2> <P>abstract: shortcut to mv</P> <P> <PRE> function move ($from, $to, $relatives = array (RELATIVE_CURRENT, RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: rm"></A> <A NAME="ss5.20">5.20</A> <A HREF="vfs.html#toc5.20">rm</A> </H2> <P>abstract: delete file/directory</P> <P>param: $string file/directory to delete</P> <P>param: $relatives Relativity array</P> <P>result: boolean True/False</P> <P> <PRE> function rm ($string, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: delete"></A> <A NAME="ss5.21">5.21</A> <A HREF="vfs.html#toc5.21">delete</A> </H2> <P>abstract: shortcut to rm</P> <P> <PRE> function delete ($string, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: mkdir"></A> <A NAME="ss5.22">5.22</A> <A HREF="vfs.html#toc5.22">mkdir</A> </H2> <P>abstract: make a new directory</P> <P>param: $dir Directory name</P> <P>param: $relatives Relativity array</P> <P>result: boolean True on success</P> <P> <PRE> function mkdir ($dir, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: set_attributes"></A> <A NAME="ss5.23">5.23</A> <A HREF="vfs.html#toc5.23">set_attributes</A> </H2> <P>abstract: Update database entry for $file with the attributes in $attributes</P> <P>param: $file file/directory to update</P> <P>param: $relatives Relativity array</P> <P>param: $attributes keyed array of attributes. key is attribute name, value is attribute value</P> <P>result: Boolean True/False</P> <P>discussion: Valid attributes are:</P> <P>owner_id</P> <P>createdby_id</P> <P>modifiedby_id</P> <P>created</P> <P>modified</P> <P>size</P> <P>mime_type</P> <P>deleteable</P> <P>comment</P> <P>app</P> <P> <PRE> function set_attributes ($file, $relatives = array (RELATIVE_CURRENT), $attributes = array ()) </PRE> </P> <H2><A NAME="sec: correct_attributes"></A> <A NAME="ss5.24">5.24</A> <A HREF="vfs.html#toc5.24">correct_attributes</A> </H2> <P>abstract: Set the correct attributes for $string (e.g. owner)</P> <P>param: $string File/directory to correct attributes of</P> <P>param: $relatives Relativity array</P> <P>result: Boolean True/False</P> <P> <PRE> function correct_attributes ($string, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: file_type"></A> <A NAME="ss5.25">5.25</A> <A HREF="vfs.html#toc5.25">file_type</A> </H2> <P>abstract: return file/dir type (MIME or other)</P> <P>param: $file File or directory path (/home/user/dir/dir2/dir3, /home/user/dir/dir2/file)</P> <P>param: $relatives Relativity array</P> <P>result: MIME type, "Directory", or nothing if MIME type is not known</P> <P> <PRE> function file_type ($file, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: file_exists"></A> <A NAME="ss5.26">5.26</A> <A HREF="vfs.html#toc5.26">file_exists</A> </H2> <P>abstract: check if file/directory exists</P> <P>param: $string file/directory to check existance of</P> <P>param: $relatives Relativity array</P> <P>result: Boolean True/False</P> <P> <PRE> function file_exists ($string, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: checkperms"></A> <A NAME="ss5.27">5.27</A> <A HREF="vfs.html#toc5.27">checkperms</A> </H2> <P>abstract: Check if you have write access to create files in $dir</P> <P>discussion: This isn't perfect, because vfs->touch () returns True even</P> <P>if only the database entry worked. ACLs need to be</P> <P>implemented for better permission checking. It's</P> <P>also pretty slow, so I wouldn't recommend using it</P> <P>often</P> <P>param: $dir Directory to check access of</P> <P>param: $relatives Relativity array</P> <P>result: Boolean True/False</P> <P> <PRE> function checkperms ($dir, $relatives = array (RELATIVE_CURRENT)) </PRE> </P> <H2><A NAME="sec: ls"></A> <A NAME="ss5.28">5.28</A> <A HREF="vfs.html#toc5.28">ls</A> </H2> <P>abstract: get directory listing</P> <P>discussion: Note: the entries are not guaranteed to be returned in any logical order</P> <P>param: $dir Directory</P> <P>param: $relatives Relativity array</P> <P>param: $checksubdirs Boolean, recursively list all sub directories as well?</P> <P>param: $mime_type Only return entries matching MIME-type $mime_type. Can be "Directory" or "\" for those without MIME types</P> <P>param: $nofiles Boolean. True means you want to return just the information about the directory $dir. If $dir is a file, $nofiles is implied. This is the equivalent of 'ls -ld $dir'</P> <P>result: array of arrays. Subarrays contain full info for each file/dir.</P> <P> <PRE> function ls ($dir = False, $relatives = array (RELATIVE_CURRENT), $checksubdirs = True, $mime_type = False, $nofiles = False) </PRE> </P> <H2><A NAME="sec: dir"></A> <A NAME="ss5.29">5.29</A> <A HREF="vfs.html#toc5.29">dir</A> </H2> <P>abstract: shortcut to ls</P> <P> <PRE> function dir ($dir = False, $relatives = array (RELATIVE_CURRENT), $checksubdirs = True, $mime_type = False, $nofiles = False) </PRE> </P> <HR> <A HREF="vfs-6.html">Next</A> <A HREF="vfs-4.html">Previous</A> <A HREF="vfs.html#toc5">Contents</A> </BODY> </HTML>