function addEntry() { require_once 'inc/geshi.php'; $code = $this->post['code']; $lang = $this->post['lang']; $poster = $this->post['poster']; $conn = parent::getPDOConn(); if ($conn == NULL) { parent::addError("Server error - Could not connect to the database"); return false; } if (empty($code) || empty($lang)) { parent::addError("You haven't pasted anything!"); return false; } if (empty($poster)) { $poster = "Anonymous"; } $stmt = $conn->prepare("SELECT * FROM `langs` WHERE `lang` = :lang"); $stmt->bindParam(":lang", $lang); if ($stmt->execute()) { $res = $stmt->fetch(PDO::FETCH_ASSOC); if (empty($res)) { parent::addError("Invalid language"); return false; } } $geshi = new GeSHi($code, $lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); if ($lang !== "None") { $formatted = $geshi->parse_code(); } else { $formatted = "<pre>" . htmlentities($code) . "</pre>"; } $hash = $this->makeHash($this->post['code'], $formatted, $this->post['lang']); $stmt = $conn->prepare("INSERT INTO `pastes` VALUES('', ?, ?, ?, ?, ?, ?)"); if ($stmt->execute(array(htmlentities($code), $formatted, $res['filename'], $hash, $poster, time()))) { parent::addMessage("Paste has been added! Click <a href=\"view.php?pid=" . $hash . "\">here</a> to view.<br /><input type=\"text\" value=\"http://pb.pwnds.info/view.php?pid=" . $hash . "\" readonly />"); return $hash; } else { parent::addError("Server error - Couldn't add paste. " . $this->post['lang'] . " " . print_r($stmt->errorInfo(), true)); return false; } }
protected function loadMessages(Page $page) { if (!empty($_GET['m'])) { foreach ($_GET['m'] as $msg) { if (isset($this->msgs[$msg])) { $page->addMessage($this->msgs[$msg]); } } } }