seeddms-code/op/op.RemoveLog.php

70 lines
2.3 KiB
PHP
Raw Normal View History

2013-04-11 07:05:36 +00:00
<?php
// MyDMS. Document Management System
// Copyright (C) 2010 Matteo Lucarelli
2016-08-09 05:34:30 +00:00
// Copyright (C) 2010-2016 Uwe Steinmann
2013-04-11 07:05:36 +00:00
//
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php");
include("../inc/inc.LogInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
2013-04-11 07:05:36 +00:00
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
2016-10-05 14:23:22 +00:00
/* Check if the form data comes from a trusted request */
if(!checkFormKey('removelog')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
2010-10-29 13:19:51 +00:00
if (!$user->isAdmin()) {
2013-04-11 07:05:36 +00:00
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
2010-10-29 13:19:51 +00:00
}
2013-04-11 07:05:36 +00:00
if (!isset($_POST["lognames"]) || !is_array($_POST["lognames"])) {
2013-04-11 07:05:36 +00:00
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
2010-10-29 13:19:51 +00:00
}
$lognames = $_POST["lognames"];
foreach($lognames as $file) {
2022-03-26 17:48:04 +00:00
$file = basename($file, '.log').'.log';
2018-04-03 08:57:29 +00:00
if(!file_exists($settings->_contentDir.'log/'.$file)) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
}
2018-04-03 08:57:29 +00:00
if (@readlink($settings->_contentDir."current.log")==$settings->_contentDir.'log/'.$file){
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
2013-04-11 07:05:36 +00:00
2018-04-03 08:57:29 +00:00
if (!SeedDMS_Core_File::removeFile($settings->_contentDir.'log/'.$file)) {
2013-04-11 07:05:36 +00:00
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
2010-10-29 13:19:51 +00:00
}
if(isset($_POST["mode"])) {
$mode = $_POST["mode"];
} else {
$mode = 'web';
}
2013-04-11 07:05:36 +00:00
add_log_line("?logname=".implode(",", $_POST["lognames"]));
2013-04-11 07:05:36 +00:00
header("Location:../out/out.LogManagement.php?mode=".$mode);
2013-04-11 07:05:36 +00:00
?>