Cleaning Executive Officer (1976-2011)

Patrick Chia


Wednesday, December 22nd, 2010

Goo.gl is available publicly and it is the most stable, secure and fastest URL shortener on the web. Now we may use it on wordpress blog post. Just upload to wordpress plugin folder and active. It’s will convert all link url into goo.gl short link. This wordpress plugin is integrate with php great class from Marcus Nunes. It’s tested with WordPress 3.0+


< ?php
/*
Plugin Name: Googl URL Shortener for WordPress Blog Posts
Plugin URI: http://patrickchia.com/
Description: Use Googl URL Shortener to convert all link in wordpress post into short url.
Version: 1.0
Author: Patrick Chia
Author URI: http://penote.com/patrick/
*/
/*  Copyright 2010  Patrick Chia  (email : mypatricks[at]gmail.com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

This PHP class uses Marcus Nunes - http://goo.gl/jVfk - 9/18/2010
*/

add_filter( 'the_content', 'strlen_short_url', 1 );

function strlen_short_url( $content ) {
preg_match_all("/<a href=\"(.*?)\">/", $content, $linkurl);

$linkurl = array_map( 'esc_url', (array) $linkurl[1] );
foreach ($linkurl as $urlcode) {
if ( strlen($urlcode) > 20 ) {
$newcode = googl_shortener($urlcode);

if ( $newcode )
$content = str_replace($urlcode, $newcode, $content);

}
}

return $content;
}

function googl_shortener($a) {
$goog_link = wp_cache_get( $a );

if ( false == $goog_link ) {
$googl = new goo_gl($a);
$goog_link = $googl->result();

wp_cache_set( $a, $goog_link, 'theme', 21600); //cache for 6 hours

}

return $goog_link;
}
if (!class_exists('class goo_gl')) {

class goo_gl{

var $url, $resul;

//goo.gl construct method
function goo_gl($url){

$this->url = $url;

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://goo.gl/api/url');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'user=toolbar [at] google.com&url='.urlencode($this->url).'&auth_token='.$this->googlToken($url));
$saida = curl_exec($curl);
curl_close($curl);
if($saida){
$json = json_decode($saida);
$this->resul = $json->short_url;
}
}

function result(){
return $this->resul;
}

function googlToken($b){
$i = $this->tke($b);
$i = $i >> 2 & 1073741823;
$i = $i >> 4 & 67108800 | $i & 63;
$i = $i >> 4 & 4193280 | $i & 1023;
$i = $i >> 4 & 245760 | $i & 16383;
$j = "7";
$h = $this->tkf($b);
$k = ($i >> 2 & 15) < < 4 | $h & 15;
$k |= ($i >> 6 & 15) < < 12 | ($h >> 8 & 15) < < 8;
$k |= ($i >> 10 & 15) < < 20 | ($h >> 16 & 15) < < 16;
$k |= ($i >> 14 & 15) < < 28 | ($h >> 24 & 15) < < 24;
$j .= $this->tkd($k);
return $j;
}

function tkc(){
$l = 0;
foreach(func_get_args() as $val){
$val &= 4294967295;
$val += $val > 2147483647 ? -4294967296 : ($val < -2147483647 ? 4294967296 : 0);
$l   += $val;
$l   += $l > 2147483647 ? -4294967296 : ($l < -2147483647 ? 4294967296 : 0);
}
return $l;
}

function tkd($l){
$l = $l > 0 ? $l : $l + 4294967296;
$m = "$l";  //deve ser uma string
$o = 0;
$n = false;
for($p = strlen($m) - 1; $p >= 0; --$p){
$q = $m[$p];
if($n){
$q *= 2;
$o += floor($q / 10) + $q % 10;
} else {
$o += $q;
}
$n = !$n;
}
$m = $o % 10;
$o = 0;
if($m != 0){
$o = 10 - $m;
if(strlen($l) % 2 == 1){
if ($o % 2 == 1){
$o += 9;
}
$o /= 2;
}
}
return "$o$l";
}

function tke($l){
$m = 5381;
for($o = 0; $o < strlen($l); $o++){
$m = $this->tkc($m < < 5, $m, ord($l[$o]));
}
return $m;
}

function tkf($l){
$m = 0;
for($o = 0; $o < strlen($l); $o++){
$m = $this->tkc(ord($l[$o]), $m < < 6, $m << 16, -$m);
}
return $m;
}

}
}
?>

Thursday, October 14th, 2010

Rehtse Evoli WordPress Theme can be insert your flickr gallery photos or your fixed photo. The background random with few images and seven days. Of course may it use your own custom background. Three column right sidebar design.


Theme Download: WordPress Theme Rehtse Evoli Download

Theme Support and Updates: Ask Question

Live Preview Site: WordPress MU Plugins

Wednesday, July 28th, 2010

Penote is a social web service that allows the subscriber to broadcast short messages or share notes to other subscribers of the service. It’s similiar like twitter and identi.ca microblogging. It’s support to post your sharing or updates to your other account such as blogger, tumblr, identica, multiply and facebook. I just wrote a simple wordpress plugin to appear your updated status into your wordpress blog. It’s has been tested with latest WordPress version. Click here to Download.

Penote Updates Widgets

Thursday, July 15th, 2010

If you are using WordPressMU or latest WordPress 3.0 MultiSite. This function may useful for you.


function is_subscriber() {
global $current_user;

if (!is_user_logged_in())
return;

$user_id = get_current_user_id();

if ( is_user_member_of_blog( $user_id ) )
return true;

return false;
}

Thursday, July 15th, 2010

Just found quite interesting comment about the famous social network. Why people said Facebook is suck and they called it “Fakebook”? I agree with them and love the name.   http://amplicate.com/sucks/facebook

Thursday, April 1st, 2010

Just signin gmail but seen the login page hacked.

Gmail hacked or just for fun?

Monday, March 15th, 2010

Do you want to setup your wordpress blog with your own domain? Now you may get the quality hosting with excellent service just 1 cent for initial cost. Click here to order your hosting plan and enter the coupon code  (freemonth) when you make a purchase. Or you want to get 20% off, you may enter this coupon – SPRING.  After your account has been setup, just login your account and using Fantastico to install your wordpress blog. If you are using WordPressMU(WPMU) version click here to learn how to setup your WordPressMU.

Tuesday, December 15th, 2009

This is very simple plugin to provides information about the last login activity on you blog account, If you’re concerned about unauthorized access to your blog account, you’ll be able to use this information to find out if and when someone gained access.

Wordpress last login activity

Wordpress last login activity

The IP address is also useful. If you always or most often sign in to your blog account using a single computer, your IP address should be the same, or start with the same two sets of numbers (for example, 125.16.xx.xx). If you’re seeing an IP address that differs greatly from your usual IP address, it could either mean that you’ve recently accessed your account from a different location, or that someone has accessed your blog.

Download the zip file and unzip the file into plugin folder or mu-plugins if you are install MU Version.

For WordPress user, just activate the plugin. No option available. You must logout and login again to see the result.

For MU user, just upload the file, nothing to activate. User logout and login will see the result at the bottom bar.

Merry Christmas and Happy New Year to all of you and your family.

Saturday, December 12th, 2009

I just make a test on Maxis Broadband without browse and surfing web. Just powered on the wireless modem and monitoring within few minutes. Please see the captured image. You may found the different Total Data Received. Maxis has changed their broadband package that control by bandwidth. But seen it’s cheating data received.

And one more thing, if you are upgrading to new package, you are entitle paid upgrading fees. But if you not going to upgrade. The suck Maxis also change your package to new selling package without your permission . For example, my subscribed package has no bandwidth control, but their new package has bandwidth control. I called to customer service, the guy informed me that my account has exceed the data quota, who’s allowed Maxis change my subscribed package?  I don’t know whether Maxis has right to change our existing package to new or not? Is it mean Maxis has right to break the signed agreement? Beware if you are powered on the modem without do anything, your money is flying too…

Thursday, November 19th, 2009

Just received a email from Edir to fixed the problem for WPMU Admin Interface Language.  Open the file with editor or notepad, just make a mirror change. Take a look.


function admin_in_english_locale( $locale ) {

$lang = get_user_option('lang_id', $user_id);

if ( !$lang ) {
return $locale; // Change HERE
}

if( WP_ADMIN === true ) {
if ( $lang ) {
$locale = $lang;
} else {
$locale = 'en_US';
}
}

return $locale;
}

To make it works, it needs to return the actual value of $locale, used in wp-config.php, when it returns false, it returns to English in the front-end. – Edir

Thanks to Edir’s fixed the problem.