<?php /* This file is part of the Pastebin package. Copyright (c) 2003-2008, Stephen Olesen All rights reserved. More information is available at http://pastebin.ca/ */ require_once "include/global.inc.php"; $tpl = new Template(); $tpl->assign('typeOptions', TypeUtil::getOptionList()); if (isset($_GET["id"])) { $p = new Paste(); if ($p->load($_GET["id"])) { $tpl->assign('paste', $p); $tpl->headers(); if ($p->id_mask != null) { $tpl->assign('urlid', $p->id_mask); } else { $tpl->assign('urlid', $p->id); } $tpl->assign('title', _("General Pastebin") . " - " . htmlentities($p->poster, ENT_COMPAT, "UTF-8") . " - " . _("Paste number") . " " . $p->id); $tpl->display('paste-main.tpl', $p->id); exit; } } $tpl->headers(); $tpl->display('main.tpl');
/** * 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; } }