require("inc/config.inc.php");
require("inc/sessions.inc.php");
require("inc/db.inc.php");
require("inc/functions.inc.php");
$paste = "";
require("inc/header.inc.php");
?>
Pastebin
if (isset($_REQUEST['paste'])) {
# Get paste_id from request path: "/p.html"
$paste_id = $_REQUEST['paste'];
if (strtoupper($paste_id) == "CURRENT") {
// Show the newest paste
# Fetch the newest paste id from db
$query = prepare_statement("SELECT P.id FROM paste P ORDER BY P.id DESC LIMIT 1");
$result = exec_statement($query);
$row = pg_fetch_row($result);
# Overwrite $paste_id with the most recent paste
$paste_id = $row[0];
}
# Record this paste hit
$query = prepare_statement("INSERT INTO pastehit(remote_ip, date_created, useragent, pasteid, http_referer)
VALUES(%s, NOW(), %s, %s, %s)", $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $paste_id, $_SERVER['HTTP_REFERER']);
$result = exec_statement($query);
# Fetch the paste from the db
$query = prepare_statement("SELECT P.sender_name, P.value, P.id, P.title, P.num_hits FROM paste P WHERE P.id = %s", $paste_id);
$result = exec_statement($query);
# Update number of hits for this paste
$query = prepare_statement("UPDATE paste SET num_hits = num_hits + 1, date_last_hit = NOW() WHERE id = %s", $paste_id);
$result2 = exec_statement($query);
if($row = pg_fetch_array( $result )) {
$n_query_low = prepare_statement("SELECT id FROM paste WHERE id < %s ORDER BY id DESC LIMIT 1;", $paste_id, $paste_id);
$n_query_high = prepare_statement("SELECT id FROM paste WHERE id > %s ORDER BY id ASC LIMIT 1;", $paste_id, $paste_id);
$n_low = pg_fetch_array(exec_statement($n_query_low));
$n_high = pg_fetch_array(exec_statement($n_query_high));
$n_low = $n_low[0];
$n_high = $n_high[0];
$sender_name = empty($row['sender_name']) ? "Anonymous Coward" : $row['sender_name'];
$paste = $row['value'];
$paste_title = $row['title'];
#$paste_url = "?paste=$paste_id";
$paste_url = "p{$paste_id}.html";
?>
Paste #:
if($n_low) {
$n_low_link = "P".htmlspecialchars($n_low).".html";
} else {
$n_low_link = "./";
}
if($n_high) {
$n_high_link = "P".htmlspecialchars($n_high).".html";
} else {
$n_high_link = "./";
}
if($paste_id) {
?>
< previous paste
-
next paste>
}
?>
Pasted by
Download
View as text
} else {
?>
Paste id does not exist
}
}
?>
New Paste
Go to
most recent paste.
require("inc/footer.inc.php");
?>