pub / pastesrv

Paste service setup for paste.jayvii.de
git clone https://https://src.jayvii.de/pub/pastesrv.git
Home | Log | Files | Exports | Refs | README | RSS

index.php (4026B)


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