Run Your Own Pastebin with Stikked

If you’re a developer of any sort, you’ve probably heard of Pastebin.com, the most widely used web application for pasting and sharing text snippets. Pastebin.com is great, but it’s not the only pastebin tool out there.

In fact, it’s becoming increasingly common for websites to host their own pastebins. It can give you more freedom. There are many open source pastebin implementations; in researching this article, I came across at least twenty pastebin projects in active development. I tested a few of their online demos and settled on using Stikked for its advanced features and streamlined user interface.

Stikked is built with PHP and jQuery and uses the CodeIgniter framework.

stikked

Stikked requires that your server is running:

  • PHP 5
  • Apache
  • MySQL

To download the latest version of Stikked, visit the Stikked GitHub page or go to your command line and run:

git clone https://github.com/claudehohl/Stikked.git

Using git clone will give you a folder called “Stikked.” Within that folder is another folder called “htdocs”; copy the contents of htdocs to a directory of your choosing on your web server.

Before you can run Stikked, you need to prepare a few things. First create a MySQL database. If your server uses cPanel, you can do this by going to your administration page and clicking on “MySQL Databases.”

stikked-mysql-database

Create a database, add a user to it, and grant the database user all privileges.

Now that you’ve set up a database for your Stikked installation, you need to modify the file application/config/stikked.php to point to it. Go to lines 18 through 21 and change the database information appropriately. For example:

$config['db_hostname'] = '127.0.0.1';
$config['db_database'] = 'rujic_stikked';
$config['db_username'] = 'rujic_rujic';
$config['db_password'] = 'stikked';

Now you should be able to access your-stikked-installation.com/index.php and see this:

stikked-installation

The stikked.php file contains some other settings you can change as well. For instance, to require LDAP authentication, edit line 117:

$config['require_auth'] = true;

Note that if you set this to true, you must also configure your LDAP settings in application/config/auth_ldap.php.

Fun fact: Line 99 lets you let you set the default name for anonymous posters to a random phrase:

$config['unknown_poster'] = 'random';

Scroll down to line 136 to view or edit the list of random nouns, followed by the list of random adjectives.

All of the style data exists in the directory called “static.” For kicks, take a look inside the sub-directory “fonts” to see some interesting choices.

Most of the styling choices are made in the file “static -> styles -> main.css”. I modified main.css to include one of the pre-installed fonts using the @font-face rule:

@font-face
{
   font-family: font19;
   src: url('../fonts/font19.ttf');
}

Here is my “Create” page after I had a bunch of fun with main.css:

stikked-new-interface

Stikked has a number of interesting features that make it stand out from the crowd of other pastebin scripts.

First off, it runs the gamut when it comes to syntax highlighting. Stikked supports a huge list of programming and scripting languages, from 4CS to Oz to ZXBasic. Whatever you’re coding in, your Stikked installation has (probably) got you covered.

Each snippet’s language is displayed in a table on the “Recent” page; if the poster didn’t specify a language for a paste, then it is labeled “text.” The table also displays the title, poster’s name, and recency, along with an RSS icon. The RSS feed is located at your-stikked-installation.com/lists/rss.

The “Trending” page is nearly identical but with the addition of a “hits” column and no RSS feed. Hits appear to be calculated based on visits from unique IP addresses.

stikked-trending-pastes

When you create a paste, you have the options to set an expiration date, create a short URL using the service at gw.gd, and/or make the post private. Note that a “private” paste is not truly private; any user who has the paste’s URL can see it, unless you’ve enabled LDAP authentication – in that case, every registered user with the URL can see it. “Private” only means that the post won’t show up on the Recent or Trending pages.

Security aside, Stikked provides some neat utilities for viewing a paste. I’m especially pleased with the embed code.

stikked-embed-code

You can also reply to pastes and add your own edits from a form below the original paste. The only downside to this is that replies don’t link back to the original post; if your pastebin has many different posts and replies made at different times, it’s easy to lose track of their structure. I can only hope that the developer will at some point introduce a solution, such as threading the replies and implementing a diff viewer.

One last feature I’ll mention is spam control, which Stikked refers to as “spamadmin.” Set it up by entering credentials in config/stikked.php on lines 79 and 80:

$config['spamadmin_user'] = 'stikked';
$config['spamadmin_pass'] = 'stikked';

Go to your-stikked-installation.com/spamadmin to log in. There you can see which pastes came from which IP addresses, remove pastes, and block IP ranges.

Stikked’s API allows you to paste to it from pastebin clients. The API URL to use in your client is your-stikked-installation.com/api/create.

A basic example is to use the cURL command to upload a file called “smalltalk.st,” setting the title, name, privacy, language, and expiration time in minutes:

curl -d title='cURL test' -d name='Ruji' -d private=1 -d lang=smalltalk -d expire=45 --data-urlencode text@smalltalk.st http://my-stikked-installation.com/api/create

This will return the URL of the paste.

If you’ve read that Stikked is dead, you’re wrong. While the old Stikked was abandoned after version 0.5.4, the new Stikked is going strong and continuing to introduce useful features with every release. I recommend you give it a try if you want an easy way to collect and share text snippets on your own website.

What do you use pastebins for? Do you have a use for your own pastebin?

Do you like what you read here?

Receive the latest update in your inbox.

Or connect with us: