-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear.php
31 lines (31 loc) · 920 Bytes
/
clear.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$rootPath = $_SERVER["DOCUMENT_ROOT"];
$hostname = $_SERVER["HTTP_HOST"];
$jsonDir = $rootPath."/boards/".$hostname."/";
$now = new DateTime();
$jsonFiles = scandir($jsonDir);
foreach($jsonFiles as $file) {
$fileContents = file_get_contents($jsonDir.$file);
$data = @json_decode($fileContents, true);;
$created = $data['created'];
$updated = $data['updated'];
if(!empty($data['expires'])){
$expires = "-".$data['expires']." days";
} else {
$expires = NULL;
}
$image = $data['image'];
$postPath = $jsonDir.$created.".json";
$imgPath = $jsonDir."images/".$image;
if (strtotime($expires) > $created) {
if(!empty($created)){
echo "<!-- DELETED ** ".$postPath." ** !-->\n";
unlink($postPath);
}
if(!empty($image)){
echo "<!-- DELETED ** ".$imgPath." ** !-->\n";
unlink($imgPath);
}
}
}
?>