dolibarr  7.0.0-beta
utils.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016 Destailleur Laurent <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
28 class Utils
29 {
30  var $db;
31 
32  var $output; // Used by Cron method to return message
33  var $result; // Used by Cron method to return data
34 
40  function __construct($db)
41  {
42  $this->db = $db;
43  }
44 
45 
53  function purgeFiles($choice='tempfilesold')
54  {
55  global $conf, $langs, $dolibarr_main_data_root;
56 
57  $langs->load("admin");
58 
59  dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG);
60  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
61 
62  $filesarray=array();
63  if (empty($choice)) $choice='tempfilesold';
64 
65  if ($choice=='tempfiles' || $choice=='tempfilesold')
66  {
67  // Delete temporary files
68  if ($dolibarr_main_data_root)
69  {
70  $filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'^temp$','','','',2);
71  if ($choice == 'tempfilesold')
72  {
73  $now = dol_now();
74  foreach($filesarray as $key => $val)
75  {
76  if ($val['date'] > ($now - (24 * 3600))) unset($filesarray[$key]); // Discard files not older than 24h
77  }
78  }
79  }
80  }
81 
82  if ($choice=='allfiles')
83  {
84  // Delete all files (except install.lock)
85  if ($dolibarr_main_data_root)
86  {
87  $filesarray=dol_dir_list($dolibarr_main_data_root,"all",0,'','install\.lock$');
88  }
89  }
90 
91  if ($choice=='logfile')
92  {
93  // Define files log
94  if ($dolibarr_main_data_root)
95  {
96  $filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$');
97  }
98 
99  $filelog='';
100  if (! empty($conf->syslog->enabled))
101  {
102  $filelog=$conf->global->SYSLOG_FILE;
103  $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
104 
105  $alreadyincluded=false;
106  foreach ($filesarray as $tmpcursor)
107  {
108  if ($tmpcursor['fullname'] == $filelog) { $alreadyincluded=true; }
109  }
110  if (! $alreadyincluded) $filesarray[]=array('fullname'=>$filelog,'type'=>'file');
111  }
112  }
113 
114  $count=0;
115  $countdeleted=0;
116  $counterror=0;
117  if (count($filesarray))
118  {
119  foreach($filesarray as $key => $value)
120  {
121  //print "x ".$filesarray[$key]['fullname']."-".$filesarray[$key]['type']."<br>\n";
122  if ($filesarray[$key]['type'] == 'dir')
123  {
124  $startcount=0;
125  $tmpcountdeleted=0;
126  $result=dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted);
127  $count+=$result;
128  $countdeleted+=$tmpcountdeleted;
129  }
130  elseif ($filesarray[$key]['type'] == 'file')
131  {
132  // If (file that is not logfile) or (if logfile with option logfile)
133  if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
134  {
135  $result=dol_delete_file($filesarray[$key]['fullname'], 1, 1);
136  if ($result)
137  {
138  $count++;
139  $countdeleted++;
140  }
141  else $counterror++;
142  }
143  }
144  }
145 
146  // Update cachenbofdoc
147  if (! empty($conf->ecm->enabled) && $choice=='allfiles')
148  {
149  require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
150  $ecmdirstatic = new EcmDirectory($this->db);
151  $result = $ecmdirstatic->refreshcachenboffile(1);
152  }
153  }
154 
155  if ($count > 0)
156  {
157  $this->output=$langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
158  if ($count > $countdeleted) $this->output.='<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
159  }
160  else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':'');
161 
162  //return $count;
163  return 0; // This function can be called by cron so must return 0 if OK
164  }
165 
166 
178  function dumpDatabase($compression='none', $type='auto', $usedefault=1, $file='auto', $keeplastnfiles=0)
179  {
180  global $db, $conf, $langs, $dolibarr_main_data_root;
181  global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass;
182 
183 
184  $langs->load("admin");
185 
186  dol_syslog("Utils::dumpDatabase type=".$type." compression=".$compression." file=".$file, LOG_DEBUG);
187  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
188 
189  // Check compression parameter
190  if (! in_array($compression, array('none', 'gz', 'bz', 'zip')))
191  {
192  $langs->load("errors");
193  $this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $compression, "Compression");
194  return -1;
195  }
196 
197  // Check type parameter
198  if ($type == 'auto') $type = $db->type;
199  if (! in_array($type, array('postgresql', 'pgsql', 'mysql', 'mysqli', 'mysqlnobin')))
200  {
201  $langs->load("errors");
202  $this->error=$langs->transnoentitiesnoconv("ErrorBadValueForParameter", $type, "Basetype");
203  return -1;
204  }
205 
206  // Check file parameter
207  if ($file == 'auto')
208  {
209  $prefix='dump';
210  $ext='.sql';
211  if (in_array($type, array('mysql', 'mysqli'))) { $prefix='mysqldump'; $ext='sql'; }
212  //if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; }
213  if (in_array($type, array('pgsql'))) { $prefix='pg_dump'; $ext='sql'; }
214  $file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext;
215  }
216 
217  $outputdir = $conf->admin->dir_output.'/backup';
218  $result=dol_mkdir($outputdir);
219 
220 
221  // MYSQL
222  if ($type == 'mysql' || $type == 'mysqli')
223  {
224  $cmddump=$conf->global->SYSTEMTOOLS_MYSQLDUMP;
225 
226 
227  $outputfile = $outputdir.'/'.$file;
228  // for compression format, we add extension
229  $compression=$compression ? $compression : 'none';
230  if ($compression == 'gz') $outputfile.='.gz';
231  if ($compression == 'bz') $outputfile.='.bz2';
232  $outputerror = $outputfile.'.err';
233  dol_mkdir($conf->admin->dir_output.'/backup');
234 
235  // Parameteres execution
236  $command=$cmddump;
237  if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
238 
239  //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
240  $param=$dolibarr_main_db_name." -h ".$dolibarr_main_db_host;
241  $param.=" -u ".$dolibarr_main_db_user;
242  if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port;
243  if (! GETPOST("use_transaction")) $param.=" -l --single-transaction";
244  if (GETPOST("disable_fk") || $usedefault) $param.=" -K";
245  if (GETPOST("sql_compat") && GETPOST("sql_compat") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat","alpha"));
246  if (GETPOST("drop_database")) $param.=" --add-drop-database";
247  if (GETPOST("sql_structure") || $usedefault)
248  {
249  if (GETPOST("drop") || $usedefault) $param.=" --add-drop-table=TRUE";
250  else $param.=" --add-drop-table=FALSE";
251  }
252  else
253  {
254  $param.=" -t";
255  }
256  if (GETPOST("disable-add-locks")) $param.=" --add-locks=FALSE";
257  if (GETPOST("sql_data") || $usedefault)
258  {
259  $param.=" --tables";
260  if (GETPOST("showcolumns") || $usedefault) $param.=" -c";
261  if (GETPOST("extended_ins") || $usedefault) $param.=" -e";
262  else $param.=" --skip-extended-insert";
263  if (GETPOST("delayed")) $param.=" --delayed-insert";
264  if (GETPOST("sql_ignore")) $param.=" --insert-ignore";
265  if (GETPOST("hexforbinary") || $usedefault) $param.=" --hex-blob";
266  }
267  else
268  {
269  $param.=" -d"; // No row information (no data)
270  }
271  $param.=" --default-character-set=utf8"; // We always save output into utf8 charset
272  $paramcrypted=$param;
273  $paramclear=$param;
274  if (! empty($dolibarr_main_db_pass))
275  {
276  $paramcrypted.=' -p"'.preg_replace('/./i','*',$dolibarr_main_db_pass).'"';
277  $paramclear.=' -p"'.str_replace(array('"','`'),array('\"','\`'),$dolibarr_main_db_pass).'"';
278  }
279 
280  $errormsg='';
281 
282  // Debut appel methode execution
283  $fullcommandcrypted=$command." ".$paramcrypted." 2>&1";
284  $fullcommandclear=$command." ".$paramclear." 2>&1";
285  if ($compression == 'none') $handle = fopen($outputfile, 'w');
286  if ($compression == 'gz') $handle = gzopen($outputfile, 'w');
287  if ($compression == 'bz') $handle = bzopen($outputfile, 'w');
288 
289  if ($handle)
290  {
291  $ok=0;
292  dol_syslog("Run command ".$fullcommandcrypted);
293  $handlein = popen($fullcommandclear, 'r');
294  $i=0;
295  while (!feof($handlein))
296  {
297  $i++; // output line number
298  $read = fgets($handlein);
299  // Exclude warning line we don't want
300  if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue;
301  fwrite($handle,$read);
302  if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1;
303  elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1;
304  }
305  pclose($handlein);
306 
307  if ($compression == 'none') fclose($handle);
308  if ($compression == 'gz') gzclose($handle);
309  if ($compression == 'bz') bzclose($handle);
310 
311  if (! empty($conf->global->MAIN_UMASK))
312  @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
313  }
314  else
315  {
316  $langs->load("errors");
317  dol_syslog("Failed to open file ".$outputfile,LOG_ERR);
318  $errormsg=$langs->trans("ErrorFailedToWriteInDir");
319  }
320 
321  // Get errorstring
322  if ($compression == 'none') $handle = fopen($outputfile, 'r');
323  if ($compression == 'gz') $handle = gzopen($outputfile, 'r');
324  if ($compression == 'bz') $handle = bzopen($outputfile, 'r');
325  if ($handle)
326  {
327  // Get 2048 first chars of error message.
328  $errormsg = fgets($handle,2048);
329  // Close file
330  if ($compression == 'none') fclose($handle);
331  if ($compression == 'gz') gzclose($handle);
332  if ($compression == 'bz') bzclose($handle);
333  if ($ok && preg_match('/^-- MySql/i',$errormsg)) $errormsg=''; // Pas erreur
334  else
335  {
336  // Renommer fichier sortie en fichier erreur
337  //print "$outputfile -> $outputerror";
338  @dol_delete_file($outputerror,1);
339  @rename($outputfile,$outputerror);
340  // Si safe_mode on et command hors du parametre exec, on a un fichier out vide donc errormsg vide
341  if (! $errormsg)
342  {
343  $langs->load("errors");
344  $errormsg=$langs->trans("ErrorFailedToRunExternalCommand");
345  }
346  }
347  }
348  // Fin execution commande
349 
350  $this->output = $errormsg;
351  $this->error = $errormsg;
352  $this->result = array("commandbackuplastdone" => $command." ".$paramcrypted, "commandbackuptorun" => "");
353  //if (empty($this->output)) $this->output=$this->result['commandbackuplastdone'];
354  }
355 
356  // MYSQL NO BIN
357  if ($type == 'mysqlnobin')
358  {
359  $outputfile = $outputdir.'/'.$file;
360  $outputfiletemp = $outputfile.'-TMP.sql';
361  // for compression format, we add extension
362  $compression=$compression ? $compression : 'none';
363  if ($compression == 'gz') $outputfile.='.gz';
364  if ($compression == 'bz') $outputfile.='.bz2';
365  $outputerror = $outputfile.'.err';
366  dol_mkdir($conf->admin->dir_output.'/backup');
367 
368  if ($compression == 'gz' or $compression == 'bz')
369  {
370  backup_tables($outputfiletemp);
371  dol_compress_file($outputfiletemp, $outputfile, $compression);
372  unlink($outputfiletemp);
373  }
374  else
375  {
376  backup_tables($outputfile);
377  }
378 
379  $this->output = "";
380  $this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => "");
381  }
382 
383  // POSTGRESQL
384  if ($type == 'postgresql' || $type == 'pgsql')
385  {
386  $cmddump=$conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
387 
388  $outputfile = $outputdir.'/'.$file;
389  // for compression format, we add extension
390  $compression=$compression ? $compression : 'none';
391  if ($compression == 'gz') $outputfile.='.gz';
392  if ($compression == 'bz') $outputfile.='.bz2';
393  $outputerror = $outputfile.'.err';
394  dol_mkdir($conf->admin->dir_output.'/backup');
395 
396  // Parameteres execution
397  $command=$cmddump;
398  if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command
399 
400  //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass);
401  //$param="-F c";
402  $param="-F p";
403  $param.=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host;
404  $param.=" -U ".$dolibarr_main_db_user;
405  if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port;
406  if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param.=" --disable-dollar-quoting";
407  if (GETPOST("drop_database")) $param.=" -c -C";
408  if (GETPOST("sql_structure"))
409  {
410  if (GETPOST("drop")) $param.=" --add-drop-table";
411  if (! GETPOST("sql_data")) $param.=" -s";
412  }
413  if (GETPOST("sql_data"))
414  {
415  if (! GETPOST("sql_structure")) $param.=" -a";
416  if (GETPOST("showcolumns")) $param.=" -c";
417  }
418  $param.=' -f "'.$outputfile.'"';
419  //if ($compression == 'none')
420  if ($compression == 'gz') $param.=' -Z 9';
421  //if ($compression == 'bz')
422  $paramcrypted=$param;
423  $paramclear=$param;
424  /*if (! empty($dolibarr_main_db_pass))
425  {
426  $paramcrypted.=" -W".preg_replace('/./i','*',$dolibarr_main_db_pass);
427  $paramclear.=" -W".$dolibarr_main_db_pass;
428  }*/
429  $paramcrypted.=" -w ".$dolibarr_main_db_name;
430  $paramclear.=" -w ".$dolibarr_main_db_name;
431 
432  $this->output = "";
433  $this->result = array("commandbackuplastdone" => "", "commandbackuptorun" => $command." ".$paramcrypted);
434  }
435 
436  // Clean old files
437  if ($keeplastnfiles > 0)
438  {
439  $tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC);
440  $i=0;
441  foreach($tmpfiles as $key => $val)
442  {
443  $i++;
444  if ($i <= $keeplastnfiles) continue;
445  dol_delete_file($val['fullname']);
446  }
447  }
448 
449 
450  return 0;
451  }
452 
453 
454 
463  function executeCLI($command, $outputfile, $execmethod=0)
464  {
465  global $conf, $langs;
466 
467  $result = 0;
468  $output = '';
469  $error = '';
470 
471  $command=escapeshellcmd($command);
472  $command.=" 2>&1";
473 
474  if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod=$conf->global->MAIN_EXEC_USE_POPEN;
475  if (empty($execmethod)) $execmethod=1;
476  //$execmethod=1;
477 
478  dol_syslog("Utils::executeCLI execmethod=".$execmethod." system:".$command, LOG_DEBUG);
479  $output_arr=array();
480 
481  if ($execmethod == 1)
482  {
483  exec($command, $output_arr, $retval);
484  $result = $retval;
485  if ($retval != 0)
486  {
487  $langs->load("errors");
488  dol_syslog("Utils::executeCLI retval after exec=".$retval, LOG_ERR);
489  $error = 'Error '.$retval;
490  }
491  }
492  if ($execmethod == 2) // With this method, there is no way to get the return code, only output
493  {
494  $ok=0;
495  $handle = fopen($outputfile, 'w+b');
496  if ($handle)
497  {
498  dol_syslog("Utils::executeCLI run command ".$command);
499  $handlein = popen($command, 'r');
500  while (!feof($handlein))
501  {
502  $read = fgets($handlein);
503  fwrite($handle,$read);
504  $output_arr[]=$read;
505  }
506  pclose($handlein);
507  fclose($handle);
508  }
509  if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
510  }
511 
512  // Update with result
513  if (is_array($output_arr) && count($output_arr)>0)
514  {
515  foreach($output_arr as $val)
516  {
517  $output.=$val.($execmethod == 2 ? '' : "\n");
518  }
519  }
520 
521  dol_syslog("Utils::executeCLI result=".$result." output=".$output." error=".$error, LOG_DEBUG);
522 
523  return array('result'=>$result, 'output'=>$output, 'error'=>$error);
524  }
525 
532  function generateDoc($module)
533  {
534  global $conf, $langs;
535  global $dirins;
536 
537  $error = 0;
538 
539  $modulelowercase=strtolower($module);
540 
541  // Dir for module
542  $dir = $dirins.'/'.$modulelowercase;
543  // Zip file to build
544  $FILENAMEDOC='';
545 
546  // Load module
547  dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
548  $class='mod'.$module;
549 
550  if (class_exists($class))
551  {
552  try {
553  $moduleobj = new $class($this->db);
554  }
555  catch(Exception $e)
556  {
557  $error++;
558  dol_print_error($e->getMessage());
559  }
560  }
561  else
562  {
563  $error++;
564  $langs->load("errors");
565  dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module));
566  exit;
567  }
568 
569  $arrayversion=explode('.',$moduleobj->version,3);
570  if (count($arrayversion))
571  {
572  $FILENAMEASCII=strtolower($module).'.asciidoc';
573  $FILENAMEDOC=strtolower($module).'.html'; // TODO Use/text PDF
574 
575  $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
576  $dirofmoduletmp = dol_buildpath(strtolower($module), 0).'/doc/temp';
577  $outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
578  if ($dirofmodule)
579  {
580  if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule);
581  if (! dol_is_dir($dirofmoduletmp)) dol_mkdir($dirofmoduletmp);
582  if (! is_writable($dirofmoduletmp))
583  {
584  $this->error = 'Dir '.$dirofmoduletmp.' does not exists or is not writable';
585  return -1;
586  }
587 
588  $destfile=$dirofmoduletmp.'/'.$FILENAMEASCII;
589 
590  $fhandle = fopen($destfile, 'w+');
591  if ($fhandle)
592  {
593  $specs=dol_dir_list(dol_buildpath(strtolower($module).'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/'));
594 
595  $i = 0;
596  foreach ($specs as $spec)
597  {
598  if (preg_match('/notindoc/', $spec['relativename'])) continue; // Discard file
599  if (preg_match('/disabled/', $spec['relativename'])) continue; // Discard file
600 
601  $pathtofile = strtolower($module).'/doc/'.$spec['relativename'];
602  $format='asciidoc';
603  if (preg_match('/\.md$/i', $spec['name'])) $format='markdown';
604 
605  $filecursor = @file_get_contents($spec['fullname']);
606  if ($filecursor)
607  {
608  fwrite($fhandle, ($i ? "\n<<<\n\n" : "").$filecursor."\n");
609  }
610  else
611  {
612  $this->error = 'Failed to concat content of file '.$spec['fullname'];
613  return -1;
614  }
615 
616  $i++;
617  }
618 
619  fwrite($fhandle, "\n\n\n== DATA SPECIFICATIONS...\n\n");
620 
621  // TODO
622  fwrite($fhandle, "TODO...");
623 
624  fclose($fhandle);
625  }
626 
627  $conf->global->MODULEBUILDER_ASCIIDOCTOR='asciidoctor';
628  if (empty($conf->global->MODULEBUILDER_ASCIIDOCTOR))
629  {
630  dol_print_error('', 'Module setup not complete');
631  exit;
632  }
633 
634  $command=$conf->global->MODULEBUILDER_ASCIIDOCTOR.' '.$destfile.' -n -o '.$dirofmodule.'/'.$FILENAMEDOC;
635  $outfile=$dirofmoduletmp.'/out.tmp';
636 
637  require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
638  $utils = new Utils($db);
639  $resarray = $utils->executeCLI($command, $outfile);
640  if ($resarray['result'] != '0')
641  {
642  $this->error = $resarray['error'].' '.$resarray['output'];
643  }
644  $result = ($resarray['result'] == 0) ? 1 : 0;
645  }
646  else
647  {
648  $result = 0;
649  }
650 
651  if ($result > 0)
652  {
653  return 1;
654  }
655  else
656  {
657  $error++;
658  $langs->load("errors");
659  $this->error = $langs->trans("ErrorFailToGenerateFile", $outputfiledoc);
660  }
661  }
662  else
663  {
664  $error++;
665  $langs->load("errors");
666  $this->error = $langs->trans("ErrorCheckVersionIsDefined");
667  }
668 
669  return -1;
670  }
671 }
Class to manage utility methods.
Definition: utils.class.php:28
dol_compress_file($inputfile, $outputfile, $mode="gz")
Compress a file.
Definition: files.lib.php:1738
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
executeCLI($command, $outputfile, $execmethod=0)
Execute a CLI command.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:414
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
Definition: files.lib.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
dumpDatabase($compression='none', $type='auto', $usedefault=1, $file='auto', $keeplastnfiles=0)
Make a backup of database CAN BE A CRON TASK.
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) ...
Definition: files.lib.php:1234
dol_now($mode='gmt')
Return date for now.
purgeFiles($choice='tempfilesold')
Purge files into directory of data files.
Definition: utils.class.php:53
generateDoc($module)
Generate documentation of a Module.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Return a prefix to use for this Dolibarr instance, for session/cookie names or email id...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null)
Remove a file or several files with a mask.
Definition: files.lib.php:1103
__construct($db)
Constructor.
Definition: utils.class.php:40
Class to manage ECM directories.