diff --git a/NewPastePanel.php b/NewPastePanel.php index f863744..3be6728 100644 --- a/NewPastePanel.php +++ b/NewPastePanel.php @@ -10,7 +10,27 @@ - +
+
+
+ + +
+
+ +
+ + +
+ +
+
+
diff --git a/cronjob.php b/cronjob.php new file mode 100644 index 0000000..702f136 --- /dev/null +++ b/cronjob.php @@ -0,0 +1,15 @@ +prepare("DELETE from `pastes` where `expire`<:time and `expire`>0"); + $stmt->bindValue(':time', $time); + $stmt->execute(); + $conn = null; //close connection to database + echo 'OK! 200'; + } +} +//Cron job example: */5 * * * * curl --silent http://127.0.0.1/paste/cronjob.php?key=b1g51bf6g > /dev/null +//More about cron jobs: http://www.shellhacks.com/en/Adding-Cron-Jobs-in-Linux-Crontab-Usage-and-Examples +?> \ No newline at end of file diff --git a/post.php b/post.php index d1e43c2..ace2446 100644 --- a/post.php +++ b/post.php @@ -34,12 +34,23 @@ if(isset($_POST["type"])){ if(isset($_POST["title"])) $title = $_POST["title"]; $uid = generate_uid(); + $created = time(); + $expire = 0; + if(isset($_POST["expire"]) && is_numeric($_POST["expire"])) + $expire = $created + $_POST["expire"]; /* Add paste to database */ - $stmt = $conn->prepare("INSERT INTO pastes (uid,title,text) - VALUES (:uid, :tit, :txt)"); + $QuerySTR = "INSERT INTO pastes (uid,title,text,created) + VALUES (:uid, :tit, :txt, :cre)"; + if($expire!=0) + $QuerySTR = "INSERT INTO pastes (uid,title,text,created,expire) + VALUES (:uid, :tit, :txt, :cre, :exp)"; + $stmt = $conn->prepare($QuerySTR); + if($expire!=0) + $stmt->bindParam(':exp', $expire); $stmt->bindParam(':uid', $uid); $stmt->bindParam(':tit', $title); $stmt->bindParam(':txt', $text); + $stmt->bindParam(':cre', $created); $stmt->execute(); $conn = null; //close connection to database header("Location: ".$uid);