-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.php
113 lines (92 loc) · 3.25 KB
/
preview.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
session_start();
include 'database/connect.php';
include 'functions.php';
protectAdmin();
include 'langCheck.php';
$id = $_GET['id'];
$query = $con->prepare( "SELECT * FROM snippets WHERE id = ?" );
$query->bind_param( "s", $id);
$query->execute();
$query->store_result();
$number = $query->num_rows;
$query->close();
if( $number>0 && isset($_GET['id']) && is_numeric($id) ) {
$query = $con->prepare( "SELECT snippet FROM snippets WHERE id = ?" );
$query->bind_param( "s", $id);
$query->execute();
$query->bind_result($code);
$query->fetch();
$query->close();
$code = htmlentities($code);
$query = $con->prepare( "SELECT title, syntax, description, date FROM snippets WHERE id = ?" );
$query->bind_param( "s", $id);
$query->execute();
$query->bind_result($title, $syntax, $description, $date);
$query->fetch();
$query->close();
$query = $con->prepare( "SELECT tags FROM tags_snippets WHERE snippets_id = ?" );
$query->bind_param( "s", $id);
$query->execute();
$query->bind_result($tag);
while($query->fetch()){
$temp[] = "#".$tag;
}
$query->close();
$tagsList = implode( ", ", $temp);
?>
<!DOCTYPE html>
<html lang="<?php if(isset($_SESSION['lang'])) { echo $_SESSION['lang']; } else { echo "en"; }?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?=$lang['pageTitle']; ?> - <?=$title; ?></title>
<link rel="stylesheet" href="assets/css/fonts.css">
<link rel="stylesheet" href="assets/css/public.css">
<script src="lib/jquery/jquery-3.6.0.min.js"></script>
<script src="lib/prism/prism.js"></script>
</head>
<body>
<main class="main-wrap">
<div class="title-area">
<a href="admin-main.php"><label title="<?=$lang['goHome']?>" class="appTitle"><?=$lang['pageTitle']; ?></label></a>
</div>
<div class="details-window-top">
<h3 id="detail-title"><?=$title?></h3>
<span id="date-label"> - <?=$lang['created']?> (<?=$date?>) </span>
</div>
<div class="details-window-under">
<span><?=$lang['description']?>:</span><br>
<span id="detail-desc"><?=$description?></span><br><br>
<span id="detail-tags"><?=$tagsList?></span>
</div>
<pre class="pre-code <?=$linenumbers?> language-<?=$date; ?> rainbow-braces">
<code id="code-block" class="language-<?=$date; ?>">
<?=$code?>
</code>
</pre>
</main>
</body>
</html>
<?php } else { ?>
<!DOCTYPE html>
<html lang="<?php if(isset($_SESSION['lang'])) { echo $_SESSION['lang']; } else { echo "en"; }?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title><?=$lang['pageTitle']; ?> - <?=$lang['notFound']; ?></title>
<link rel="stylesheet" href="assets/css/fonts.css">
<link rel="stylesheet" href="assets/css/public.css">
<script src="lib/jquery/jquery-3.6.0.min.js"></script>
<script src="lib/prism/prism.js"></script>
</head>
<body>
<main class="main-wrap">
<a href="admin-main.php"><h2 class="main-label"><?=$lang['pageTitle']; ?></h2></a>
<p id="message"><?=$lang['snippetNotFound']; ?></p>
</main>
</body>
</html>
<?php } ?>