Posts Under Article Category
Everybody's a web host
To cut straight to the point, “we’re living in the age where everybody’s a web host”. Whether it be small and quite pathetic or just another reseller of a larger service trying to get their cut of things, everybody truly is spamming the world with more and more web hosting packages. Just a few short years ago this problem didn’t exist and getting web hosting was quite expensive, unless you…
Restrict PHPMyAdmin to IP Address
Would you like to restrict PHPMyAdmin from being accessible to the whole world? Firstly you need to SSH into your box if you are not on the local machine where PHPMyAdmin is installed along with Apache. cd /etc/phpmyadmin/ vi apache.conf You will need to look for the following text “<Directory /usr/share/phpmyadmin>” and add in the below code: Remember that you need to press “i” in order to start editting text…
Replace all spaces in HTML with except in HTML tags using PHP
If you would like to replace all the spaces in an HTML string with so that you can render it out to the browser but you also want to retain current spaces in HTML tags you can use the below method: $inputString = ‘<span class="color:red">1</span> 2 3′; $outputString = preg_replace_callback("#>[^<]+<#","relSpaces",$inputString); function relSpaces($match){return str_replace(" "," ",$match[0]);} This will replace: “<span>1</span> 2 3″ ..to look like this: “<span>1</span> 2 3″
Using PHP to validate an IP address
You can use the PHP code below to check if an IP address is valid or not. $ip = ""; //enter a valid or invalid ip address here if(filter_var($ip, FILTER_VALIDATE_IP)) { // The IP Address is valid } else { // The IP Address is not valid } Wasn’t that easy!?!
What is 1e100.net?
So you are probably reading this because you are not sure what 1e100.net is or why you are being redirected via it when performing Google searches or using products such as youtube etc. Perform a SiteWhois lookup 1e100.net is owned by Google and has been in use since October 2009, if you perform a whois on the domain you can see it’s registration details linked back to Google. Perform an…
Hide all error messages PHP
PHP Error messages showing up in your web applications are a dangerous thing. Not only does it look unprofessional, but it is also a serious security concern! Once you have completed debugging your website or web application you can place the following one liner at the beginning of your code, this will turn off error reporting and therefore make sure that no application details are spilled to your users. error_reporting(0);…
What is xmlrpc.php?
It is a script which allows clients to make procedural calls over the net. As it says in the name, the encoding is XML and because it is used on websites we can make the fair assessment that it uses the HTTP protocol. If we break the name down we get: XML transmition via Remote Procedure Calls. So you are still not sure what this is all about? Read on…..
Stop That Referrer in PHP!
Today I will show you a method to stop the traffic that a referrer site is sending your way, you may wonder why you would want to ignore traffic, after all, isn’t inbound traffic to your site fantastic no matter what? The simple answer is “NO!” Let me explain it in a real life situation so that you can better understand where to use this. Understanding where to use it…
Ternary Operation
If you do not know what the Ternary operator is, or do not use it while you are coding, let me be the first to tell you how much you are missing out! The Ternary operator looks like this: “?“, that’s right, it’s a question mark! My favourite way of using it is to shorten Conditional If Statements, so let me show you what I’m on about. The long way:…
And then there was Google Instant!
If you have visited the Google.co.uk homepage (Yes, that’s Google UK) recently – since about the 8th of September 2010 then you would have noticed a new search feature Google is pushing called Google Instant. Now what is so nice about Google Instant? It is an ajax type search application that now searches using keyword ghosting and searches and returns results as you type to populate the normal search results…
PHP's typeof – gettype()
Quite often you may need the ability to check what type of data type a variable is. In most programming languages this is possible to do and is usually called typeof(). PHP too has a way to check this, it is called gettype() and it’s so simple to use. All you have to do is echo out a call to gettype() with your variable as the first argument. Like so:…