52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
|
|
||
|
<?php
|
||
|
|
||
|
|
||
|
include '../config.php';
|
||
|
|
||
|
$sql = "SELECT file_expire.id, file_expire.req_id, file_expire.doc_id, file_expire.temp, file_expire.deleted,file_expire.uid, file_expire.cur_date, file_expire.exp_date
|
||
|
FROM file_expire";
|
||
|
|
||
|
$result = $conn->query($sql);
|
||
|
|
||
|
while ($row = $result->fetch_assoc()) {
|
||
|
$id = $row['id'];
|
||
|
$req_id = $row['req_id'];
|
||
|
$doc_id = $row['doc_id'];
|
||
|
$temp = $row['temp'];
|
||
|
$deleted = $row['deleted'];
|
||
|
$uid = $row['uid'];
|
||
|
$exp_date = $row['exp_date'];
|
||
|
|
||
|
$current_date = strtotime(date('Y-m-d'));
|
||
|
|
||
|
if ($current_date > strtotime($exp_date)) {
|
||
|
|
||
|
echo "Current Date: " . date('Y-m-d', $current_date) . "<br>";
|
||
|
echo "Expiration Date: " . $exp_date . "<br>";
|
||
|
|
||
|
if (file_exists($temp)) {
|
||
|
echo "File exists: " . $temp . "<br>";
|
||
|
if (unlink($temp)) {
|
||
|
echo "File deleted successfully.<br>";
|
||
|
|
||
|
// Update the deleted column for this specific row
|
||
|
$updateSql = "UPDATE file_expire SET deleted = 1";
|
||
|
|
||
|
|
||
|
if ($conn->query($updateSql) === TRUE) {
|
||
|
echo $id . "<br>";
|
||
|
echo "Deleted column updated successfully.<br>";
|
||
|
} else {
|
||
|
echo "Error updating deleted column: " . $conn->error . "<br>";
|
||
|
}
|
||
|
} else {
|
||
|
echo "Failed to delete the file.<br>";
|
||
|
}
|
||
|
} else {
|
||
|
echo "File does not exist: " . $temp . "<br>";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|