************************* * MySQLfs V2.0 Red Neon * ************************* +----------------------------------------------------------------------------+ | ZDDD IDDD ,777777777 =7777777= =77 | | OOOZ8 7ZOOZ$ 77$$$$$$$$Z $777Z$$$$$77: +7I | | OZ OO, OZ7DO$ I7 77? ?7$ +7I | | OZ :O8 DZO NZ$ 8Z: OZ, II: 77? ?7$ +7I | | OZ IOD DZ8 NZ$ 8Z: OZ, :I$$$$$I7? 77? ?7$ +77 | | OZ 8Z: ZZ, NZ$ 8Z: OZ, :7$ 77? ?7$ +7I | | OZ =O8 DZO NZ$ 8Z: OZ, :7$ $77 77$ ?7$ +77 | | Z$ IZZZ8 D$7, D88DDDDDDOZ, ,7777777I7$, ,$II7777I77$ OMMMI7777777 | | N:: :, OZ, ,:::,,=7, =?DMMMMM | | D$88, ~:~:888888888OOD,::,, ~~++8 ,MMM?I=,$D~ | | 7 Z88?: +==:$77777777+,$,:::,?,:+=Z MMM IMMMMMM | | :N ON, +===M8888OOOZZD+,::::I,,=~7 MMMMMMMMMMMMZ | | 8 N D= Z== ::::~7 ,~~I MM MMMMMMM MMM= | | Z, ,D N~~~~~~ ~O: +,:::7 ,:~+ MMMM NMMM | | N 8==~~~ 8 :::::::::::::I ::= 8MMMM MMMMMMM | | N D ~~O ~~:~~ +I, :::::~::$MMMM 7MM ~MMMMMMN | | ~ 8 ~,~~~:M ~::::7 :::: DMMMM MMMM M$ | | N ? ?8 ~:::::~:::::~,:::, DMMMMMM~ | | M I ,8Z,~::::: ,:::::: DMMMM= | | M D $ ~ N ~::::::::::,::, DMMMM+ | | D ON D~~~ D+,~ ,:~::::, :~: DMMMM+ | | 8=+ N M+?~+=,,Z8 ======:::::: DMMZ = | | ~ D O+~~~~~~~~IO:~~~~~~~~~: D~:~ D | | 8ZZZ$Z$?:O8N+ZZZZZZZOOOOOOO M | | ~+OZ$$$~8 Z$IN+~N,M Z~==~:+=:D | | Z+O7+7I??:8I=I, I $ ~~~,88~~ O | | ? Z , Z by GlassGiant.com | +----------------------------------------------------------------------------+ Function reference ------------------ void __construct( resource $connction [, string $table = 'index' ] ) Startup function for the class. Registers MySQL connection and table settings --- void setuser ( string $user, string $group ) Sets $user and $group --- void valid_user ( string $function ) Uses $function to check if a user name is valid for chown --- array|NULL readdir_full( string $path ) Reads the directory into an array, like scandir() Returns NULL on failure or array ( [type]=> string(1) "f"|"d", [filename]=> string , [time]=> int timestamp, [rights]=> int(3) UNIX mod, [mime]=> string mimetype, [size]=> int filesize in bytes, [owner]=> string|NULL UNIX owner, [group]=> int(1) UNIX owner group ) on success --- string Sizetohuman( int $size ) Converts bytes to Normal file sizes --- mixed getinfo( string $path [, string $what = NULL] ) Gets system info for a path Returns the requested info $what or array ( [type]=> string(1) "f"|"d", [filename]=> string , [time]=> int timestamp, [rights]=> int(3) UNIX mod, [mime]=> string mimetype, [size]=> int filesize in bytes, [mfi]=> int MasterFileIndex, [owner]=> string|NULL UNIX owner, [group]=> int(1) UNIX owner group ) --- int filegroup ( string $path ) Gets the file group. The group ID is returned in numerical format --- int filemtime( string $path ) This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed. --- string fileowner ( string $path ) Gets the file owner. --- int fileperms( string $path ) Gets permissions for the given file. --- int filesize (string $path ) Gets the size for the given file in bytes --- string filetype( string $path ) Returns the type of the given file. --- string simplify_path( string $path ) Removes /./ and resolves /../ --- bool is_file ( string $path ) Returns true if the path is a file, false otherwise --- bool is_dir( string $path ) Returns true if the path is a directory, false otherwise --- string|false file_get_contents( string $path ) Returns contents of the file at $path or false if $path isn't a file --- bool is_empty( string $path ) Checks if a directory is empty Returns true if $path is a file or if $path is an empty directory, false if the directory $path is not empty --- bool rmdir( string $path ) Removes the empty directory $path Returns true on success and false on failure (probably dir not empty) --- bool unlink( string $path ) Removes the file at $path Returns true on success and false on failure --- bool file_exists ( string $path ) Checks if a file exists Returns true if $path exists, false if $path doesn't exist --- bool mkdir( string $path, [int $mode=NULL] ) Creates a directory $path if $mode is NULL, it takes the mode of the directory above Returns true on success or false on failure --- bool mkfile (string $path, [int $mode=NULL, [string $mime=NULL]] ) Creates a file $path if $mode is NULL, it takes the mode of the directory. If $mime is NULL, it searches the type based on the extention Returns true on success or false on failure --- string mime_content_type( string $path ); Gets the content type based on the extention Returns the mimetype --- bool file_put_contents( string $path, string $data ) Puts $data into $pathinfo Returns true on success or false on failure --- bool is_readable( string $path ) Checks if the file is readable Returns true is the file is readable, false otherwise --- bool is_writable( string $path ) Checks if the file is writeable Returns true if the file is writeable, false otherwise --- bool is_executable ( string $path ) Checks if the file is executable by php Returns true if the file is executable, false otherwise --- bool security ( mixed $key ) You can add some extra security here To write (once) supply array with key-value pairs To read, supply the array key --- mixed exec ( string $path ) Executes a PHP file Returns the value returned by the script --- bool chmod ( string $path, int $mode ) UNIX chmod command Returns true on success, false on failure --- bool chown (string $path, string $user ) UNIX chown command Only the current owner can chown Returns true on success, false on failure --- bool chgrp ( string $path, int $group ) UNIX chgrp command Only current group and owner can chgrp Returns true on success, false on failure --- bool rename ( string $oldpath, string $newpath ) Rename $oldpath to $newpath You must have reading permissions on $oldpath and writing permissions on $newpath Returns true on success, false on failure --- bool copy ( string $source, string $dest ) Copy $source to $dest You must have reading permissions on $source and writing permissions on $dest Returns true on success, false on failure --- sra fopen ( string $path, string $mode ) fopen() binds a named resource, specified by $path, to a stream. Returns sra on success or false on failure --- string fgets( sra $handle, [int $length=-1] ) Gets a line from file pointer. --- string fgetc( sra $handle ) Gets a character from the given file pointer. --- int fpassthru( sra $handle ) Reads the file from the current pointer to EOF --- bool fputs( sra $handle, string $string ) Alias of fwrite --- bool fwrite ( sra $handle, string $string ) fwrite() writes the contents of $string to the file stream pointed to by $handle --- string fread ( sra $handle, int $length ) fread() reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: * length bytes have been read * EOF (end of file) is reached * 8192 bytes have been read (after opening userspace stream) --- int fseek( sra $handle, int $offset, [ int $whence=SEEK_SET ] ) Sets the file position indicator for the file referenced by handle. The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence. --- int ftell( sra $handle ) Returns the position of the file pointer referenced by handle. --- bool ftruncate( sra $handle, int $size ) Takes the filepointer, handle, and truncates the file to length, size. --- bool move_uploaded_file ( string $filename, string $destination ) This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination. WARNING: !!! This function works on the actual filesystem and moves it to MySQLfs. !!! Make sure $filename is a valid name --- int readfile ( string $path ) Reads a file and writes it to the output buffer. --- bool rewind ( sra $handle ) Sets the file position indicator for handle to the beginning of the file stream. --- int bin64K_uploadString ( string $data, int $id ) PRIVATE FUNCTION Method to insert the data into the tables creating an entry in the Inodes table and the corresponding "chunk" entries in the data table ** @author Paul Scott @copyright Paul Scott @package phpclasses ** Changes: * Modified to upload strings * Modified for MySQLi * Modified for MySQLfs (only filedata part) * New encoding: base64 --- string bin64K_getFile ( int $id ) PRIVATE FUNCTION Get the splitted file and paste it back together ** @author Paul Scott @copyright Paul Scott @package phpclasses ** Changes: * Modified for MySQLi * Modified for MySQLfs (only filedata part) * Code performance upgraded: wrap in while block, 1 query * New encoding: base64 --- sra opendir ( string $path ) Opens up a directory handle to be used in subsequent closedir(), readdir_full(), and rewinddir() calls. --- string readdir ( [sra $handle] ) Returns the filename of the next file from the directory. The filenames are returned in the order in which they are stored by the filesystem. --- void rewinddir ( [sra $handle] ) Resets the directory stream indicated by $handle to the beginning of the directory. --- void closedir ( [sra $handle ]) Closes the directory stream indicated by $handle. The stream must have previously been opened by opendir(). --- array scandir ( string $path [, int $sorting_order] ) Returns an array of files and directories from the directory. ---