initial commit

This commit is contained in:
Luke Ogburn
2019-03-30 23:03:43 -04:00
commit 3d9e0c7717
29 changed files with 740 additions and 0 deletions

12
read/delete.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
if($_GET["del"]){
$postID = $_GET["post"];
$stmt = $conn->prepare("DELETE FROM posts WHERE id = :id");
$stmt->bindParam(":id", $postID);
$stmt->execute();
header("Location: /500/read");
}
?>

23
read/index.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
require "/home/lukeuxao/public_html/500/global.php";
?>
<!DOCTYPE html>
<html>
<head>
<?php
$title = "Your Writings";
$css = "read";
require $root."/res/head.php";
?>
</head>
<body>
<?php
require $root."/res/top.php";
if(isset($_GET["post"])){
require "open.php";
}else{
require "list.php";
}
?>
</body>
</html>

12
read/list.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
$stmt = $conn->prepare("SELECT * FROM posts WHERE user_id = :usr ORDER BY date DESC");
$stmt->bindParam(":usr", $current_userID);
$stmt->execute();
$posts = $stmt->fetchAll(PDO::FETCH_OBJ);
foreach($posts as $post){
$link = $post->id;
$date = date("F j, Y", strtotime($post->date));
echo "<h3><a href=?post=$link>$date</a></h3>";
}
?>

31
read/open.php Normal file
View File

@@ -0,0 +1,31 @@
<div id=open>
<?php
if(isset($_GET["del"])){
require "delete.php";
}
require $root."enc.php";
$pid = $_GET["post"];
$stmt = $conn->prepare("SELECT * FROM posts WHERE id = :pid");
$stmt->bindParam(":pid", $pid);
$stmt->execute();
$post = $stmt->fetch(PDO::FETCH_OBJ);
if($current_userID != $post->user_id){
echo "Hey, that's not your post!";
exit();
}
$text = $post->text;
$iv = $post->iv;
$tag = $post->tag;
$text = decrypt($text, $current_key, $iv, $tag);
echo "<h3>".date("F j, Y", strtotime($post->date))."</h3>";
echo "<p>".str_word_count($text)." words <a href=?post=".$_GET["post"]."&del=1 class=hoverColor>delete</a></p>";
echo "<pre>".$text."</pre>";
?>
</div>

21
read/read.css Normal file
View File

@@ -0,0 +1,21 @@
h3{
text-align: center;
}
h3>a.postLink{
color: var(--main-light-color) !important;
text-decoration: none !important;
}
#open{
width: 60%;
margin-left: auto;
margin-right: auto;
}
pre{
font-family: inherit;
font-size: 1em;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}