Categories

List images in a folder

// the directory, where your images are stored $imgdir = ‘/images/’;   // list of filetypes you $allowed_types = array(‘png’,’jpg’,’jpeg’,’gif’); want to show   $dimg = opendir($imgdir); while($imgfile = readdir($dimg)) { [...]

Compress css files

header(‘Content-type: text/css’); ob_start("compress"); function compress($buffer) {   /* remove comments */   $buffer = preg_replace(‘!/\*[^*]*\*+([^/][^*]*\*+)*/!’, ”, $buffer);   /* remove tabs, spaces, newlines, etc. */   $buffer = str_replace(array("\r\n", "\r", "\n", "\t", [...]

Get average feedburner reader numbers

function get_average_readers($feed_id,$interval = 7) { $today = date(‘Y-m-d’, strtotime("now")); $ago = date(‘Y-m-d’, strtotime("-".$interval." days")); $feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, [...]

Escape characters in a MySQL statement

$query = "SELECT * FROM users WHERE username=’" . $username . "’            AND password=’" . $password . "’";   // the record exists function is defined elsewhere if (record_exists($query)) { echo "Access granted"; [...]

Currency conversion

 

function currency($from_Currency,$to_Currency,$amount) { $amount = urlencode($amount); $from_Currency = urlencode($from_Currency); $to_Currency = urlencode($to_Currency); $url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency"; $ch = curl_init(); $timeout = 0; curl_setopt ($ch, CURLOPT_URL, [...]