Giter Site home page Giter Site logo

pasthis's Introduction

Pasthis

Pasthis is a pastebin written in PHP using SQLite as database backend, prettify to handle syntax highlighting and skeleton. This project is licensed under GPLv2+.

Pasthis screenshot

Privacy, security, simplicity

  • Expired pastes are automatically deleted.
  • Paste IDs aren't predictable (their URL cannot be guessed easily).
  • No statistics, counter or public list of pastes is available.
  • The use of HTTPS to post or get the pastes is enforced.
  • A trivial anti-spam filter is built-in.
  • By default the content is not formatted nor changed in any way (no wrap, no syntax highlighting). It is a user driven choice to do so.
  • Pastes can be displayed as raw.
  • A command-line tool can be downloaded to post pastes directly from terminals.
  • Tabulations are handled within the textarea to avoid changing the focus.
  • The design is mobile friendly (responsive) 😊

Deployment

  1. Download Pasthis.
  2. Configure the web server:
  3. Make sure that the folder is readable and writable by www-data, since this is required by PHP to be able to create the SQLite database.

It is required to call the cron method on a regular basis to delete expired pastes, as a privacy concern. To do this on a GNU/Linux machine edit the /etc/crontab file and add the following line:

*/10 * * * * www-data php /path/to/pasthis/index.php

Be aware expired pastes can only be deleted when requested or when the cron method is called. Without the previous cron configuration, their deletion can't be ensured. They just won't be displayed.

Update

  1. Update to the latest version (keep the database!).
  2. Run php update.php.

Command line tool

A command line tool is available allowing you to post files. In order to take advantage of this utility, download it, make it executable and display the help output for more information:

chmod +x ./pasthis.py
./pasthis.py --help
./pasthis.py --url https://www.example.net/pasthis/ file.txt

Anti-spam

Every time a paste is sent, a value (called degree) is associated to the poster's ip hash. It is used in the following formula:

T = time() + intval(pow(degree, 2.5))

If the user posts another paste after T, the degree is reset to zero. If he tries before T, the degree is incremented, and the paste is denied.

There is also an hidden field, that set the degree to 512 (which corresponds to ~72h) if filled.

pasthis's People

Contributors

atenart avatar hyask avatar jvoisin avatar paulkocialkowski avatar tpetazzoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pasthis's Issues

Unusable "burn after reading" option

Summary

When trying to use the "burn after reading" option the paste becomes unavailable, using the latest version of this repo.

Steps to reproduce

  1. Create a new paste
  2. Select "burn after reading"
  3. Send the paste
  4. Get redirected to see the paste

Expected behavior

Create a new paste, get redirected to it but let it be available one more time. I think that the issue comes from step 4 described above.

Change text color

When the syntax highlight fails, the read is rendered in black, on a black background.

Url routing

Pasthis should come with an .htaccess to have nice urls, and the equivalent for nginx ;)

This should also fix #3 .

Line numbers

It would be nice to have line numbers displayed on pastes.

Nginx won't rewrite after sending paste

Hi there,

I get always a 404 error, my files.conf look like this:

server {
    listen 80;
    server_name paste.blah.org;

    root /srv/htdocs/paste.blah.org;
    index index.php;

    location / {
            if (!-e $request_filename){
            rewrite "^([a-zA-Z0-9]{6}(@raw)?)$" /index.php?p=$1;
            }
    }

    location /pasthis.db {
                deny all;
    }

    location ~ \.php$ {
                 include fastcgi.conf;
                 fastcgi_index index.php;
                 fastcgi_pass 127.0.0.1:9000;
    }
}

Thanks in advance for helping.
Cheers,

<tab> handling

When the user has javascript, should insert a tab instead of going to the next input.

Cosmetic

Improve coding style consistency

Show remaining time

Maybe we should show the remaining time before expiration of the current paste ?

Harmonize the design

Currently, the input and the show pages are not assorted at all. Either use the default theme from the browser, or force the black and white one.

Throttle

It would be nice to fix a throttle, to avoid/reduce spam.
Storing a timestamp and a hash of the ip?

Return HTTP code to spammers?

I think we should return an HTTP code to spammers. Either:

  • a 301 (or the shiny new 308), to redirect to a randomly generated URL, or even its own IP
  • a 420 (β™₯) : Enhance Your Calm
  • a 429 : Too Many Requests

New release tag

There has been quite a few commits since v4, especially some fixing PHP 8 compatibility issues.

Would it be possible to create a new tag, so php update.php works?

Thanks! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.