Paste 3.5

Changelog

Paste is a project that began in 2010 from the original pastebin.com source and has evolved into a fully-featured, modern code sharing platform.

A Python paste with syntax highlighting and line numbers, with the recent pastes list beside it
A paste on the default theme.

Features

Pastes

  • Syntax highlighting for over 200 languages with GeSHi or highlight.php, and language autodetection
  • Public, unlisted and private pastes that expire after 10 minutes to a year, after the first view, or never
  • Password protection with every paste encrypted, and optional AES-256-GCM client-side encryption
  • Every paste is stored encrypted in the database
  • Forks with a diff view, comments, Markdown, raw and download links, and embeds
  • Short random URLs or numeric IDs, with clean URLs on Apache or nginx

Uploads

  • Image and video uploads, each stored encrypted with its link as the key, so a file can't be opened without its link, even by admins
  • Optional client-side encryption, and EXIF and GPS tags removed by default
  • Upload host for IRC clients that support the IRCv3 draft/FILEHOST spec

Accounts and admin

  • Registration with email verification, and sign-in with Google
  • Admin panel for pastes, users, uploads, IP bans, pages, ads, statistics and the sitemap
  • Admin accounts can be limited to the sections they look after
  • An installer that also upgrades an existing site in place
  • Interface in ten languages

Spam

  • A points-based filter with your own rules, a filter that learns from what you approve and reject, link domain and IP blocklists, StopForumSpam and a moderation queue
  • reCAPTCHA v2 or v3, Cloudflare Turnstile, or a built-in image captcha

API

  • JSON API to create, read, update, search and delete pastes, and to upload files
  • Keys are stored hashed, can be limited to what they may do, and are rate limited
  • A command-line client in Python
The new paste form with title, language, expiry, visibility and password fields
New paste
The spam filter settings in the admin panel
Admin > Spam Filter

Install

  1. Create a MySQL or MariaDB database and a user for it:
  1. CREATE DATABASE paste CHARACTER SET utf8mb4;
  2. CREATE USER 'paste'@'localhost' IDENTIFIED BY 'choose-a-password';
  3. GRANT ALL ON paste.* TO 'paste'@'localhost';
  1. Upload the files to your web server.
  2. Open /install/ in your browser. It checks your PHP setup, asks for the database details and an admin account, and writes config.php.
  3. Delete the install folder.

Upgrading: upload the new files over the old ones, keeping config.php, then open /install/ again and sign in with a full-access admin account, or run php install/upgrade.php. Your settings, pastes and uploads are kept.

Clean URLs work with the included .htaccess on Apache; on nginx, start from docs/nginx.example.conf. Composer is only needed for Google sign-in and SMTP mail.

Create a paste from the command line

Bash curl and the Python client
API documentation
  1. curl -X POST "https://paste.example.com/api.php?action=paste" \
  2. -H "X-API-Key: your_api_key" \
  3. -H "Content-Type: application/json" \
  4. -d '{"content": "print(\"hello\")", "title": "hello.py", "syntax": "python", "expiry": "1W"}'
  5. # or, with docs/paste_client.py
  6. export PASTE_API_URL=https://paste.example.com/api.php PASTE_API_KEY=your_api_key
  7. python3 paste_client.py --title "build log" < build.log
  8. python3 paste_client.py --upload screenshot.png --url-only

Keys are made in Profile > API Keys. The reply gives the new paste's id, URL and raw URL. A site can also let guests create pastes and upload files without a key, with its own per-IP limit.