From: Winfried Kappeler Date: Tue, 4 Feb 2020 07:59:57 +0000 (+0100) Subject: initial state X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=HEAD;p=wartung.git initial state --- f64862bf1bb46bcc50e8c24fe3ab140f3a96ba3e diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d74e21 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode/ diff --git a/data/youtube.csv b/data/youtube.csv new file mode 100644 index 0000000..4682ecb --- /dev/null +++ b/data/youtube.csv @@ -0,0 +1,4 @@ +Titel;Youtube;Linktext;OnlineSeit;Beschreibung +Brunnenbohrung;Ui7gGa9zbDc;Motorisierte Bohrung;11.12.2018;EMAS-Bohrmethode (motorisierte Spülbohrung) + + diff --git a/data/youtube.html b/data/youtube.html new file mode 100644 index 0000000..4682ecb --- /dev/null +++ b/data/youtube.html @@ -0,0 +1,4 @@ +Titel;Youtube;Linktext;OnlineSeit;Beschreibung +Brunnenbohrung;Ui7gGa9zbDc;Motorisierte Bohrung;11.12.2018;EMAS-Bohrmethode (motorisierte Spülbohrung) + + diff --git a/emastool.php b/emastool.php new file mode 100644 index 0000000..033c783 --- /dev/null +++ b/emastool.php @@ -0,0 +1,137 @@ +
Mode: '$mode'
"; +$result = ''; +if ($mode === 'main'){ + if (array_key_exists('convert', $_POST)) { + $result = convert($template, $csv); + } elseif (array_key_exists('save_template', $_POST)) { + saveFile("$kind.html", $_POST['template']); + } elseif (array_key_exists('save_csv', $_POST)) { + saveFile("$kind.csv", $_POST['csv']); + } elseif (array_key_exists('upload', $_POST)){ + $mode = 'upload'; + } + $body = " + + +
+ + +

Vorlage:

+ +

CSV-Daten:

+ +

+

+

Ergebnis:

+ +
+ + +"; +} elseif ($mode === 'upload') { + $info = ''; + if (array_key_exists('toShell', $_POST)) { + $mode = "main"; + } elseif (array_key_exists('select', $_FILES)) { + $tempName = $_FILES['select']['tmp_name']; + $nodeName = $_FILES['select']['name']; + $error = $_FILES['select']['error']; + $size = $_FILES['select']['size']; + rename($tempName, $tempDir . '/' . $nodeName); + if (! file_exists($tempDir)){ + mkdir($tempDir); + } + $list = scandir($tempDir); + $files = implode("\n", $list); + $info = "

Hochladeinfo

+

TempName: $tempName
+Name: $nodeName
+Größe: $size
+Fehler: $error
+

+

Temp-Verzeichnis $tempDir

+
$files
+"; + } + $body = " + + +
+

Gehe zur Shell +

+ +

Eingabe:

+ +

+

+$info +
+ + +"; +} +print $body; + +function saveFile(string $name, string $content){ + global $root; + $fn = "$root/data/$name"; + file_put_contents($fn, $content); +} +function loadFile(string $name): string{ + global $root; + $fn = "$root/data/$name"; + $rc = file_get_contents($fn); + return $rc; +} +function convert(string $template, string $csv): string { + $rc = ''; + $data = explode("\n", $csv); + if (count($data) > 1){ + $headers = explode(';', trim($data[0])); + unset($data[0]); + foreach ($data as $line){ + if ( ($line = trim($line)) === ''){ + continue; + } + $cols = explode(';', $line); + $item = $template; + for ($ix = 0; $ix < count($cols); $ix++){ + if ($ix >= count($headers)){ + continue; + } + $name = $headers[$ix]; + $item = str_replace("#$name#", $cols[$ix], $item); + } + $rc .= $item . "\n"; + } + } + return $rc; +} \ No newline at end of file diff --git a/nanoshell.php b/nanoshell.php new file mode 100644 index 0000000..6b710ff --- /dev/null +++ b/nanoshell.php @@ -0,0 +1,104 @@ +
Mode: '$mode'
"; +if ($mode === 'shell'){ + if (array_key_exists('doit', $_POST)) { + $content2 = html_entity_decode($content); + $fn = '/tmp/nanoshell.task'; + $fn2 = '/tmp/nanoshell.out'; + file_put_contents($fn, trim($content2)); + $out = ''; + $cmd = "/bin/bash $fn >$fn2 2>&1"; + file_put_contents("/tmp/cmd.txt", $cmd); + exec($cmd, $out); + $content2 = file_get_contents($fn2); + // $content2 = ''.join($out).trim(); + } elseif (array_key_exists('info', $_POST)) { + $content2 = ''; + foreach ($_SERVER as $entry) { + $content2 .= $entry . ': ' . $_SERVER[$entry] . "\n"; + } + } elseif (array_key_exists('upload', $_POST)){ + $mode = 'upload'; + } + $body = " + + +
+

Gehe zu Hochladen +

+ +

Eingabe:

+ +

+ +

+

Ergebnis:

+ +

Merkzettel:

+ +
+ + +"; +} elseif ($mode === 'upload') { + $info = ''; + if (array_key_exists('toShell', $_POST)) { + $mode = "shell"; + } elseif (array_key_exists('select', $_FILES)) { + $tempName = $_FILES['select']['tmp_name']; + $nodeName = $_FILES['select']['name']; + $error = $_FILES['select']['error']; + $size = $_FILES['select']['size']; + rename($tempName, $tempDir . '/' . $nodeName); + if (! file_exists($tempDir)){ + mkdir($tempDir); + } + $list = scandir($tempDir); + $files = implode("\n", $list); + $info = "

Hochladeinfo

+

TempName: $tempName
+Name: $nodeName
+Größe: $size
+Fehler: $error
+

+

Temp-Verzeichnis $tempDir

+
$files
+"; + } + $body = " + + + +
+

Gehe zur Shell +

+ +

Eingabe:

+ +

+

+$info + +
+ + +"; +} +print $body;