<?php require_once "../common.php"; function generate_latex($filein) { print system("pdflatex -halt-on-error -output-directory ../gen " . $filein, $ret); if ($ret == 0) { return "../gen/" . basename(str_replace(".tex", ".pdf", $filein)); } else { return NULL; } } foreach ($_GET as $k => $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)) { ?> <!doctype html> <html> <head> <meta charset="UTF-8"> <title>.: Pommultimédia - Paste :.</title> <link href="style.css" rel="stylesheet" type="text/css"> <link href="favicon.ico" type="image/x-icon" rel="shortcut icon"/> </head> <body> <div id="corps" style="text-align: center;"> <h1> <?php echo htmlentities($paste->title); ?>
/** * Save the current paste */ function save($filename = NULL) { $this->hash = base64_encode(sha1($this->content, true)); if (empty($filename)) { $i = 0; do { $filename = substr(str_replace("+", "", str_replace("/", "", $this->hash)), $i++, NB_CHAR); } while (is_file(Paste::get_path($filename)) && Paste::speed_cmp(Paste::get_path($filename), $this->hash)); } $this->filename = $filename; $xml = new DOMDocument('1.0', 'UTF-8'); $xml->formatOutput = true; $xml_paste = $xml->createElement("paste"); $xml_paste->appendChild($xml->createElement("title", $this->title)); $xml_paste->appendChild($xml->createElement("author", $this->author)); $xml_paste->appendChild($xml->createElement("language", $this->language)); $xml_paste->appendChild($xml->createElement("date", $this->date)); $xml_paste->appendChild($xml->createElement("ip", $this->ip)); $cnt = $xml->createElement("content"); $cnt->appendChild($xml->createCDATASection($this->content)); $xml_paste->appendChild($cnt); if (!empty($this->crypt)) { $xml_paste->appendChild($xml->createElement("crypt", base64_encode($this->crypt))); } if (!empty($this->ref)) { //Also indicate in the parent file $parent = new Paste($this->ref); //Does the parent exist? if ($parent->load()) { $xml_paste->appendChild($xml->createElement("ref", $this->ref)); if ($parent->add_answer($this->filename)) { $parent->save(); } } } foreach ($this->answers as $a) { $xml_paste->appendChild($xml->createElement("answer", $a)); } $xml_paste->appendChild($xml->createElement("hash", $this->hash)); if ($this->is_private()) { $xml_paste->appendChild($xml->createElement("private")); } $xml->appendChild($xml_paste); if ($xml->save(Paste::get_path($this->filename))) { return $this->filename; } else { die("Sorry, an error occured while saving the file. Please try again later."); return FALSE; } }
$boundary = $out[1]; } else { if (empty($ffrom) && preg_match("#^From: (.+)#", $line, $out)) { $ffrom = $out[1]; } else { if (empty($subject) && preg_match("#^Subject: (.+)#", $line, $out)) { $subject = $out[1]; } } } } } } // Extract username instead of email adress if it exists if (preg_match("#([^<]+) <#ui", $ffrom, $out)) { $from = $out[1]; } else { $from = $ffrom; } // Create the paste $paste = new Paste(); $paste->title = $subject; $paste->author = $from; $paste->date = time(); $paste->content = utf8_encode(trim($cnt[max(0, $i - 1)])); // Save the paste and give read right to all users (if mail user is different from php one) $link = $paste->save(); chmod(Paste::get_path($paste->filename), 0644); // Send confirmation email $headers = 'From: paste@p0m.fr' . "\r\n" . 'Content-Type: text/plain; charset="utf-8"' . "\r\n" . 'X-Mailer: ' . ucfirst(HTTP_URL); mail($ffrom, "Re: " . $subject, "Bonjour,\n\nVotre paste a bien été publié à l'adresse suivante :\nhttp://" . HTTP_URL . "/?" . $link . "\n\n-- \n" . HTTP_URL, $headers);
} ?> </div> </div> </body> </html> <?php $view++; } } //Don't show the creation part when we show paste if (!empty($view)) { exit; } //Load answer paste if (!empty($_GET["a"]) && preg_match("#^([a-zA-Z0-9]{" . RGXP_NB . "})(:([a-zA-Z0-9]{" . RGXP_NB . "}))?\$#", $_GET["a"], $kout) && is_file(Paste::get_path($k = $_GET["a"]))) { $paste = new Paste($k); } else { $paste = new Paste(); } ?> <header> <h1><span>Pommultimédia</span></h1> <h2><span>Service de partage de code</span></h2> </header> <div id="corps"> <form method="post" action="save.php"> <fieldset class="paste_form"> <label for="title">Titre :</label> <input type="text" size="42" id="title" name="title" value="<?php echo $paste->title;