diff options
Diffstat (limited to 'paste/paste.php')
-rw-r--r-- | paste/paste.php | 110 |
1 files changed, 47 insertions, 63 deletions
diff --git a/paste/paste.php b/paste/paste.php index 2c5a8df..3c7891e 100644 --- a/paste/paste.php +++ b/paste/paste.php @@ -39,76 +39,60 @@ require_once("include/pastify.inc"); // check config if (!is_subclass_of($config['storage'], 'StorageEngine')) { - header('HTTP/1.0 503 Service Unavailable'); - die('Invalid config'); + header('HTTP/1.0 503 Service Unavailable'); + die('Invalid config'); } $refererurl = $_SERVER['HTTP_REFERER']; $refererurl = preg_replace("/\/[^\/]*$/", "", $refererurl); -$thisurl = "http://" . $_SERVER['HTTP_HOST']; -$thisurl .= $_SERVER['PHP_SELF']; -$thisurl = preg_replace("/\/[^\/]*$/", "", $thisurl); - if (isset($_POST['text']) && "" != ($ttemp = rtrim($_POST['text']))) { - $url = ""; - $baseurl = $_SERVER['PHP_SELF']; - $baseurl = preg_replace("/\/[^\/]*$/", "", $baseurl); - - $text = $ttemp; - - // Figure out if the post specified a syntax highlighting language - if (isset($_POST['lang']) && "" != ($ltemp = rtrim($_POST['lang']))) - { - $language = $ltemp; - if (strlen($language) > 20) - $language = substr($language, 0, 20); - $language = stripslashes($language); - $language = strip_tags($language); - $language = htmlspecialchars($language, ENT_QUOTES); - } - else - { - $language = 'Plain Text'; - } - - - // Add a description if available - if (isset($_POST['desc']) && "" != ($dtemp = rtrim($_POST['desc']))) - { - $desc = stripslashes($dtemp); - if (strlen($desc) > 80) - { - $desc = substr($desc, 0, 76); - $desc .= " ..."; - } - $desc = strip_tags($desc); - $desc = htmlspecialchars($desc, ENT_QUOTES); - if ("" == $desc) - $desc = "No description"; - } - else - $desc = "No description"; - - - if (get_magic_quotes_gpc()) - $text = stripslashes($text); - - $url = $config['storage']->setContent($text, $language, $nick, $desc); - - // Note: this function was pretty specific to my implementation. It stored - // paste metadata about the language used, description, and URL, as well as - // a timestamp (but the raw pastes were never preserved - they always expired - // as promised after 24 hours) - //add_to_db($desc, $language, $url); - - Header("Location: $url"); -} -else -{ - header("Location: " . $_SERVER['HTTP_REFERER']); - exit; + $text = $ttemp; + + // Figure out if the post specified a syntax highlighting language + if (isset($_POST['lang']) && "" != ($ltemp = rtrim($_POST['lang']))) + { + $language = $ltemp; + if (strlen($language) > 20) + $language = substr($language, 0, 20); + + $language = stripslashes($language); + $language = strip_tags($language); + $language = htmlspecialchars($language, ENT_QUOTES); + } + else + { + $language = 'Plain Text'; + } + + // Add a description if available + if (isset($_POST['desc']) && "" != ($dtemp = rtrim($_POST['desc']))) + { + $desc = stripslashes($dtemp); + if (strlen($desc) > 80) + { + $desc = substr($desc, 0, 76) . '...'; + } + + $desc = strip_tags($desc); + $desc = htmlspecialchars($desc, ENT_QUOTES); + if ("" == $desc) + $desc = "No description"; + } + else + $desc = "No description"; + + + if (get_magic_quotes_gpc()) + $text = stripslashes($text); + + $url = $config['storage']->setContent($text, $language, $nick, $desc); + header('Location: ' . $url); + exit; } +header('Location: ' . $_SERVER['HTTP_REFERER']); +exit; + ?> |