Moved php from cgi-bin to backend

This commit is contained in:
Oleg Sh
2024-10-10 20:17:45 +02:00
parent aac9da9d45
commit 1576a1c6e4
24 changed files with 100 additions and 100 deletions
-42
View File
@@ -1,42 +0,0 @@
<?php
// File remove old images from all sub folder of this folder.
// maxDate in hours.
function rrmdir($dir, $extention, $maxDate, &$removedList)
{
if (is_dir($dir))
{
$objects = scandir($dir);
foreach ($objects as $object)
{
if ($object != "." && $object != "..")
{
$objectName = $dir . "/" . $object;
if (filetype($objectName) == "dir")
{
rrmdir($objectName, $extention, $maxDate, $removedList);
}
else if (pathinfo($objectName)['extension'] == $extention
&& time() - filemtime($objectName) > $maxDate * 3600)
{
unlink ($objectName);
$removedList[] = $objectName;
}
}
}
reset($objects);
//rmdir($dir);
}
}
// Remove only png and 1 month old.
$removedList = [];
rrmdir(".", "png", 24 * 30, $removedList);
foreach($removedList as $value)
{
echo ($value . "<br>");
}
?>
-16
View File
@@ -1,16 +0,0 @@
<?php
include ("../core/config/main.php");
//if ("RdukIxdb0Lxc+uNhgfFXb7ll" == $_POST["notification_secret"])
{
$file = fopen("../" . $g_config['donateTransactions'], "a");
if ($file)
{
fprintf($file, "%d\n", $_POST["amount"]);
fclose($file);
}
}
?>
-10
View File
@@ -1,10 +0,0 @@
<?php
$matrix = $_GET["matrix"];
$text = $_GET["text"];
$file = fopen("../tmp/faildMatrix.txt", "a");
fprintf($file, "\n%s:\n", date("d.m.y"));
fprintf($file, "FaildMatrix (%s):\n%s\n", $text, $matrix);
fclose($file);
?>
-25
View File
@@ -1,25 +0,0 @@
<?php
$tempFilename = "../tmp/pluginsList.txt";
if (isset($_GET["reset"]))
{
unlink($tempFilename);
}
$res = "";
if (!file_exists($tempFilename))
{
$jsScripts = glob("../script/plugins/*.js");
$res = json_encode($jsScripts);
file_put_contents ($tempFilename, $res);
}
else
{
$res = file_get_contents($tempFilename);
}
echo $res;
?>
-14
View File
@@ -1,14 +0,0 @@
<?php
include ("../core/config/main.php");
include ("saveGraphHelpers.php");
$name = $_GET["name"];
if (isValidName($name))
{
echo (gzuncompress(file_get_contents(getXMLFileName($name))));
}
echo ("");
?>
-16
View File
@@ -1,16 +0,0 @@
<?php
include ("../core/config/main.php");
include ("saveGraphHelpers.php");
$graph = file_get_contents("php://input");
$name = $_GET["name"];
if (isValidName($name))
{
$file = fopen(getXMLFileName($name), "w");
fprintf($file, "%s", gzcompress($graph, -1));
fclose($file);
echo ("OK");
}
?>
-73
View File
@@ -1,73 +0,0 @@
<?php
/*
Function to save/open graph
*/
// Only latic.
function isValidName($name)
{
return preg_match("(^[a-zA-Z]+[_test]*$)", $name);
}
function getXMLFileName($graphName, $fromRoot=false)
{
global $g_config;
$dirName = ($fromRoot ? "" : "../") . $g_config['graphSavePath'] . substr($graphName, 0, 2);
if(!file_exists($dirName))
{
mkdir($dirName, 0777, true);
}
return $dirName . "/$graphName.xml";
}
function getImageFileName($graphName, $fromRoot=false)
{
global $g_config;
$dirName = ($fromRoot ? "" : "../") . $g_config['graphSavePath'] . substr($graphName, 0, 2);
if(!file_exists($dirName))
{
mkdir($dirName, 0777, true);
}
return $dirName . "/$graphName.png";
}
function getSvgFileName($graphName, $fromRoot=false)
{
global $g_config;
$dirName = ($fromRoot ? "" : "../") . $g_config['graphSavePath'] . substr($graphName, 0, 2);
if(!file_exists($dirName))
{
mkdir($dirName, 0777, true);
}
return $dirName . "/$graphName.svg";
}
function saveGraphXML($graph, $name, $fromRoot = false)
{
$res = false;
if (isValidName($name))
{
$file = fopen(getXMLFileName($name, $fromRoot), "w");
if ($file)
{
fprintf($file, "%s", gzcompress($graph, -1));
fclose($file);
$res = true;
}
}
return $res;
}
?>
-32
View File
@@ -1,32 +0,0 @@
<?php
include ("../core/config/main.php");
include ("saveGraphHelpers.php");
$name = $_GET["name"];
if (isValidName($name))
{
$imageFilename = getImageFileName($name);
$imageData = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $_POST['base64data']));
if (isset($_GET["x"]) && $_GET["width"] < 4000 && $_GET["height"] < 4000)
{
$src = imagecreatefromstring($imageData);
$dst = imagecreatetruecolor($_GET["width"], $_GET["height"]);
imagesavealpha($dst, true);
imagealphablending($dst, false);
imagecopy($dst, $src, 0, 0, $_GET["x"], $_GET["y"], $_GET["width"], $_GET["height"]);
imagepng($dst, $imageFilename);
}
else
{
file_put_contents($imageFilename, $imageData);
}
chmod($imageFilename, 0644);
echo ("OK");
}
?>
-19
View File
@@ -1,19 +0,0 @@
<?php
include ("../core/config/main.php");
include ("saveGraphHelpers.php");
$name = $_GET["name"];
if (isValidName($name))
{
$imageFilename = getSvgFileName($name);
$svgData = $_POST['svgdata'];
file_put_contents($imageFilename, $svgData);
chmod($imageFilename, 0644);
echo ("OK");
}
?>
-21
View File
@@ -1,21 +0,0 @@
<?php
/*
Sample page
*/
$mymail = "soft_support@list.ru";
header('Content-type: text/html; charset=utf-8');
$text = "New Algorithm!\n" . $_GET["text"];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n";
$headers .= "From: support@graphonline.ru \r\n";
echo ($headers);
echo ($text);
mail($mymail, "New algorithm", $text, $headers);
?>
-15
View File
@@ -1,15 +0,0 @@
<?php
include ("../core/config/main.php");
if (!isset($_COOKIE["vote0"]))
{
$index = $_GET["index"];
setcookie("vote0", "true", time() + 3600 * 24 * 90, '/'); // 3 month
$file = fopen("../" . $g_config['vote'], "a");
fprintf($file, "%d\n", $index);
fclose($file);
echo ("OK");
}
?>