Archive for March, 2007

Selamat Jalan Chrisye

Friday, March 30th, 2007

Aku merasa kehilangan salah satu sahabat remajaku, seorang pria dengan suara tipis menyanyikan berbagai lagu indah. Teringat akan “Anak Jalanan”, “Angin Malam”, “Badai Pasti Berlalu”, “Pagi yang Cerah”, “Lilin Kecil”, yang ikut membantu melintasi masa remaja, masa yang pasti cukup sulit bagi semua orang.

Masih kucari dimanakah bisa kudapatkan “Guruh Gipsy”, dimana kau sempat singgah. Walaupun kau pergi tetap senandungmu adalah bagian dari senandungku juga. Setelah kau pergi, entah kepada siapa kita percayakan sebuah lagu ditembangkan . Selamat jalan, Chrisye. Badai sudah berlalu, semoga saat ini dalam damai dan menyanyilah di surga.

Make a RSS Feeder for Your Site

Thursday, March 29th, 2007

In this time, i’d like to show you how to make a RSS enabled site. Firstly, we have to clear things about RSS itself.

RSS: How the content flies everywhere

RSS (Really Simple Syndication, or elses) technology enables content to read not only where it located. How can it be? simple. RSS just a bunch of text file which standardized in formatting. Because of W3C (WWW Consortium) has been pointing XML as a universal data formatting to be exchanged among applications, XML is becoming the foundation of RSS itself.

The Structure of RSS File

RSS file contains some standard tags to be used. Look a sample below:

<?xml version=”1.0″ encoding=”utf-8″?>
<rss version=”2.0″>
<channel>
<title>JCO Donuts and Coffee News</title>
<description>You can syndicate our content freely</description>
<language>en-us</language>
<docs>
http://backend.userland.com/rss</docs>
<generator>PHP/</generator>
<item>
<title>Technology Update</title>
<link>
http://localhost/jco_ok/index2.php?page=read_news&id=10</link>
<description>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tatio</description>
<pubDate>Thu, 08 Mar 2007 10:14:55 +0700</pubDate>
<guid isPermaLink=”false”>
http://localhost/jco_ok/index2.php?page=read_news&id=10</guid>
</item>
<item>
<title>Kongkalikong Jeger</title>
<link>
http://localhost/jco_ok/index2.php?page=read_news&id=9</link>
<description>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tatio</description>
<pubDate>Thu, 08 Mar 2007 09:44:42 +0700</pubDate>
<guid isPermaLink=”false”>
http://localhost/jco_ok/index2.php?page=read_news&id=9</guid>
</item>
</channel>
</rss>

Detailed explanation:

<?xml version=”1.0″ encoding=”utf-8″?>

The first line XML above means the file must be consider as a XML entity (technically, force browser or any content readers read the file as XML file ).

<rss version=”2.0″>

The second line states itself as RSS 2.0, means, the readers must be able to adopt RSS 2.0 (newest version).

<channel>

The channel opening tag is notice the reader to start fetching the whole body of content. 

<title>JCO Donuts and Coffee News</title>
<description>You can syndicate our content freely</description>
<language>en-us</language>
<docs>
http://backend.userland.com/rss</docs>
<generator>PHP/</generator>

Above part commonly called as meta of RSS containing the title of feed publisher, description and what language that used and how to get the documentation of RSS technology. Also, what programming language used to output the file.

<item>
<title>Technology Update</title>
<link>
http://localhost/jco_ok/index2.php?page=read_news&id=10</link>
<description>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tatio</description>
<pubDate>Thu, 08 Mar 2007 10:14:55 +0700</pubDate>
<guid isPermaLink=”false”>
http://localhost/jco_ok/index2.php?page=read_news&id=10</guid>
</item>

Here we go, we are in the most important of the feed. Firstly, browse above bunch of code. The most top line is <item> and the lowest one is </item>. Those tags mark the start and end of data which will be displayed on the reader. The amount of item is simply similiar of how many this part is repeated, ofcourse with a different data inside.

Ok, let’s make an analogy with a news in an ordinary newspaper. Text between <title></title> is relating to news title. <link></link> is similiar with the page you should go for the full text of news. <description></description> means the body of news. <pubDate></pubDate> means when the news is published. <guid></guid> means a string that uniquely identifies the item itself, some kind of indexing. Permalink, common term in blogging context, is a URL that points to a specific entry even it has passed from the front page. Permalink is a portmanteau word made from permanent link and is often simply stated so as to be human-readable.

</channel>
</rss>

Absolutely, the closing tags and define the end of RSS statement. Remember, you must make the RSS file in well-formatted condition or your content will not readable! Go to http://validator.w3.org/ to check your file validity.

Ok, Feed Doesn’t Always a *.xml File

Feed also can be a PHP file, means? It means you can output dynamic data without involving physically file writing mechanism which eat the server resources. Here is the sample script (you will need a MySQL server and database):

 

<?php

include(”config/config.php”);
include(”lib/class/class_database.php”);
$db = new Database($db['host'], $db['user'], $db['pwd'], $db['name']);
$db->Connect();

$q = “SELECT * FROM news WHERE active = 1 ORDER BY idnews DESC”
$q = new Query($q);
$q->Fetch();

/**********************************************************************************
* rss.php
* Version: 1.00
* Author: Gins
* Date: 05/21/2004
*
http://gin2.info/
*
**********************************************************************************
header(”Content-Type: text/xml;charset=utf-8″);
// prepare HTML text for use as UTF-8 character data in XML
function cleanText($intext) {
return utf8_encode(
htmlspecialchars(
stripslashes($intext)));
}

ECHO <<<END
<?xml version=”1.0″ encoding=”utf-8″?>
<rss version=”2.0″>
<channel>
<title>JCO Donuts and Coffee News</title>
<link>
http://localhost/jco_ok/feed.php</link>
<description>You can syndicate our content freely</description>
<language>en-us</language>
<docs>
http://backend.userland.com/rss</docs>
<generator>PHP/$phpversion</generator>
END;

// loop through the array pulling database fields for each item
do {
//$title = date(”r”, strtotime($q->Fetch["date"]));
$title = cleanText($q->Fetch["title"]);
$image = $site_url.”module/mod_news/image/”.$q->Fetch["image"];
$link = $site_url.”index2.php?page=read_news&id=”.$q->Fetch["idnews"];
$guid = $site_url.”index2.php?page=read_news&id=”.$q->Fetch["idnews"];
$description = cleanText($q->Fetch["body"]);
if(strlen($description) > 200){
$description = substr($description, 0, 200);
$description .= ” <a href=$guid>[more]</a>”
}
$pubDate = date(”r”, strtotime($q->Fetch["date"]));

// display an item
ECHO <<<END

<item>
<title>$title</title>
<image>$image</image>
<link>$link</link>
<description>$description</description>
<pubDate>$pubDate</pubDate>
<guid isPermaLink=”false”>$guid</guid>
</item>
END;

} while ($q->Fetch());

ECHO <<<END

</channel>
</rss>
END;

?>

You will need this like SQL script:

CREATE TABLE news (
idnews INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
idnews_category INTEGER(10) UNSIGNED NOT NULL,
iduser INTEGER(10) UNSIGNED NOT NULL,
date DATETIME NOT NULL,
title VARCHAR(200) NOT NULL,
body TEXT NOT NULL,
image VARCHAR(255) NULL,
active TINYINT(1) NOT NULL,
PRIMARY KEY(idnews)
);

Inform Firefox to show RSS icon at Address Bar

After all creating process is done let’s go the next step. How can visitors know that a web page contain a feed? One of solutions from Firefox is showing a RSS icon at the adress bar. You can order Firefox to this by inserting below code between <head></head> of your index file. I.e:

<head>

….

<LINK REL=”alternate” TITLE=”JCO Donut & Coffee | RSS” HREF=”feed.php” TYPE=”application/rss+xml” />

</head>

 

Good luck!

Classical Snippet: Finn De Bailar

Tuesday, March 27th, 2007

I’d love to share my short composition which planned to be the first movement of a sequential works based on an unfinished textual scenario. I do welcome any critics. This snippet entitled: Finn De Bailar (Last Dance). You can download here

John Lennon on My Piano

Saturday, March 24th, 2007

Just wanna share my tribute to John Lennon. I please you to download my poor piano play. The song is entitled “Jealous Guy”, the most intimate song of John Lennon after his golden time with The Beatles. You can download here.

The Danger of PHP Nude Code

Tuesday, March 20th, 2007

Dear Developers,

I do suggest you to not write any critical codes especially referred to your site configuration with no encoding. Just use maximum encoding to reduce the risks. Download or buy dedicated softwares such as Ioncube or PHTML Encoder. Many accidents occured that server force PHP files to be downloaded by client instead rather than executed by.

Copying Beethoven: Musik dan Pesan Dari Tuhan

Monday, March 5th, 2007

Bee
Kemaren, kasak-kusuk di BeMall Bandung, eh, nemuin satu DVD dengan judul Copying Beethoven. Pastinya bajakan lah. Lama sudah gak ketemu film yang ngomongin soal maestro musik klasik setelah Amadeus (tentang Mozart dan Salinery).

Diputar. Introduksi dijejali dengan berbagai gambar kusam dan lirih kemudian diujung sekuen tergeletak sang maestro, Beethoven, diatas ranjang apartemen kumuhnya dalam hembusan-hembusan nafas terakhirnya, ditemani tangisan Anna Holtz, sang asisten.

Menarik, ada sebuah adegan konser dengan musik full-lenght, Symphony No. 9, dimana Beethoven berdiri sebagai konduktor tanpa mendengar musik yang ia ciptakan sendiri, bahkan gemuruh tepukan audiens saat pertunjukan berkahir baru bisa ia rasakan ketika sang asisten membalikkan tubuhnya.

Beethoven adalah seorang yang kesepian dan pathetique namun seringkali meledak-ledak (ditandai dengan sering masuknya potongan mars pada karya-karya besarnya). Kondisi kejiwaan itulah yang membuat berbagai komposisinya terasa unik, indivdualistik. Ditambah gangguan pendengaran dan peristiwa bunuh diri sang keponakan (diadopsi oleh Beethoven dari adik perempuannya), walaupun selamat,  semakin memperparah kondisinya.

Oh ya, ada satu adegan dimana Beethoven memainkan sebuah komposisi intermezzo yang mirip Ragtime (sebuah genre yang yang ikut mendorong lahirnya Jazz). Dia bilang, orang-orang biasa perlu musik dan ia ciptakan untuk mereka.

Jika kita terbiasa nonton film hollywood, mungkin film ini agak boring. Film ini disutradai orang Belanda dengan wajah-wajah kusam arsitektur Austria tahun 1800-an.

Saya tergugah dengan adegan dimana Beethoven mengatakan pada Anna Holtz: "Disaat Tuhan memberiku kemampuan musikal, kenapa ia mengambil pendengaranku?"

Namun, Beethoven menemukan jawabannya: "Tuhan memintaku menciptakan musik dengan rasa bukan dengan suara."