Files
resatennis_tyroltenn/IDrive/.config/clearLog.php

70 lines
2.2 KiB
PHP
Executable File

<?php
include 'path.php';
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true)
exit(header("Location:../index.php"));
if($_SESSION['validUser'] === true)
{
$res = array();
$nonRemovable = array();
if($_GET)
{
$jobNameGetString = $_GET["FILE_NAME"];
if(strpos($jobNameGetString,"_SUCCESS") || strpos($jobNameGetString,"_ABORTED") || strpos($jobNameGetString,"_FAILURE")){
if(file_exists($jobNameGetString))
unlink($jobNameGetString);
createOrVerifyOrDeleteLink($jobNameGetString,1);
} else {
$exp = explode("/LOGS/",$jobNameGetString);
$jobPath = $exp[0];
if(file_exists("$jobPath/$startPid") && file_exists("$jobPath/".LOG_PID_FILE)){
$logpid = file_get_contents("$jobPath/".LOG_PID_FILE);
$realPathVal = realpath($jobNameGetString);
if($realPathVal==$logpid){
$nonRemovable[]= $jobNameGetString;
} else {
unlink($jobNameGetString);
createOrVerifyOrDeleteLink($jobNameGetString,1);
}
} else {
unlink($jobNameGetString);
createOrVerifyOrDeleteLink($jobNameGetString,1);
}
}
} else if($_POST){
foreach($_POST['chk_elements'] as $jobNameGetString){
$jobNameGetString = rawurldecode($jobNameGetString);
if(strpos($jobNameGetString,"_SUCCESS") || strpos($jobNameGetString,"_ABORTED") || strpos($jobNameGetString,"_FAILURE")){
if(file_exists($jobNameGetString))
unlink($jobNameGetString);
createOrVerifyOrDeleteLink($jobNameGetString,1);
} else {
$exp = explode("/LOGS/",$jobNameGetString);
$jobPath = $exp[0];
if(file_exists("$jobPath/$startPid") && file_exists("$jobPath/logpid.txt")){
$logpid = file_get_contents("$jobPath/logpid.txt");
$realPathVal = realpath($jobNameGetString);
if($realPathVal==$logpid){
$nonRemovable[]= $jobNameGetString;
} else {
unlink($jobNameGetString);
createOrVerifyOrDeleteLink($jobNameGetString,1);
}
} else {
unlink($jobNameGetString);
createOrVerifyOrDeleteLink($jobNameGetString,1);
}
}
}
}
if(count($nonRemovable)>0){
$res[] = false;
$res[] = $nonRemovable;
} else {
$res[] = true;
}
print json_encode($res);
exit();
}
?>