<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gary Bell</title>
	<atom:link href="https://www.garybell.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.garybell.co.uk</link>
	<description>Developer &#124; Photographer &#124; Movie Lover</description>
	<lastBuildDate>Tue, 17 Apr 2018 20:05:53 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.1</generator>
	<item>
		<title>Jenkins disk space usage</title>
		<link>https://www.garybell.co.uk/blog/jenkins-disk-space-usage/</link>
		<pubDate>Tue, 17 Apr 2018 20:05:53 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Jenkins]]></category>

		<guid isPermaLink="false">https://www.garybell.co.uk/?p=148</guid>
		<description><![CDATA[I&#8217;m working on a project, part time, in my spare time.  As part of that project I have Jenkins for continual building when I publish anything into the master branch in git.  I&#8217;ve not done much for a month or so, but logged in to it today to be given a lovely warning that the &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/jenkins-disk-space-usage/" class="more-link">Continue reading<span class="screen-reader-text"> "Jenkins disk space usage"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m working on a project, part time, in my spare time.  As part of that project I have Jenkins for continual building when I publish anything into the master branch in git.  I&#8217;ve not done much for a month or so, but logged in to it today to be given a lovely warning that the disk space is nearly full.</p>
<p><span id="more-148"></span></p>
<p>I logged into the server to find out there was zero disk space left (I know, I need monitoring on it!).  After clearing down all of the old builds (most were for testing the configuration of the build job anyway) and a few obvious log files, I&#8217;d cleared up a huge 400MB.  Nothing on a 50GB disk.</p>
<p>After spotting a jenkins folder within /var/logs, I checked that out.  Two files over 20G in size for logs.  Less than ideal!  One of them was easy enough to remove, but the active log file would show as removed, but not free the disk space.  A quick restart of the jenkins service sorted that out.</p>
<p>Now to check the logging settings of jenkins to see what we can limit!</p>
]]></content:encoded>
			</item>
		<item>
		<title>My First Attempt at Open-Source Contribution</title>
		<link>https://www.garybell.co.uk/blog/development/my-first-attempt-at-open-source-contribution/</link>
		<pubDate>Sun, 21 May 2017 21:31:40 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Bulma]]></category>
		<category><![CDATA[Contribution]]></category>
		<category><![CDATA[CSS Framework]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=108</guid>
		<description><![CDATA[I&#8217;ve always wanted to contribute to an open source project, so I thought it was time to finally start.  I&#8217;ve been investigating different CSS frameworks, and came across Bulma.  I saw the contribute link and figured I&#8217;d see what issues there were in Github for it, and there was an issue about some typos.  I figured that &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/development/my-first-attempt-at-open-source-contribution/" class="more-link">Continue reading<span class="screen-reader-text"> "My First Attempt at Open-Source Contribution"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve always wanted to contribute to an open source project, so I thought it was time to finally start.  I&#8217;ve been investigating different CSS frameworks, and came across <a title="Bulma.io - CSS Framework" href="http://bulma.io/" target="_blank" rel="noopener">Bulma</a>.  I saw the contribute link and figured I&#8217;d see what issues there were in Github for it, and there was an <a title="Bulma.io - issue #744" href="https://github.com/jgthms/bulma/issues/744" target="_blank" rel="noopener">issue about some typos</a>.  I figured that was a good place to start; check if any more remained.  I forked and clones the repo to my machine and blasted it through &#8220;Inspect Code&#8221; option in PhpStorm, but found a different issue to look into, a one not raised currently as an issue, but still as part of the title.sass file.  It was to do with the following on line 14:</p>
<p><span id="more-108"></span></p>
<pre class="EnlighterJSRAW" data-enlighter-language="css">word-break: break-word</pre>
<p>PhpStorm didn&#8217;t like it, as it didn&#8217;t fit with the CSS specification.  There were no real adverse effects, as it still did what it was supposed to, but the options for word-break are as follows:</p>
<ul>
<li>normal</li>
<li>break-all</li>
<li>keep-all</li>
</ul>
<p>However, break-word is available for the <a title="W3C Spec for overflow-wrap" href="https://www.w3.org/TR/css-text-3/#overflow-wrap" target="_blank" rel="noopener">overflow-wrap</a> property, so I thought I would give it a change and see what happens.  My original test was to use a repeating paragraph of &#8220;The quick brown fox jumps over the lazy dog&#8221;, and see what the output was, shown below:</p>
<p><img class="alignnone size-full wp-image-109" src="http://www.garybell.co.uk/wp-content/uploads/2018/01/original-css.png" alt="Original CSS output" width="1853" height="923" /></p>
<p>The property for the &#8220;title&#8221; class is shown as an invalid property value, so could be ignored by some browsers.  After the change to make the code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="css">overflow-wrap: break-word</pre>
<p>The output became the following:</p>
<p><img class="alignnone size-full wp-image-110" src="http://www.garybell.co.uk/wp-content/uploads/2018/01/after-css-change.png" alt="After CSS change" width="1855" height="951" /></p>
<p>The visual output is the same, and this time the developer tools doesn&#8217;t show the property as being invalid.</p>
<p>I&#8217;ve submitted this as a pull request, and wait to see how it goes.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Automating the simple stuff</title>
		<link>https://www.garybell.co.uk/blog/development/automating-the-simple-stuff/</link>
		<pubDate>Fri, 23 Sep 2016 21:31:03 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=106</guid>
		<description><![CDATA[We all use computers for one thing or another, and in most cases we&#8217;ll do the same things on them over and over.  Part of being a developer is realising the things which need doing a lot, and automating them to increase productivity.  Doesn&#8217;t matter what it is, there&#8217;s generally a way to automate things. &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/development/automating-the-simple-stuff/" class="more-link">Continue reading<span class="screen-reader-text"> "Automating the simple stuff"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>We all use computers for one thing or another, and in most cases we&#8217;ll do the same things on them over and over.  Part of being a developer is realising the things which need doing a lot, and automating them to increase productivity.  Doesn&#8217;t matter what it is, there&#8217;s generally a way to automate things.</p>
<p><span id="more-106"></span></p>
<p>As part of builting my (other) website, I came to realise that there&#8217;s a lot of things which would need to be set up as repetitive tasks, and thought about these from the start.  Other jobs were things which needed to be coded, but as I was building the code in PHP, it was going to be inefficent to write the code in that.  This is where we have to pick the right tool for the job.  In my case, it came down to some simple Python scripts.</p>
<p>As the other website is (in time) going to have a lot of pages, I needed to set up something to build a sitemap, and update this regularly.  To do this I get a list of articles out of the database and use the imported ElementTree to build the XML before outputting.  Simple really, and here&#8217;s basically what it does to build the site map:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">def add_sitemap_element(loc, mod, change, priority):
    url = et.Element('url')
    # build the sub-elements
    # add loc node
    loc_node = et.Element('loc')
    loc_node.text = loc
    # add last modified
    modified_node = et.Element('lastmod')
    modified_node.text = mod
    # priority
    priority_node = et.Element('priority')
    priority_node.text = priority
    # change frequency
    change_frequency_node = et.Element('changefreq')
    change_frequency_node.text = change
    # add nodes to URL level
    url.append(loc_node)
    url.append(modified_node)
    url.append(change_frequency_node)
    url.append(priority_node)
    sitemap_root.append(url)</pre>
<p>An area where PHP isn&#8217;t particularly great is with image manipulation.  It can be done, and it&#8217;s fairly trivial once you get into it, but I&#8217;ve always found the amount of code needed for it was huge.  I decided that to create thumbnails I was going to use Python for that too.  Every few minutes I check to see what images don&#8217;t have thumbnails linked to them and create them.  I use the PIL library and import Image, but resizing an image is as simple as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">image = Image.open(input_image_name)  # full path
new_image = image.resize((int(new_width), int(new_height)))
new_image.save(output_image_name)  # full path</pre>
<p>Okay, so there&#8217;s other processing in between the lines, like calculating the new sizes, but there&#8217;s no need to worry about what type of image it is.  If it&#8217;s a PNG or JPEG and you want to output it as a bitmap or GIF, then you can.  I also found the performance of the re-size in Python much better than in PHP.  The right tool for the job (even if there&#8217;s probably faster libraries out there).</p>
<p>There&#8217;s other jobs I have automated, and more which I need to automate, but when something needs automating do it.  Some things might be part of an application scope to do (such as create thumbnails) but you&#8217;re better off creating a background job to do it rather than keeping the user waiting for them to be created upon save.</p>
<p>A little thought and a little code can help in many ways!</p>
]]></content:encoded>
			</item>
		<item>
		<title>Encrypting the site</title>
		<link>https://www.garybell.co.uk/blog/hosting/encrypting-the-site/</link>
		<pubDate>Wed, 21 Sep 2016 21:28:25 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[Let's Encrypt]]></category>
		<category><![CDATA[Secure]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=104</guid>
		<description><![CDATA[I&#8217;ve just moved my site from HTTP over to HTTPS.  It&#8217;s not a huge deal for something like this, but it&#8217;s something which I&#8217;ve really needed to do for a while, and something which is becoming more and more popular.  For most people this won&#8217;t mean much, and for this site it doesn&#8217;t amke much &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/hosting/encrypting-the-site/" class="more-link">Continue reading<span class="screen-reader-text"> "Encrypting the site"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve just moved my site from HTTP over to HTTPS.  It&#8217;s not a huge deal for something like this, but it&#8217;s something which I&#8217;ve really needed to do for a while, and something which is becoming more and more popular.  For most people this won&#8217;t mean much, and for this site it doesn&#8217;t amke much difference, but given that encrypting web pages is a simple process, there&#8217;s no real reason not to be doing it.</p>
<p><span id="more-104"></span></p>
<p>I chose to use <a href="https://letsencrypt.org/" target="_blank" rel="noopener">Let&#8217;s Encrypt</a> for setting up the SSL certificate as I&#8217;ve always had trouble in the past when I&#8217;ve tried it (admittedly under Apache on Windows) but this made it as simple as possible.  Just get their &#8216;certbot&#8217;. run a command in the terminal and away we go.  I did have to set an additional IP address on the server, and then set this site to use that IP address to listen on, but once that was done, it was very straight forward.  The command I ran was:</p>
<p><code>./certbot-auto --apache -d garybell.co.uk -d </code><a href="http://www.garybell.co.uk/">www.garybell.co.uk</a></p>
<p>and then follow the prompts on screen.  It took care of the new vhost in Apache, setting up the certificate and restarting apache.  Done! Simple.</p>
<p>With all that in mind, it amazes me that there are websites out there which will take payments and they aren&#8217;t loading their page over HTTPS.  Sure they will load the payment section in a HTTPS iframe, but it&#8217;s often difficult to tell that the payment part is an iframe, and that it is secure.  After going through the process of setting up the SSL certificate on this and another domain I own, I certainly won&#8217;t buy from a company which serves their payment page in a HTTPS iframe, but fails to serve their website over HTTPS.</p>
<p>How much does it cost to get an SSL certificate?  It depends.  If you go via one of the major routes, then anything form around $30 right up into the hundreds.  It depends on what you want and where you shop.  With let&#8217;s encrypt it costs nothing.  Zero! I have yet to pay for the SSL certificates I have from them, and I don&#8217;t have to pay if I don&#8217;t want to or can&#8217;t afford it.  That said, I will be donating something to them for providing the service.  They esitmate it costs them just over $2m a year to run, and they have over 5m unexpired certificates.  If each one of those certificates contributed $1 each, then they would get enough to keep the service running for 2 years.</p>
<p>Given the cost of the certificates are free, and the barrier to getting it is essentially nil for anyone with some technical knowledge, there&#8217;s really no reason not to encrypt!</p>
]]></content:encoded>
			</item>
		<item>
		<title>Introducing Charon File Uploader</title>
		<link>https://www.garybell.co.uk/blog/development/introducing-charon-file-uploader/</link>
		<pubDate>Tue, 26 Apr 2016 21:26:24 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Charon]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=102</guid>
		<description><![CDATA[I&#8217;ve wanted to build a useful javascript library for a while, but never found any of the ones out there lacking.  I&#8217;ve been working on a new project recently and one of the things I needed to do for that was be able to upload an image via AJAX, along with the alt-text and other &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/development/introducing-charon-file-uploader/" class="more-link">Continue reading<span class="screen-reader-text"> "Introducing Charon File Uploader"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve wanted to build a useful javascript library for a while, but never found any of the ones out there lacking.  I&#8217;ve been working on a new project recently and one of the things I needed to do for that was be able to upload an image via AJAX, along with the alt-text and other information for the image.  There&#8217;s libraries out there for uploading files and images, but I&#8217;ve not found one which lets you add other information to the post easily.  That&#8217;s when I figured I could build it myself.  Charon was born!</p>
<p><span id="more-102"></span></p>
<p>Charon is named after the ferryman who took souls across the river Styx in Greek mythology.  In this case, it takes files and other information across the internet whilst the rest of the web page continues as normal.</p>
<p>It&#8217;s still early days in development, but the majority of the workings are there.  It uses javascript alone to do what it needs to and doesn&#8217;t rely on jQuery.  I might look to build a jQuery version at some point, but I wanted to keep it basic for now.  It&#8217;s all available in <a title="Charon project on GitHub" href="https://github.com/gabe3886/charon" target="_blank" rel="noopener">GitHub</a> for use and modification.</p>
<p>Documentation is available as part of the GitHub page, and there&#8217;s a minified version included which reduces the footprint required to use it on a production server.  It&#8217;s available under the MIT licence, so do with it what you will, but I&#8217;m not responsible for anything that goes wrong with it.</p>
<p>I&#8217;ll be dogfooding it soon enough as I overhaul the gallery section of this site, and modify my other projects to use it too.  If there&#8217;s issues, raise them on GitHub, and if I find any, I&#8217;ll work to fix them too.  If I&#8217;m going to use it for things, it&#8217;s going to be looked after going forward.</p>
<p>If you&#8217;re wondering about the use case, consider the following scenario.  You&#8217;ve got a website (like this one) and you have a gallery on it (like this one).  For web best practices, you should have an alt-text for your images.  It&#8217;s something which is better to store with the image at the time, but file uploaders tend to only look after files, not other data.  A traditional web form might be too large to post with several images on it, so you want to do the uploading at the time.  This is where charon comes in.  You can select an image, set the alt text and upload to a script of your choice, and send back any information of your choice as easy as the following code</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var charon = new Charon({
    url: '/upload.php', // upload location
    file: document.getElementById('image1'), // file field
    additionalData: { altText: document.getElementById('altText1').value }
});
charon.sendFile();</pre>
<p>If you then need to change the file and additional data before sending a new file, the following can do that :</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">charon.file = document.getElementById('image2');
charon.additionalData = { altText: document.getElementById('altText2').value };
// then send the next file
charon.sendFile();</pre>
<p>With the custom callback functionality added in, you can get it to run your own functions as it&#8217;s uploading (for managing progress bars), for when it&#8217;s completed (for letting you know it&#8217;s uploaded or for processing any return information) or for any other <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" target="_blank" rel="noopener">XMLHttpRequest event</a>.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Database Connection Mis-information</title>
		<link>https://www.garybell.co.uk/blog/development/database-connection-mis-information/</link>
		<pubDate>Mon, 25 Apr 2016 21:24:27 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=100</guid>
		<description><![CDATA[Whilst on my usual rounds on StackOverflow to help spred useful knowledge of computing and web development I came across the following comments on a thread: Um&#8230; mysql doesn&#8217;t connect over http&#8230; nor to a directory Neither should it be an url. Usually it&#8217;s localhost or the IP address of the remote mysql server The first of &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/development/database-connection-mis-information/" class="more-link">Continue reading<span class="screen-reader-text"> "Database Connection Mis-information"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Whilst on my usual rounds on StackOverflow to help spred useful knowledge of computing and web development I came across the following comments on a thread:</p>
<blockquote><p>Um&#8230; mysql doesn&#8217;t connect over http&#8230; nor to a directory</p>
<p>Neither should it be an url. Usually it&#8217;s <code>localhost</code> or the IP address of the remote mysql server</p></blockquote>
<p><span id="more-100"></span></p>
<p>The first of these is, to my knowledge, correct.  However the second is absolutely wrong.  A connection to a database, or at least MySQL, does not have to be via IP address specifically.  Let&#8217;s break down the claim a little further:</p>
<h3>Usually it&#8217;s localhost</h3>
<p>This is often the case for development purposes as developers tend to run a small development database locally, allowing them to work whilst on the go and without an internet connection.</p>
<p>Some hosts will also tell you to use localhost and have a database server running on the platform you are deploying to.  Similarly, some websites run their databases on their webserver (I&#8217;ll go into why that&#8217;s not always a good idea another time).</p>
<p>I guess this part of the claim is true.</p>
<h3>or the IP adress of the remote mysql server</h3>
<p>I&#8217;ll start by saying this part is also true, as it&#8217;s perfectly possible to replace &#8216;localhost&#8217; with, say, &#8216;192.168.0.7&#8217; for things on a local network, or &#8216;81.81.81.81&#8217; if that&#8217;s your MySQL server somewhere.</p>
<h3>Neither should it be an url</h3>
<p>This is where the remainder of the comment loses all credibility, and unfortunately it&#8217;s at the beginning of the comment.  It&#8217;s perfectly possible to establish a database connection to something like &#8216;database01.myhost.com&#8217; or, a more real example, &#8216;mysql-master.garybell.co.uk&#8217; (though that doesn&#8217;t work, so save your time).  That leads me on to why you might want to use a URL over an IP address:</p>
<p>Company X has a SaaS application which stores data in a MySQL database.  They have multiple servers and their database is on a large distributed cluster and/or has master-slave replication, so if one of their servers needs maintenance or dies, they can switch over easily.</p>
<p>Their connection configuration files are set up on each application as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">// database connection information
$database['host'] = '10.17.83.123'; // master server
$database['user'] = 'web_app_user';
$database['password'] = 'w3B4pPU53R!';
$database['schema'] = 'client1';</pre>
<p>If their master server blew up, the data center suffered a catastrophic failure or any other reason why a connection into that IP was stopped, then they would need to correct the configuration files of all of their clients.  If that is only 2 or 3, then no problem.  When it runs into tens, hundreds or thousands it&#8217;s just not practical.</p>
<p>They decide the sensible thing form the get go is to use a similar config file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">/ database connection information
$database['host'] = 'mysql-master.companyx.com'; // master server on 10.17.83.123
$database['user'] = 'web_app_user';
$database['password'] = 'w3B4pPU53R!';
$database['schema'] = 'client1';</pre>
<p>If the same disaster is thrust upon them they can open up their DNS manager, point the domain &#8216;mysql-master.companyx.com&#8217; to one of their slave servers and, with a quick change of settings on the slave server have their hundreds of customer systems running with minimal interruption, all from using a URL.</p>
<p>A URL is a Uniform Resource Locator, and in this case the resource is MySQL, so it&#8217;s perfectly possible to use a URL as a database host name and, in some cases, actually preferential.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Check, test and check again</title>
		<link>https://www.garybell.co.uk/blog/development/check-test-and-check-again/</link>
		<pubDate>Wed, 13 Apr 2016 21:23:16 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Issues]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=98</guid>
		<description><![CDATA[I noticed today as I was about to start a different article that my website was looking a bit, well, funny.  The layout was wrong, some of the colours were off, the whole thing was a mess.  Don&#8217;t get me wrong, it&#8217;s not at the forefront of design, and won&#8217;t win any beauty awards, but &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/development/check-test-and-check-again/" class="more-link">Continue reading<span class="screen-reader-text"> "Check, test and check again"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I noticed today as I was about to start a different article that my website was looking a bit, well, funny.  The layout was wrong, some of the colours were off, the whole thing was a mess.  Don&#8217;t get me wrong, it&#8217;s not at the forefront of design, and won&#8217;t win any beauty awards, but it looked awful!</p>
<p><span id="more-98"></span></p>
<p>The reason, I found, was because a lot of the assets for the styles and functionality just weren&#8217;t being loaded.  Couldn&#8217;t be found.  Vanished.  I worried about the state of the server for a moment, but then realised if someone had compromised it, they wouldn&#8217;t just boot off a couple of assets; they would be making a lot more serious changes.  Nope, this one was user error on my part.</p>
<p>I recently moved servers.  Same provider, better spec box.  As part of that, there was obviously a migration of the setup (mostly) and it all seemed to work fine, until I moticed it today.  The issue was that I was sending requests for some of the loaded assets off to a faux-CDN; basically a different subdomain of my site to let them load alongside one another.  The trouble was, when I moved everything I didn&#8217;t set those up, so I was effectively seeing a cached version of those files.  When accessing the site from a different machine, there was no cached version to be had, and therefore the issue was all too clear to see.</p>
<p>This brings me to the title of the article, and how this could have been avoided.  I should have gotten everything set up, checked it was working and then checked from somewhere different; or even simply clearing the browser cache to check everything was as it should be.  Testing is something which does take a lot of time to do right, and if it&#8217;s not done right is fairly obvious.  With something as important as my own personal website, it should have been far higher on my list of things to do; but it wasn&#8217;t, I messed up and I look bad for it being that way.</p>
<p>It&#8217;s all fixed now, briefly, but I&#8217;ll have the faux-CDN to reconfigure to improve load speeds.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Joomla 3.5.1 released</title>
		<link>https://www.garybell.co.uk/blog/cms/joomla-3-5-1-released/</link>
		<pubDate>Wed, 06 Apr 2016 21:22:24 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[bug fixes]]></category>
		<category><![CDATA[CMS. Joomla]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=96</guid>
		<description><![CDATA[Joomla has announced the release of their open source CMS system, version v3.5.1.  The latest version fixes the following issues which were found in v3.5: Fix root url sometimes returning empty in canonical URLs Fix having to log in twice when user session expires Some SMTP emails could no longer be sent due to a &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/cms/joomla-3-5-1-released/" class="more-link">Continue reading<span class="screen-reader-text"> "Joomla 3.5.1 released"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Joomla has announced the release of their open source CMS system, version v3.5.1.  The latest version fixes the following issues which were found in v3.5:</p>
<ul>
<li><a href="https://github.com/joomla/joomla-cms/pull/9565">Fix root url sometimes returning empty in canonical URLs</a></li>
<li><a href="https://github.com/joomla/joomla-cms/pull/9619">Fix having to log in twice when user session expires</a></li>
<li><a href="https://github.com/joomla/joomla-cms/pull/9528">Some SMTP emails could no longer be sent due to a bug in the SMTP email server setup</a></li>
<li>Session restarts caused PHP Errors</li>
<li>Fix insertid() returning 0 for the PDO MySQL driver</li>
<li>Fix the Empty trash and unarchive button not existing for com_banners</li>
</ul>
]]></content:encoded>
			</item>
		<item>
		<title>Joomla 3.5 Released</title>
		<link>https://www.garybell.co.uk/blog/cms/joomla-3-5-released/</link>
		<pubDate>Mon, 28 Mar 2016 21:21:10 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[bug fixes]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=94</guid>
		<description><![CDATA[A little over a week ago, the Joomla! Project anounced the release of Joomla 3.5.  The major advantage this has is that the widely used CMS has PHP7 support, allowing webmasters to upgrade their server installations and take advantage of the performance improvements that PHP7 brings. The new version comes with an e-mail update plugin to allow &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/cms/joomla-3-5-released/" class="more-link">Continue reading<span class="screen-reader-text"> "Joomla 3.5 Released"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>A little over a week ago, the <a href="https://www.joomla.org/announcements/release-news/5654-joomla-3-5-is-here.html" target="_blank" rel="noopener">Joomla! Project</a> anounced the release of Joomla 3.5.  The major advantage this has is that the widely used CMS has PHP7 support, allowing webmasters to upgrade their server installations and take advantage of the performance improvements that PHP7 brings.</p>
<p>The new version comes with an e-mail update plugin to allow site admins to know when there are patches and bug fixes; hopefully they will then patch their sites to the benefit of everyone.</p>
<p>A run down of the listed major changes are:</p>
<p><span id="more-94"></span></p>
<ul>
<li><strong>Download system &amp; environment information</strong>: gives users the option to download system/environment information for support purposes.</li>
<li><strong>Ability to add a user CSS file to Protostar</strong>: currently it is impossible to use a custom.css file when using the Protostar template. This update adds a check to see if the file user.css exists and loads the file to allow for user customisation.</li>
<li><strong>Added site and admin links to module user</strong>: adds switches to the mod_status module to show/hide links to the front-end and back-end of the site.</li>
<li><strong>Article counts</strong>: a set of updates that allows the visual presentation of published, unpublished and trashed articles in the Category Manager for articles, banners, contacts and newsfeeds.</li>
<li><strong>Random category blog and list order</strong>: this update answers a common user request to add a random ordering option for articles in the blog category and category list view.</li>
<li><strong>Editor Buttons added to the Toolbar</strong>: You no longer need to scroll down the page to find the “readmore” or “insert image” buttons. Editor extension buttons that used to be placed below the text area can now be found in the toolbar where they belong.</li>
<li><strong>Easily Insert Modules in Articles</strong>: allows users to easily add a module into an article with a button directly on the editor toolbar. Users don’t need to learn any syntax or remember the module details as the user interface does it for them.</li>
<li><strong>Drag and Drop Images</strong>: Adding an image is now as easy as dragging and dropping it from your computer directly into the content. This works anywhere that you are using the default TinyMCE WYSIWYG editor.</li>
</ul>
]]></content:encoded>
			</item>
		<item>
		<title>NEVER trust user input</title>
		<link>https://www.garybell.co.uk/blog/development/never-trust-user-input/</link>
		<pubDate>Wed, 16 Mar 2016 21:19:38 +0000</pubDate>
		<dc:creator><![CDATA[garybell86]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[sanitisation]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL injection]]></category>

		<guid isPermaLink="false">http://localhost:8080/?p=91</guid>
		<description><![CDATA[I&#8217;ve had the joys recently of being part of a code audit for a potential client for a change or re-build of a system.  The code in itself was complete textbook&#8230;of how not to code a system.  It looked like it had been built long long ago when OO principles didn&#8217;t exist, and when no-one &#8230; <p class="link-more"><a href="https://www.garybell.co.uk/blog/development/never-trust-user-input/" class="more-link">Continue reading<span class="screen-reader-text"> "NEVER trust user input"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve had the joys recently of being part of a code audit for a potential client for a change or re-build of a system.  The code in itself was complete textbook&#8230;of how not to code a system.  It looked like it had been built long long ago when OO principles didn&#8217;t exist, and when no-one knew about security unless they were in that field.  Certainly <a href="https://garybell.co.uk/blog/developers-still-lack-security-know-how" target="_blank" rel="noopener">developers knew nothing about security</a>.</p>
<p><span id="more-91"></span></p>
<p>It started like any audit I&#8217;ve been involved in, get it set up and then log in.  Usually that means asking for a password after checking the database to be sure they aren&#8217;t stored in plain text.  Nope, these were plain text.  Ok, so we can get in, and chalk 1 up in the bad developer column.  After a small poke around to see what it was doing, it became apparent that every page was its own contained file.  There were some includes for navigation, but most of it all stylesheets, javascript includes and other common resources were written in each and every file.  I wouldn&#8217;t want to be the one to have to update the version of jQuery on that one!</p>
<p>When we discovered this, we found that the queries being ran on each page were not sanitising any of the user input.  They were putting it blindly into queries and using old mysql_* functions; long since deprecated.  The bad developer count just hit 2, 3 and 4 from one simple check.  There were some instances where the developer was checking for one result being returned and failing if there was more, but that only gets a fraction of a percent off, when I could simply do a &#8216;limit 1&#8217; via the GET variable.  Still, this was in the application where there users probably aren&#8217;t technical enough to try, they wouldn&#8217;t have that sort of code on a login page, right?</p>
<p>I can&#8217;t even just add 1 to the bad developer for this.  It&#8217;s a minimum of +10 for allowing such simple &#8220;hacks&#8221; to let someone into the system.  Below is an example of literally what I could put as the username:</p>
<blockquote><p>&#8216; or user=&#8217;admin&#8217;#</p></blockquote>
<p>No password needed.  No sanitisation done.  I might forgive them if it was a 12 year old system, but the earliest entry in the database (the developer&#8217;s username) was last year.  It used jQuery 1.10 and bootstrap 3.3.8, which only came out in November.  Bad person hitting a keyboard (no longer afforded developer status).</p>
<p>Ok, so what can be done to prevent these things?  Firstly, stop using <a href="http://php.net/manual/en/function.mysql-query.php" target="_blank" rel="noopener">mysql_* functions</a>.  They were deprecated in PHP 5.5, and there&#8217;s other alternatives around which are better, like PDO and mysqli_*.  That said, in the given example code, I could have done the following with mysqli_query functionality and potentially had worse consequences:</p>
<blockquote><p>&#8216;;drop table users;#</p></blockquote>
<p>Which reminds me so much of the following <a href="https://xkcd.com/327/" target="_blank" rel="noopener">XKCD comic</a>:</p>
<p><img src="http://imgs.xkcd.com/comics/exploits_of_a_mom.png" alt="Her daughter is named Help I'm trapped in a driver's license factory." width="666" height="205" /></p>
<p>Aside from using current database interaction functionality, you should NEVER put data sent from a browser into a query.  Always sanitise it in one way or another.  Ideally use parametised queries which will take care of sanitisation for you, and also will build the query in a much safer manner (<a href="http://php.net/manual/en/book.pdo.php" target="_blank" rel="noopener">PDO</a> is my friend, it can be yours too).</p>
<p>There&#8217;s millions of web pages out there on how to prevent SQL injection, how to sanitise data input, how not to code, and why not to trust users.  Okay, so there&#8217;s also a lot of bad resources out there just the same, but there&#8217;s no reason anyone should be passing anything from the browser straight to the database.</p>
<p>Developers like to blame users when something in the system goes wrong.  Sure it would be a user issue if I logged in in that manner, but it&#8217;s more of a developer issue for allowing it in the first place.  Those things aren&#8217;t limited to just logins either though.  If you delete data using the following manner:</p>
<blockquote><p>delete.php?id=2</p></blockquote>
<p>Without input sanitisation, I can most likely do:</p>
<blockquote><p>delete.php?id=2+or+id+&gt;+0#</p></blockquote>
<p>Wave goodbye to your data or, best case, enjoy finding everything being flagged as deleted in the database.</p>
<p>NEVER trust your users to input things correctly, and never trust their input.</p>
]]></content:encoded>
			</item>
	</channel>
</rss>
