Yay using my old stats system

For the past year or so I’ve been using Google Analytics because it’s free, before that I used a premium service called Clicky.

Why have I picked it up again? Well I do have to pay out money for it, but I just find it so much easier to use than Analytics.

Direct links to pages people view in real time

Screenshot 2016-05-08 14.11.19

When I’m not working through a set task list, I like to improve my sites based on what pages I see people viewing at that moment.

This means that I can find old parts of the site that needs updates but have been overlooked because it wasn’t included in the monthly stats report (easy when lots of subpages).

Full links to referral pages

Screenshot 2016-05-08 14.13.09

Another issue I had with Analytics was that it was super hard to get the full URL of a page that was linking to yours. The reports I could see just showed the domain, while Clicky made it very clear where incoming traffic was coming from.

 

Analytics might offer a load of features and be great for a free service but it seems that it is designed for the depth of large organisation and marketing department.

I do admit that I may be using Analytics completely wrong, but I’ll take the simplicity.

Migrating Web Servers

Screenshot 2016-05-07 21.08.33For the past few years I’ve been adding more and more websites to my server instance. This has the benefit of a single pool of resources and a single cost.

However the number of sites has grown a fair bit, and if something is running in the background it slows them all down.

So the more recent sites I’ve been placing on new servers and for Defiance (the oldest of my sites) I decided to move that to a new one too.

I’ve always been afraid of site migration, which is why I have rarely done it, but it went surprisingly smoothly.

Because there wasn’t much database and file activity, I didn’t stress too much about doing pre and post updates, just a single dump.

The process went as follows.

  1. Download all site files from the server
  2. Create the new server instance
  3. Upload all site files to the new server
    • Add a change to the files to make it identifiable as the new server
  4. Dump the database to a file
  5. Import the database to the new server
    • Spend a while correcting the errors on import (cry)
  6. Update the DNS information to point to the new server
  7. Wait until the DNS update propagates throughout the internet
  8. Visit the new server

I was able to access the new server about 5 hours after I updated the DNS, but I saw visitors from other places in the world a few hours earlier.

Commenting System Upgrades

I’ve tried to use some existing commenting systems before, but these tended to not integrate nicely with my accounts system. I do like writing my own stuff though, so I upgraded mine.

Some images to start with!

DAoCDB was the first comments system I wrote many years ago. Ugly terrible and bad.

Screenshot 2016-05-05 13.05.24

Defiance Data was my first site that took off, and so I spent more time writing the system for that. It’s received a few minor cosmetic upgrades over the years.

Screenshot 2016-05-05 13.06.32

After allowing just standalone text in the comments I wanted to allow people to quote and reply like they would on forums. I didn’t style it in the best way though and it was quite confusing.

Screenshot 2016-05-05 13.07.24

When I launched Trovesaurus and it used the same commenting system. It wasn’t until I launched AtlasReactor.info that I wanted to take it in a new direction.

Screenshot 2016-05-05 13.10.22

The AR system added the concept of threaded comments and votes, members could up or downvote individual comments, and people could reply to comments and make comment threads. This stopped the need to keep quoting things.

Trovesaurus then received the basis of that. The first draft was still fairly ugly.

Jzk3rHN

Through user feedback we enhanced the style, and I think it’s in a much better position.  Also the user experience was improved as I added something I don’t usually do, allow posting through javascript in the background).

This made it so that people didn’t have to reload pages or lose their place. Less painful than I thought it would be, I’m not sure why I’ve always avoided it.

mMWvdLx

It’s still a work in progress, and without feedback it wouldn’t be getting the constant updates.

 

Trying to transition my PHP sites to PDO

Screenshot 2016-05-02 22.26.15

PDO – PHP Data Objects is a database access layer that the web developer community has been shifting to over the past few years mostly because of the enhanced security that prepared statements offer.

Over the past few weeks I’ve been trying to make the transition. It’s a pain!

I didn’t realise just how much I was relying on PHPs MySQL functions, from mysql_fetch_assoc() to mysql_insert_id(), I had to rewrite a large portion of my sites database interactions.

I still haven’t got a reliable way of getting the last id inserted, it’s meant to be the following, but I have had some odd returns so I’m not that confident about it.

$db->lastInsertId();

For the transition I am running both systems side by side, I have another query function mirroring my “query” function called pdoQuery.

try 
{
   $result = $db->query($sql);
}
catch (PDOException $ex) 
{
   echo $ex->getMessage();
}

This allows me to essentially run the same SQL, and output any errors same as with mysql_error until I am ready to move over to parameterized query.

Instead of using mysql_fetch_assoc in my loops, I wrote another function to get a single result in an associative array and an array of results.

function getResult($result)
{
   return $result->fetch(PDO::FETCH_ASSOC);
}

function getResults($result)
{
   return $result->fetchAll(PDO::FETCH_ASSOC);
}

So the code

$result = query($sql);
while ($row = mysql_fetch_assoc($result))
{

becomes

$result = pdoQuery($sql);
$rows = getResults($result);
foreach ($rows as $row)
{

This is a bit clunky and I guess I could remove the $rows assignment and iterate through $result->fetchAll(PDO::FETCH_ASSOC) directly.

I’ve still got a lot to learn about PDO, but I’m working on it.

The elusive spacing and  character in header

For a long time I had odd issues when I tried to generate images.

I was using php to include my general site scripts which provided the db connection and common functions but the images always generated an error.

I had to do away with trying to include the common functions as it was the only way to get the image to generate. This makes sense now as I fixed another issue.

Screenshot 2016-05-01 15.21.29

I noticed after creating a new file (with copy and paste from an older one) that a space started appearing at the top of my site. As well as the  character in the header.

I turned up this post on Stack Overflow: http://stackoverflow.com/questions/6784799/what-is-this-char-65279

The answer mentioned that character was a zero-width no-break space that was commonly used as a byte-order mark (BOM).

This didn’t really mean anything until it was mentioned to look it up in Notepad++, and there it was.

Screenshot 2016-05-01 15.21.59

The encoding on the bottom-right was UTF-8-BOM while my other files were UTF-8.

Screenshot 2016-05-01 15.22.04

So from the top menu, Encoding button, I selected Encode in UTF-8, saved the file and uploaded and the problem was sorted.

So this is my note for my future reference and for any others who have encountered this problem 🙂

 

 

Great Britain – Europa Universalis IV

There are very few countries I enjoy playing, I do tend to go for England, Great Britain when available.

My current play session uses the the MEIOU and Taxes mod which adds a bunch of new features, my favourite is the development system. Provinces improve on their own.

The current state of Great Britain  involves holding France and the majority of the Iberian Peninsula. As well as overseas holdings including Egypt, India, and Indonesian Islands.

Subjects include most colonial nations in the Americas, as well as the United Provinces in Europe, which have been freed from Burgundian control.

Ming, which rivals me in Technological, Economical and Military development have been attacking me over several wars for control of Taiwan, but with more ships then the entire world combined they cannot reach it. I have recently taken Guangdong from them as punishment.

It’s not often I play to the end date of EUIV, but in this case I am hooked. I look forward to steady expansion, although the game has become notably slower in calculating.