General function

Bhavesh M Khanpara

<?php

//Detect if the Browser is Internet Explorer
function detectIE(){
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;
}


// Detect if the Browser is FireFox
function detectFF(){
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false))
return true;
else
return false;
}
 // Create unique filename function uniqueFilename($length=12, $path, $ext) { $characters = "0123456789abcdefghijklmnopqrstuvwxyz"; $string = ""; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters) -1)]; } while (file_exists($path.$string.$ext)){ $string = uniqueFilename($length++, $path, $ext); } $string = $string.'.'.$ext; return $string; } // Resize an image for GD function resizeImage($pathToImage, $newPath, $thumbWidth, $swap=false, $square=false){ $info = pathinfo( $pathToImage ); $extension = strtolower( $info['extension'] ); $newImagePath = $newPath.$info['filename'].'.'.$extension; if (!$swap){ list($width, $height, $imgtype) = getimagesize($pathToImage); $ratio = $width / $height; /* Decide how we should resize image - fixed width or fixed height */ if ($height > $width) { $type = 'fixedheight'; } else…

View original post 1,244 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s