Error: [2048] date() [function.date]: It is not safe to rely on the system’s timezone settings.

I GOT THE FOLLOWING ERROR WHILE A CONTACT FORM WAS SUBMITTING:

Error: [2048] date() [function.date]: It is not safe to rely on the system’s timezone settings.”

All the site was doing was echoing a simple date(‘Y’) for a copyright notice.

Many of the answers I read online suggest editing the php.ini file. Are you kidding me?.. for a shared hosting account and such a benign problem?

SIMPLE SOLUTION:

Set the timezone of your site with this one extra line of code..

<?php date_default_timezone_set('Europe/London'); ?>

Other timezones can be found here..

COMPLETE EXAMPLE:

<?php date_default_timezone_set('Europe/London'); ?>

<div> &copy;1998 - <?php echo date('Y');?> COMPANY NAME </div>

Sorted!

How to respray a motorcycle..

No more VFR. I traded in the ’99 VFR. It was an awesome motorbike, but has some how become sterile. It was so perfect that I didn’t need to do anything to it. It was so fast that it was a threat to my licence. And ultimately, it just became ‘boring’. I traded it in, I had hand over a few quid upstream, but I got the XV700. It’s a 1986 (1986 was the year I first went on the road on a Fizzy 50). She is a JOY to work on.. she needs attention to the paintwork. That is a not a shine, it feels like fine sandpaper!.. shame on the former owner.

So, it begins. A winter of restoration.

If you want to know what I used and how, drop me a line..

2013-02-16-13.28.03 20130216_132346

First Experience of Windows 8

My first experience with Windows 8 and when I say first experience, I mean this is just booting off the ISO .. A. Blue. Screen.. Microsoft! Really?

Ok, I tried running it off a 90-day developer version, which Microsoft themselves recommend you run in a Virtual PC. So, I did I run it in a virtual PC. In fact I run in Microsoft’s OWN virtual PC that comes with Windows 7 Ultimate. The same virtual PC that quite happily runs even Windows 3.1 and Windows 95.

Also, this is the 32bit version of Windows 8, which actually got further than the 64bit version.

When PC gaming becomes mainstream on Linux, Microsoft are going to disappear or adapt VERY quickly. In fact with Steam coming to Linux, this may just be the very beginning of the end for Windows as we know it.

Thinking of selling my faithful VFR

I’m just not riding it anymore. Since tearing the ligament in my hip last year, I wince just stepping over the Veef. Time to find something lower’n'slower methinks..

It’s a 1999, done just over 40 thousand miles. It has never missed a beat nor let me down.

Am thinking about getting something smaller, lower and slower. Looked at a Royal Enfield Bullet, but I’m not sure I could get used to the gears being on the other side!!

Also looked at:

HONDA SHADOW
YAMAHA VIRAGO
YAMAHA DRAGSTAR
KWAK VN800
HONDA VLX600
SUZUKI LS 650 SAVAGE (S40)

Interested in a swap or PX?

 

 

Spam comments not welcome..

This new version of my site has been up a very short time and already there has been some people who think they can post faux compliments and expect me to allow them to do this.

Well, sorry I have so interest in promoting your crappy sites that sell certain fashion footwear types or potentially illegal medication.

Thanks http://akismet.com/ lets see if your system can do something to battle this crap..

Very simple PHP number of users guests visitors online system.

Create a file called guestsonline.txt save it in the document root. CHMOD 750.

Create a guestsonline.php and paste in the following:

<?php
$dataFile = "guestsonline.txt";

$sessionTime = 5; //time in **minutes**. If no response after this time, they will be deleted from the txt file.

error_reporting(E_ERROR | E_PARSE);

if(!file_exists($dataFile)) {
	$fp = fopen($dataFile, "w+");
	fclose($fp);
}

$ip = $_SERVER['REMOTE_ADDR'];
$users = array();
$onusers = array();

//getting
$fp = fopen($dataFile, "r");
flock($fp, LOCK_SH);
while(!feof($fp)) {
	$users[] = rtrim(fgets($fp, 32));
}
flock($fp, LOCK_UN);
fclose($fp);

//cleaning
$x = 0;
$alreadyIn = FALSE;
foreach($users as $key => $data) {
	list( , $lastvisit) = explode("|", $data);
	if(time() - $lastvisit >= $sessionTime * 60) {
		$users[$x] = "";
	} else {
		if(strpos($data, $ip) !== FALSE) {
			$alreadyIn = TRUE;
			$users[$x] = "$ip|" . time(); //updating
		}
	}
	$x++;
}

if($alreadyIn == FALSE) {
	$users[] = "$ip|" . time();
}

//writing
$fp = fopen($dataFile, "w+");
flock($fp, LOCK_EX);
$i = 0;
foreach($users as $single) {
	if($single != "") {
		fwrite($fp, $single . "\r\n");
		$i++;
	}
}
flock($fp, LOCK_UN);
fclose($fp);

if($uo_keepquiet != TRUE) {
echo '<div style="padding:5px; margin:auto; color:#ffffff; background-color:#595959"><b>' . $i . ' guests online</b></div>';
}

?>

Usage:

<?php include('guestsonline.php'); ?>

Add an image to each corner of a DIV

Create a small image of something like a screw head and save it as (in this examples thing.png) in your images folder. Then add these lines to the CSS for your div..

background-image: url("images/thing.png"), url("images/thing.png"), url("images/thing.png"), url("images/thing.png");
background-position: left top, right top, left bottom, right bottom;
background-repeat: no-repeat;

A page has moved. Redirect your users..

You moved a page and want people to find the new one..

There are easy ways to do this using .htaccess, but this simple way uses Javascript.

<html>
<body>
<p align="center">The page you are looking for has a new home here:</p>
<p align="center">
<a href= "http://www.YOURSITE.com/subfolder/">THE PAGE YOU WANT</a></p>
<p align="center">If you are not redirected automatically within a few
seconds then please click on the link above.</p>
<script type="text/javascript"><!--
setTimeout('Redirect()',4000);
function Redirect()
{
location.href = 'http://www.YOURSITE.com/subfolder/';
}
// --></script>
</body>
</html>

Using PHP to check if a file exists remotely or locally

How do I check if a file exists?

There are times when it is prudent to check if a certain file is available for use before setting your code on it. If the file doesn’t exist, it might be a good idea to have a back up plan so your site doesn’t fall over and display an embarrassing message to your users..

Check if Local File Exists:

To check if a file exists on your own server..

<?php
$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
echo "YES";
} else {
echo "NO";
}
?>

Check if Remote File Exists:

To check if a file exists on a different server..

<?php
function fileExists($path){
return (@fopen($path,"r")==true);
}

if fileExists('http://some.path/to/foo.txt'){
echo "YES";
} else {
echo "NO";
}
?>