Category: Tutorials

Occasional code snippets and useful code explanations.

Enthusiast 3.1.5 fixes

2016.04.12 Tutorials 4 Comments

First of all, I want to say, oops sorry for disappearing. Let’s just say I got distracted playing Dragon Age Inquisition.

This post is mostly focused on Enthusiast, the most popular fanlisting management script used. A few days ago, I woke up to about 10 inactivity emails from TAFL/TFL about my fanlistings being more than two month out of date, which was a surprise, because I had just checked my Enth dashboard the day before. After tweeting about it, a friend told me that it’s been happening to others, and they had to mess around with the script to change the inactivity warning time.

I looked into the code, and tried that, but it wasn’t getting all my fanlistings that were clearly out of date, so I ended up rewriting the portion of the code that checks for inactivity. The old way was done by using PHP’s date() function to figure out which sequential week of the year a particular fanlisting’s last update date was, and checking if it had more than 8 difference to the current sequential week of the year. For whatever reason, it wasn’t consistent, so I rewrote it instead comparing the difference between the two dates in the number of days between them.

It’s not a full tutorial because it’s basically just some search and replace or move lines around.

If you’re using Enthusiast 3.1.5, I highly recommend applying this fix, so you don’t have to worry about your dashboard not warning you.

View the instructions on pastebin / github gist.

I’ve been working on a syntax update for Enthusiast, but until that’s done, it’ll just be a few fixes here and there. There’s a bug in the disabling country field for fanlistings that I fixed, but still need to be fully tested. I’ll link it here later when it’s been tested by more people.

PHP Dynamic Navigation

2015.11.03 Tutorials 1 Comment

Oops, so I wrote this bit of code months ago, but got lazy about writing the actual tutorial. Basically, if you don’t want to install a CMS and just want to have dynamic/variable page title or navigation highlight, where your current page is displayed differently in the navigation, so that your visitor knows which menu item they are on.

First, you want to grab the page name, be it page.php or index.php?page


Then we need to parse it, depending on if it’s just page.php, or it has a query string (aka the stuff after the ? in page.php?query or page.php?q=query).

if (strlen($_SERVER['QUERY_STRING']) > 0)
$page = (strpos($url, "=") > 0) ? (substr($url, strpos($url, "=") + 1))
: (substr($url, strpos($url, "?") + 1));

In the if statement, we are testing if the length of the query is greater than 0, so if there is a query, presumably it will be greater than 0, after which we need to determine if it’s page.php?query or page.php?var=query (var being anything).

Continue Reading

What OS are you running?

2015.05.16 Tutorials 7 Comments

Are you using Windows, Mac OS X, or Linux? And the second question I’d ask is, are you interested in learning basic programming?

If you’re using Linux, chances are, you already know some basic programming. If you’re using Mac OS X, which is Linux-based, you can easily code and compile your programs, too. If you’re using Windows though, you’ll have to jump through some hoops to accomplish the same thing, but it’s definitely doable.

I have a Windows desktop and a Macbook Pro. I code mostly on my Macbook Pro. And the biggest reason is the Terminal. Before I started studying Computer Science, command line stuff scared me, and I preferred doing everything through a graphical interface. Now that I’ve used a lot of command line stuff, for a lot of things I prefer running things command line instead of through a graphical user interface.

If you’re using Linux or OS X, you can easily code in C and C++, but if you’re running Windows, you might have to install some extra programs just to get that running.

I would prefer to do tutorials in C++, but most people probably would prefer PHP. It’s just C++ is easily transferable because so many other languages are based on C, so once you know the foundation, it’s easy to apply it. Another reason is C/C++ is more powerful than PHP and has strong data typing, which makes for better foundation than weak data typing in PHP.

So I guess what I’m getting at is if enough people have OS X, I’ll do tutorials in both PHP and C++, otherwise I’ll stick to PHP.