mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-02-16 02:30:51 +00:00
Add script to clear old autosaved graphs
This commit is contained in:
23
backend/clear_autosave_graphs.php
Normal file
23
backend/clear_autosave_graphs.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
include ("../core/config/main.php");
|
||||
|
||||
$dirName = "../" . $g_config['graphSavePath'] . 'autosave/*';
|
||||
$days_to_remove = 14;
|
||||
//echo($dirName . "<br>");
|
||||
$files = glob($dirName, 0);
|
||||
$count = 0;
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$fileAgeInDays = (time() - filemtime($file)) / (3600 * 24);
|
||||
if ($fileAgeInDays > $days_to_remove)
|
||||
{
|
||||
if (unlink($file))
|
||||
{
|
||||
echo($file . " " . $fileAgeInDays . "<br>");
|
||||
$count = $count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo("Deleted " . $count . " graphs");
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user