Advertisement
sindeus

php

Oct 2nd, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <?php
  4.     $resdir = '/var/www/html/res/';
  5.     if (!file_exists($resdir) ) {
  6.         mkdir ($resdir, 0744);
  7.     }
  8.     $slogans = array("Literally the best.", "Airship.moe 2.0", "Jingly as Fuck.");
  9.     $actSlogan = $slogans[array_rand($slogans)];
  10. ?>
  11.  
  12. <html>
  13.     <head>
  14.         <meta charset="UTF-8">
  15.         <title>Marzana.tk</title>
  16.         <link rel="stylesheet" type="text/css" href="style.css">
  17.     </head>
  18.     <body>
  19.         <h1>Marzana.tk</h1>
  20.         <h2> - <?php echo $actSlogan;?></h2>
  21.         <div id="text">
  22.             <?php
  23.                 $txtfile;
  24.                 if($_POST['posttxt'] == '!CLEAR') {
  25.                     unlink($resdir . 'text.txt');
  26.                    
  27.                 }
  28.                 elseif(isset($_POST['posttxt'])) {
  29.                     if(!$txtfile = fopen($resdir . 'text.txt', 'a+')) {
  30.                             echo 'File write open error.<br />';
  31.                         }
  32.                     if(!fwrite($txtfile, str_replace(PHP_EOL, '<br />', htmlspecialchars($_POST['posttxt'])) . PHP_EOL)) {
  33.                             echo 'File write error.<br />';
  34.                         }
  35.                     fclose($txtfile);
  36.                 }
  37.                    
  38.                 if(!$txtfile = fopen($resdir . 'text.txt', 'r')) {
  39.                     echo '<span style="color: #cccccc;">Nothing here.</span><br />';
  40.                 }
  41.                 while ($line = fgets($txtfile)) {
  42.                     echo '<div class="line">' . $line . '</div>' . PHP_EOL;
  43.                 }
  44.                
  45.                 fclose($txtfile);
  46.             ?>
  47.         </div>
  48.         <br /><br />
  49.         <form type="text/multipart" method="post">
  50.             <textarea id="posttxt" name="posttxt" cols="80" rows="10""></textarea>
  51.             <br />
  52.             <br />
  53.             <input type="submit" value="Post" />
  54.         </form>
  55.     </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement