eleksir 5c6fdef0b6 * Changed EOL to UNIX type
* Refactor code to respect OOP coding style, now we have interface and class here!
2017-03-26 01:43:27 +03:00
2017-03-18 16:14:52 +03:00
2017-03-26 01:43:27 +03:00
2017-03-18 16:14:52 +03:00

Paste.

This is pastebin replacement. It does not use ads, it is opensource, it is relatively small. And it has minimal pastebin API stub, at least pastebinit can paste to it with minimal config changes. Besides pastebinit there are 2 cli clients available on main page of this app.

And as a bonus this app can short links too! But it either shorts links or stores paste, not both at same time.

How do I get set up?

This paste utilizes PDO SQLite driver, well, at least for now :) and mbstrings. Tested php versions are 5.6.30 and 7.0.12. Paste uses paste/paste.sqlite file as db.

Tested on apache/fcgid (windows) for dev and nginx/php-fpm for prod.

Default installation assumes that paste runs as / app on site, but you can change it (BASEURL) in app.ini.

Settings for paste mode

edit app.ini and set correct address, base url, db path, application type (type = paste)

Nginx config snippet:

# limit paste size to ~ 200k
client_max_body_size 256k;

location /raw {
	rewrite "^\/raw\/([a-z|A-Z]*)$" /index.php?$1;
}

rewrite "^/([a-z|A-Z]*)$" /index.php?$1;

location / {
	root /var/www/htdocs/empty;

	index index.php;
	location ~ \.php$ {
		if ($request_method !~ ^(GET|HEAD|POST)$ ) {
			return 499;
		}

		root /var/www/htdocs;
		fastcgi_split_path_info                 ^(.+\.php)(/.+)$;
		#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
		fastcgi_index                           index.php;
		include                                 fastcgi.conf;
		fastcgi_pass                            php;
	}
}

Database initializes automatically :)

edit app.ini and set correct address, base url, db path, application type (type = short)

Nginx config snippet:

# limit links size to ~ 50k
client_max_body_size 64k;

rewrite "^/([a-z|A-Z]*)$" /index.php?$1;

location / {
	root /var/www/htdocs/empty;

	index index.php;
	location ~ \.php$ {
		if ($request_method !~ ^(GET|HEAD|POST)$ ) {
			return 499;
		}

		root /var/www/htdocs;
		fastcgi_split_path_info                 ^(.+\.php)(/.+)$;
		#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
		fastcgi_index                           index.php;
		include                                 fastcgi.conf;
		fastcgi_pass                            php;
	}
}

Database initializes automatically :)

Contribution guidelines

Clean code, preferably with comments for some quirky places.

PasteBinIt configuration

default pastebin site, ~/.pastebinit.xml:

 <pastebinit>
     <pastebin>http://your.site</pastebin>
     <author>Stephane Graber</author>
     <jabberid>stgraber@stgraber.org</jabberid>
     <format>text</format>
 </pastebinit>

and how to work with it ~/.pastebinit.d/your.site.conf:

[pastebin]
basename = your.site
regexp = http://((([a-zA-Z0-9\-_\.]*)(your\.site)))

[format]
content = api_paste_code
user = api_paste_name
subdomain = api_paste_subdomain
private = api_paste_private
expiry = api_paste_expire_date
format = api_paste_format
email = api_paste_email
page = page
submit = submit
regexp = regexp
api_dev_key = api_dev_key
api_option = api_option

[defaults]
submit = submit
format = text
private = 0
expiry = 1M
subdomain =
email =
api_dev_key = 253ce2f0a45140ee0a44ca99aa492260
api_option = paste
page = /
regexp = (.*)

FYI difference between pastebin and paste are minimal:

diff -ruN pastebin.com.conf your.site.conf
--- pastebin.com.conf
+++ your.site.conf
@@ -1,6 +1,6 @@
 [pastebin]
-basename = pastebin.com
-regexp = http://((([a-zA-Z0-9\-_\.]*)(pastebin\.com)))
+basename = your.site
+regexp = http://((([a-zA-Z0-9\-_\.]*)(your\.site)))

 [format]
 content = api_paste_code
@@ -25,5 +25,5 @@
 email =
 api_dev_key = 253ce2f0a45140ee0a44ca99aa492260
 api_option = paste
-page = /api/api_post.php
+page = /
 regexp = (.*)

TODO

  • Make one app that shorten links, stores paste, stores pictures (yes! image hosting).
  • Configurable features (not everyone wants all features enabled).
  • Before implementing picture storage, there should be made authorization.
  • Sane and clear API.
Description
Simple pastebin
Readme 36 KiB
Languages
PHP 100%