forked from mikhnyuk/Story
-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
80 lines (78 loc) · 3.38 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
include_once("config.php");
// SQL Connect
$sql = mysqli_connect($config["MySQL_host"],$config["MySQL_user"],$config["MySQL_pass"],$config["MySQL_db"]);
if ($config["Debug"] && mysqli_connect_errno()){
exit("Failed to connect to db");
}
// If there is no input to associate in mysql, then go home
if (!empty($_GET["url_title"])) {
$ut_result = $sql->query("SELECT url_title FROM stories WHERE url_title = '" . $_GET["url_title"] . "'");
$url_title = $ut_result->num_rows > 0 ? true : false;
if (!$url_title) {
header("Location: index.php"); exit;
}
$from_url_title = $sql->real_escape_string($_GET["url_title"]);
// Get data from database
$get_data = $sql->query("SELECT title, author, content, date, hits FROM stories WHERE url_title = '$from_url_title'")->fetch_assoc();
// Add +1 to hits in database since someone viewed the story
$get_hits = $get_data["hits"] +1;
$sql->query("UPDATE stories SET hits = '$get_hits' WHERE url_title = '$from_url_title'");
} else {
header("Location: index.php"); exit;
}
$og_title = strlen($get_data["title"]) > 36 ? substr($get_data["title"], 0, 36) . " ..." : $get_data["title"];
$og_description = strlen($get_data["content"]) > 106 ? substr($get_data["content"], 0, 106) . " ..." : $get_data["content"];
$og_author = $get_data["author"];
mysqli_close($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $config["Site_Title"]; ?></title>
<meta name="description" content="<?php echo $config["Site_Description"]; ?>">
<meta name="author" content="<?php echo $config["Site_Author"]; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="index, follow">
<meta property="og:site_name" content="<?php echo $config["Site_Title"]; ?>">
<meta property="og:type" content="article">
<meta property="og:title" content="<?php echo $og_title; ?>">
<meta property="og:description" content="<?php echo $og_description; ?>">
<meta property="article:published_time" content="<?php echo date("Y-m-d", strtotime($get_data["date"])) . "T" . date("H:i:s", strtotime($get_data["date"])) . "+0000"; ?>">
<meta property="article:author" content="<?php echo $og_author; ?>">
<link href="css/fonts.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<link href="css/quill.bubble.css" rel="stylesheet" />
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/dark.css">
<script src="js/quill.js"></script>
<script src="js/links.js"></script>
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<div class="container">
<div class="row" id="rowtop">
<div class="eleven columns">
<form>
<h4 class="E-title"><strong><?php echo $get_data["title"]; ?></strong></h4>
<br>
<h6 class="V-author"><?php echo $get_data["author"]; ?>
×
<?php echo date($config["DateShowTypeView"], strtotime($get_data["date"])); ?></h6>
<div class="editor"></div>
</div>
<div class="one column"></div>
</form>
<script>
var quill = new Quill('.editor', {
theme: 'bubble',
readOnly: true
});
quill.setContents(<?php echo $get_data["content"]; ?>);
</script>
</div>
</div>
</body>
</html>