Archive for November, 2006

Kilabret - The Reverse Text generator

Tuesday, November 21st, 2006

Started from strange topic in diskusiweb.com, I write down this tiny script to reverse and un-reverse the text written there.

If you type kamen rider, it will return nemak redir. Sound cool right?


// save it as reverse.php
foreach($argv as $arg){
if($arg == $argv[0]) continue;
echo strrev($arg)." ";
}
?>

Now let’s give it a try:

C:\php4>php reverse.php reverse this words with thy power!!!!
Content-type: text/html
X-Powered-By: PHP/4.3.11

esrever siht sdrow htiw yht !!!!rewop

Hi..hi.. ridiculous?

Unrelated advertisement in this blog

Monday, November 20th, 2006

Free Image Hosting at www.ImageShack.us I’ve optimized any part of this blog to get related ads. But I got the opposite >_< I don't hate any sex-orientation, just hoping to get relevan advertisement in this blog.

Sometimes it made me laughing ^_^

How To Backup Account in FileZilla

Friday, November 17th, 2006

I got new PC at my office, yesterday. So, I need to transfer all my chats, email and any account from my old PC into the new one.

One of my favorite application is FileZilla that I use to transfer file from and to remote server. Surely it will be a pain to write down all servers, usernames and passwords. So I decided to take a look in FileZilla’s installation directory.

I found a XML file named FileZilla.xml located in C:\Program Files\FileZilla\FileZilla.xml and that’s where my accounts saved. So, I only need to copy that XML file into my new PC at the same directory as the old one. Surely, after I installed FileZilla on my new machine :p

And it works!

Well, the method can be successfull only if you choose XML file for saving all the accounts instead of the registry key. FileZilla will ask for the method when you first installing it on your machine.

By the way, I haven’t tried this method with different version of FileZilla.

Problem With Comment Is Fixed

Tuesday, November 14th, 2006

Dear readers, I didn’t realize that I have problem with my comment script until a friend told me about it. Now I’ve fixed it.

And great apology for all readers who had write their comment but lost in space…

PHP-CLI Introduction-Part-One

Tuesday, November 14th, 2006

PHP CLI? What kinda food is that? Don’t get mad with any “PHP variation” because PHP-CLI is a very simple thing.

CLI stands from Command Line Interface. That means PHP that run from command line. You can mention MS DOS in Windows or console/shell in Linux platform. No need web server anymore because we aren’t going to make a web. We will use it to create desktop applications.

First step, identify your PHP installation. Where did you install PHP on your machine? Linux user just need to write:

$ whereis php

and system will tell you where is PHP living in your machine.

Second step, let’s create the world’s famous programmer’s phrase:


// name it test.php
echo "Hello World!";
?>


and save it at the same directory as your PHP installation. It’s not a must, just to ease our practise.

Then, the moment we are waiting for. Executing the script!

C:\php4>php.exe test.php [enter]
Hello World!

of course we do the same in linux:

$ php test.php [enter]
Hello World!

Our third step is reading user’s input. We won’t create a selfish application, right? There will be two variables passed by the command line: $argv and $argc.

$argv is an array containing all parameters passed on the command line with space as the delimiters. While $argc is the number of total $argv array.


// name it test2.php
print_r($argv);
?>

Let’s see what will appear in the next post ^_*

I’m Claiming This Blog

Monday, November 13th, 2006

Dear reader, please ignore this post. I just use it to claim sandalian.com in my Technorati Profile

Silly Me: MD5 Feature on PHPMyAdmin

Wednesday, November 8th, 2006

Today, I lost forget a password that I stored in my local database (MySQL). The password was hashed using MD5 so I can’t read it using PHPMyAdmin. So, I decided to create new hash using MD5 too. I use this script to do same thing since few months ago:

// usage: php.exe md5.php password
echo md5($argv[1]);
?>

c:\php4>php.exe md5 p455w0rd
Content-type: text/html

a4fd8e6fa9fbf9a6f2c99e7b70aa9ef2

My friend saw me doing this and laughing for a while. Then he said that PHPMyAdmin has a tool to auto generate md5 password:
MD5 hash using PHPMyAdmin

What a DH&AYD&*A ^o^

&nbsp;

Resize Image And Create Thumbnail With Aspect Ratio

Tuesday, November 7th, 2006

Here’s a little script how to create thumbnail with PHP and GD library and still keeping aspect ratio. You only need to specify new image’s maximum width and height.

By default, it will create a maximum 110×110 pixel, both width or height, depend on which is longer.

Function to create thumbnail from an image
Example: makeThumb('img/image.jpg','img/thumbnail/','gambar_kecil.jpg','',150,150);
*/
function makeThumb($file,$thumb_dir,$new_name="",$resize="10",$new_width="110",$new_height="110"){
// get file info
$size = getimagesize($file);
$width = $size[0];
$height = $size[1];
if(!$new_name){
$filename = basename($file);
}
else{
$filename = $new_name;
}
// new size
if($resize){
$new_w = ($width*($resize/100));
$new_h = ($height*($resize/100));
}
else{
// tentuin new width and height
$new_w = $new_width;
$new_h = $new_height;

if($width>=$height){
$stat=”hor”;
}
elseif($width<=$height){
$stat="ver";
}
if($stat=="hor"){
$new_h=$height*$new_w/$width;
}
elseif($stat=="ver"){
$new_w=$width*$new_h/$height;
}
}
// ayo menggambar
$src_img = imagecreatefromjpeg($file);
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, $width, $height);
imagejpeg($dst_img,$thumb_dir.$filename,100);
// bersihin sampah memori
imagedestroy($src_img);
imagedestroy($dst_img);
}
?>

Don’t forget to create [b]thumbnail[/b] directory first. Have phun!

&nbsp;

Review: New Category Added

Saturday, November 4th, 2006

Since programming always dealing with choosing the best text editor to use, so here I add this category. Review will be made by me myself based on my expericences using the tool.

You can suggest me text editor to review by drop me private message to my Yahoo! ID: yeni.setiawan.

Vim For Windows

Saturday, November 4th, 2006

Today I downloaded Vim form Windows. It’s cool.

Just don’t figured out how to activate the syntax highlighting >_<