Compare commits
No commits in common. "25470375b047e554c6d760e388d8befa69cf46d0" and "bb06c6ba5ce381b4d9b339c8f3f3f8d071ad57f5" have entirely different histories.
25470375b0
...
bb06c6ba5c
|
@ -1,6 +1,6 @@
|
|||
FROM debian:12
|
||||
RUN apt-get update && apt-get upgrade -y && apt-get clean
|
||||
RUN apt-get install -y supervisor apache2 php libapache2-mod-php php-mbstring php-zip curl git openscad zip cmake build-essential php-opcache
|
||||
RUN apt-get install -y supervisor apache2 php libapache2-mod-php php-mbstring php-zip curl git openscad zip cmake build-essential
|
||||
RUN apt-get clean
|
||||
RUN chown -R www-data:www-data /var/www
|
||||
RUN curl https://files.openscad.org/snapshots/OpenSCAD-2024.03.28.ai18952-x86_64.AppImage > /tmp/openscad
|
||||
|
|
2
devrun
2
devrun
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
docker build -t taggor .
|
||||
docker run -p 8888:80 -v "$PWD/src:/var/www/src" --rm -it taggor "$@"
|
||||
docker run -p 8888:80 -v "$PWD/src:/var/www/src" --rm -it taggor "$@"
|
|
@ -1,54 +1,55 @@
|
|||
<?php
|
||||
phpinfo();
|
||||
exit();
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$tags = explode("\n", $_POST["tags"]);
|
||||
$tags = array_map("trim", $tags);
|
||||
$tags = array_filter($tags, function ($tag) {
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$tags = explode("\n", $_POST['tags']);
|
||||
$tags = array_map('trim', $tags);
|
||||
$tags = array_filter($tags, function($tag) {
|
||||
return !empty($tag);
|
||||
});
|
||||
|
||||
if (empty($tags)) {
|
||||
if(empty($tags)){
|
||||
header("Location: /?err=notags");
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$jobId = microtime(1) . "_" . uniqid();
|
||||
|
||||
$jobId=microtime(1).'_'.uniqid();
|
||||
#file_put_contents()
|
||||
$queueDir = __DIR__ . "/../queue";
|
||||
$queueDir = realpath($queueDir);
|
||||
$queueFile = $queueDir . "/" . $jobId . ".json";
|
||||
$queueDir=__DIR__.'/../queue';
|
||||
$queueDir=realpath($queueDir);
|
||||
$queueFile=$queueDir.'/'.$jobId.'.json';
|
||||
file_put_contents($queueFile, json_encode($tags));
|
||||
header("Location: /?jobid=" . $jobId);
|
||||
exit();
|
||||
header('Location: /?jobid='.$jobId);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET["jobid"])) {
|
||||
$jobId = $_GET["jobid"];
|
||||
$queueDir = __DIR__ . "/../queue";
|
||||
$queueDir = realpath($queueDir);
|
||||
$queueFile = $queueDir . "/" . $jobId . ".json";
|
||||
if(isset($_GET['jobid'])){
|
||||
$jobId=$_GET['jobid'];
|
||||
$queueDir=__DIR__.'/../queue';
|
||||
$queueDir=realpath($queueDir);
|
||||
$queueFile=$queueDir.'/'.$jobId.'.json';
|
||||
|
||||
$allJobs = glob($queueDir . "/*.json");
|
||||
|
||||
$allJobs=glob($queueDir.'/*.json');
|
||||
sort($allJobs);
|
||||
$myPositionInQueue = array_search($queueFile, $allJobs);
|
||||
$myPositionInQueue=array_search($queueFile, $allJobs);
|
||||
|
||||
if (false === $myPositionInQueue) {
|
||||
if (isset($_GET["download"]) && "1" == $_GET["download"]) {
|
||||
$dlDir = __DIR__ . "/../html/dl";
|
||||
$dlDir = realpath($dlDir);
|
||||
$zipFile = $dlDir . "/" . $jobId . ".zip";
|
||||
header("Content-Type: application/zip");
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="' .
|
||||
basename($zipFile) .
|
||||
'"'
|
||||
);
|
||||
readfile($zipFile);
|
||||
|
||||
exit();
|
||||
} else {
|
||||
echo <<<EOT
|
||||
|
||||
if(false === $myPositionInQueue) {
|
||||
|
||||
|
||||
if(isset($_GET['download']) && $_GET['download'] == '1'){
|
||||
$dlDir=__DIR__.'/../html/dl';
|
||||
$dlDir=realpath($dlDir);
|
||||
$zipFile=$dlDir.'/'.$jobId.'.zip';
|
||||
header('Content-Type: application/zip');
|
||||
header('Content-Disposition: attachment; filename="'.basename($zipFile).'"');
|
||||
readfile($zipFile);
|
||||
|
||||
|
||||
exit;
|
||||
}else{
|
||||
echo <<<EOT
|
||||
<html>
|
||||
<head>
|
||||
<title>c3RE AuerBoxTag Generator (Download starting)</title>
|
||||
|
@ -62,9 +63,12 @@ Your job $jobId is Finished.
|
|||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
|
||||
|
||||
|
||||
}
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
exit();
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
exit;
|
||||
}
|
||||
|
||||
$myPositionInQueue++;
|
||||
|
@ -81,13 +85,15 @@ Your job $jobId is $myPositionInQueue in the queue.
|
|||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$err = "";
|
||||
switch ($_GET["err"]) {
|
||||
case "notags":
|
||||
$err = "Please provide at least one tag";
|
||||
|
||||
|
||||
$err='';
|
||||
switch($_GET['err']){
|
||||
case 'notags':
|
||||
$err='Please provide at least one tag';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
while :; do
|
||||
sleep 5 &
|
||||
./queueWorker
|
||||
wait
|
||||
done
|
||||
done
|
|
@ -1,35 +1,36 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
$queueDir = __DIR__ . "/../queue";
|
||||
$queueDir = realpath($queueDir);
|
||||
$queueItems = glob($queueDir . "/*.json");
|
||||
$dlDir = __DIR__ . "/../html/dl/";
|
||||
if (!is_dir($dlDir)) {
|
||||
$queueDir=__DIR__.'/../queue';
|
||||
$queueDir=realpath($queueDir);
|
||||
$queueItems=glob($queueDir.'/*.json');
|
||||
$dlDir=__DIR__.'/../html/dl/';
|
||||
if(!is_dir($dlDir)){
|
||||
mkdir($dlDir);
|
||||
}
|
||||
if (empty($queueItems)) {
|
||||
if(empty($queueItems)){
|
||||
//clean up old files from dldir older than 24h
|
||||
$oldFiles = glob($dlDir . "/*.zip");
|
||||
foreach ($oldFiles as $oldFile) {
|
||||
if (filemtime($oldFile) < time() - 24 * 60 * 60) {
|
||||
$oldFiles=glob($dlDir.'/*.zip');
|
||||
foreach ($oldFiles as $oldFile){
|
||||
if(filemtime($oldFile) < time()-24*60*60){
|
||||
unlink($oldFile);
|
||||
}
|
||||
}
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
sort($queueItems);
|
||||
$jobFile = array_shift($queueItems);
|
||||
$jobId = basename($jobFile, ".json");
|
||||
$tags = json_decode(file_get_contents($jobFile), true);
|
||||
$zipFile = $dlDir . $jobId . ".zip";
|
||||
chdir(__DIR__ . "/../AuerNameTag");
|
||||
$shellArgs = array_map("escapeshellarg", $tags);
|
||||
$jobFile=array_shift($queueItems);
|
||||
$jobId=basename($jobFile, '.json');
|
||||
$tags=json_decode(file_get_contents($jobFile), true);
|
||||
$zipFile=$dlDir.$jobId.'.zip';
|
||||
chdir(__DIR__.'/../AuerNameTag');
|
||||
$shellArgs=array_map('escapeshellarg', $tags);
|
||||
system("rm -rf out");
|
||||
system("git reset --hard");
|
||||
system("./make.sh " . implode(" ", $shellArgs));
|
||||
system("./make.sh ". implode(' ', $shellArgs));
|
||||
chdir("out");
|
||||
system("zip -r $zipFile .");
|
||||
chdir("..");
|
||||
chdir('..');
|
||||
system("rm -rf out");
|
||||
unlink($jobFile);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue