dolibarr  7.0.0-beta
Functions
files.lib.php File Reference

Library for file managing functions. More...

Go to the source code of this file.

Functions

 dol_basename ($pathfile)
 Make a basename working with all page code (default PHP basenamed fails with cyrillic). More...
 
 dol_dir_list ($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
 Scan a directory and return a list of files/directories. More...
 
 dol_dir_list_in_database ($path, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
 Scan a directory and return a list of files/directories. More...
 
 completeFileArrayWithDatabaseInfo (&$filearray, $relativedir)
 Complete $filearray with data from database. More...
 
 dol_compare_file ($a, $b)
 Fast compare of 2 files identified by their properties ->name, ->date and ->size. More...
 
 dol_is_dir ($folder)
 Test if filename is a directory. More...
 
 dol_is_file ($pathoffile)
 Return if path is a file. More...
 
 dol_is_url ($url)
 Return if path is an URL. More...
 
 dol_dir_is_emtpy ($folder)
 Test if a folder is empty. More...
 
 dol_count_nb_of_line ($file)
 Count number of lines in a file. More...
 
 dol_filesize ($pathoffile)
 Return size of a file. More...
 
 dol_filemtime ($pathoffile)
 Return time of a file. More...
 
 dolReplaceInFile ($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0)
 Make replacement of strings into a file. More...
 
 dolReplaceRegExInFile ($srcfile, $arrayreplacement, $destfile='', $newmask=0, $indexdatabase=0)
 Make replacement of strings into a file. More...
 
 dol_copy ($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
 Copy a file to another file. More...
 
 dolCopyDir ($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null)
 Copy a dir to another dir. More...
 
 dol_move ($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=1)
 Move a file into another name. More...
 
 dol_unescapefile ($filename)
 Unescape a file submitted by upload. More...
 
 dolCheckVirus ($src_file)
 Check virus into a file. More...
 
 dol_move_uploaded_file ($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile')
 Make control on an uploaded file from an GUI page and move it to final destination. More...
 
 dol_delete_file ($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null)
 Remove a file or several files with a mask. More...
 
 dol_delete_dir ($dir, $nophperrors=0)
 Remove a directory (not recursive, so content must be empty). More...
 
 dol_delete_dir_recursive ($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
 Remove a directory $dir and its subdirectories (or only files and subdirectories) More...
 
 dol_delete_preview ($object)
 Delete all preview files linked to object instance. More...
 
 dol_meta_create ($object)
 Create a meta file with document file into same directory. More...
 
 dol_init_file_process ($pathtoscan='', $trackid='')
 Scan a directory and init $_SESSION to manage uploaded files with list of all found files. More...
 
 dol_add_file_process ($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1)
 Get and save an upload file (for example after submitting a new file a mail form). More...
 
 dol_remove_file_process ($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='')
 Remove an uploaded file (for example after submitting a new file a mail form). More...
 
 dol_convert_file ($fileinput, $ext='png', $fileoutput='')
 Convert an image file into another format. More...
 
 dol_compress_file ($inputfile, $outputfile, $mode="gz")
 Compress a file. More...
 
 dol_uncompress ($inputfile, $outputdir)
 Uncompress a file. More...
 
 dol_most_recent_file ($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png)$','^\.'), $nohook=false, $mode='')
 Return file(s) into a directory (by default most recent) More...
 
 dol_check_secure_access_document ($modulepart, $original_file, $entity, $fuser='', $refname='', $mode='read')
 Security check when accessing to a document (used by document.php, viewimage.php and webservices) More...
 
 dol_filecache ($directory, $filename, $object)
 Store object in file. More...
 
 dol_cache_refresh ($directory, $filename, $cachetime)
 Test if Refresh needed. More...
 
 dol_readcachefile ($directory, $filename)
 Read object from cachefile. More...
 
 getFilesUpdated (&$file_list, SimpleXMLElement $dir, $path= '', $pathref= '', &$checksumconcat=array())
 Function to get list of updated or modified files. More...
 

Detailed Description

Library for file managing functions.

Definition in file files.lib.php.

Function Documentation

completeFileArrayWithDatabaseInfo ( $filearray,
  $relativedir 
)

Complete $filearray with data from database.

This will call doldir_list_indatabase to complate filearray.

Parameters
array$filearrayArray of files get using dol_dir_list
string$relativedirRelative dir from DOL_DATA_ROOT
Returns
void

Definition at line 297 of file files.lib.php.

References dol_dir_list_in_database(), dol_osencode(), dol_syslog(), and setEventMessages().

Referenced by FormFile\list_of_documents(), and Product\show_photos().

dol_add_file_process (   $upload_dir,
  $allowoverwrite = 0,
  $donotupdatesession = 0,
  $varfiles = 'addedfile',
  $savingdocmask = '',
  $link = null,
  $trackid = '',
  $generatethumbs = 1 
)

Get and save an upload file (for example after submitting a new file a mail form).

Database index of file is also updated if donotupdatesession is set. All information used are in db, conf, langs, user and _FILES. Note: This function can be used only into a HTML page context.

Parameters
string$upload_dirDirectory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename)
int$allowoverwrite1=Allow overwrite existing file
int$donotupdatesession1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index.
string$varfiles_FILES var name
string$savingdocmaskMask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
string$linkLink to add (to add a link instead of a file)
string$trackidTrack id (used to prefix name of session vars to avoid conflict)
int$generatethumbs1=Generate also thumbs for uploaded image files
Returns
int <=0 if KO, >0 if OK

Definition at line 1478 of file files.lib.php.

References dol_mkdir(), dol_move_uploaded_file(), dol_osencode(), dol_sanitizeFileName(), dol_syslog(), GETPOST(), image_format_supported(), setEventMessages(), and vignette().

dol_basename (   $pathfile)

Make a basename working with all page code (default PHP basenamed fails with cyrillic).

We supose dir separator for input is '/'.

Parameters
string$pathfileString to find basename.
Returns
string Basename of input

Definition at line 35 of file files.lib.php.

dol_cache_refresh (   $directory,
  $filename,
  $cachetime 
)

Test if Refresh needed.

Parameters
string$directoryDirectory of cache
string$filenameName of filecache
int$cachetimeCachetime delay
Returns
boolean 0 no refresh 1 if refresh needed

Definition at line 2736 of file files.lib.php.

References dol_filemtime(), and dol_now().

Referenced by box_activity\loadBox(), and ModeleBoxes\showBox().

dol_check_secure_access_document (   $modulepart,
  $original_file,
  $entity,
  $fuser = '',
  $refname = '',
  $mode = 'read' 
)

Security check when accessing to a document (used by document.php, viewimage.php and webservices)

Parameters
string$modulepartModule of document ('module', 'module_user_temp', 'module_user' or 'module_temp')
string$original_fileRelative path with filename, relative to modulepart.
string$entityRestrict onto entity (0=no restriction)
User$fuserUser object (forced)
string$refnameRef of object to check permission for external users (autodetect if not provided)
string$modeCheck permission for 'read' or 'write'
Returns
mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
See also
restrictedArea

Definition at line 1970 of file files.lib.php.

References dol_syslog().

Referenced by Documents\builddoc(), getDocument(), and Documents\index().

dol_compare_file (   $a,
  $b 
)

Fast compare of 2 files identified by their properties ->name, ->date and ->size.

Parameters
string$aFile 1
string$bFile 2
Returns
int 1, 0, 1

Definition at line 380 of file files.lib.php.

dol_compress_file (   $inputfile,
  $outputfile,
  $mode = "gz" 
)

Compress a file.

Parameters
string$inputfileSource file name
string$outputfileTarget file name
string$mode'gz' or 'bz' or 'zip'
Returns
int <0 if KO, >0 if OK

Definition at line 1738 of file files.lib.php.

References dol_osencode(), and dol_syslog().

Referenced by Utils\dumpDatabase(), and Website\exportWebSite().

dol_convert_file (   $fileinput,
  $ext = 'png',
  $fileoutput = '' 
)

Convert an image file into another format.

This need Imagick php extension.

Parameters
string$fileinputInput file name
string$extFormat of target file (It is also extension added to file if fileoutput is not provided).
string$fileoutputOutput filename
Returns
int <0 if KO, 0=Nothing done, >0 if OK

Definition at line 1688 of file files.lib.php.

References dol_syslog().

Referenced by dol_banner_tab().

dol_copy (   $srcfile,
  $destfile,
  $newmask = 0,
  $overwriteifexists = 1 
)

Copy a file to another file.

Parameters
string$srcfileSource file (can't be a directory)
string$destfileDestination file (can't be a directory)
int$newmaskMask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
int$overwriteifexistsOverwrite file if exists (1 by default)
Returns
int <0 if error, 0 if nothing done (dest file already exists and overwriteifexists=0), >0 if OK
See also
dol_delete_file

Definition at line 631 of file files.lib.php.

References dol_is_file(), dol_osencode(), and dol_syslog().

Referenced by Project\createFromClone(), Task\createFromClone(), dolCopyDir(), modSupplierProposal\init(), modContrat\init(), modPropale\init(), modCommande\init(), modFacture\init(), modExpedition\init(), modProjet\init(), modSociete\init(), and InterfaceActionsAuto\runTrigger().

dol_count_nb_of_line (   $file)

Count number of lines in a file.

Parameters
string$fileFilename
Returns
int <0 if KO, Number of lines in files if OK
See also
dol_nboflines

Definition at line 484 of file files.lib.php.

References dol_osencode().

Referenced by ImportCsv\import_get_nb_of_lines().

dol_delete_dir (   $dir,
  $nophperrors = 0 
)

Remove a directory (not recursive, so content must be empty).

If directory is not empty, return false

Parameters
string$dirDirectory to delete
int$nophperrorsDisable all PHP output errors
Returns
boolean True if success, false if error
See also
dol_delete_file dol_copy

Definition at line 1210 of file files.lib.php.

References dol_osencode(), and dol_syslog().

Referenced by EcmDirectory\delete(), Livraison\delete(), dol_delete_dir_recursive(), and Website\exportWebSite().

dol_delete_dir_recursive (   $dir,
  $count = 0,
  $nophperrors = 0,
  $onlysub = 0,
$countdeleted = 0 
)

Remove a directory $dir and its subdirectories (or only files and subdirectories)

Parameters
string$dirDir to delete
int$countCounter to count nb of elements found to delete
int$nophperrorsDisable all PHP output errors
int$onlysubDelete only files and subdir, not main directory
int$countdeletedCounter to count nb of elements found really deleted
Returns
int Number of files and directory we try to remove. NB really removed is returned into $countdeleted.

Definition at line 1234 of file files.lib.php.

References dol_delete_dir(), dol_delete_file(), dol_is_dir(), dol_osencode(), dol_syslog(), and utf8_check().

Referenced by FormMail\clear_attached_files(), Website\createFromClone(), Task\delete(), Dolresource\delete(), Project\delete(), Fichinter\delete(), FactureFournisseur\delete(), Product\delete(), Contrat\delete(), Expedition\delete(), Societe\delete(), Facture\delete(), CommandeFournisseur\delete(), SupplierProposal\delete(), Propal\delete(), Commande\delete(), migrate_delete_old_dir(), and Utils\purgeFiles().

dol_delete_file (   $file,
  $disableglob = 0,
  $nophperrors = 0,
  $nohook = 0,
  $object = null 
)

Remove a file or several files with a mask.

This delete file physically but also database indexes.

Parameters
string$fileFile to delete or mask of files to delete
int$disableglobDisable usage of glob like * so function is an exact delete function that will return error if no file found
int$nophperrorsDisable all PHP output errors
int$nohookDisable all hooks
object$objectCurrent object in use
Returns
boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
See also
dol_delete_dir

Definition at line 1103 of file files.lib.php.

References dol_osencode(), dol_syslog(), and setEventMessages().

Referenced by ActionComm\build_exportfile(), Website\createFromClone(), WebsitePage\delete(), Livraison\delete(), Fichinter\delete(), FactureFournisseur\delete(), Expedition\delete(), Facture\delete(), CommandeFournisseur\delete(), SupplierProposal\delete(), Propal\delete(), Commande\delete(), Categorie\delete_photo(), Product\delete_photo(), dol_delete_dir_recursive(), dol_delete_preview(), dol_move(), dol_remove_file_process(), dolReplaceInFile(), dolSavePageContent(), Utils\dumpDatabase(), Website\exportWebSite(), migrate_delete_old_files(), and Utils\purgeFiles().

dol_delete_preview (   $object)

Delete all preview files linked to object instance.

Note that preview image of PDF files is generated when required, by dol_banner_tab() for example.

Parameters
object$objectObject to clean
Returns
int 0 if error, 1 if OK
See also
dol_convert_file

Definition at line 1283 of file files.lib.php.

References dol_delete_file(), and dol_sanitizeFileName().

Referenced by Fichinter\delete(), Facture\delete(), SupplierProposal\delete(), Propal\delete(), Commande\delete(), don_create(), and fichinter_create().

dol_dir_is_emtpy (   $folder)

Test if a folder is empty.

Parameters
string$folderName of folder
Returns
boolean True if dir is empty or non-existing, False if it contains files

Definition at line 455 of file files.lib.php.

References dol_osencode().

dol_dir_list (   $path,
  $types = "all",
  $recursive = 0,
  $filter = "",
  $excludefilter = null,
  $sortcriteria = "name",
  $sortorder = SORT_ASC,
  $mode = 0,
  $nohook = 0,
  $relativename = "" 
)

Scan a directory and return a list of files/directories.

Content for string is UTF8 and dir separator is "/".

Parameters
string$pathStarting path from which to search. This is a full path.
string$typesCan be "directories", "files", or "all"
int$recursiveDetermines whether subdirectories are searched
string$filterRegex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function, but must not contains the start and end '/'. Filter is checked into basename only.
array$excludefilterArray of Regex for exclude filter (example: array('(.meta|_preview.*.png)$','^.')). Exclude is checked both into fullpath and into basename (So '^xxx' may exclude 'xxx/dirscanned/...' and dirscanned/xxx').
string$sortcriteriaSort criteria ('','fullname','relativename','name','date','size')
string$sortorderSort order (SORT_ASC, SORT_DESC)
int$mode0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
int$nohookDisable all hooks
string$relativenameFor recursive purpose only. Must be "" at first call.
Returns
array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
See also
dol_dir_list_indatabase

Definition at line 58 of file files.lib.php.

References dol_filemtime(), dol_filesize(), dol_osencode(), dol_syslog(), and utf8_check().

Referenced by actions_prepare_head(), bank_prepare_head(), commande_prepare_head(), complete_substitutions_array(), contact_prepare_head(), contract_prepare_head(), Project\createFromClone(), Task\createFromClone(), dol_init_file_process(), dol_most_recent_file(), donation_prepare_head(), Utils\dumpDatabase(), expensereport_prepare_head(), facture_prepare_head(), facturefourn_prepare_head(), fichinter_prepare_head(), Utils\generateDoc(), Setup\getCheckIntegrity(), FormFile\getDocumentsLink(), Documents\getDocumentsListByElement(), getListOfModels(), holiday_prepare_head(), doc_generic_odt\info(), doc_generic_user_odt\info(), doc_generic_product_odt\info(), doc_generic_contract_odt\info(), doc_generic_proposal_odt\info(), doc_generic_supplier_proposal_odt\info(), doc_generic_usergroup_odt\info(), doc_generic_order_odt\info(), doc_generic_invoice_odt\info(), doc_generic_shipment_odt\info(), doc_generic_task_odt\info(), doc_generic_project_odt\info(), PrintingDriver\listDrivers(), loan_prepare_head(), member_prepare_head(), myobjectPrepareHead(), ordersupplier_prepare_head(), product_prepare_head(), project_prepare_head(), propal_prepare_head(), Utils\purgeFiles(), EcmDirectory\refreshcachenboffile(), resource_prepare_head(), FormEcm\selectAllSections(), Fichinter\setValid(), ExpenseReport\setValidate(), Product\show_photos(), FormFile\showdocuments(), societe_prepare_head(), task_prepare_head(), tax_prepare_head(), user_prepare_head(), Commande\valid(), Livraison\valid(), CommandeFournisseur\valid(), Expedition\valid(), SupplierProposal\valid(), Propal\valid(), Contrat\validate(), FactureFournisseur\validate(), Facture\validate(), various_payment_prepare_head(), doc_generic_task_odt\write_file(), and doc_generic_project_odt\write_file().

dol_dir_list_in_database (   $path,
  $filter = "",
  $excludefilter = null,
  $sortcriteria = "name",
  $sortorder = SORT_ASC,
  $mode = 0 
)

Scan a directory and return a list of files/directories.

Content for string is UTF8 and dir separator is "/".

Parameters
string$pathStarting path from which to search. Example: 'produit/MYPROD'
string$filterRegex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
array | null$excludefilterArray of Regex for exclude filter (example: array('(.meta|_preview.*.png)$','^.'))
string$sortcriteriaSort criteria ("","fullname","name","date","size")
string$sortorderSort order (SORT_ASC, SORT_DESC)
int$mode0=Return array minimum keys loaded (faster), 1=Force all keys like description
Returns
array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','type'=>'dir|file',...)
See also
dol_dir_list

Definition at line 224 of file files.lib.php.

References $resql, and dol_print_error().

Referenced by completeFileArrayWithDatabaseInfo().

dol_filecache (   $directory,
  $filename,
  $object 
)

Store object in file.

Parameters
string$directoryDirectory of cache
string$filenameName of filecache
mixed$objectObject to store in cachefile
Returns
void

Definition at line 2720 of file files.lib.php.

References dol_is_dir(), and dol_mkdir().

Referenced by box_activity\loadBox(), and ModeleBoxes\showBox().

dol_filemtime (   $pathoffile)
dol_filesize (   $pathoffile)

Return size of a file.

Parameters
string$pathoffilePath of file
Returns
integer File size

Definition at line 516 of file files.lib.php.

References dol_osencode().

Referenced by dol_dir_list(), Setup\getCheckIntegrity(), and FormFile\showdocuments().

dol_init_file_process (   $pathtoscan = '',
  $trackid = '' 
)

Scan a directory and init $_SESSION to manage uploaded files with list of all found files.

Note: Only email module seems to use this. Other feature initialize the $_SESSION doing $formmail->clear_attached_files(); $formmail->add_attached_files()

Parameters
string$pathtoscanPath to scan
string$trackidTrack id (used to prefix name of session vars to avoid conflict)
Returns
void

Definition at line 1440 of file files.lib.php.

References dol_dir_list(), and dol_mimetype().

dol_is_dir (   $folder)
dol_is_file (   $pathoffile)
dol_is_url (   $url)

Return if path is an URL.

Parameters
string$urlUrl
Returns
boolean True or false

Definition at line 439 of file files.lib.php.

Referenced by RssParser\parser().

dol_meta_create (   $object)

Create a meta file with document file into same directory.

This make "grep" search possible. This feature to generate the meta file is enabled only if option MAIN_DOC_CREATE_METAFILE is set.

Parameters
CommonObject$objectObject
Returns
int 0 if do nothing, >0 if we update meta file too, <0 if KO

Definition at line 1361 of file files.lib.php.

References dol_mkdir(), dol_print_date(), dol_sanitizeFileName(), and dol_syslog().

dol_most_recent_file (   $dir,
  $regexfilter = '',
  $excludefilter = array('(\.meta|_preview.*\.png)$','^\.'),
  $nohook = false,
  $mode = '' 
)

Return file(s) into a directory (by default most recent)

Parameters
string$dirDirectory to scan
string$regexfilterRegex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
array$excludefilterArray of Regex for exclude filter (example: array('(.meta|_preview.*.png)$','^.')). This regex value must be escaped for '/', since this char is used for preg_match function
int$nohookDisable all hooks
int$mode0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
Returns
string Full path to most recent file

Definition at line 1952 of file files.lib.php.

References dol_dir_list().

dol_move (   $srcfile,
  $destfile,
  $newmask = 0,
  $overwriteifexists = 1,
  $testvirus = 0,
  $indexdatabase = 1 
)

Move a file into another name.

Note:

  • This function differs from dol_move_uploaded_file, because it can be called in any context.
  • Database indexes for files are updated.
  • Test on antivirus is done only if param testvirus is provided and an antivirus was set.
Parameters
string$srcfileSource file (can't be a directory. use native php () to move a directory)
string$destfileDestination file (can't be a directory. use native php () to move a directory)
integer$newmaskMask in octal string for new file (0 by default means $conf->global->MAIN_UMASK)
int$overwriteifexistsOverwrite file if exists (1 by default)
int$testvirusDo an antivirus test. Move is canceled if a virus is found.
int$indexdatabaseIndex new file into database.
Returns
boolean True if OK, false if KO
See also
dol_move_uploaded_file

Definition at line 780 of file files.lib.php.

References dol_delete_file(), dol_is_file(), dol_osencode(), dol_syslog(), dolCheckVirus(), and setEventMessages().

Referenced by ActionComm\build_exportfile(), dolReplaceInFile(), Project\update(), and Task\update().

dol_move_uploaded_file (   $src_file,
  $dest_file,
  $allowoverwrite,
  $disablevirusscan = 0,
  $uploaderrorcode = 0,
  $nohook = 0,
  $varfiles = 'addedfile' 
)

Make control on an uploaded file from an GUI page and move it to final destination.

If there is errors (virus found, antivir in error, bad filename), file is not moved. Note:

  • This function can be used only into a HTML page context. Use dol_move if you are outside.
  • Test on antivirus is always done (if antivirus set).
  • Database of files is NOT updated.
Parameters
string$src_fileSource full path filename ($_FILES['field']['tmp_name'])
string$dest_fileTarget full path filename ($_FILES['field']['name'])
int$allowoverwrite1=Overwrite target file if it already exists
int$disablevirusscan1=Disable virus scan
integer$uploaderrorcodeValue of PHP upload error code ($_FILES['field']['error'])
int$nohookDisable all hooks
string$varfiles_FILES var name
Returns
int >0 if OK, <0 or string if KO
See also
dol_move

Definition at line 962 of file files.lib.php.

References dol_osencode(), dol_syslog(), and dolCheckVirus().

Referenced by Categorie\add_photo(), Product\add_photo(), mailing_xinputfile\add_to_target(), dol_add_file_process(), and FileUpload\handleFileUpload().

dol_readcachefile (   $directory,
  $filename 
)

Read object from cachefile.

Parameters
string$directoryDirectory of cache
string$filenameName of filecache
Returns
mixed Unserialise from file

Definition at line 2751 of file files.lib.php.

Referenced by box_activity\loadBox(), and ModeleBoxes\showBox().

dol_remove_file_process (   $filenb,
  $donotupdatesession = 0,
  $donotdeletefile = 1,
  $trackid = '' 
)

Remove an uploaded file (for example after submitting a new file a mail form).

All information used are in db, conf, langs, user and _FILES.

Parameters
int$filenbFile nb to delete
int$donotupdatesession1=Do not edit _SESSION variable
int$donotdeletefile1=Do not delete physically file
string$trackidTrack id (used to prefix name of session vars to avoid conflict)
Returns
void

Definition at line 1640 of file files.lib.php.

References dol_delete_file(), and setEventMessages().

dol_uncompress (   $inputfile,
  $outputdir 
)

Uncompress a file.

Parameters
string$inputfileFile to uncompress
string$outputdirTarget dir name
Returns
array array('error'=>'Error code') or array() if no error

Definition at line 1791 of file files.lib.php.

References dol_syslog().

dol_unescapefile (   $filename)

Unescape a file submitted by upload.

PHP escape char " (%22) or char ' (%27) into $FILES.

Parameters
string$filenameFilename
Returns
string Filename sanitized

Definition at line 908 of file files.lib.php.

dolCheckVirus (   $src_file)

Check virus into a file.

Parameters
string$src_fileSource file to check
Returns
array Array of errors or empty array if not virus found

Definition at line 923 of file files.lib.php.

Referenced by dol_move(), and dol_move_uploaded_file().

dolCopyDir (   $srcfile,
  $destfile,
  $newmask,
  $overwriteifexists,
  $arrayreplacement = null 
)

Copy a dir to another dir.

This include recursive subdirectories.

Parameters
string$srcfileSource file (a directory)
string$destfileDestination file (a directory)
int$newmaskMask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
int$overwriteifexistsOverwrite file if exists (1 by default)
array$arrayreplacementArray to use to replace filenames with another one during the copy (works only on file names, not on directory names).
Returns
int <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK
See also
dol_copy

Definition at line 687 of file files.lib.php.

References dol_copy(), dol_is_dir(), dol_mkdir(), dol_osencode(), and dol_syslog().

Referenced by Website\createFromClone(), and Website\exportWebSite().

dolReplaceInFile (   $srcfile,
  $arrayreplacement,
  $destfile = '',
  $newmask = 0,
  $indexdatabase = 0 
)

Make replacement of strings into a file.

Parameters
string$srcfileSource file (can't be a directory)
array$arrayreplacementArray with strings to replace. Example: array('valuebefore'=>'valueafter', ...)
string$destfileDestination file (can't be a directory). If empty, will be same than source file.
int$newmaskMask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
int$indexdatabaseIndex new file into database.
Returns
int <0 if error, 0 if nothing done (dest file already exists), >0 if OK
See also
dol_copy dolReplaceRegExInFile

Definition at line 545 of file files.lib.php.

References dol_delete_file(), dol_is_file(), dol_move(), dol_osencode(), dol_syslog(), and make_substitutions().

dolReplaceRegExInFile (   $srcfile,
  $arrayreplacement,
  $destfile = '',
  $newmask = 0,
  $indexdatabase = 0 
)

Make replacement of strings into a file.

Parameters
string$srcfileSource file (can't be a directory)
array$arrayreplacementArray with strings to replace. Example: array('valuebefore'=>'valueafter', ...)
string$destfileDestination file (can't be a directory). If empty, will be same than source file.
int$newmaskMask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
int$indexdatabaseIndex new file into database.
Returns
int <0 if error, 0 if nothing done (dest file already exists), >0 if OK
See also
dol_copy dolReplaceInFile

Definition at line 615 of file files.lib.php.

getFilesUpdated ( $file_list,
SimpleXMLElement  $dir,
  $path = '',
  $pathref = '',
$checksumconcat = array() 
)

Function to get list of updated or modified files.

$file_list is used as global variable

Parameters
array$file_listArray for response
SimpleXMLElement$dirSimpleXMLElement of files to test
string$pathPath of files relative to $pathref. We start with ''. Used by recursive calls.
string$pathrefPath ref (DOL_DOCUMENT_ROOT)
array$checksumconcatArray of checksum
Returns
array Array of filenames

Definition at line 2770 of file files.lib.php.

Referenced by Setup\getCheckIntegrity().