31-Aug-2020 : Web site refresh

  • by

After becoming more and more dissatisfied with the appearance of my Web site and the frequency with which I was updating it, I decided a couple of days ago to give it a complete revamp. I don’t think many people are accessing it – or even know it exists – unless they happen across it accidentally, but I’m supposed to be an IT professional, so I should be able to produce something a lot less clunky than it used to be, and now that I’m retired I should have more time to make the occasional update.

If you ever visited the old site, you’ll notice that the WordPress theme has been changed (from Atahualpa to a much cleaner and allegedly faster-loading one called Neve).  Neve is easy to set up and fairly flexible but I’m having trouble finding a place to insert some custom PHP code which collects page statistics without it affecting the layout of the pages.  There’s only one sidebar and when I place the code in tat, it produces an intrusive sidebar border.  The second sidebar and the footers appear only to be available to registered users: I’m not paying £59/year just to get rid of one sidebar border.

If you have any ideas, please drop me a line by clicking this link or fill out this contact form and let me have your suggestions, otherwise I might be looking for another new theme…

Long into the night… and I’ve cracked it.  The Neve theme has a set of PHP files which control the loading of the header/body/widgets/footer/etc of each page.  I’ve tried inserting my custom PHP code into these files but whichever file I chose, however I did it, wherever I put it, it screwed up the page every time.  I eventually managed to insert a snippet of HTML into header.php which loaded (i.e. ran) the PHP in an IFRAME:-

<iframe src="http://wp.lacchin.co.uk/admin/pagesetup.php" width="0" height="0"></iframe>

The pagesetup.php is as follows:-

 * Records all page loads except my own IP address (xx.xx.xx.xx)
 * Installed 01.09.2020
 * This file is: public_html/wp/admin/pagesetup.php
  if (getenv ("HTTP_CLIENT_IP"))
    $ip = getenv ("HTTP_CLIENT_IP");
    if (getenv ("HTTP_X_FORWARDED_FOR"))
      $ip = getenv ("HTTP_X_FORWARDED_FOR");
      if (getenv ("REMOTE_ADDR"))
        $ip = getenv ("REMOTE_ADDR");
        $ip = "UNKNOWN";
  $ip = str_pad ($ip , 15); 
  if ( str_replace(' ', '', $ip) == "xx.xx.xx.xx" ) { return; }
  $page = getenv ("HTTP_REFERER");
  date_default_timezone_set ("Europe/London");
  $logfilename = date ("Ymd") . ".log";
  $fh = fopen ("./logs/$logfilename" , "a");
  fwrite ($fh , date ("Y/m/d H:i:s - ") . $ip . " - " . $page . "\n");
  return "";

I think it’s fairly self-explanatory but if you can’t work out what’s going on, drop me an email or fill out this contact form and let me know what you don’t understand and I’ll try to explain.