diff --git a/common.php b/common.php index cb92ff8..2051b62 100644 --- a/common.php +++ b/common.php @@ -1,7 +1,34 @@ NB_CHAR) + define("RGXP_NB", NB_CHAR.",".ALLOW_NB_MIN); + else + define("RGXP_NB", ALLOW_NB_MIN.",".NB_CHAR); + } +else + define("RGXP_NB", NB_CHAR); + ?> \ No newline at end of file diff --git a/htdocs/index.php b/htdocs/index.php index 462ccda..c6fa1ce 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -12,34 +12,60 @@ require_once("../common.php"); foreach ($_GET as $k => $t) { - if (preg_match("#^[a-zA-Z0-9]{5}$#", $k) && is_file(DESTINATION . "/" . $k . ".xml")) + if (preg_match("#^[a-zA-Z0-9]{".RGXP_NB."}$#", $k) + && is_file(DESTINATION . "/" . $k . ".xml")) { require_once("../geshi/geshi.php"); $doc = new DOMDocument(); $doc->load(DESTINATION . "/" . $k . ".xml"); - $lang = $doc->getElementsByTagName("language")->item(0)->textContent; + $lang = strtolower($doc->getElementsByTagName("language")->item(0)->textContent); if (empty($lang) || !is_file(GESHI_DIR.$lang.".php")) - $lang = "whitespace"; + $lang = "text"; $geshi = new GeSHi( $doc->getElementsByTagName("content")->item(0)->textContent, $lang); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5); + ?>
-

getElementsByTagName("title")->item(0)->textContent ?>

-

Posté par getElementsByTagName("author")->item(0)->textContent; if (empty($a)) echo "un anonyme"; else echo $a; ?>, le getElementsByTagName("date")->item(0)->textContent); ?>

+

+ getElementsByTagName("title")->item(0)->textContent)); ?> +

+

+ Posté par getElementsByTagName("author")->item(0)->textContent; + if (empty($a)) + echo "un anonyme"; + else + echo htmlentities(utf8_decode($a)); + ?>, le getElementsByTagName("date")->item(0)->textContent); + ?>

+
+ Répondre + getElementsByTagName("ref"); + if ($ref->length > 0) + { + $r = $ref->item(0)->textContent; + echo 'Voir l\'original'; + } + ?> +
parse_code(); - ?> + ?>
-
-

+ +


-

+

- +'; +?>
diff --git a/htdocs/save.php b/htdocs/save.php index c0e1a2b..ac18378 100644 --- a/htdocs/save.php +++ b/htdocs/save.php @@ -8,21 +8,43 @@ if (!empty($_POST["content"])) $xml_paste = $xml->createElement("paste"); - $xml_paste->appendChild($xml->createElement("title", $_POST["title"])); - $xml_paste->appendChild($xml->createElement("author", $_POST["author"])); - $xml_paste->appendChild($xml->createElement("language", $_POST["lang"])); - $xml_paste->appendChild($xml->createElement("date", time())); - $xml_paste->appendChild($xml->createElement("ip", $_SERVER["REMOTE_ADDR"])); - $xml_paste->appendChild($xml->createElement("content", $_POST["content"])); + $xml_paste->appendChild( + $xml->createElement("title", $_POST["title"])); + $xml_paste->appendChild( + $xml->createElement("author", $_POST["author"])); + $xml_paste->appendChild( + $xml->createElement("language", $_POST["lang"])); + $xml_paste->appendChild( + $xml->createElement("date", time())); + $xml_paste->appendChild( + $xml->createElement("ip", $_SERVER["REMOTE_ADDR"])); + $xml_paste->appendChild( + $xml->createElement("content", $_POST["content"])); + + if (!empty($_POST["ref"])) + $xml_paste->appendChild( + $xml->createElement("ref", $_POST["ref"])); + + $hash = base64_encode(md5($_POST["content"], true)); + $xml_paste->appendChild( + $xml->createElement("hash", $hash)); $xml->appendChild($xml_paste); - $filename = substr(str_replace("+", "", str_replace("/", "", base64_encode(md5($xml->saveXML(), true)), 0, 5))); + //Save the paste + $filename = substr( + str_replace("+", "", + str_replace("/", "", + $hash)), 0, NB_CHAR); - $xml->save(DESTINATION . "/" . $filename . ".xml"); - - header("Location: /?".$filename); - exit; + if ($xml->save(DESTINATION . "/" . $filename . ".xml")) + { + //Redirect the user to is paste + header("Location: /?".$filename); + exit; + } + else + die ("Sorry, an error occured while saving the file. Please try again later."); } header("Location: /"); diff --git a/htdocs/style.css b/htdocs/style.css index 71b9beb..06e2c31 100644 --- a/htdocs/style.css +++ b/htdocs/style.css @@ -1,6 +1,7 @@ body { background: url('img/background.jpg'); + margin-bottom: 234px; } header @@ -95,10 +96,20 @@ fieldset, div#content { div#content { padding: 5px; text-align: left; - width: 80%; + min-width: 80%; +} + +div#content pre { + overflow-x: auto; } textarea#content { height: 200px; width: 90%; -} \ No newline at end of file +} + +div.answer { + float: right; + font-size: 65%; + font-style: italic; +}