CentOS 7 Linux Minimal Install – ifconfig: command not found (let’s use ip instead)

As someone who doesn’t closely follow what’s happening with Linux tools, I recently tried a minimal CentOS 7 install, and found out by chance that a command I use a lot on Windows has been deprecated in a number of Linux releases.

Not having run into this before, my first thought was to see if it was in the core repos.

yum provides ifconfig

ifconfig is part of the net-tools package

Continue reading “CentOS 7 Linux Minimal Install – ifconfig: command not found (let’s use ip instead)”

SEATT updated to 1.4.0

I’ve updated Simple Event Attendance (SEATT WordPress plugin) to version 1.4.0. This brings bug fixes, and updates in line with the release of WordPress 4.5.3, as well as the upcoming 4.6.0 release.

The plugin can now also be found on GitHub: https://github.com/withdave/SEATT to help you track changes if you’ve made any modifications yourself.

This covered some of the feature requests at https://withdave.com/2017/05/seatt-feature-request-may-2017-update/, as well as fixes for get_currentuserinfo in WP 4.5:

* Replaced get_currentuserinfo with wp_get_current_user to fix deprecation issue
* Fixed bug where users couldn’t register to an event with limit set to 0 (unlimited)
* Fixed bug where server time was used rather than blog local time on front end form
* Updated admin and template to allow use of TinyMCE for WYSIWYG editor. Can now also add images, colours etc.

Qlik Sense and general port troubleshooting on Windows Server 2012 R2

One of the beauties of Qlik Sense Enterprise is that it can be installed on nearly any Windows machine, with very few pre-requisites.

One of the drawbacks is that you may then be tempted to load it onto a multi-purpose box, or at the very least, one with a number of core Windows roles installed (especially if you’re just testing).

Uh oh, it's a 404
Uh oh, it’s a 404

This post is going to offer some quick ways of resolving port clashes, and working out what’s binding where without changing the core Qlik Sense Enterprise installation.

Continue reading “Qlik Sense and general port troubleshooting on Windows Server 2012 R2”

Changing the RDP Port on Windows 10

By default, remote desktop connections on windows use port 3389. If you find the need to change this port, the following should help. Make sure you have “Allow remote connections to this computer” checked under “System Properties > Remote” before you begin.

In my experience, you should avoid changing the mapped port for core Windows services if possible, as this can cause numerous configuration and management issues. Other options include:
– Using port mapping (forwarding) on your router (e.g. externalip:10000 -> serverip:3389), however not all routers offer this functionality.
– Installing a third party remote desktop app, like Chrome Remote Desktop or LogMeIn, however these require specific software and/or subscriptions
– Deploying a server/PC as a RDP “gateway”. You then access all further RDP hosts from this first point of contact.
– Using a RD gateway/RD Web access. This requires a server with the appropriate role installed, but can optionally be configured with two-factor authorisation like Duo.

To check what port your RDP is currently listening on, use the netstat command in an elevated command prompt.

netstat -abo

This will show information about current network connections and listening ports, as well as associated executables and processes. You’ll see port 3389 bound to “svchost.exe” on “TermService”.

 

To change the bound port you’ll need to open an elevated command prompt and run regedit.

regedit

Navigate to the PortNumber setting.

HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Control > Terminal Server > WinStations > RDP-Tcp

Right click on the “REG_DWORD” named “PortNumber” and hit “Modify”. Change the base to Decimal and enter the new port (between 1025 and 65535). You can use NetStat to check if a particular port is already bound to a process.

Once you’ve changed the value, exit RegEdit and either reboot the computer, or simply restart the Remote Desktop Services service using the “Services” snap-in in “Computer Management”. You can confirm the port has been changed by running netstat again (in my case, to 10000).

RDP on port 10000

Finally, open up Windows Firewall and add a new inbound rule for the new port. You won’t be able to change the existing rule as that’s a core system rule, but copy across the values into a new rule and you’ll be good to go.

SEATT updated to 1.3.0

I’ve updated Simple Event Attendance (SEATT WordPress plugin) to version 1.3.0. This brings bug fixes, and updates in line with the release of WordPress 4.3.1.

Firstly, an apology for taking so long to release another version – feel welcome to get in touch if you want to discuss changes you’ve made to your code in the interim. These are largely security changes, so it’s recommended that you update when you can. The database structure hasn’t changed, so you should experience no loss of data.

Changes:

  • Ensured the database elements all use the correct version of wpdb->prepare where needed, and tidied up any inconsistent usage where statements weren’t prepared. Thanks to J.D. Grimes for chasing me on this.
  • Made some text and layout changes throughout to work better with the WordPress default templates.

In the pipeline are a few more changes that should further improve functionality of the plugin:

  • Some sort of functionality to allow repeatable events – whether this be decoupling of event details from dates, or some other mechanism.
  • Selectable categories for lists, allowing you to put one shortcode into a post/page and get a list of all active events.
  • Anonymous registration – something that quite a few have asked for. It will be turned off by default but it is coming with captcha user verification.
  • Email notification – I haven’t explored this yet, but am hoping it can be done using internal wordpress functions.

Live at https://wordpress.org/plugins/simple-event-attendance/

As always, any feedback is very welcome.

Google Maps Distance (DistanceMatrix) API for UK in JSON

The postcode code has been updated to use Google’s distancematrix api, which provides a very different set of data from the old “as the bird flies” calculation (it calculates road distance, and provides transport options etc).

The following code is merely a demonstration, which can be seen here.

<?php
// Specify Postcodes to Geocode
$postcode1 = 'BH151DA';
$postcode2 = 'BH213AP';

// Set and retrieve the query URL
$request = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=" . $postcode1 . "&destinations=" . $postcode2 . "&mode=driving&language=en-GB&sensor=false&units=imperial";
$distdata = file_get_contents($request);

// Put the data into an array for easy access
$distances = json_decode($distdata, true);

// Do some error checking, first for if the response is ok
$status = $distances["status"];
$row_status = $distances["rows"][0]["elements"][0]["status"];

if ($status == "OK" && $row_status == "OK") {

// Calculate the distance in miles
$distance = $distances["rows"][0]["elements"][0]["distance"]["value"];
$distance_miles = round($distance * 0.621371192/1000, 2);

echo 'The distance between '.$postcode1.' and '.$postcode2.' is '.($distance/1000).'Km ('.$distance_miles.' miles).';

} else {
    echo "Calculating the distance between your locations caused an error.";
}

?>

Having better error checking would also be a good idea if you plan to use the above code. Using &unit=imperial is optional, as Google always returns metres – so the code runs a basic calculation on these to convert to miles.

SEATT updated to 1.2.7

I’ve updated Simple Event Attendance (SEATT WordPress plugin) to version 1.2.7. This brings bug fixes, and updates in line with the release of WordPress 3.5.

  • Fixed problems with apostrophes being escaped with numerous backspaces in admin panel and in the comment box
  • Removed first+last name from page template as this is rarely used, with list users no longer in a table format, but now in an ordered list
  • Admins can now sign up registered users simply by supplying a username in the admin panel
  • Fixed problems with wp_prepare() causing errors in wordpress 3.5
  • Deleting the plugin now removes all database tables as well as files to provide clean removal. This means uninstalling will now remove all events

 

Live at http://wordpress.org/extend/plugins/simple-event-attendance/

SEATT updated to 1.2.6

Simple Event Attendance has been updated to 1.2.6:

  1. Addition of extra table columns in admin view.
  2. Updated screenshots to reflect recent changes.
  3. Corrected use of date() function to current_time() to use timezone specified in WordPress rather than the server one.
  4. Added list of user emails signed up to an event.
  5. Some other small cosmetic changes, including register & login links on the event signup form.

The plugin is live at http://wordpress.org/extend/plugins/simple-event-attendance/

Facebook Like Buttons, &fb_xd_fragment=, Blank pages and SEO

This is a problem that’s been around for months now and yet still bugs thousands of users.

Any of your pages with facebook widgets on can result in URL’s like

www.example.com/page.php?fb_xd_fragment=

This has several implications. Firstly – it can cause blank pages through unwanted interactions with div areas on the page. We can solve this by adding the following fix just before the </body> tag. This came from http://forum.developers.facebook.net/viewtopic.php?id=60571&p=1 (temporary solutions)

<!-- Correct fb_xd_fragment Bug Start -->
<script>
document.getElementsByTagName('html')[0].style.display='block';
</script>
<!-- Correct fb_xd_fragment Bug End -->

The second, more long term issue is that this page will appear in search results alongside the normal page…resulting in duplicate content. Obviously you could just remove the like button but that’s not an ideal solution. So you can do a couple of things.

Head to webmastertools (https://www.google.com/webmasters/tools/home) and add the fb_xd_fragment= as something that should be ignored on your site.

Filtering out fb_xd_fragment in Google Webmaster Tools
Filtering out fb_xd_fragment in Google Webmaster Tools

Another option is to use .htaccess and 301 redirects to clip out the &fb_xd_fragment=, which is a pain but very easily do-able and removes the requirement to put the display fix on every page. So try this (modified per your site) in your .htaccess.

RewriteCond %{QUERY_STRING} fb_xd_fragment=
RewriteRule ^(.*) http://www.example.com/$1? [R=301]

Note: This is now fixed.