From 9d8d0ce4e99fbfd745679af1a34c4dddfbb94960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9munaire?= Date: Fri, 3 Feb 2012 19:41:19 +0100 Subject: [PATCH] Add a compilation link for LaTeX documents --- gen/gen | 0 htdocs/gen.php | 121 +++++++++++++++++++++++++++++++++++++++++++++++ htdocs/index.php | 1 + paste.class.php | 19 ++++++++ 4 files changed, 141 insertions(+) create mode 100644 gen/gen create mode 100644 htdocs/gen.php diff --git a/gen/gen b/gen/gen new file mode 100644 index 0000000..e69de29 diff --git a/htdocs/gen.php b/htdocs/gen.php new file mode 100644 index 0000000..5ecc4c1 --- /dev/null +++ b/htdocs/gen.php @@ -0,0 +1,121 @@ + $t) +{ + if (preg_match("#^([a-zA-Z0-9]{".RGXP_NB."})(:([a-zA-Z0-9]{".RGXP_NB."}))?$#", $k, $kout) + && is_file(Paste::get_path($kout[1]))) + { + $paste = new Paste($kout[1]); + + if (!empty($paste->crypt) && empty($_POST["passwd"]) && empty($t)) + { +?> + + + + + .: Pommultimédia - Paste :. + + + + +
+

+ title); ?> +

+

get_subtitle(); ?>

+
+
+
+ + +

+ +
+
+
+ + +crypt)) + { + if (!empty($_POST["passwd"])) + $paste->crypt($_POST["passwd"]); + else + $paste->crypt($t); + } + + $filename = "../gen/".$paste->fileref; + + ob_start(); + if (strtolower($paste->language) == "latex") + $f = generate_latex($filename, $paste->content); + else if (strtolower($paste->language) == "html") + die ($paste->content); + else + print "Je ne sais pas compiler ce code source :("; + $log = ob_get_clean(); + ob_end_clean(); + + if (isset($f) && is_file($f)) + { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header("Content-Disposition: attachment; filename=\"".basename($paste->title).substr($f, count($f)-5, 4)."\""); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . filesize($f)); + readfile($f); + } + else + die(nl2br($log)); + } + } +} +?> \ No newline at end of file diff --git a/htdocs/index.php b/htdocs/index.php index 405bfd5..7e2b2de 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -55,6 +55,7 @@ foreach ($_GET as $k => $t)
Répondre get_ref(isset($diff)); ?> + get_gen(isset($diff)); ?>
fileref.$passwd.'">Raw '; + + if ($this->language == "latex") + return $raw.'Générer le document '; + else + return $raw; + } + /** * Get the parsed code */ @@ -300,6 +314,11 @@ class Paste return $ret.'
'; } } + + function export_to_file($fileto) + { + file_put_contents($fileto, $this->content); + } } ?> \ No newline at end of file