Bootstrap Request Tracker

At one of my previous jobs I had setup Request Tracker to handle support tickets. Request tracker is actually a very powerful piece of software that is unfortunately stucking using a quite ugly theme. They did recently modernize the code behind the theme but it’s still far from perfect.

To that end I decided to include some Bootstrap (pre-version 3) to the theme to help spice things up a little bit. I’ve decided to share my custom CSS with the world.

Custom CSS

Apply this stylesheet in Tools -> Configuration -> Tools -> Theme -> Custom CSS (Advanced)

Note: This has only been tested on 4.0 <= RT version <= 4.0.13.

Custom background

In the CSS I set a custom background image. I choose a nice background from Subtle Patterns like this to help spice up the background. Put that file in the noauth section of RT on the filesystem and name it custbg.png. If you name it something else just find and replace in the custom CSS.

CloudFlare Dynamic DNS

So I have an extra computer back home that runs some VMs that I like to have access to remotely. Easy enough, just some basic DDNS. However, I use CloudFlare whom doesn’t directly offer dynamic DNS. Worry not though, for CloudFlare does have an awesome API for updating DNS records.

Final Script:

So let’s go over how I got here. First things first, you’ll need your API key which you can get from your account settings page. You’ll also need to know the DNS Record ID of the record you which to modify.That’s where we’ll start

Getting your DNS Record ID:

If you need help, see here. To keep it short, run this command:

curl https://www.cloudflare.com/api_json.html \
  -d a=rec_load_all \
  -d tkn=8afbe6dea02407989af4dd4c97bb6e25 \
  -d email=sample@example.com \
  -d z=example.com

If you’re confused about what some of this stuff is then let me explain quickly. tkn should be set to your CloudFlare API key. email is the e-mail address of your CloudFlare account (same one that issued the API key). z is the TLD of the domain you want to manage on CloudFlare.

Dealing with the return can be interesting. Your response will be in JSON so you’ll have to scan through there for the record you want to mange and pull out its ID. If you need it formatted nicer, try using this online JSON parser.

Editing the Record

Similiar, the official documentation is here. This time though, there’s a little bit more involved:

curl https://www.cloudflare.com/api_json.html \
  -d a=rec_edit \
  -d tkn=8afbe6dea02407989af4dd4c97bb6e25 \
  -d id=9001 \
  -d email=sample@example.com \
  -d z=example.com \
  -d type=A
  -d name=sub
  -d content=1.2.3.4

A lot of the information is overlap from last time but there are a few new additions.

id
The DNS Record ID you got in the previous step
type
The type of the DNS record (A, CNAME, AAAA, MX, SRV, etc.)
name
The name of the subdomain (you can give the full domain name)
content
The content of the record. For A records it should be the IP address

Putting it together

To finalize I grab the current WAN IP from the plaintext service ifconfig.io/ip. With a little work I get the final product at the top of this post. I also create a gist of this if you prefer to make some edits.

To automate the process I simply wrote a cron to:

*/5	*	*	*	*	~/scripts/cf_dynamic_ip.sh

Some Notes

Right now I have it store the current WAN IP in /var/. You can change it to your preferred location or you can just get rid of the storing of it and the comparison. An issue that could arise that if the script fails to set the IP on CloudFlare, it will not try again until the WAN IP changes.

Kunaki PHP Class

Overview

Kunaki is a popular disk publishing service that is fully automated and low-overhead. I went ahead and created an interface layer between Kunaki’s XML web service and PHP. It’s incredibly straight-forward and simple to use and sticts to OOP. It’s fully documented (to the best of my ability, limited by Kunaki’s documentation) and provides example uses.

Simple Example

Here’s a really simple example getting shipping options and pricing for an order:

$order = new Kunaki_Order();
$order->addProductId($ProductId, 10);
$order->PostalCode = 10004;
$order->Country = United States;
$order->State_Province = NY;
$shipping = $Kunaki->getShippingOptions($order);

From here you can have the pick the shipping method you want, fill in the rest of the customer infromation (though you likely already have it), and submit the order.

Notes

It should be noted though that you once you submit an order, it still has to be approved in your Kunaki panel. Also, depending on the input data and what you allow, it might not line up with what Kunaki wants and might error out when you submit a request. Error response checking is important and making sure the order gets resubmitted if you’ve already taken payment.

There is no API method to being able to approve orders so I would suggest trying to submit the order first, fix data or prompt the user to fix it if it fails, and then taking payment. Then store the Kunaki order number and the payment gateway information (ex. Paypal order ID) in a table and then using that to approve orders on Kunaki. This should cover your bases but application-specific circumstances always arise. Just be mindful of the limitations of this API.

Download & Documentation

You can find my full documentation and code over at the Github repo.

License

This software is released under the GPLv3 license. If you want to have some bonding time with the license you can do so here.

Personal Blog

Alas I have opted to venture out and create my own blog. This will be my place to write articles on my work and helpful tidbits of code that I come across.