From 74608799f7e503f70b8cf1fd6c390f9e7a4f05fc Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Sat, 11 Nov 2006 14:47:37 +0000
Subject: [PATCH] =?UTF-8?q?New:=20Ajout=20page=20admin=20pour=20purger=20l?=
 =?UTF-8?q?es=20fichiers=20de=20documents=20New:=20Quelques=20am=E9liorati?=
 =?UTF-8?q?ons=20mineures=20sur=20exp=E9ditions=20Trad:=20Un=20peu=20plus?=
 =?UTF-8?q?=20de=20traduction=20sur=20exp=E9ditions?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/admin/tools/purge.php | 122 +++++++++++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)
 create mode 100644 htdocs/admin/tools/purge.php

diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php
new file mode 100644
index 00000000000..0c2aaafbd62
--- /dev/null
+++ b/htdocs/admin/tools/purge.php
@@ -0,0 +1,122 @@
+<?php
+/* Copyright (C) 2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ * $Source$
+ */
+
+/**
+		\file 		htdocs/admin/tools/purge.php
+		\brief      Page de purge des fichiers temporaires
+		\version    $Revision$
+*/
+
+require("./pre.inc.php");
+include_once $dolibarr_main_document_root."/lib/databases/".$conf->db->type.".lib.php";
+
+$langs->load("admin");
+
+if (! $user->admin)
+  accessforbidden();
+
+if ($_GET["msg"]) $message='<div class="error">'.$_GET["msg"].'</div>';
+
+
+
+/*
+*	Actions
+*/
+if ($_POST["action"]=='purge')
+{
+	$filesarray=array();
+	
+	if ($_POST["choice"]=='tempfiles')
+	{
+		// Delete temporary files
+		if ($dolibarr_main_data_root)
+		{
+			$filesarray=dolibarr_dir_list($dolibarr_main_data_root,"directories",1,'temp');
+		}
+	}
+
+	if ($_POST["choice"]=='allfiles')
+	{
+		// Delete all files
+		if ($dolibarr_main_data_root)
+		{
+			$filesarray=dolibarr_dir_list($dolibarr_main_data_root,"all",0);
+		}
+	}
+
+	$count=0;
+	if (sizeof($filesarray))
+	{
+		foreach($filesarray as $key => $value)
+		{
+			//print "x ".$filesarray[$key]['fullname']."<br>\n";
+			$count=dol_delete_dir_recursive($filesarray[$key]['fullname']);
+		}		
+
+	}
+
+	if ($count) $message=$langs->trans("PurgeNDirectoriesDeleted",$count);
+	else $message=$langs->trans("PurgeNothingToDelete");
+	$message='<div class="ok">'.$message.'</div>';
+}
+
+
+/*
+* Affichage page
+*/
+
+llxHeader();
+
+$html=new Form($db);
+
+print_fiche_titre($langs->trans("Purge"),'','setup');
+print '<br>';
+
+print $langs->trans("PurgeAreaDesc",$dolibarr_main_data_root).'<br>';
+print '<br>';
+
+if ($message) 
+{
+	print $message.'<br>';
+	print "\n";
+}
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+
+print '<input type="hidden" name="action" value="purge">';
+
+print '<table class="border" width="100%"><tr><td>';
+print '<input type="radio" name="choice" value="tempfiles"';
+print (! $_POST["choice"] || $_POST["choice"]=='tempfiles') ? ' checked="true"' : '';
+print '> '.$langs->trans("PurgeDeleteTemporaryFiles").'<br>';
+print '<input type="radio" name="choice" value="allfiles"';
+print ($_POST["choice"] && $_POST["choice"]=='allfiles') ? ' checked="true"' : '';
+print '> '.$langs->trans("PurgeDeleteAllFilesInDocumentsDir",$dolibarr_main_data_root).'<br>';
+print '</td></tr></table>';
+
+print '<br>';
+print '<center><input class="button" type="submit" value="'.$langs->trans("PurgeRunNow").'"></center>';
+
+
+print '</form>';
+
+llxFooter('$Date$ - $Revision$');
+?>
\ No newline at end of file
-- 
GitLab