Advertisement
Snuggledash

makiba.patch

Feb 4th, 2020
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.70 KB | None | 0 0
  1. acquire file lock in writeposts() too
  2. fix redirects
  3. fix noko for replies
  4. show thread-specific post IDs instead of IPs
  5. remove various debug messages interrupting flow
  6.  
  7. diff --git a/README.md b/README.md
  8. index 55fc067..d2ddcc2 100644
  9. --- a/README.md
  10. +++ b/README.md
  11. @@ -3,13 +3,14 @@ small imageboard script- on devel
  12.  A futaba-style imageboard script that doesn't require a database.
  13.  ~~~~~~~~~~~~~~~~~~~
  14.  
  15. -#credits
  16. +# credits
  17.  tripcode!q/7 - helping out with the software
  18.  Pineapple - helping out aswell
  19. +qa-tari - several fixes suggested on /qa/
  20.  
  21.  ~~~~~~~~~~~~~~~~~~~
  22.  
  23. -# Admin pannel Installation
  24. +# Admin panel installation
  25.  ~~~~~~~~~~~~
  26.  -> sudo apt install php-mbstring
  27.  make sure php-mbstring is installed
  28. @@ -18,20 +19,18 @@ make sure php-mbstring is installed
  29.  # Installation
  30.  ~~~~~~~~~~~~
  31.  make sure to install php-gd
  32. -https://www.php.net/manual/de/image.installation.php
  33. +https://www.php.net/manual/image.installation.php
  34.  imagecreatefromjpeg is in plain php undefined
  35. -debian:
  36. +On Debian:
  37.  -> sudo apt install php-gd
  38.  
  39. -if you need help answer's are here: https://stackoverflow.com/questions/13338339/imagecreatefromjpeg-and-similar-functions-are-not-working-in-php
  40. -
  41. -
  42. +If you need help, answers are here: https://stackoverflow.com/questions/13338339/imagecreatefromjpeg-and-similar-functions-are-not-working-in-php
  43.  
  44.  
  45.  To install, move all the files in the repo to a directory in the
  46.  root of your webserver. For example, for a board called `/b/`, move
  47.  them to /usr/share/nginx/html/b/. Create the directories `src`,
  48. -`thumb`, `bans`, `bad` and `res` and the files `posts` and `info`,
  49. +`thumb` and `res` and the files `bans`, `bad`, `posts` and `info`,
  50.  make sure they are all writable to by the web server user.
  51.  
  52.  Should work on any unix-like system with PHP 5.5 or above and GD Library.
  53. diff --git a/post.php b/post.php
  54. index 3215553..fbd2866 100644
  55. --- a/post.php
  56. +++ b/post.php
  57. @@ -67,8 +67,7 @@ a:visited {
  58.  
  59.  </div>
  60.  </div>
  61. -</form>';
  62. -</html>
  63. +</form>
  64.  <?php
  65.    
  66.  
  67. @@ -139,6 +138,12 @@ define("ERR_TOOLONG", "Your comment is too long. Try and summarise it.");
  68.  define("ERR_FULLTHREAD", "The thread you have replied to has reached the maximum number of posts.");
  69.  define("ERR_ADMINOPONLY", "Sorry, only the administrator can create new threads at the moment.");
  70.  
  71. +function posthash($tp){
  72. +    $threadid = $tp['thread']?$tp['thread']:$tp['id'];
  73. +    $identity = $tp['ip']."\x1f".$threadid."\x1f".SECRETKEY;
  74. +    return substr(hash("sha256", $identity),-8);
  75. +}
  76. +
  77.  function mktripcode($pw){
  78.      /* this function is Copyright (C) avimedia, licensed under the GPLv3
  79.         source: http://avimedia.livejournal.com/1583.html
  80. @@ -243,7 +248,6 @@ function num_posts($parent){
  81.  
  82.  function postexists($id){
  83.     foreach(getposts() as $p){
  84. -        print "id is " . $p['id'];
  85.         if($p['id'] == $id){
  86.              return 1;
  87.         }
  88. @@ -384,7 +388,7 @@ function can_post($ip){
  89.  function old_style_text($tp){
  90.      $time = date("y/m/d (D) H:i", $tp['time']);
  91.      return '<input type=checkbox name="del[]" value="'.$tp['id'].'"><font color="#cc1105"><b>'.$tp['subject'].'</b></font>
  92. -Name <font color="#117743"><b '.($tp['admin'] ? 'class="adminpost"' : '').'>'.$tp['name'].' </b></font> '.$time.' IP:'.$tp['ip'].' No.<a href="javascript:void(0);" onclick="javascript:quote('.$tp['id'].');">'.$tp['id'].'</a>';
  93. +Name <font color="#117743"><b '.($tp['admin'] ? 'class="adminpost"' : '').'>'.$tp['name'].' </b></font> '.$time.' ID:'.posthash($tp).' No.<a href="javascript:void(0);" onclick="javascript:quote('.$tp['id'].');">'.$tp['id'].'</a>';
  94.  }
  95.  
  96.  function old_style_image($tp){
  97. @@ -515,7 +519,7 @@ function postform($op){
  98.          if(!ADMINOPONLY || $op > 0){
  99.      if(!LOCKED){
  100.          if(num_posts($op) < MAXREPLIES){
  101. -        $r .= '<form action="post.php?mode=post" method="POST" enctype="multipart/form-data">';
  102. +        $r .= '<form action="'.URLROOT.SCRIPTNAME.'?mode=post" method="POST" enctype="multipart/form-data">';
  103.  
  104.          $r .= '<input type="hidden" name="thread" value="'.$op.'">';
  105.      
  106. @@ -703,7 +707,7 @@ function writeposts($posts){
  107.              $l .= "\x1e";
  108.          }
  109.      }
  110. -    file_put_contents(POSTSFILE, $l);
  111. +    file_put_contents(POSTSFILE, $l, LOCK_EX);
  112.  
  113.  }
  114.  
  115. @@ -895,7 +899,6 @@ if(isset($_GET['mode'])){
  116.             $tidi = intval($_POST['thread']);
  117.             if($tidi == 0) { $op = 0; }
  118.             else {
  119. -                print "postexists(tidi) is " . postexists($tidi);
  120.                 if(postexists($tidi)) { $op = $tidi; }
  121.                 else { abort_error(ERR_NOTFOUND); }
  122.             }
  123. @@ -1117,16 +1120,19 @@ if(isset($_GET['mode'])){
  124.          
  125.         insertpost($pinf);
  126.          
  127. -        echo '<!doctype html><html><head>';
  128.          if($pinf['email'] == "noko"){
  129. -            echo '<meta http-equiv="refresh" content="2; url='.URLROOT.THREADDIR.$pinf['id'].'.html"></head><body>';
  130. +       if($op>0) {
  131. +                echo '<meta http-equiv="refresh" content="2; url='.URLROOT.THREADDIR.$op.'.html#p'.$pinf['id'].'">';
  132. +            } else {
  133. +                echo '<meta http-equiv="refresh" content="2; url='.URLROOT.THREADDIR.$pinf['id'].'.html">';
  134. +            }
  135.              if($pinf['src'] != ""){
  136.                  echo '<h2>'.$pinf['file'].' uploaded. Redirecting to the thread.';
  137.              } else {
  138.                  echo '<h2>Comment posted. Redirecting to the thread.</h2>';
  139.              }
  140.          } else {
  141. -            echo '<meta http-equiv="refresh" content="2; url=".URLROOT."0.html"></head><body>';
  142. +            echo '<meta http-equiv="refresh" content="2; url='.URLROOT.'0.html">';
  143.              if($pinf['src'] != ""){
  144.                  echo '<h2>'.$pinf['file'].' uploaded.';
  145.              } else {
  146. @@ -1136,3 +1142,4 @@ if(isset($_GET['mode'])){
  147.      }
  148.  }
  149.  ?>
  150. +</html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement