index.php (4069B)
1 <!DOCTYPE html>
2 <html lang="en">
3
4 <head>
5 <meta charset="UTF-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 <meta name="robots" content="noindex">
9 <link rel=stylesheet type=text/css href=/assets/css/simple.min.css />
10 <link rel=icon href=/assets/img/favicon.ico>
11 <link rel=icon type=img/png sizes=128x128 href=/assets/img/favicon_128.png>
12 <link rel=icon type=img/png sizes=64x64 href=/assets/img/favicon_64.png>
13 <link rel=icon type=img/png sizes=32x32 href=/assets/img/favicon_32.png>
14 <link rel=icon type=img/png sizes=16x16 href=/assets/img/favicon_16.png>
15 <title>pastesrv</title>
16 </head>
17
18 <body>
19
20 <header>
21 <h1>pastesrv</h1>
22 <a class="button" href="/">
23 Home
24 </a>
25 <a class="button" href="#about">
26 About
27 </a>
28 <a class="button" href="#how">
29 How
30 </a>
31 <a class="button" href="https://src.jayvii.de/pub/pastesrv">
32 Source
33 </a>
34 </header>
35
36 <?php
37
38 /* Load Configuration */
39 include("config/config.php");
40
41 /* If auth is successfull, show uploader or process file */
42 if (hash("sha256", $_GET["auth"]) === $auth_hash) {
43
44 ?>
45
46 <!-- Uploader -->
47 <section id="paste">
48 <h2>Paste Text or Upload file</h2>
49 <p>
50 You may also upload a file here directly or paste text in the textbox
51 below instead.
52 </p>
53 <form
54 action="<?php echo "/?auth=" . $_GET["auth"] . "#paste"; ?>"
55 target="_self"
56 method="post"
57 enctype="multipart/form-data"
58 >
59 <input
60 name="file"
61 type="file"
62 style="width:100%;"
63 class="button"
64 >
65 <textarea
66 name="text"
67 style="width:100%;"
68 autofocus
69 placeholder="Insert Text you want to paste"
70 wrap="soft"
71 ></textarea>
72 <input type="submit" value="Paste!">
73 </form>
74
75 <?php
76
77 /* Process file if available */
78 if (!is_null($_FILES["file"]["tmp_name"]) || $_POST["text"] != "") {
79
80 /* Create Hash Name */
81 $hash = hash("sha256", time() . $salt);
82 $pasted = false;
83
84 /* Process if file was uploaded */
85 if (!is_null($_FILES["file"]["tmp_name"])) {
86
87 /* Move file to designated place */
88 $pasted = move_uploaded_file(
89 $_FILES["file"]["tmp_name"],
90 "./" . $hash
91 );
92
93 }
94
95 /* Process if text was given */
96 if ($_POST["text"] != "") {
97 $pasted = file_put_contents(
98 "./" . $hash,
99 $_POST["text"]
100 );
101 $pasted = $pasted > 0;
102 }
103
104 if ($pasted) {
105
106 ?>
107
108 <p>
109 Your file is available at:<br>
110 <a href="<?php echo $hash; ?>" target="_blank">
111 <?php echo $_SERVER["SERVER_NAME"] . "/" . $hash; ?>
112 </a>
113 </p>
114
115 <?php
116
117 } /* Pasting was successful */
118
119 } /* File was uploaded or text input was given */
120
121 } /* Auth is correct */
122
123 ?>
124
125 <!-- About Section -->
126 <section id="about">
127 <h2>About pastesrv</h2>
128 <p>
129 Super simple selfhosted paste server, based around minimal and basic
130 tools, which you can selfhost within seconds without much effort.
131 </p>
132 </section>
133
134 <!-- How To Use -->
135 <section id="how">
136 <h2>How to use</h2>
137 <p>
138 The original functionality is described in a blogpost on
139 <a
140 href="https://www.codemadness.org/paste-service.html"
141 target="_blank"
142 >
143 codemadness.org
144 </a>
145 </p>
146 <p>
147 Using the
148 <code>
149 <a
150 href="https://src.jayvii.de/pub/pastesrv/file/pastesrv.sh.html"
151 target="_blank"
152 >
153 pastesrv.sh
154 </a>
155 </code>
156 function, you can pipe any content to the paste service through SSH.
157 </p>
158 </section>
159
160 </body>
161
162 </html>