All pastes #2092834 Raw Edit

Something

public php v1 · immutable
#2092834 ·published 2011-11-01 23:13 UTC
rendered paste body
<?phpinclude_once("header.php");include_once("config/config.php");@ $db = new mysqli($HOST, $USER, $PASSWORD, $DATABASE, $PORT);if (mysqli_connect_errno()){    echo "Error. Could not connect to the database. Please try again later.";    exit;}if (isset($_GET['id'])){    $id = $_GET['id'];    $query = "SELECT * FROM images WHERE imageid='".$id."'";    $result = $db->query($query);        if ($result)    {        $num = $result->num_rows;        if ($num == 0)        { ?>            <meta http-equiv="refresh" content="0;url=404.php" />        <?php }                else        {            echo "<div id=\"image\">";            for ($i=0; $i < $num; $i++)            {                $row = $result->fetch_assoc();                echo "<h3 class=\"picnumber\"><i>PavThat</i> Image #".$row['imageid']."</h3>";                $id = $row['imageid'];                ?>                <form id="formtop" action="view.php" method="post">                    <input type="hidden" name="lastvisited" value="<?php echo $id; ?>" />                    <input type="image" id="inputsubmittop"  name="submit" value="Next Image &raquo;" src="imgs/next.jpg" onmouseover="this.src='imgs/nextdark.jpg'" onmouseout="this.src='imgs/next.jpg'" />                </form>                <?php                list($width, $height) = getimagesize(IMAGE_DIR."/".$row['source']);                if ($width > MAX_WIDTH)                {                    echo "<img src=\"".IMAGE_DIR."/".$row['source']."\" alt=\"image ".$row['imageid']."\" width=\"".MAX_WIDTH."\" />";                }                else                {                    echo "<img src=\"".IMAGE_DIR."/".$row['source']."\" alt=\"image ".$row['imageid']."\" />";                }                //echo "<p><small>submitted on ".date("F jS \a\t g:ia", strtotime($row['time']))."</small></p>";                echo "<p class=\"description\">".$row['description']."</p>";                echo "<p class=\"pavrating\"><b>Pav Rating: ".round(($row['pavrating']*100),2)."%</b></p>";            }            echo "</div>";            $query = "SELECT * FROM comments WHERE imageid='".$id."'";            $result = $db->query($query);            echo "<div id=\"comments\">";            echo "<h4>Comments:</h4>";            ?>            <form id="commentform" action="submitcomment.php" method="post" onsubmit="if (this.comment.value == 'Add a comment...' || this.comment.value.replace(/^\s*|\s*$/g,'') == '') { alert('Please enter a comment.'); return false; } else { return true; }" >                <textarea name="comment" id="inputcomment" rows="0" cols="0" onfocus="if (this.value=='Add a comment...'){ this.value=''; } this.style.fontStyle='normal'" onblur="if (this.value==''){ this.value='Add a comment...'; this.style.fontStyle='italic' }" >Add a comment...</textarea>                <input type="hidden" name="imageid" value="<?php echo $id; ?>" />                <input type="image" id="inputsubmit" name="submit" value="Submit &raquo;" src="imgs/submit.jpg" onmouseover="this.src='imgs/submitdark.jpg'" onmouseout="this.src='imgs/submit.jpg'" />            </form>            <?php            if ($result)            {                $results = array();                while ($temp = $result->fetch_assoc())                {                    $results[] = $temp;                }                $results = array_reverse($results);                $i=0;                                if (count($results) == 0)                {                    echo "<h5>No comments...</h5>";                }                else                {                    echo "<div id=\"commentbox\">";                    foreach ($results as $row)                    {                        echo "<span class=\"commentauthor\">".$row['author']." says:</span>";                        echo "<span class=\"commenttime\">Posted on ".date("F jS \a\\t g:ia", strtotime($row['time']))."</span>";                        $comment = str_ireplace("/pav", "<span class=\"pav\">/pav</span>", $row['comment']);                        if ($i%2 == 0)                            echo "<p class=\"commenteven\">";                        else                            echo "<p class=\"commentodd\">";                        echo preg_replace("(\n\n|\n)", "<br />", $comment);                        echo "</p>";                        $i++;                    }                    echo "</div>";                }            }            echo "</div>";        }    }    }else if (isset($_POST['lastvisited'])){    $lastid = $_POST['lastvisited'];    $query = "SELECT * FROM images WHERE imageid!='".$lastid."' ORDER BY RAND() LIMIT 1";    $result = $db->query($query);        if ($result)    {        $num = $result->num_rows;        for ($i=0; $i < $num; $i++)        {            $row = $result->fetch_assoc();            $newid = $row['imageid'];            break;        }        echo "<meta http-equiv=\"refresh\" content=\"0;url=view.php?id=".$newid."\" />";    }    else    {        echo "<h4>Something went wrong...</h4>";    }}else{    $query = "SELECT * FROM images ORDER BY RAND() LIMIT 1";    $result = $db->query($query);        if ($result)    {        $num = $result->num_rows;        for ($i=0; $i < $num; $i++)        {            $row = $result->fetch_assoc();            $newid = $row['imageid'];            break;        }        echo "<meta http-equiv=\"refresh\" content=\"0;url=view.php?id=".$newid."\" />";    }    else    {        echo "<h4>Something went wrong...</h4>";    }}$db->close();        include_once("footer.php");?>