first commit

This commit is contained in:
/usr/bin/nano
2017-04-15 01:34:36 +03:00
commit c715e2a604
5325 changed files with 329700 additions and 0 deletions

2
cgi-bin/.htaccess Executable file
View File

@@ -0,0 +1,2 @@
Options +ExecCGI
AddHandler cgi-script .pl .exe

42
cgi-bin/CleanImages.php Normal file
View File

@@ -0,0 +1,42 @@
<?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
cgi-bin/addDonate.php Normal file
View File

@@ -0,0 +1,16 @@
<?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);
}
}
?>

9
cgi-bin/addFailedMatrix.php Executable file
View File

@@ -0,0 +1,9 @@
<?
$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);
?>

7
cgi-bin/getPluginsList.php Executable file
View File

@@ -0,0 +1,7 @@
<?
$jsScripts = glob("../script/plugins/*.js");
echo json_encode($jsScripts);
?>

12
cgi-bin/loadGraph.php Executable file
View File

@@ -0,0 +1,12 @@
<?
include ("saveGraphHelpers.php");
$name = $_GET["name"];
if (isValidName($name))
{
echo (gzuncompress(file_get_contents(getXMLFileName($name))));
}
echo ("");
?>

14
cgi-bin/saveGraph.php Executable file
View File

@@ -0,0 +1,14 @@
<?
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");
}
?>

62
cgi-bin/saveGraphHelpers.php Executable file
View File

@@ -0,0 +1,62 @@
<?php
/*
Function to save/open graph
*/
include ("../core/config/main.php");
// Only latic.
function isValidName($name)
{
return preg_match("(^[a-zA-Z]+$)", $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 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;
}
?>

30
cgi-bin/saveImage.php Normal file
View File

@@ -0,0 +1,30 @@
<?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");
}
?>