Categories

Category Specific RSS

Soundex function example

$word2find = ‘stupid’;    $words = array(     ‘stupid’,     ‘stu and pid’,     ‘hello’,     ‘foobar’,     ‘stpid’,     ‘supid’,     ‘stuuupid’,     ‘sstuuupiiid’, );    while(list($id, $str) = each($words)){        $soundex_code = soundex($str);        if (soundex($word2find) == $soundex_code){         print ‘"’ . $word2find . ‘" sounds like ‘ . $str;     […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

Basic watermarking example

<?php   header("Content-type: image/jpeg");   // get image file $img_name = "test.jpg"; $img_src = imagecreatefromjpeg($img_name); $width_src = imagesx($img_src); $height_src = imagesy($img_src);   // new image size = old image size $width_dst = $width_src; $height_dst = $height_src; $quality = 80;   // create new image $img = imagecreatetruecolor($width_src, $height_dst); imagecopyresampled($img, $img_src, 0, 0, 0, 0, $width_dst, […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

PHP and GTK example

<?php       class GUI extends GtkWindow {           /*          * Class constructor          *          *    @param int $width        window width          *    @param int $height        window height          *    @param int $title        title bar text          *          */           public function __construct($width=400, $height=200, $title="PHP-GTK GUI") {             // Call […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

Get bluray release dates

<?php   if(isset($_GET[‘movie’])) {     $pdata = $_GET[‘movie’]; } else {     die(""); }   if (strlen($pdata) < 5) { die("At least 5 letters in search."); }   $data = file_get_contents("http://bluray.highdefdigest.com/releasedates.html"); preg_match_all(‘/<li><b>.*<a href=\"http\:\/\/bluray\.highdefdigest\.com\/[0-9]+\/.*\.html\">.*<\/a>/’, $data, $results);   foreach ($results[0] as $linkki) {         preg_match(‘/http\:\/\/bluray.highdefdigest\.com\/[0-9]+\/.*\.html/’, $linkki, $linkit[]);         preg_match(‘/html\">.*<\/a>/’, $linkki, $leffax);         $leffa = str_replace(‘html">’, ”, $leffax[0]); […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

Force a file to download

 

function downloadFile($file){         $file_name = $file;         $mime = ‘application/force-download’;     header(‘Pragma: public’);     // required     header(‘Expires: 0’);        // no cache     header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);     header(‘Cache-Control: private’,false);     header(‘Content-Type: ‘.$mime);     header(‘Content-Disposition: attachment; filename="’.basename($file_name).’"’);     header(‘Content-Transfer-Encoding: binary’);     header(‘Connection: close’);     readfile($file_name);        // push it out     exit(); }

from http://www.tecnocrazia.com/

[…]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare