Friday 27 July 2007

MySQL time date difference in Minutes

Here's a handy MySQL function from finding the number of minutes since a given date. In the following example, there is a table called message with 3 colums - id, pubdate and message;

SELECT TIMESTAMPDIFF(MINUTE, pubdate, now()), id, message from message;

Messages from the last 5 minutes


You can get all messages from the last 5 minutes with the following example;

SELECT TIMESTAMPDIFF(MINUTE, pubdate, now()), id, message from message where (TIMESTAMPDIFF(MINUTE, pubdate, now()) < 5);

This method is quite handy for systems displaying live data.

Thursday 26 July 2007

PHP IP Addresses

I keep finding naffexample of how to find someones ip address.

However, I stumbled across this solution;

$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

echo($ip);

It returns the ip address, even if somone is behind a proxy and appears to always return an ip address.

Monday 23 July 2007

Adobe Contribute Port Settings

Macromedia's Contribute is essentially an ftp program made to help users with limited knowledge of web design to make new and edit existing pages to their website.

Sounds Great?

Well for those of you who have had to make contribute for commercial environments and have encountered networks with a firewall - things aren't always straight forward. Lots of business networks are so secure - they prohibit contribute from accessing the internet at all.

This is very important to check out your clients network before building a contribute site.

Therefore You need to make sure the following ports are open on your clients pc/network;

Ports;
21
80
8100
8900

To test this, I would recommend asking your client to download a copy of contribute from adobe and then ask them to connect to an ftp server test page which you have setup.

If you don't do this test, you run the risk of having to make a basic CMS very quickly for your client.

If you need a CMS very quickly and are reading this article, please feel free contact me - I have experience with having to make very quick, good CMS's for just this purpose!

http://www.suffolk-web-design.co.uk/site/60/get_a_free_quote/

Saturday 21 July 2007

Your Indexed Pages on Google

Have you ever wanted to know what google sees when it looks at your site? Here's a search command you can use which should help.

If you want to see which pages are indexed, you can run the following command as a google search;

site:suffolk-web-design.co.uk - asdf

The "site:" part of the search means use this site, the "-asdf" part means don't use any keywords. the result is that google pulls back all pages it has indxed on your site.

This command should give you a list of all of the pages google has indexed on your site. In my experience, the most popular pages appear near the top of the search results.

You can click here to see the search in action.