+
+
+prepare('SELECT * FROM pastes WHERE uid=:uid');
+ $stmt->bindParam(':uid', $paste);
+ $stmt->execute();
+ if($stmt->rowCount()>0){
+ while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ if($row['owner'] === $uid){
+ include "NewPastePanel.php";
+ } else {
+ $conn = null;
+ echo '
You are not the owner of the paste '.$row["uid"].'
';
+ echo '';
+ die();
+ }
+ }
+ } else {
+ $conn = null;
+ echo 'The paste '.$row["uid"].' does not exist
';
+ echo '';
+ }
+ $conn = null;
+ }
+?>
+
+
+
\ No newline at end of file
diff --git a/index.php b/index.php
index cfa04d0..51a1626 100644
--- a/index.php
+++ b/index.php
@@ -12,7 +12,7 @@ if(isset($_GET["page"]) && $_GET["page"] == "login" && isset($_POST["type"]) &&
';
$dir = "";
- if (isset($_GET["user"]))$dir="../";
+ if (isset($_GET["user"]) || isset($_GET["page"]) && $_GET["page"]=="edit")$dir="../";
echo '
';
echo '';
@@ -41,7 +41,7 @@ if(isset($_GET["page"]) && $_GET["page"] == "login" && isset($_POST["type"]) &&
@@ -54,7 +54,7 @@ if(isset($_GET["page"]) && $_GET["page"] == "login" && isset($_POST["type"]) &&
query('SELECT owner FROM pastes WHERE uid="'.$uid.'"');
+ if($result = $stmt->fetch(PDO::FETCH_ASSOC)){
+ $paste_owner = $result['owner'];
+ }
+ /* Edit paste in database */
+ if($owner === $paste_owner && $owner !== 0){
+ $QuerySTR = " UPDATE pastes SET title=:tit,text=:txt,created=:cre,expire=:exp,exposure=:exposure,owner=:own,highlight=:hl
+ WHERE uid=:uid";
+ $stmt = $conn->prepare($QuerySTR);
+ $stmt->bindParam(':exp', $expire);
+ $stmt->bindParam(':uid', $uid);
+ $stmt->bindParam(':tit', $title);
+ $stmt->bindParam(':txt', $text);
+ $stmt->bindParam(':cre', $created);
+ $stmt->bindParam(':exposure', $exposure);
+ $stmt->bindParam(':own', $owner);
+ $stmt->bindParam(':hl', $syntax);
+ $stmt->execute();
+ $conn = null; //close connection to database
+ header("Location: ".$uid);
+ die();
+ } else {
+ $conn = null; //close connection to database
+ echo "
This paste does not belong to you!
";
+ die();
+ }
}
}
?>
\ No newline at end of file