dolibarr  9.0.0
purge.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2006-2012 Regis Houssin <regis.houssin@inodbox.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
24 require '../../main.inc.php';
25 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
26 
27 $langs->load("admin");
28 
29 if (! $user->admin)
31 
32 $action=GETPOST('action','alpha');
33 $confirm=GETPOST('confirm','alpha');
34 $choice=GETPOST('choice','aZ09');
35 
36 
37 // Define filelog to discard it from purge
38 $filelog='';
39 if (! empty($conf->syslog->enabled))
40 {
41  $filelog=$conf->global->SYSLOG_FILE;
42  $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
43 }
44 
45 
46 /*
47  * Actions
48  */
49 if ($action=='purge' && ! preg_match('/^confirm/i',$choice) && ($choice != 'allfiles' || $confirm == 'yes') )
50 {
51  require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
52  $utils = new Utils($db);
53  $result = $utils->purgeFiles($choice);
54 
55  $mesg = $utils->output;
56  setEventMessages($mesg, null, 'mesgs');
57 }
58 
59 
60 /*
61  * View
62  */
63 
64 llxHeader();
65 
66 $form=new Form($db);
67 
68 print load_fiche_titre($langs->trans("Purge"),'','title_setup');
69 
70 print $langs->trans("PurgeAreaDesc",$dolibarr_main_data_root).'<br>';
71 print '<br>';
72 
73 
74 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
76 print '<input type="hidden" name="action" value="purge" />';
77 
78 print '<table class="border" width="100%">';
79 
80 print '<tr class="border"><td style="padding: 4px">';
81 
82 if (! empty($conf->syslog->enabled))
83 {
84  print '<input type="radio" name="choice" value="logfile"';
85  print ($choice && $choice=='logfile') ? ' checked' : '';
86  $filelogparam=$filelog;
87  if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog)))
88  {
89  $filelogparam ='<a class="wordbreak" href="'.DOL_URL_ROOT.'/document.php?modulepart=logs&file=';
90  $filelogparam.=basename($filelog);
91  $filelogparam.='">'.$filelog.'</a>';
92  }
93  print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam);
94  print '<br><br>';
95 }
96 
97 print '<input type="radio" name="choice" value="tempfiles"';
98 print (! $choice || $choice=='tempfiles' || $choice=='allfiles') ? ' checked' : '';
99 print '> '.$langs->trans("PurgeDeleteTemporaryFiles").'<br><br>';
100 
101 print '<input type="radio" name="choice" value="confirm_allfiles"';
102 print ($choice && $choice=='confirm_allfiles') ? ' checked' : '';
103 print '> '.$langs->trans("PurgeDeleteAllFilesInDocumentsDir",$dolibarr_main_data_root).'<br>';
104 
105 print '</td></tr></table>';
106 
107 //if ($choice != 'confirm_allfiles')
108 //{
109  print '<br>';
110  print '<div class="center"><input class="button" type="submit" value="'.$langs->trans("PurgeRunNow").'"></div>';
111 //}
112 
113 print '</form>';
114 
115 if (preg_match('/^confirm/i',$choice))
116 {
117  print '<br>';
118  $formquestion=array();
119  print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2);
120 }
121 
122 // End of page
123 llxFooter();
124 $db->close();
Class to manage utility methods.
Definition: utils.class.php:28
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
llxHeader()
Empty header.
Definition: wrapper.php:44