diff --git a/.htaccess b/.htaccess index 54b366f..5015e36 100644 --- a/.htaccess +++ b/.htaccess @@ -6,4 +6,5 @@ RewriteBase "/paste/" RewriteRule ^u/([A-Za-z0-9-]+)/?$ index.php?user=$1 RewriteRule ^delete/([A-Za-z0-9-]+)/?$ delete.php?id=$1 +RewriteRule ^edit/([A-Za-z0-9-]+)/?$ index.php?page=edit&id=$1 RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 diff --git a/MyPastes.php b/MyPastes.php index c03f5fc..0385c53 100644 --- a/MyPastes.php +++ b/MyPastes.php @@ -41,7 +41,12 @@ if($stmt->rowCount()>0){ //Paste url printf(''.htmlspecialchars($row["uid"], ENT_QUOTES, 'UTF-8').''); //Actions - printf(''); + printf(''); + //delete paste + printf(''); + //edit paste + printf(''); + printf(''); } printf(''); } else { diff --git a/NewPastePanel.php b/NewPastePanel.php index 60e57b5..05ff2af 100644 --- a/NewPastePanel.php +++ b/NewPastePanel.php @@ -1,21 +1,41 @@
-
+'); + }else printf(''); +?>
- + '); + } else printf(''); + ?>
- + '.$row['text'].''); + } else printf(''); + ?>
- + "); + printf(""); + } else printf(""); + ?>
- +
@@ -36,6 +56,10 @@
diff --git a/ViewPaste.php b/ViewPaste.php index de12930..330a548 100644 --- a/ViewPaste.php +++ b/ViewPaste.php @@ -1,4 +1,4 @@ -
+
+
+
+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