<?php
mkdir (“/htdocs/testdir”, 0644);
echo “Test directory made successfully”;
?>
function url_exists($url)
{
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLOPT_POST,false);
curl_setopt($ch,CURLOPT_FAILONERROR,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_exec($ch);
$curlInfo = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
if ($curlInfo != 200 && $curlInfo != 302 && $curlInfo != 304)
{
return false;
}
else
{
return true ;
}
}
//get current month
$currentMonth=date(“m”);
//work out the season
if ($currentMonth>=”03″ && $currentMonth<=”05″)
$season = “spring”;
elseif ($currentMonth>=”06″ && $currentMonth<=”08″)
$season = “summer”;
elseif ($currentMonth>=”09″ && $currentMonth<=”11″)
$season = “autumn”;
else
$season = “winter”;
this example shows how to get a short url using the service from is.gd
<?php
/*
Get a is.gd short url using PHP
*/
function isgd($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,’http://is.gd/api.php?longurl=’.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$content = curl_exec($ch);
curl_close($ch);
//return the data
return $content;
}
//how to use
$shorty = isgd(‘http://progged.net’);
echo $shorty;
?>
if (stristr($_SERVER['HTTP_USER_AGENT'], ‘iPhone’))
{
// redirect to an iphone version
}