dolibarr 20.0.0
|
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). | |
dol_dir_list ($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0) | |
Scan a directory and return a list of files/directories. | |
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. | |
completeFileArrayWithDatabaseInfo (&$filearray, $relativedir) | |
Complete $filearray with data from database. | |
dol_compare_file ($a, $b) | |
Fast compare of 2 files identified by their properties ->name, ->date and ->size. | |
dol_is_dir ($folder) | |
Test if filename is a directory. | |
dol_is_dir_empty ($dir) | |
Return if path is empty. | |
dol_is_file ($pathoffile) | |
Return if path is a file. | |
dol_is_link ($pathoffile) | |
Return if path is a symbolic link. | |
dol_is_writable ($folderorfile) | |
Test if directory or filename is writable. | |
dol_is_url ($uri) | |
Return if path is an URI (the name of the method is misleading). | |
dol_dir_is_emtpy ($folder) | |
Test if a folder is empty. | |
dol_count_nb_of_line ($file) | |
Count number of lines in a file. | |
dol_filesize ($pathoffile) | |
Return size of a file. | |
dol_filemtime ($pathoffile) | |
Return time of a file. | |
dol_fileperm ($pathoffile) | |
Return permissions of a file. | |
dolReplaceInFile ($srcfile, $arrayreplacement, $destfile='', $newmask='0', $indexdatabase=0, $arrayreplacementisregex=0) | |
Make replacement of strings into a file. | |
dol_copy ($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0) | |
Copy a file to another file. | |
dolCopyDir ($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null, $excludearchivefiles=0) | |
Copy a dir to another dir. | |
dol_move ($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array()) | |
Move a file into another name. | |
dol_move_dir ($srcdir, $destdir, $overwriteifexists=1, $indexdatabase=1, $renamedircontent=1) | |
Move a directory into another name. | |
dol_unescapefile ($filename) | |
Unescape a file submitted by upload. | |
dolCheckVirus ($src_file, $dest_file='') | |
Check virus into a file. | |
dolCheckOnFileName ($src_file, $dest_file='') | |
Check virus into a file. | |
dol_move_uploaded_file ($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='') | |
Check validity of a file upload from an GUI page, and move it to its final destination. | |
dol_delete_file ($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0) | |
Remove a file or several files with a mask. | |
dol_delete_dir ($dir, $nophperrors=0) | |
Remove a directory (not recursive, so content must be empty). | |
dol_delete_dir_recursive ($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0) | |
Remove a directory $dir and its subdirectories (or only files and subdirectories) | |
dol_delete_preview ($object) | |
Delete all preview files linked to object instance. | |
dol_meta_create ($object) | |
Create a meta file with document file into same directory. | |
dol_init_file_process ($pathtoscan='', $trackid='') | |
Scan a directory and init $_SESSION to manage uploaded files with list of all found files. | |
dol_add_file_process ($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null) | |
Get and save an upload file (for example after submitting a new file a mail form). | |
dol_remove_file_process ($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='') | |
Remove an uploaded file (for example after submitting a new file a mail form). | |
addFileIntoDatabaseIndex ($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null) | |
Add a file into database index. | |
deleteFilesIntoDatabaseIndex ($dir, $file, $mode='uploaded') | |
Delete files into database index using search criteria. | |
dol_convert_file ($fileinput, $ext='png', $fileoutput='', $page='') | |
Convert an image file or a PDF into another image format. | |
dol_uncompress ($inputfile, $outputdir) | |
Uncompress a file. | |
dol_most_recent_file ($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0) | |
Return file(s) into a directory (by default most recent) | |
dol_check_secure_access_document ($modulepart, $original_file, $entity, $fuser=null, $refname='', $mode='read') | |
Security check when accessing to a document (used by document.php, viewimage.php and webservices to get documents). | |
dol_filecache ($directory, $filename, $object) | |
Store object in file. | |
dol_cache_refresh ($directory, $filename, $cachetime) | |
Test if Refresh needed. | |
dol_readcachefile ($directory, $filename) | |
Read object from cachefile. | |
dirbasename ($pathfile) | |
Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string. | |
getFilesUpdated (&$file_list, SimpleXMLElement $dir, $path='', $pathref='', &$checksumconcat=array()) | |
Function to get list of updated or modified files. | |
dragAndDropFileUpload ($htmlname) | |
Function to manage the drag and drop of a file. | |
archiveOrBackupFile ($filetpl, $max_versions=5, $archivedir='', $suffix="v", $moveorcopy='move') | |
Manage backup versions for a given file, ensuring only a maximum number of versions are kept. | |
Library for file managing functions.
Definition in file files.lib.php.
addFileIntoDatabaseIndex | ( | $dir, | |
$file, | |||
$fullpathorig = '', | |||
$mode = 'uploaded', | |||
$setsharekey = 0, | |||
$object = null ) |
Add a file into database index.
Called by dol_add_file_process when uploading a file and on other cases. See also commonGenerateDocument that also add/update database index when a file is generated.
string | $dir | Directory name (full real path without ending /) |
string | $file | File name (May end with '.noexe') |
string | $fullpathorig | Full path of origin for file (can be '') |
string | $mode | How file was created ('uploaded', 'generated', ...) |
int | $setsharekey | Set also the share key |
Object | $object | Object used to set 'src_object_*' fields |
Definition at line 2113 of file files.lib.php.
References $object, dol_osencode(), dol_string_nospecial(), dol_syslog(), getDolGlobalString(), and getRandomPassword().
Referenced by dol_add_file_process(), and EmailCollector\saveAttachment().
archiveOrBackupFile | ( | $filetpl, | |
$max_versions = 5, | |||
$archivedir = '', | |||
$suffix = "v", | |||
$moveorcopy = 'move' ) |
Manage backup versions for a given file, ensuring only a maximum number of versions are kept.
string | $filetpl | Full path of the source filename for the backups. Example /mydir/mydocuments/mymodule/filename.ext |
int | $max_versions | The maximum number of backup versions to keep. |
string | $archivedir | Target directory of backups (without ending /). Keep empty to save into the same directory than source file. |
string | $suffix | 'v' (versioned files) or 'd' (archived files after deletion) |
string | $moveorcopy | 'move' or 'copy' |
Definition at line 3746 of file files.lib.php.
References dol_copy(), dol_delete_file(), dol_move(), and dol_now().
Referenced by dolSavePageContent().
completeFileArrayWithDatabaseInfo | ( | & | $filearray, |
$relativedir ) |
Complete $filearray with data from database.
This will call doldir_list_indatabase to complete filearray.
array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string}> | $filearray Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) Array of files obtained using dol_dir_list | |
string | $relativedir | Relative dir from DOL_DATA_ROOT |
Definition at line 341 of file files.lib.php.
References $object, dol_dir_list_in_database(), dol_osencode(), dol_syslog(), getDolGlobalInt(), and setEventMessages().
Referenced by FormFile\list_of_autoecmfiles(), FormFile\list_of_documents(), CommonObject\show_photos(), and FormFile\showdocuments().
deleteFilesIntoDatabaseIndex | ( | $dir, | |
$file, | |||
$mode = 'uploaded' ) |
Delete files into database index using search criteria.
string | $dir | Directory name (full real path without ending /) |
string | $file | File name |
string | $mode | How file was created ('uploaded', 'generated', ...) |
Definition at line 2219 of file files.lib.php.
References dol_syslog().
dirbasename | ( | $pathfile | ) |
Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string.
string | $pathfile | Full path of a file |
Definition at line 3569 of file files.lib.php.
Referenced by Ticket\copyFilesForTicket().
dol_add_file_process | ( | $upload_dir, | |
$allowoverwrite = 0, | |||
$updatesessionordb = 0, | |||
$varfiles = 'addedfile', | |||
$savingdocmask = '', | |||
$link = null, | |||
$trackid = '', | |||
$generatethumbs = 1, | |||
$object = null ) |
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.
string | $upload_dir | Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) |
int | $allowoverwrite | 1=Allow overwrite existing file |
int | $updatesessionordb | 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. -1=Do not update SESSION neither db. |
string | $varfiles | _FILES var name |
string | $savingdocmask | Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' |
string | $link | Link to add (to add a link instead of a file) |
string | $trackid | Track id (used to prefix name of session vars to avoid conflict) |
int | $generatethumbs | 1=Generate also thumbs for uploaded image files |
Object | $object | Object used to set 'src_object_*' fields |
Definition at line 1874 of file files.lib.php.
References $object, addFileIntoDatabaseIndex(), dol_mkdir(), dol_move_uploaded_file(), dol_sanitizeFileName(), dol_string_nohtmltag(), dol_syslog(), getDefaultImageSizes(), getDolGlobalInt(), getDolGlobalString(), GETPOST(), GETPOSTINT(), image_format_supported(), setEventMessages(), and vignette().
dol_basename | ( | $pathfile | ) |
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
We suppose dir separator for input is '/'.
string | $pathfile | String to find basename. |
Definition at line 38 of file files.lib.php.
Referenced by Documents\post().
dol_cache_refresh | ( | $directory, | |
$filename, | |||
$cachetime ) |
Test if Refresh needed.
string | $directory | Directory of cache |
string | $filename | Name of filecache |
int | $cachetime | Cachetime delay |
Definition at line 3541 of file files.lib.php.
References dol_filemtime(), and dol_now().
Referenced by ModeleBoxes\showBox().
dol_check_secure_access_document | ( | $modulepart, | |
$original_file, | |||
$entity, | |||
$fuser = null, | |||
$refname = '', | |||
$mode = 'read' ) |
Security check when accessing to a document (used by document.php, viewimage.php and webservices to get documents).
TODO Replace code that set $accessallowed by a call to restrictedArea()
string | $modulepart | Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp'). Example: 'medias', 'invoice', 'logs', 'tax-vat', ... |
string | $original_file | Relative path with filename, relative to modulepart. |
string | $entity | Restrict onto entity (0=no restriction) |
User | null | $fuser | User object (forced) |
string | $refname | Ref of object to check permission for external users (autodetect if not provided by taking the dirname of $original_file) or for hierarchy |
string | $mode | Check permission for 'read' or 'write' |
Definition at line 2737 of file files.lib.php.
References $object, checkUserAccessToObject(), dol_hash(), dol_syslog(), getDolUserInt(), and GETPOST().
Referenced by Documents\builddoc(), Documents\delete(), getDocument(), Documents\index(), and Documents\post().
dol_compare_file | ( | $a, | |
$b ) |
Fast compare of 2 files identified by their properties ->name, ->date and ->size.
object | $a | File 1 |
object | $b | File 2 |
Definition at line 446 of file files.lib.php.
dol_convert_file | ( | $fileinput, | |
$ext = 'png', | |||
$fileoutput = '', | |||
$page = '' ) |
Convert an image file or a PDF into another image format.
This need Imagick php extension. You can use dol_imageResizeOrCrop() for a function that need GD.
string | $fileinput | Input file name |
string | $ext | Format of target file (It is also extension added to file if fileoutput is not provided). |
string | $fileoutput | Output filename |
string | $page | Page number if we convert a PDF into png |
Definition at line 2278 of file files.lib.php.
References dol_is_file(), and dol_syslog().
dol_copy | ( | $srcfile, | |
$destfile, | |||
$newmask = '0', | |||
$overwriteifexists = 1, | |||
$testvirus = 0, | |||
$indexdatabase = 0 ) |
Copy a file to another file.
string | $srcfile | Source file (can't be a directory) |
string | $destfile | Destination file (can't be a directory) |
string | $newmask | Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' |
int | $overwriteifexists | Overwrite file if exists (1 by default) |
int | $testvirus | Do an antivirus test. Move is canceled if a virus is found. |
int | $indexdatabase | Index new file into database. |
Definition at line 767 of file files.lib.php.
References dol_is_file(), dol_osencode(), dol_syslog(), dolCheckVirus(), dolChmod(), getDolGlobalString(), and setEventMessages().
Referenced by archiveOrBackupFile(), Project\createFromClone(), Task\createFromClone(), dolCopyDir(), Website\exportWebSite(), Utils\generateDoc(), modBom\init(), modCommande\init(), modContrat\init(), modEventOrganization\init(), modExpedition\init(), modFacture\init(), modFournisseur\init(), modKnowledgeManagement\init(), modMrp\init(), modMyModule\init(), modPartnership\init(), modProjet\init(), modPropale\init(), modReception\init(), modRecruitment\init(), modSociete\init(), modStock\init(), modSupplierProposal\init(), modTicket\init(), modWebsite\init(), modWorkstation\init(), DolibarrModules\insert_module_parts(), migrate_user_photospath(), migrate_user_photospath2(), rebuildObjectClass(), rebuildObjectSql(), and InterfaceActionsAuto\runTrigger().
dol_count_nb_of_line | ( | $file | ) |
Count number of lines in a file.
string | $file | Filename |
Definition at line 602 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
string | $dir | Directory to delete |
int | $nophperrors | Disable all PHP output errors |
Definition at line 1596 of file files.lib.php.
References dol_osencode(), and dol_syslog().
Referenced by Delivery\delete(), EcmDirectory\delete(), and dol_delete_dir_recursive().
dol_delete_dir_recursive | ( | $dir, | |
$count = 0, | |||
$nophperrors = 0, | |||
$onlysub = 0, | |||
& | $countdeleted = 0, | ||
$indexdatabase = 1, | |||
$nolog = 0 ) |
Remove a directory $dir and its subdirectories (or only files and subdirectories)
string | $dir | Dir to delete |
int | $count | Counter to count nb of elements found to delete |
int | $nophperrors | Disable all PHP output errors |
int | $onlysub | Delete only files and subdir, not main directory |
int | $countdeleted | Counter to count nb of elements found really deleted |
int | $indexdatabase | Try to remove also index entries. |
int | $nolog | Disable log files (too verbose when making recursive directories) |
Definition at line 1621 of file files.lib.php.
References dol_delete_dir(), dol_delete_dir_recursive(), dol_delete_file(), dol_is_dir(), dol_osencode(), dol_syslog(), and utf8_check().
Referenced by Expedition\cancel(), FormMail\clear_attached_files(), FormTicket\clear_attached_files(), Website\createFromClone(), Commande\delete(), CommandeFournisseur\delete(), Contrat\delete(), Dolresource\delete(), Don\delete(), EcmDirectory\delete(), Expedition\delete(), ExpenseReport\delete(), Facture\delete(), FactureFournisseur\delete(), Fichinter\delete(), Product\delete(), Project\delete(), Propal\delete(), Reception\delete(), Societe\delete(), SupplierProposal\delete(), Task\delete(), Ticket\delete(), Website\delete(), dol_delete_dir_recursive(), Website\exportWebSite(), migrate_delete_old_dir(), and Utils\purgeFiles().
dol_delete_file | ( | $file, | |
$disableglob = 0, | |||
$nophperrors = 0, | |||
$nohook = 0, | |||
$object = null, | |||
$allowdotdot = false, | |||
$indexdatabase = 1, | |||
$nolog = 0 ) |
Remove a file or several files with a mask.
This delete file physically but also database indexes.
string | $file | File to delete or mask of files to delete |
int | $disableglob | Disable usage of glob like * so function is an exact delete function that will return error if no file found |
int | $nophperrors | Disable all PHP output errors |
int | $nohook | Disable all hooks |
object | null | $object | Current object in use |
boolean | $allowdotdot | Allow to delete file path with .. inside. Never use this, it is reserved for migration purpose. |
int | $indexdatabase | Try to remove also index entries. |
int | $nolog | Disable log file |
Definition at line 1469 of file files.lib.php.
References $object, dol_osencode(), dol_syslog(), dolChmod(), and setEventMessages().
Referenced by archiveOrBackupFile(), ActionComm\build_exportfile(), Expedition\cancel(), Utils\compressSyslogs(), Website\createFromClone(), Commande\delete(), CommandeFournisseur\delete(), Delivery\delete(), Expedition\delete(), ExpenseReport\delete(), Facture\delete(), FactureFournisseur\delete(), Fichinter\delete(), Propal\delete(), Reception\delete(), SupplierProposal\delete(), WebsitePage\delete(), Categorie\delete_photo(), Product\delete_photo(), CommonObject\delThumbs(), dol_delete_dir_recursive(), dol_delete_preview(), dol_move(), dol_remove_file_process(), dol_uncompress(), dolReplaceInFile(), dolSaveIndexPage(), dolSaveMasterFile(), dolSavePageContent(), Utils\dumpDatabase(), Website\exportWebSite(), DolibarrModules\insert_module_parts(), migrate_delete_old_files(), Website\overwriteTemplate(), Documents\post(), 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.
object | $object | Object to clean |
Definition at line 1673 of file files.lib.php.
References $object, dol_delete_file(), and dol_sanitizeFileName().
Referenced by CommonObject\commonGenerateDocument(), Commande\delete(), ExpenseReport\delete(), Facture\delete(), Fichinter\delete(), Propal\delete(), SupplierProposal\delete(), fichinter_create(), and Don\generateDocument().
dol_dir_is_emtpy | ( | $folder | ) |
Test if a folder is empty.
string | $folder | Name of folder |
Definition at line 569 of file files.lib.php.
References dol_osencode().
dol_dir_list | ( | $utf8_path, | |
$types = "all", | |||
$recursive = 0, | |||
$filter = "", | |||
$excludefilter = null, | |||
$sortcriteria = "name", | |||
$sortorder = SORT_ASC, | |||
$mode = 0, | |||
$nohook = 0, | |||
$relativename = "", | |||
$donotfollowsymlinks = 0, | |||
$nbsecondsold = 0 ) |
Scan a directory and return a list of files/directories.
Content for string is UTF8 and dir separator is "/".
string | $utf8_path | Starting path from which to search. This is a full path. |
string | $types | Can be "directories", "files", or "all" |
int | $recursive | Determines whether subdirectories are searched |
string | $filter | Regex 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. |
string | string[] | $excludefilter | Array 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 | $sortcriteria | Sort criteria ('','fullname','relativename','name','date','size') |
int | $sortorder | Sort order (SORT_ASC, SORT_DESC) |
int | $mode | 0=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, 4=Force load of perm |
int | $nohook | Disable all hooks |
string | $relativename | For recursive purpose only. Must be "" at first call. |
int | $donotfollowsymlinks | Do not follow symbolic links |
int | $nbsecondsold | Only files older than $nbsecondsold |
Definition at line 63 of file files.lib.php.
References $object, dol_dir_list(), dol_filemtime(), dol_fileperm(), dol_filesize(), dol_now(), dol_osencode(), dol_sort_array(), dol_syslog(), and utf8_check().
Referenced by account_statement_prepare_head(), actions_prepare_head(), Partnership\approve(), assetPrepareHead(), availabilitiesPrepareHead(), bank_prepare_head(), bomPrepareHead(), calendarPrepareHead(), commande_prepare_head(), CommonObject\commonGenerateDocument(), Website\compareFichierModifie(), Utils\compressSyslogs(), conferenceorboothPrepareHead(), contact_prepare_head(), contract_prepare_head(), Project\createFromClone(), Task\createFromClone(), delivery_prepare_head(), dol_dir_list(), dol_init_file_process(), dol_most_recent_file(), dol_move_dir(), dolGetListOfObjectClasses(), donation_prepare_head(), Utils\dumpDatabase(), evaluationPrepareHead(), expensereport_prepare_head(), AccountancyExport\exportFEC(), AccountancyExport\exportFEC2(), AccountancyExport\exportQuadratus(), facture_prepare_head(), facturefourn_prepare_head(), fichinter_prepare_head(), Utils\generateDoc(), Setup\getCheckIntegrity(), FormWebsite\getContentPageTemplate(), FormFile\getDocumentsLink(), FormWebPortal\getDocumentsLink(), Documents\getDocumentsListByElement(), getListOfModels(), Asset\getNomUrl(), AssetModel\getNomUrl(), Availabilities\getNomUrl(), Calendar\getNomUrl(), ConferenceOrBooth\getNomUrl(), ConferenceOrBoothAttendee\getNomUrl(), Evaluation\getNomUrl(), EvaluationLine\getNomUrl(), Job\getNomUrl(), KnowledgeRecord\getNomUrl(), MyObject\getNomUrl(), Partnership\getNomUrl(), PartnershipType\getNomUrl(), Position\getNomUrl(), ProductAttribute\getNomUrl(), ProductFournisseurPrice\getNomUrl(), RecruitmentCandidature\getNomUrl(), RecruitmentJobPosition\getNomUrl(), Skill\getNomUrl(), Skilldet\getNomUrl(), SkillRank\getNomUrl(), StockTransfer\getNomUrl(), StockTransferLine\getNomUrl(), Target\getNomUrl(), TimeSpent\getNomUrl(), WebPortalPartnership\getNomUrl(), Workstation\getNomUrl(), holiday_prepare_head(), doc_generic_asset_odt\info(), doc_generic_bom_odt\info(), doc_generic_contract_odt\info(), doc_generic_invoice_odt\info(), doc_generic_member_odt\info(), doc_generic_mo_odt\info(), doc_generic_myobject_odt\info(), doc_generic_odt\info(), doc_generic_order_odt\info(), doc_generic_product_odt\info(), doc_generic_project_odt\info(), doc_generic_proposal_odt\info(), doc_generic_reception_odt\info(), doc_generic_recruitmentjobposition_odt\info(), doc_generic_shipment_odt\info(), doc_generic_stock_odt\info(), doc_generic_supplier_invoice_odt\info(), doc_generic_supplier_order_odt\info(), doc_generic_supplier_proposal_odt\info(), doc_generic_task_odt\info(), doc_generic_ticket_odt\info(), doc_generic_user_odt\info(), doc_generic_usergroup_odt\info(), modWebsite\init(), DolibarrModules\insert_module_parts(), jobPrepareHead(), knowledgerecordPrepareHead(), PrintingDriver\listDrivers(), loan_prepare_head(), member_prepare_head(), Societe\mergeCompany(), moPrepareHead(), myobjectPrepareHead(), ordersupplier_prepare_head(), partnershipPrepareHead(), positionCardPrepareHead(), product_prepare_head(), productlot_prepare_head(), project_prepare_head(), propal_prepare_head(), Utils\purgeFiles(), reception_prepare_head(), recruitmentCandidaturePrepareHead(), recruitmentjobpositionPrepareHead(), EcmDirectory\refreshcachenboffile(), resource_prepare_head(), FormEcm\selectAllSections(), FormWebsite\selectSampleOfContainer(), Fichinter\setValid(), ExpenseReport\setValidate(), shipping_prepare_head(), CommonObject\show_photos(), FormFile\showdocuments(), skilldetPrepareHead(), skillPrepareHead(), skillrankPrepareHead(), societe_prepare_head(), stocktransferPrepareHead(), task_prepare_head(), tax_prepare_head(), ticket_prepare_head(), user_prepare_head(), Commande\valid(), CommandeFournisseur\valid(), Delivery\valid(), Expedition\valid(), Propal\valid(), Reception\valid(), SupplierProposal\valid(), Availabilities\validate(), BOM\validate(), Calendar\validate(), ConferenceOrBoothAttendee\validate(), Contrat\validate(), Evaluation\validate(), EvaluationLine\validate(), Facture\validate(), FactureFournisseur\validate(), Holiday\validate(), Job\validate(), KnowledgeRecord\validate(), Mo\validate(), MyObject\validate(), Partnership\validate(), Position\validate(), ProductFournisseurPrice\validate(), RecruitmentCandidature\validate(), RecruitmentJobPosition\validate(), Skill\validate(), Skilldet\validate(), SkillRank\validate(), StockTransfer\validate(), StockTransferLine\validate(), Target\validate(), TimeSpent\validate(), various_payment_prepare_head(), vat_prepare_head(), workstationPrepareHead(), doc_generic_project_odt\write_file(), and doc_generic_task_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 "/".
string | $path | Starting path from which to search. Example: 'produit/MYPROD' |
string | $filter | Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function |
string[] | null | $excludefilter | Array of Regex for exclude filter (example: array('(.meta|_preview.*.png)$','^.')) |
string | $sortcriteria | Sort criteria ("","fullname","name","date","size") |
int | $sortorder | Sort order (SORT_ASC, SORT_DESC) |
int | $mode | 0=Return array minimum keys loaded (faster), 1=Force all keys like description |
Definition at line 262 of file files.lib.php.
References dol_print_error().
Referenced by completeFileArrayWithDatabaseInfo().
dol_filecache | ( | $directory, | |
$filename, | |||
$object ) |
Store object in file.
string | $directory | Directory of cache |
string | $filename | Name of filecache |
mixed | $object | Object to store in cachefile |
Definition at line 3518 of file files.lib.php.
References $object, dol_is_dir(), dol_mkdir(), dol_syslog(), and dolChmod().
Referenced by ModeleBoxes\showBox().
dol_filemtime | ( | $pathoffile | ) |
Return time of a file.
string | $pathoffile | Path of file |
Definition at line 647 of file files.lib.php.
References dol_osencode().
Referenced by ActionComm\build_exportfile(), dol_cache_refresh(), dol_dir_list(), Stats\getAllByProductEntry(), Stats\getAmountByMonthWithPrevYear(), Setup\getCheckIntegrity(), Stats\getNbByMonthWithPrevYear(), ProjectStats\getTransformRateByMonthWithPrevYear(), ProjectStats\getWeightedAmountByMonthWithPrevYear(), ICal\parse(), RssParser\parser(), FormFile\showdocuments(), and showWebsiteTemplates().
dol_fileperm | ( | $pathoffile | ) |
Return permissions of a file.
string | $pathoffile | Path of file |
Definition at line 659 of file files.lib.php.
References dol_osencode().
Referenced by dol_dir_list().
dol_filesize | ( | $pathoffile | ) |
Return size of a file.
string | $pathoffile | Path of file |
Definition at line 635 of file files.lib.php.
References dol_osencode().
Referenced by Utils\compressSyslogs(), DocumentController\display(), dol_dir_list(), AccountancyExport\export(), Setup\getCheckIntegrity(), FileUpload\handleFileUpload(), Utils\sendBackup(), FormFile\showdocuments(), showWebsiteTemplates(), and FileUpload\validate().
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()
string | $pathtoscan | Path to scan |
string | $trackid | Track id (used to prefix name of session vars to avoid conflict) |
Definition at line 1836 of file files.lib.php.
References dol_dir_list(), and dol_mimetype().
dol_is_dir | ( | $folder | ) |
Test if filename is a directory.
string | $folder | Name of folder |
Definition at line 489 of file files.lib.php.
References dol_osencode().
Referenced by Ticket\copyFilesForTicket(), Don\delete(), Societe\delete(), Ticket\delete(), dol_delete_dir_recursive(), dol_filecache(), dol_move_dir(), dolCopyDir(), AccountancyExport\export(), CMailFile\findHtmlImagesIsSrcData(), Utils\generateDoc(), Stats\getAllByProductEntry(), Stats\getAmountByMonthWithPrevYear(), Stats\getNbByMonthWithPrevYear(), ProjectStats\getTransformRateByMonthWithPrevYear(), ProjectStats\getWeightedAmountByMonthWithPrevYear(), Societe\mergeCompany(), migrate_product_photospath(), migrate_user_filespath(), migrate_user_photospath(), migrate_user_photospath2(), RssParser\parser(), Documents\post(), and treeOutputForAbsoluteDir().
dol_is_dir_empty | ( | $dir | ) |
Return if path is empty.
string | $dir | Path of Directory |
Definition at line 505 of file files.lib.php.
dol_is_file | ( | $pathoffile | ) |
Return if path is a file.
string | $pathoffile | Path of file |
Definition at line 519 of file files.lib.php.
References dol_osencode().
Referenced by checkPHPCode(), CommonObject\commonGenerateDocument(), Utils\compressSyslogs(), deletePropsAndPermsFromDoc(), dol_convert_file(), dol_copy(), dol_move(), dolReplaceInFile(), dolSavePageContent(), Website\exportWebSite(), CMailFile\findHtmlImagesIsSrcData(), DolibarrModules\getChangeLog(), Setup\getCheckIntegrity(), DolibarrModules\getDescLongReadmeFound(), FileUpload\getFileObject(), getHtmlOfLayout(), FileUpload\handleFileUpload(), BOM\is_photo_available(), Product\is_photo_available(), Ticket\is_photo_available(), Categorie\isAnyPhotoAvailable(), FormFile\list_of_documents(), Categorie\liste_photos(), Product\liste_photos(), migrate_product_photospath(), migrate_user_filespath(), migrate_user_photospath(), migrate_user_photospath2(), Website\overwriteTemplate(), Documents\post(), rebuild_merge_pdf(), rebuildObjectClass(), rebuildObjectSql(), Notify\send(), Utils\sendBackup(), CommonObject\show_photos(), FileUpload\trimFileName(), and writeApiUrlsInDoc().
dol_is_link | ( | $pathoffile | ) |
Return if path is a symbolic link.
string | $pathoffile | Path of file |
Definition at line 531 of file files.lib.php.
References dol_osencode().
dol_is_url | ( | $uri | ) |
Return if path is an URI (the name of the method is misleading).
URLs are addresses for websites, URI refer to online resources.
string | $uri | URI to test |
Definition at line 557 of file files.lib.php.
Referenced by RssParser\parser().
dol_is_writable | ( | $folderorfile | ) |
Test if directory or filename is writable.
string | $folderorfile | Name of folder or filename |
Definition at line 543 of file files.lib.php.
References dol_osencode().
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.
CommonObject | $object | Object |
Definition at line 1751 of file files.lib.php.
References $object, dol_mkdir(), dol_print_date(), dol_sanitizeFileName(), dol_syslog(), dolChmod(), and getDolGlobalString().
Referenced by CommonObject\commonGenerateDocument().
dol_most_recent_file | ( | $dir, | |
$regexfilter = '', | |||
$excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), | |||
$nohook = 0, | |||
$mode = 0 ) |
Return file(s) into a directory (by default most recent)
string | $dir | Directory to scan |
string | $regexfilter | Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function |
string[] | $excludefilter | Array 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<0,1> | $nohook Disable all hooks | |
int<0,3> | $mode 0=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 |
Definition at line 2718 of file files.lib.php.
References dol_dir_list().
Referenced by Utils\sendBackup().
dol_move | ( | $srcfile, | |
$destfile, | |||
$newmask = '0', | |||
$overwriteifexists = 1, | |||
$testvirus = 0, | |||
$indexdatabase = 1, | |||
$moreinfo = array() ) |
Move a file into another name.
Note:
string | $srcfile | Source file (can't be a directory. use native php @rename() to move a directory) |
string | $destfile | Destination file (can't be a directory. use native php @rename() to move a directory) |
string | $newmask | Mask in octal string for new file ('0' by default means $conf->global->MAIN_UMASK) |
int | $overwriteifexists | Overwrite file if exists (1 by default) |
int | $testvirus | Do an antivirus test. Move is canceled if a virus is found. |
int | $indexdatabase | Index new file into database. |
array | $moreinfo | Array with more information to set in index table |
Definition at line 1011 of file files.lib.php.
References dol_delete_file(), dol_is_file(), dol_osencode(), dol_syslog(), dolCheckOnFileName(), dolCheckVirus(), dolChmod(), getDolGlobalString(), and setEventMessages().
Referenced by archiveOrBackupFile(), ActionComm\build_exportfile(), Utils\compressSyslogs(), Ticket\copyFilesForTicket(), dol_move_dir(), dolReplaceInFile(), CMailFile\dump_mail(), Utils\dumpDatabase(), Societe\mergeCompany(), migrate_product_photospath(), migrate_user_filespath(), Website\overwriteTemplate(), Documents\post(), and CMailFile\save_dump_mail_in_err().
dol_move_dir | ( | $srcdir, | |
$destdir, | |||
$overwriteifexists = 1, | |||
$indexdatabase = 1, | |||
$renamedircontent = 1 ) |
Move a directory into another name.
string | $srcdir | Source directory |
string | $destdir | Destination directory |
int | $overwriteifexists | Overwrite directory if it already exists (1 by default) |
int | $indexdatabase | Index new name of files into database. |
int | $renamedircontent | Also rename contents inside srcdir after the move to match new destination name. |
Definition at line 1175 of file files.lib.php.
References dol_dir_list(), dol_is_dir(), dol_move(), dol_move_dir(), dol_osencode(), and dol_syslog().
Referenced by dol_move_dir(), and Task\update().
dol_move_uploaded_file | ( | $src_file, | |
$dest_file, | |||
$allowoverwrite, | |||
$disablevirusscan = 0, | |||
$uploaderrorcode = 0, | |||
$nohook = 0, | |||
$varfiles = 'addedfile', | |||
$upload_dir = '' ) |
Check validity of a file upload from an GUI page, and move it to its final destination.
If there is errors (virus found, antivir in error, bad filename), file is not moved. Note:
string | $src_file | Source full path filename ($_FILES['field']['tmp_name']) |
string | $dest_file | Target full path filename ($_FILES['field']['name']) |
int | $allowoverwrite | 1=Overwrite target file if it already exists |
int | $disablevirusscan | 1=Disable virus scan |
integer | $uploaderrorcode | Value of PHP upload error code ($_FILES['field']['error']) |
int | $nohook | Disable all hooks |
string | $varfiles | _FILES var name |
string | $upload_dir | For information. Already included into $dest_file. |
Definition at line 1331 of file files.lib.php.
References $object, dol_osencode(), dol_syslog(), dolCheckVirus(), dolChmod(), getDolGlobalInt(), getDolGlobalString(), and isAFileWithExecutableContent().
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.
string | $directory | Directory of cache |
string | $filename | Name of filecache |
Definition at line 3556 of file files.lib.php.
References $object.
Referenced by 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.
int | $filenb | File nb to delete |
int | $donotupdatesession | -1 or 1 = Do not update _SESSION variable |
int | $donotdeletefile | 1=Do not delete physically file |
string | $trackid | Track id (used to prefix name of session vars to avoid conflict) |
Definition at line 2055 of file files.lib.php.
References dol_delete_file(), and setEventMessages().
dol_uncompress | ( | $inputfile, | |
$outputdir ) |
Uncompress a file.
string | $inputfile | File to uncompress |
string | $outputdir | Target dir name |
Definition at line 2464 of file files.lib.php.
References dol_delete_file(), dol_mkdir(), dol_sanitizeFileName(), dol_sanitizePathName(), dol_syslog(), and getDolGlobalString().
Referenced by Website\overwriteTemplate().
dol_unescapefile | ( | $filename | ) |
Unescape a file submitted by upload.
PHP escape char " (%22) or char ' (%27) into $FILES.
string | $filename | Filename |
Definition at line 1246 of file files.lib.php.
dolCheckOnFileName | ( | $src_file, | |
$dest_file = '' ) |
Check virus into a file.
string | $src_file | Source file to check |
string | $dest_file | Destination file name (to know the expected type) |
Definition at line 1292 of file files.lib.php.
References dol_syslog(), and getDolGlobalString().
Referenced by dol_move(), and dolCheckVirus().
dolCheckVirus | ( | $src_file, | |
$dest_file = '' ) |
Check virus into a file.
string | $src_file | Source file to check |
string | $dest_file | Destination file name (to know the expected type) |
Definition at line 1262 of file files.lib.php.
References dolCheckOnFileName(), and getDolGlobalString().
Referenced by dol_copy(), dol_move(), dol_move_uploaded_file(), and Documents\post().
dolCopyDir | ( | $srcfile, | |
$destfile, | |||
$newmask, | |||
$overwriteifexists, | |||
$arrayreplacement = null, | |||
$excludesubdir = 0, | |||
$excludefileext = null, | |||
$excludearchivefiles = 0 ) |
Copy a dir to another dir.
This include recursive subdirectories.
string | $srcfile | Source file (a directory) |
string | $destfile | Destination file (a directory) |
string | $newmask | Mask for new file ('0' by default means getDolGlobalString('MAIN_UMASK')). Example: '0666' |
int | $overwriteifexists | Overwrite file if exists (1 by default) |
array<string,string> | $arrayreplacement Array to use to replace filenames with another one during the copy (works only on file names, not on directory names). | |
int | $excludesubdir | 0=Do not exclude subdirectories, 1=Exclude subdirectories, 2=Exclude subdirectories if name is not a 2 chars (used for country codes subdirectories). |
string[] | $excludefileext | Exclude some file extensions |
int | $excludearchivefiles | Exclude archive files that begin with v+timestamp or d+timestamp (0 by default) |
Definition at line 896 of file files.lib.php.
References dol_copy(), dol_is_dir(), dol_mkdir(), dol_osencode(), dol_syslog(), dolCopyDir(), and getDolGlobalString().
Referenced by Website\createFromClone(), dolCopyDir(), Website\exportWebSite(), and modWebsite\init().
dolReplaceInFile | ( | $srcfile, | |
$arrayreplacement, | |||
$destfile = '', | |||
$newmask = '0', | |||
$indexdatabase = 0, | |||
$arrayreplacementisregex = 0 ) |
Make replacement of strings into a file.
string | $srcfile | Source file (can't be a directory) |
array<string,string> | $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...) | |
string | $destfile | Destination file (can't be a directory). If empty, will be same than source file. |
string | $newmask | Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' |
int | $indexdatabase | 1=index new file into database. |
int | $arrayreplacementisregex | 1=Array of replacement is already an array with key that is a regex. Warning: the key must be escaped with preg_quote for '/' |
Definition at line 677 of file files.lib.php.
References dol_delete_file(), dol_is_file(), dol_move(), dol_osencode(), dol_syslog(), dolChmod(), getDolGlobalString(), and make_substitutions().
Referenced by addObjectsToApiFile(), deletePerms(), Website\exportWebSite(), Utils\generateDoc(), removeObjectFromApiFile(), Website\replaceLineUsingNum(), reWriteAllMenus(), reWriteAllPermissions(), updateDictionaryInFile(), writeApiUrlsInDoc(), writePermsInAsciiDoc(), and writePropsInAsciiDoc().
dragAndDropFileUpload | ( | $htmlname | ) |
Function to manage the drag and drop of a file.
We use global variable $object
string | $htmlname | The id of the component where we need to drag and drop |
Definition at line 3628 of file files.lib.php.
References $object, currentToken(), dol_escape_js(), and img_picto().
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
array | $file_list | Array for response |
SimpleXMLElement | $dir | SimpleXMLElement of files to test |
string | $path | Path of files relative to $pathref. We start with ''. Used by recursive calls. |
string | $pathref | Path ref (DOL_DOCUMENT_ROOT) |
array | $checksumconcat | Array of checksum |
Definition at line 3586 of file files.lib.php.
References getFilesUpdated().
Referenced by Setup\getCheckIntegrity(), and getFilesUpdated().