All pastes #608074 Raw Edit

index.php

public ini v1 · immutable
·published 2007-07-08 01:26 UTC
rendered paste body
<?php### PasteBin sort of thing, but for any source typerequire("template.php");$DB = pg_Connect("host=postgres.netmonks.ca dbname=pastebin user=slepp password=blank");pg_Exec("SET DATESTYLE TO 'Postgres'");if($_POST["s"] == "Submit Post") {    # Sanitize the name    $name = preg_replace("/[^a-zA-Z0-9 .,]/", "", $_POST["name"]);    if(empty($name)) {        $name = "Anonymous";    }    # Store the name in a cookie if requested    if($_POST["save"] == 1 && $name != "Anonymous") {        SetCookie("nmpb",$name,time()+60*60*24*30);        $_COOKIE["nmpb"] = $name;    }    if(strlen($_POST["content"]) < 2) {        pageHeader("empty content");        pageError("You did not provide any content. Please try again.");        pageFooter();        pg_Close($DB);        exit;    }    $name = pg_Escape_String($name);    $content = pg_Escape_String($_POST["content"]);    $type = 1;    pg_Exec("INSERT INTO bin (poster,content,posted,type,remote) VALUES ('$name','$content','now','$type','$_SERVER[REMOTE_ADDR]')");}$fields = "bin.id,poster,content,to_char(posted,'FMDay, Month FMDDth, YYYY at FMHH12:MM:SSam TZ') as posted_format,posted,types.name,date_trunc('second',age('now',posted)) as age";$Res = pg_Exec("SELECT $fields FROM bin,types WHERE types.id=bin.type ORDER BY posted DESC LIMIT 15");if(pg_NumRows($Res) == 0) {    # There are no results    pageHeader("no posts to display");    pageSidebar();    pageMain();    pageFooter();    pg_Close($DB);    exit;}$Posts = array();for($i = 0; $i < pg_NumRows($Res); $i++) {    $Posts[] = pg_Fetch_Array($Res, $i);}pageHeader("collaborative general debugging");pageSidebar($Posts);if($_GET["a"] == "n") {    pageMain();} else {    if(isset($_GET["id"]) && is_numeric($_GET["id"])) {        $Res = pg_Exec("SELECT $fields FROM bin,types WHERE types.id=bin.type AND bin.id='".pg_Escape_String($_GET["id"])."'");        if(pg_NumRows($Res) == 0) {            pageError("That is an invalid ID.", false);            pageFooter();            pg_Close($DB);            exit;        }        $Post = pg_Fetch_Array($Res, 0);        pageMain($Post);    } else {        pageMain($Posts[0]);    }}pageFooter();pg_Close($DB);?>