What is a Pastebin?
The concept of a pastebin is to provide a simple service turning code snippets or large blocks of computer input or output into a short reference (short URL). This reference only fills one line in a textual conversation. It can be used conveniently for quick exchange of the referenced content via IRC or IM. That way, the risk of being banned for “flooding” the chat can be avoided.
Requirements and Features of PHP-pastebin
Requirements: a server with mod_rewrite enabled, and PHP/MySQL. It was written in PHP and smarty. It includes a decent installer, user management, integrated PayPal payment for premium accounts, and a responsive design based on an older version of Bootstrap. PHP-pastebin was developed with the aim of facilitating collaborative coding, and features syntax highlighting of the pastes. There is also some support for plugins.
SeeHe.re, a Pastebin based on PHP-pastebin
BestNa.me has deployed a pastebin based on PHP-pastebin for the domain SeeHe.re. On the start page of SeeHe.re, specific syntax highlighting modes are available for more than fifty programming languages:
It is possible to choose between public or private mode for pasting: public pastes are listed publicly, whereas private pastes remain hidden. Therefore they are only accessible for a person knowing the random short link. The time frame for expiry can also be selected. It ranges from 10 minutes to unlimited. The next screenshot shows a pasted snippet of Ruby code for tr.im with syntax highlighting (which is powered by GeSHi):
A list of all public pastes can easily be retrieved. It shows all important information related to the paste, e.g. the user name of the author and simple access counts.
There is also a dedicated info page for each user. It lists all the pastes issued by this particular user, including the private ones. This page can be accessed by the admin and by the respective user. The user needs to be logged in to access it in his user panel via account settings. Unfortunately, it can also be accessed by everyone if at least one public persistent paste of this user exists: in this case the info page of this user is accessible via the list of all public pastes. More precisely: via the link in the column author in the corresponding row for this paste. So the behavior of PHP-pastebin (and, for the moment, also of SeeHe.re) is that only users without any public paste are able to stay entirely “behind the scenes”. On the info page of a user, also the Gravatar of the user is displayed along with a summary of information about the user.
Logged in users can edit the details of their account and info page:
PHP-pastebin distinguishes between anonymous users, registered users, premium users, and the admin. To become a premium user, the PHP-pastebin software first requests a payment via PayPal. Payment then goes to the PayPal email address configured by the admin. After payment, the premium account is activated instantly. For this, Instant Payment Notification (IPN) is used:
Premium users are given much larger limits for the length of their pastes. It should be noted that some corrections to the script were necessary to make IPN (and the instant activation of the premium user account) work correctly. There is a second point that needed correction: ATTOW, PHP-pastebin does not check the size limits for the pastes—so even anonymous users can insert pastes of (almost) arbitrary length. On SeeHe.re, this has been corrected by a few lines of code in function
In the last part of our series of short articles, several other self-hosted scripts for URL shorteners are briefly reviewed: polr, URL Shortener, and kissa.be.