From b7128a450891fd5913f8a5f158b8034f4bbe5571 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 12 Oct 2017 13:33:51 -0400 Subject: [PATCH] Fix TGUI compiler git updates --- tools/TGUICompiler.php | 198 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 tools/TGUICompiler.php diff --git a/tools/TGUICompiler.php b/tools/TGUICompiler.php new file mode 100644 index 0000000000..a393e1d3c6 --- /dev/null +++ b/tools/TGUICompiler.php @@ -0,0 +1,198 @@ + 0 && strpos($name, '\\') == false && strpos($name, '/') == false){ + $ext = pathinfo($name, PATHINFO_EXTENSION); + $mime = $finfo->file($F['tmp_name']); + if($ext == 'ract' && $mime == 'text/plain') + $good_files[] = $F; + } + } + $the_count = count($good_files); + if($the_count > 0 && $the_count < $max_number_of_uploads){ + $tgtgui_path = $tgdir . $path_to_tgui_from_repo; + $requests_dir = $parent_dir . '/requests'; + if(!is_dir($requests_dir)) + mkdir($requests_dir); + $target_path = str_replace('\\', '/', tempnam($requests_dir, 'tgui')); + unlink($target_path); + recurse_copy($tgtgui_path, $target_path); + $parent_node = $parent_dir . '/node_modules'; + $target_node = $target_path . '/node_modules'; + exec('mklink /j "' . str_replace('/', '\\', $target_node) . '" "' . str_replace('/', '\\', $parent_node) . '"'); + + //now copy the uploads to the thing + $target_interfaces = $target_path . '/src/interfaces/'; + foreach($good_files as $F){ + $target_name = $target_interfaces . $F['name']; + if(file_exists($target_name)) + unlink($target_name); //remove the file + move_uploaded_file($F['tmp_name'], $target_name); + } + + //compile + $command = '"' . $full_path_to_gulp . '" --cwd "' . str_replace('/', '\\', $target_path) . '" --min 2>&1'; + $output = shell_exec($command); + + $zip = new ZipArchive(); + $zippath = $target_path . '/TGUI.zip'; + if($zip->open($zippath, ZipArchive::CREATE) == TRUE){ + $zip->addFile($target_path . '/assets/tgui.css', 'tgui.css'); + $zip->addFile($target_path . '/assets/tgui.js', 'tgui.js'); + $zip->addFromString('gulp_output.txt', $output); + $zip->close(); + download_file($zippath); + } + else + $error = 'Unable to create output zipfile!'; + exec('rmdir "' . str_replace('/', '\\', $target_node) . '"'); //improtant + rrmdir($target_path); + } + else if(!$updated_git) + throw new RuntimeException('No valid files uploaded!'); + } +} +catch(Exception $e){ + $error = $e->getMessage(); +} + +?> + + + + TGUI .ract Compiler + + + An error occured: ' . $error . '

'; ?> +

Upload up to .ract files

+

Based off revision: ' . $revision . '' : $revision; ?> +
+ Update to latest revision (don't use this unless you have to)
+
+
+
+ + +
+ + + +