Redesign
Hello,
I have decided that it is time to replace my mspaint layout with something better. I have started to redesign the site to be better flowing, easier on the eye and easier to use+navigate. This is all available to view [url=/indexnew.php]over here[/url]. I would appreciate any criticism from you guys as I change this design. I think it will probably be released on the main page within a week or two.
Keep checking back for more updates
Groomi
Most people have an above average number of feet
[i]From [url=http://news.bbc.co.uk/1/hi/magazine/7581120.stm]bbc.co.uk[/url][/i]
[b]The "average" salary is £24,000, but most people earn less. Most people have an "above average" number of feet. In his fourth lesson of a weekly series, author Michael Blastland cracks the myth of the average.[/b]
Lesson Four: Averages
[b]The story[/b]: Productivity in the UK is below average for the G7 group of leading economies. Put bluntly, we're rubbish.
[b]The flaw[/b]: Productivity is also "below average" in France, "below average" in Canada, Germany and Italy and, yes, "below average" in Japan. That is, in six out of seven of the countries in the G7, productivity is "below average".
Feet
Think the average number of feet is two? Think again
[b]The lesson[/b]: If the thought that nearly everyone can be below average makes no sense, you might be muddled by the middle.
"Average" is commonly used to mean something like "ordinary", "typical", "normal" or "what's expected". Above is good, below is bad.
Most people remember from school that there are different kinds of average. But what mostly endures, if news coverage is anything to go by, is the notion that they all have something to do with a vague place which is, roughly, somehow, you know, in "the middle".
So it's easy to be horribly flustered by what is a simple principle - that the average is not necessarily anywhere near the middle. Sometimes, it is miles away. Sometimes it is about as atypical as you can get, and true of no one at all.
If you are still struggling, try this:
What's the average number of feet?
No, not two. The answer is slightly less. Think about it.
This is because the average can be pulled to one side by the influence of a tiny minority of people, in this case, the small number who have fewer than two feet.
Almost everyone has more than the average number of feet.
With productivity, the United States is the 800lb gorilla pulling the average to one side, away from what everyone else in the G7 achieves.
In fact, the UK is more or less indistinguishable from Canada, Italy and Germany, a bit ahead of Japan, and slightly behind France (if the data is reliable, see lesson two for why it often isn't). Only the US is really out in front (though we have been catching up).
[b]Junk rating: Two out of five. The "average" part of this story is useless. But productivity figures themselves are worth keeping an eye on, particularly as they change over the years.[/b]
With incomes, to take another example, many people are aware that the average in the UK (also known as the mean) is about £24,000 a year (in fact, about £463 a week).
Less well known is that well over half of us (about two thirds, in fact) earn less than average. This is because there are enough income centipedes - millipedes even - to pull the average well above what's typical
The chart shows a measure of the income distribution (how incomes are shared out) in the UK, divided into bands, each band representing 10% of the population.
You can see the average (the mean) marked on the chart. You can also see a large mound of people below it.
[img]http://newsimg.bbc.co.uk/media/images/44959000/gif/_44959418_uk_income_dist466.gif[/img]
Graph showing
If you lined everyone up according to income, the person who was truly in the middle, the median, would have been on about £377 week, that is about £86 a week below average.
Pick a person at random and their most likely income will be between about £200 and £300 a week.
So for a "typical" weekly income in the UK, you could - and I would - choose £377 (nearly 20% below average). Or you might say that it is between £200 and £300 (from about 65 to 35% below average).
In short, if you want to know what's typical, or normal, or in the middle, treat averages with care. In particular, beware gorillas and centipedes. They don't make averages useless, far from it, but knowing they are there helps no end to work out what the numbers really tell you.
[b]Classroom reminder[/b]: When you see "average" in the news, it is usually the arithmetical mean. With incomes, this is what you get if you add all incomes together then divide the total by the number of people. If you line everyone up according to income, the median is what's earned by the person who stands in the middle of the line. The mode is the income around which more people are grouped than any other.
I’m fixed :)
It's true!
Today I got the all clear from the hospital and have since given back my [url=http://blog.groomi.net/The_loss_of_a_limb_:(-,22]moon boot[/url] and crutches!
The hospital appointment was very uneventful but I just figured I had better let the one or two regular blog readers know that I'm working again.
Google calculator. It’s insane!
After glancing at that annoying 118 118 advert, I typed into google, [url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=A10&q=speed+of+sound&btnG=Search&meta=]"Speed of Sound"[/url]. After this I thought, would it put it into a more usable unit, so then I tried [url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=GNg&q=speed+of+sound+in+mph&btnG=Search&meta=]"Speed of Sound in mph"[/url]. I then thought "wow that's quite clever. Wonder if I can trick it".
Now, see the results of my curiosity, some of them are just plain rediculous!
[url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=VOg&q=speed+of+sound+in+inch%2Fsecond&btnG=Search&meta=]"Speed of Sound in inch/second"[/url]
[url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=440&q=speed+of+sound+in+inches+per+hour&btnG=Search&meta=]"Speed of Sound in inches per hour"[/url]
[url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=skL&q=speed+of+sound+in+inches+per+day&btnG=Search&meta=]"Speed of Sound in inches per day"[/url]
It seems this was too easy for Google. So now I moved on to more difficult things. See here:
[url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=ZQg&q=speed+of+sound+in+millimeters+per+year&btnG=Search&meta=]"Speed of Sound in millimeters per year"[/url]
[url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=NmL&q=speed+of+sound+in+millimeters+per+century&btnG=Search&meta=]"Speed of Sound in millimeters per century"[/url]
[url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=aSg&q=speed+of+sound+in+millimeters+per+millenium&btnG=Search&meta=]"Speed of Sound in millimeters per millenium"[/url]
Now I ask, is there any need for this?? The only useful thing I learned because of this insanity is that The speed of light is around [url=http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=FVg&q=speed+of+light+in+feet+per+nanosecond&btnG=Search&meta=cr%3DcountryUK%7CcountryGB]1 foot per nanosecond[/url]
A little random
Stephen
Secure login form with AJAX, Javascript + PHP
Hello, It has been quite a while since I posted a tutorial on this website and I have noticed that my Javascript/AJAX tutorials are in quite high demand. In between developing some other sites, I remembered how interesting it was coding my admin panel's secure AJAX login and how little documentation there was about such a method on the internet.
[b]The theory[/b]
The page I was protecting was to be accessed by me only and was to display a login prompt to all users attempting to access it. The form would then be filled in and the data would be sent to my PHP script. The PHP script would then need to decide wether or not the user's credentials are correct and either display the page requested or refuse the user access. The problem that I faced was that it was very difficult to create a javascript function that would do all this while remaining secure. I think my method is hack-proof but I will soon find out when this source code is read by the public, so here goes!
[b]How it's done[/b]
The first thing we will need is a HTML login form, but not a normal login form. This one will contain an [i]onSubmit[/i] attribute containing our javascript function call. Here is the form we will be using:
[code]<div id="content">
<form action="javascript:void(0);" onsubmit="login(document.getElementById('user').value,document.getElementById('pass').value);">
<p>
Username<br /><input id="user" type="text" /><br />
Password<br /><input id="pass" type="password" />
<input id="submitpop" type="submit" value="" />
</p>
</form>
</div>
[/code]
The action attribute is set to call [i]javascript:void(0);[/i] which simply ensures that the form does not post the data conventionally. The onSubmit attibute calls our javascript function, which will be used to authorise the user. We use [i]document.getElementById('input_id').value[/i] to send the values of the user and pass text inputs to our javascript.
Next, we need to create the javascript function [i]login[/i].
[code]function createhandler(){
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
return xmlhttp;
}
function login(user,pass)
{
var content=document.getElementById('content');
var xmlhttp=createhandler();
var params='user='+user+'&pass='+pass;
xmlhttp.open('POST', '/login.php', true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.setRequestHeader('Content-length', params.length);
xmlhttp.setRequestHeader('Connection', 'close');
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4){
if(xmlhttp.responseText!=0)
{
xmlhttp.open('POST', '/loggedin.php', true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.setRequestHeader('Content-length', params.length);
xmlhttp.setRequestHeader('Connection', 'close');
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
content.innerHTML=xmlhttp.responseText;
}
};
xmlhttp.send(params);
}
else
{
alert("Failled Login");
}
}
};
xmlhttp.send(params);
}[/code]
The [i]login[/i] function starts by calling [i]createhandler[/i]. This returns our ajax [i]XmlHttpRequest[/i] object. The function then posts our username and password to login.php. If login.php returns a value other than '0' then loggedin.php is loaded with the same user and password as login.php, this extra step probably isn't really necessary but it was the way I coded the function for my purpose. It may be just as easy to put your content inside login.php, but for some reason I didn't. If 0 is returned, then an alert box is called with the text "Failled Login" and no further action is taken.
That is it for the HTML and Javascript. The next step is our php file(s) which determine wether or not a correct username + password has been entered. For my script I used a username and password stored in a MySQL database but for ours we are going to set the correct values within the script.
[b]login.php[/b]
[php]
$user='username'; //Our username
$pass='password'; //Our password
if($user==$_POST['user'] && $pass==$_POST['pass'])
echo 1;
else
echo 'Failled Login';
?>[/php]
This PHP script checks if the username submitted is [i]username[/i] and the password is [i]password[/i]. If the combination is correct, it displays 1, 0 if it is incorrect.
[b]loggedin.php[/b]
[php]
$user='username'; //Our username
$pass='password'; //Our password
if($user!=$_POST['user'] || $pass!=$_POST['pass'])
return;
echo'Anything below the return; statement will be displayed only if the correct password is entered. There is no need for an error message as this page should only be accessed by a javascript hack attempt or correct password
';
?>[/php]
The page will return blank if it is not given the correct username and password. If it is, the page is displayed. If you want a user to be logged in without having to enter his details again, it is a good idea to store his username + password in a session or cookie. If you are reading this tutorial though, I would assume you already know how to do this. If you want information about how to implement sessions or cookies into this script, please leave a comment below and I will write another tutorial.
Peace
Stephen
[b]PS.[/b] I would love for someone to try to hack the system on this site so please do, this code is implemented as written on my admin login available if you right-click. I would love to hear any weaknesses the code has so feel free to try