• Home
  • Services
  • Profile
  • Portfolio
  • Contact
  • Links
  • Blog
  • Archives
  • Sitemap
Subscribe: Posts | Comments | E-mail
  • Ajax XMLHttpRequestAsynchronous HTTP Request How To's
  • FreebiesBest Freebies Collection
  • MiscellaneousNews, Announcements & General Stuffs
  • Print & Web DesignPhotoshop, Vector, CSS, XHTML
  • ProgrammingProgramming PHP, ASP, .NET and more

Bali Web Design

404 - Page Not Found

There is known permalink issue after server migration.
Please try to search or navigate from the category instead

Perhaps the links below might help you find what you are after:

Posted on May 7, 2010 - by webmaster

WordPress 3.0 Theme Development: The Comment Form

Programming Tutorials

Otto at ottopress has written a great article about the new handy & standarized tags in wordpress 3.0 to display comment form. Replacing the old messy comment template with versatile costumizable wordpress template tag.  go check out the article for detail

Posted on September 24, 2009 - by webmaster

PHP Class Create Short URL via TinyURL, Is.gd, Hex.io, Tr.im & Bit.ly API

Programming Tutorials

Short URL is commonly used today for several reasons: avoid url garbling, take smallest space especially for long url which need to be posted at limited space format eg: twitter, also often used to manipulate user for specific purposes eg: hiding orginal url for phising and ads/affiliation links.

There are many websites that provide shortening url services, tinyurl, bit.ly, hex.io are some of them, below is simple PHP script as an implementation to use their API, create short url on the fly, currently support: tinyURL, bit.ly, is.gd, tr.im and hex.io, but you can easily add other providers.


PHP Class

<?php
/*
** Title: Shortening URL Class
** Author: chazzuka <ariel@chazzuka.com>
** Author URL: http://www.chazzuka.com
** Latest Updated: September 24 2009
*/
class ShortUrl {

	public static function create($url,$provider='tinyurl',$user='',$key='') {
		$api_url = sprintf(self::api($provider),urlencode($url),$user,$key);
		return self::inspect($provider,self::execute($api_url));
	}

	private static function execute($url) {
		$ch = curl_init();
		curl_setopt ($ch, CURLOPT_URL, $url);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
		$text = curl_exec($ch);
		curl_close($ch);
		return $text;
	}

	private static function inspect($provider,$xml) {
		if(!empty($xml)) {
			switch(strtolower(trim($provider))){
				case "bitly":
					$o = new SimpleXMLElement($xml);
					return (string)$o->results->nodeKeyVal->shortUrl;
					break;
				case "trim":
					$o = new SimpleXMLElement($xml);
					return (string)$o->url;
					break;
				case "isgd":
				case "hexio":
				default:
					return $xml;
			}
		}
		return false;
	}

	private static function api($provider) {
		switch(strtolower(trim($provider))){
			case "bitly":
				$return = "http://api.bit.ly/shorten?version=2.0.1&format=xml&longUrl=%s&login=%s&apiKey=%s";
				break;
			case "isgd":
				$return = "http://is.gd/api.php?longurl=%s";
				break;
			case "hexio":
				$return = "http://hex.io/api-create.php?url=%s";
				break;
			case "digg":
				$return = "http://services.digg.com/url/short/create?url=%s&appkey=%s&type=xml";
				break;
			case "trim":
				$return = "http://api.tr.im/v1/trim_url.xml?url=%s";
				break;
			default:
				$return = "http://tinyurl.com/api-create.php?url=%s";
		}
		return $return;
	}
}
?>

Sample of usage:

<?php
$url = 'http://www.chazzuka.com/blog/?p=192';
echo ShortUrl::create($url,'trim');
echo '<hr />';
echo ShortUrl::create($url,'tinyurl');
echo '<hr />';
echo ShortUrl::create($url,'isgd');
echo '<hr />';
echo ShortUrl::create($url,'hexio');
echo '<hr />';
echo ShortUrl::create($url,'bitly','your_user_name','your_api_key');
?>
Posted on September 12, 2009 - by ruby

How to embed plurk status in wordpress blog

Programming Tutorials

I had signup with plurk a year ago but haven’t “plurking” since i use twitter a lot, and for me both of them were created for same purpose, microblogging, sharing what you’re up to in few sentences and follow what your friends up to. Today i had re-theming my personal blog and use free seven five wordpress theme by press75 which is very simple and already integrated with twitter status, delicious bookmarks, and external RSS feed, then i thinks its good to add plurk also.

Theres a wordpress plugin to achieve this purpose already, but here i only need to fetch status update, and dont need any widget or possibility to update my status from my blog, and here we go,

// fetch plurk messages
function plurk_messages(
$username = '',
$num = 1,
$list = true,
$show_username = false,
$show_moods = true,
$encode_utf8 = false)
{
$plurk_url = 'http://www.plurk.com';

$plurk_moods = array('loves','likes','shares','gives','hates','wants','wishes','needs','will','hopes','asks','has','was','wonders','feels','thinks','says','is');
array_walk($plurk_moods, 'plurk_addspace');

$plurk_mood_replace = array();
$plurk_mood_replacer = array();

include_once(ABSPATH . WPINC . '/rss.php');

$messages = fetch_rss('http://www.plurk.com/user/' . $username . '.xml');

if ($list) echo '&amp;amp;lt;ul class="plurk"&amp;amp;gt;';

if ($username == '')
{
if ($list) echo '&amp;amp;lt;li&amp;amp;gt;';
echo 'RSS not configured';
if ($list) echo '&amp;amp;lt;/li&amp;amp;gt;';
}
else
{
if ( empty($messages-&amp;amp;gt;items) )
{
if ($list) echo '&amp;amp;lt;li&amp;amp;gt;';
echo 'No public plurk messages.';
if ($list) echo '&amp;amp;lt;/li&amp;amp;gt;';
}
else
{
// start fetching
$i = 0;
foreach ( $messages-&amp;amp;gt;items as $message )
{
$msg = $message['atom_content'];
$author_name = $message['author_name'];
$link = $plurk_url.$message['link_'];
$time = strtotime($message['published']);

if(!$show_moods) { $msg = str_replace($plurk_moods,'',$msg); }
else {
if(empty($plurk_mood_replace)||empty($plurk_moods_replacer)){
list($plurk_mood_replace,$plurk_mood_replacer) = plurk_moods_format($plurk_moods,$author_name);
}
$msg = str_replace($plurk_mood_replace,$plurk_mood_replacer,$msg);
}

if(!$show_username) { $msg = str_replace($author_name.' ','',$msg); }
else { $msg = str_replace($author_name,'&amp;amp;lt;a class="plurk_username" href="'.$plurk_url.'/'.$username.'"&amp;amp;gt;'.$author_name.'&amp;amp;lt;/a&amp;amp;gt;',$msg); }

if($encode_utf8) $msg = utf8_encode($msg);

if ($list) { echo '&amp;amp;lt;li class="plurk-item"&amp;amp;gt;'; } else { echo '&amp;amp;lt;p class="plurk-message"&amp;amp;gt;'; }

$msg = preg_replace("/&amp;amp;lt;a href=[\"' ]?([^\"' &amp;amp;gt;]+)[\"' ]?[^&amp;amp;gt;]*&amp;amp;gt;(.*?)&amp;amp;lt;\/a&amp;amp;gt;/i",'$1',$msg);
$msg = plurk_hyperlinks($msg);
$msg = plurk_users($msg);

echo $msg;

if ( ( abs( time() - $time) ) &amp;amp;lt; 86400 ) {  $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); }
else{ $h_time = date(__('Y/m/d'), $time); }

echo '&amp;amp;lt;span class="plurk-timestamp"&amp;amp;gt;&amp;amp;lt;abbr title="' . date(__('Y/m/d H:i:s'), $time) . '"&amp;amp;gt;' . $h_time . '&amp;amp;lt;/abbr&amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;';

if ($list) { echo '&amp;amp;lt;/li&amp;amp;gt;'; } else { echo '&amp;amp;lt;/p&amp;amp;gt;'; }

$i++;
if ( $i &amp;amp;gt;= $num ) break;
}
// end fetching --&amp;amp;gt;
}
}
if ($list) echo '&amp;amp;lt;/ul&amp;amp;gt;';
}
// set pattern + replacement for message prefix (says, is etc.)
function plurk_moods_format($plurk_moods,$user){
$plurk_moods_replace = $plurk_moods_replacer = array();
foreach($plurk_moods as $mood){
$plurk_moods_replace[] = "$user $mood";
$plurk_moods_replacer[] = $user.' &amp;amp;lt;span class="plurk-'.trim($mood).'"&amp;amp;gt;'.trim($mood).'&amp;amp;lt;/span&amp;amp;gt; ';
}
return array($plurk_moods_replace,$plurk_moods_replacer);
}
// add spaces into moods
function plurk_addspace(&amp;amp;amp;amp;$item,$key) { $item = "$item "; }

And couple of functions below taken from Twitter for Wordpress plugin by Ricardo Gonzalez to format autolink and in-reply message.

// format autolink
function plurk_hyperlinks($text) {
// Props to Allen Shaw &amp;amp;amp;amp; webmancers.com
// match protocol://address/path/file.extension?some=variable&amp;amp;amp;amp;another=asf%
//$text = preg_replace("/\b([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&amp;amp;amp;amp;\%]*)\b/i","&amp;amp;lt;a href=\"$1\" class=\"plurk-link\"&amp;amp;gt;$1&amp;amp;lt;/a&amp;amp;gt;", $text);
$text = preg_replace('/\b([a-zA-Z]+:\/\/[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&amp;amp;amp;amp;%#+$*!]*)\b/i',"&amp;amp;lt;a href=\"$1\" class=\"plurk-link\"&amp;amp;gt;$1&amp;amp;lt;/a&amp;amp;gt;", $text);
// match www.something.domain/path/file.extension?some=variable&amp;amp;amp;amp;another=asf%
//$text = preg_replace("/\b(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&amp;amp;amp;amp;\%]*)\b/i","&amp;amp;lt;a href=\"http://$1\" class=\"plurk-link\"&amp;amp;gt;$1&amp;amp;lt;/a&amp;amp;gt;", $text);
$text = preg_replace('/\b(?&amp;amp;lt;!:\/\/)(www\.[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&amp;amp;amp;amp;%#+$*!]*)\b/i',"&amp;amp;lt;a href=\"http://$1\" class=\"plurk-link\"&amp;amp;gt;$1&amp;amp;lt;/a&amp;amp;gt;", $text);

// match name@address
$text = preg_replace("/\b([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})\b/i","&amp;amp;lt;a href=\"mailto://$1\" class=\"plurk-link\"&amp;amp;gt;$1&amp;amp;lt;/a&amp;amp;gt;", $text);
//mach #trendingtopics. Props to Michael Voigt
$text = preg_replace('/([\.|\,|\:|\¡|\¿|\&amp;amp;gt;|\{|\(]?)#{1}(\w*)([\.|\,|\:|\!|\?|\&amp;amp;gt;|\}|\)]?)\s/i', "$1&amp;amp;lt;a href=\"http://plurk.com/#search?q=$2\" class=\"plurk-link\"&amp;amp;gt;#$2&amp;amp;lt;/a&amp;amp;gt;$3 ", $text);
return $text;
}
// in-reply to
function plurk_users($text) {
$text = preg_replace('/([\.|\,|\:|\¡|\¿|\&amp;amp;gt;|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\&amp;amp;gt;|\}|\)]?)\s/i', "$1&amp;amp;lt;a href=\"http://plurk.com/$2\" class=\"plurk-user\"&amp;amp;gt;@$2&amp;amp;lt;/a&amp;amp;gt;$3 ", $text);
return $text;
}

Copy those functions in your functions.php at your active theme folder, or you can put it in separate file then include it in your functions.php file.

The implementation is simple, just call the function in your file where you need your plurk status to be placed.

plurk_messages('username',10) ;

The function tahe few parameters in sequential order as follow:

  1. Username
  2. Number of status to be displayed
  3. Flag true/false Use unordinal list or note (ul li or p)
  4. Flag true/false show your username in the message
  5. Flag true/false show the message prefix or not
  6. Flag true/false Encode the message in UTF8 or not

How to styling? you need to add CSS for few class of the HTML tag which are auto generated by the function

ul.plurk, li.plurk-item. p.plurk-message, a.plurk_username, span.plurk-timestamp, a.plurk-link, a.pluk-user, also series of span with classes prefix by plurk- and followed by message prefix eg: span.plurk-says, span.plurk-loves etc.

Do you plurking? add me!

Thas it, hopely it usefull for you.

Scripty2 the successor of script.aculo.us
by ruby on June 29, 2009
Social Network Icon Pack
by ruby on June 29, 2009
jQuery validation engine, jquery inline form validation
by ruby on June 12, 2009
Js.Class Ruby style javascript
by ruby on June 12, 2009
Javascript Infovis Toolkit
by ruby on June 12, 2009
Wordpress 2.8 available for download
by ruby on June 11, 2009
Website Optimization Best Practices, speed up your website load
by ruby on May 21, 2009
« Older Entries
Newer Entries »
Freebies

Social Network Icon Pack

80+ social network icons which consists of 40+ 16 pixel x 16 pixel icons and 40+ 32 pixel by 32 pixel icons all in 32-bit PNG format by komodomedia.

Download it here

Freebies Print & Web Design

Free Icons flavour & twitter icons

Awsome free icons at smashingmagazine available for download, 2 different set of high quality icons in PNG format with different sizes and downlaodable along with PSD & AI (adobe illustrator format) source for free, allow you to make any modifications to the icons to fit your needs.

Flavours Icon Set by Oliver Twardowski, aimed to help [...]

Freebies Print & Web Design

Free Icons flavour & twitter icons

Awsome free icons at smashingmagazine available for download, 2 different set of high quality icons in PNG format with different sizes and downlaodable along with PSD & AI (adobe illustrator format) source for free, allow you to make any modifications to the icons to fit your needs.

Flavours Icon Set by Oliver Twardowski, aimed to help [...]

Freebies Print & Web Design

Gallery a free wordpress theme for portfolio showcase

Smashingmagazine has released a new free wordpress theme designed by Christopher Wallace named “gallery”, based on the result of smashing community wordpress theme polling.

Gallery is a beautiful, free, gallery-style Thematic child theme for WordPress. It is extremely flexible and can be used as a starting point for design galleries and portfolio.
Gallery is packed with loads [...]

Featured Programming

PHP Newbie: Proper handling of Error & Exception in PHP

Got a question from a friend today who is actually a great desktop programmer and just learn PHP since he believe that the future is in the web (hope you’re right dude). He asked me about how to handling error in PHP. Well i’ll write my answer here so can share with others and got [...]

Featured Programming

Install, Configure & Running Memcache in Windows as Service

Installing memcache server in windows is a little bit complicated compared to how it can be done in *nix since theres not yet available ready to use package for win32.

Luckily i found the compiled memcached for win32 (exe) which was made by jellycan, within this exe file you can install configure and running memcached as a service in your windows environment, here are how i made it

Programming Tutorials

WordPress 3.0 Theme Development: The Comment Form

Otto at ottopress has written a great article about the new handy & standarized tags in wordpress 3.0 to display comment form. Replacing the old messy comment template with versatile costumizable wordpress template tag

Programming Tutorials

PHP Class Create Short URL via TinyURL, Is.gd, Hex.io, Tr.im & Bit.ly API

Short URL is commonly used today for several reasons: avoid url garbling, take smallest space especially for long url which need to be posted at limited space format eg: twitter, also often used to manipulate user for specific purposes eg: hiding orginal url for phising and ads/affiliation links.
There are many websites that provide shortening url [...]

Web 2.0

Beautiful jquery lightbox plugins

When I am re-designing my official website i have googling for thickbox alternatives to used in my portfolio section, thickbox is great but i need a lightbox effect plugins with beautiful predefined styles and compatible with latest jquery 1.3.1 version, and jquery lightbox below match my requirements.

PrettyPhoto jquery lightbox
I have been using prettyphoto since few [...]

Freebies Tutorials Web 2.0

Update: Jquery Image Loader

Follow up the comments from my previous post about animate loading image with jquery which asking about how to populate images from the DOM instead of declare the image within the javascript codes manualy, so i made a little changes into the code since it seems to be easier for you all to adopt this [...]

View The Archives
  • Most Popular Posts

    • { 108 } ResponsesPHP ajax login form using Jquery
    • { 79 } Responsesphp ajax tutorial create ajax based login form using jquery
    • { 71 } ResponsesASP Classic Programming Still Alive
    • { 53 } Responses63+ best practice to optimize PHP code performances
    • { 44 } ResponsesVideobox: Lightbox for videos
  • Latest Posts

    • PHP Newbie: Proper handling of Error & Exception in PHP
    • Why SEO lost importance
    • jQuery Mobile Announced : Touch-Optimized Web Framework for Smartphones & Tablets
    • Multiple Google Account Signin
    • Install, Configure & Running Memcache in Windows as Service
    • DynamicWP Image Cube Wordpress Plugin
    • New Wordpress 3.0 API menu_page_url
    • Wordpress 3.0 Custom Taxonomy
    • JQuery DataGrid Plugin Compass
    • Upgrading to upcoming CodeIgniter 2.0
  • Categories

    • advertorial
    • Ajax XMLHttpRequest
    • Featured
    • Freebies
    • Miscellaneous
    • Print & Web Design
    • Programming
    • Tutorials
    • Web 2.0
  • Featured News

    • PHP Newbie: Proper handling of Error & Exception in PHP by webmaster on August 18, 2010
    • Why SEO lost importance by webmaster on August 16, 2010
    • jQuery Mobile Announced : Touch-Optimized Web Framework for Smartphones & Tablets by webmaster on August 16, 2010
    • Install, Configure & Running Memcache in Windows as Service by webmaster on June 27, 2010
    • Website Optimization Best Practices, speed up your website load by ruby on May 21, 2009
  • Tag Cloud

    • Actionscript advertorial Ajax XMLHttpRequest API best practices CakePHP chat Classic ASP CMS CSS Development facebook firefox Flash flickr Freebies gmail HTML icons Javascript Jobs jQuery jQuery Plugins Library Lightbox memcache Mootools news Personal PHP PHP Frameworks plurk Print & Web Design prism Prototype regex regular expression Scriptaculous SEO Tutorial twitter Web 2.0 Wordpress Works YUI
  • Archives

    • August 2010
    • June 2010
    • May 2010
    • September 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
copyleft 2007 - 2010 Bali Website Design Studio