]> _ Git - fluidbook_distantstorage.git/commitdiff
wip #5725 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Feb 2023 10:02:15 +0000 (11:02 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Feb 2023 10:02:15 +0000 (11:02 +0100)
app/src/Tools.php [new file with mode: 0644]
app/tools.php [new file with mode: 0644]

diff --git a/app/src/Tools.php b/app/src/Tools.php
new file mode 100644 (file)
index 0000000..3b8410d
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+namespace Fluidbook\DistantStorage;
+
+use Cubist\Util\Files\Files;
+use Cubist\Util\Zip;
+
+class Tools {
+       public static function zip($a) {
+               $a = self::_args($a, ['compression' => 0]);
+               Zip::archive($a['source'], $a['dest'], $a['compression']);
+       }
+
+       public static function copy($a) {
+               foreach ($a['files'] as $from => $to) {
+                       Files::copy($from, $to);
+               }
+       }
+
+       protected static function _args($args, $defaults = []) {
+               return array_merge($defaults, $args);
+       }
+}
\ No newline at end of file
diff --git a/app/tools.php b/app/tools.php
new file mode 100644 (file)
index 0000000..0224aa5
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+use Fluidbook\DistantStorage\Tools;
+
+require_once __DIR__ . "/vendor/autoload.php";
+
+$f = $_POST['function'];
+if (is_callable([Tools::class, $f])) {
+       die(Tools::$f($_POST));
+}
\ No newline at end of file