mirror of
https://github.com/UnickSoft/graphonline.git
synced 2025-07-03 00:06:40 +00:00
Added function to remove saved images.
This commit is contained in:
parent
2c2e40a96f
commit
5fa10c12d8
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
include ("cgi-bin/saveGraphHelpers.php");
|
||||
include ("./src/graphs_examples_func.php");
|
||||
|
||||
//ini_set('display_errors', 1);
|
||||
//ini_set('display_startup_errors', 1);
|
||||
@ -64,21 +65,6 @@ if (isset($_POST["source_id"]))
|
||||
}
|
||||
|
||||
|
||||
$examples = array();
|
||||
|
||||
// Load from cvs
|
||||
|
||||
if (($handle = fopen($examplesFilename, "r")) !== FALSE)
|
||||
{
|
||||
while (($data = fgetcsv($handle, 1000, "|")) !== FALSE)
|
||||
{
|
||||
$item = array();
|
||||
$item["id"] = $data[0];
|
||||
$item["title_ru"] = $data[1];
|
||||
$item["title_en"] = $data[2];
|
||||
$examples[] = $item;
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
$examples = getAllExampleGraphs();
|
||||
|
||||
?>
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
include ("./src/graphs_examples_func.php");
|
||||
|
||||
function glob_recursive($pattern, $flags = 0)
|
||||
{
|
||||
@ -11,7 +12,7 @@ function glob_recursive($pattern, $flags = 0)
|
||||
return $files;
|
||||
}
|
||||
|
||||
function processFiles($mask, &$countFiles, &$sizeFiles, &$ageCount, $ageCallback)
|
||||
function processFiles($mask, &$countFiles, &$sizeFiles, &$ageCount, $ageCallback, $ageActionCallback)
|
||||
{
|
||||
// Process graph project files.
|
||||
$files = glob_recursive($mask);
|
||||
@ -24,12 +25,12 @@ function processFiles($mask, &$countFiles, &$sizeFiles, &$ageCount, $ageCallback
|
||||
|
||||
if ($ageCallback($fileAgeInMonth))
|
||||
{
|
||||
$ageCount = $ageCount + 1;
|
||||
$ageActionCallback($ageCount, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ageCallback = function($age)
|
||||
$age6mLessCallback = function($age)
|
||||
{
|
||||
return $age <= 6;
|
||||
};
|
||||
@ -43,9 +44,52 @@ $ageGraph = 0;
|
||||
$totalImages = 0;
|
||||
$totalImagesSize = 0; // In Kb
|
||||
$ageImage = 0;
|
||||
$msg = "";
|
||||
|
||||
processFiles($g_config['graphSavePath'] . "*.xml", $totalGraphCount, $totalGraphSize, $ageGraph, $ageCallback);
|
||||
processFiles($g_config['graphSavePath'] . "*.png", $totalImages, $totalImagesSize, $ageImage, $ageCallback);
|
||||
|
||||
if ($_POST["submit"] == "delete1YImages")
|
||||
{
|
||||
$age1yMoreCallback = function($age)
|
||||
{
|
||||
return $age > 12;
|
||||
};
|
||||
|
||||
$examples = getAllExampleGraphs();
|
||||
|
||||
$msg = "Deleted files: ";
|
||||
$deletedCount = 0;
|
||||
|
||||
$ageDelActionCallback = function(&$ageCount, $file) use($examples, &$msg, &$deletedCount)
|
||||
{
|
||||
// Ignory examples.
|
||||
foreach ($examples as $item)
|
||||
{
|
||||
if (strpos ($file, $item["id"]) !== FALSE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlink($file))
|
||||
{
|
||||
$msg = $msg . $file . ", ";
|
||||
$deletedCount = $deletedCount + 1;
|
||||
}
|
||||
};
|
||||
|
||||
processFiles($g_config['graphSavePath'] . "*.png", $totalImages, $totalImagesSize, $ageImage, $age1yMoreCallback, $ageDelActionCallback);
|
||||
|
||||
$msg = $msg . "<br/>" . "Total: $deletedCount";
|
||||
}
|
||||
|
||||
|
||||
$ageActionCallback = function(&$ageCount, $file)
|
||||
{
|
||||
$ageCount = $ageCount + 1;
|
||||
};
|
||||
|
||||
processFiles($g_config['graphSavePath'] . "*.xml", $totalGraphCount, $totalGraphSize, $ageGraph, $age6mLessCallback, $ageActionCallback);
|
||||
processFiles($g_config['graphSavePath'] . "*.png", $totalImages, $totalImagesSize, $ageImage, $age6mLessCallback, $ageActionCallback);
|
||||
|
||||
$totalGraphSize = intval($totalGraphSize);
|
||||
$totalImagesSize = intval($totalImagesSize);
|
||||
|
@ -1,21 +1,13 @@
|
||||
<?php
|
||||
$examples = array();
|
||||
|
||||
include ("./src/graphs_examples_func.php");
|
||||
|
||||
$examples = getAllExampleGraphs();
|
||||
|
||||
// Load from cvs
|
||||
|
||||
$examplesFilename = $g_config['graphSavePath'] . $g_config['graphExamplesFile'];
|
||||
|
||||
if (($handle = fopen($examplesFilename, "r")) !== FALSE)
|
||||
foreach ($examples as $item)
|
||||
{
|
||||
while (($data = fgetcsv($handle, 1000, "|")) !== FALSE)
|
||||
{
|
||||
$item = array();
|
||||
$item["id"] = $data[0];
|
||||
$item["title_ru"] = $data[1];
|
||||
$item["title_en"] = $data[2];
|
||||
$g_lang["m_keyWords"] .= ", " . $item["title_" . $g_lang["current_language"]];
|
||||
$examples[] = $item;
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
?>
|
@ -14,21 +14,13 @@
|
||||
</div>
|
||||
|
||||
<form action="<?= GetCurUrl()?>" method="post" class="form-horizontal" role="form">
|
||||
<input type="hidden" name="is_add_page" value="1">
|
||||
<div class="form-group">
|
||||
<div class="col-lg-offset-2 col-lg-6">
|
||||
<?= $msg?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputName" class="col-lg-2 control-label">Название страницы</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" id="inputName" autocomplete="on" name="name" value="<?= Post("name")?>" placeholder="Только маленькие латинские буквы и цифры">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-offset-2 col-lg-6">
|
||||
<button type="submit" class="btn btn-primary">Добавить</button>
|
||||
<button name="submit" type="submit" class="btn btn-primary" value="delete1YImages">Удалить изображения старше 1 года</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<p><?= $msg ?></p>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user