Block AntiVir Ad

February 10th, 2009

Avira AntiVir Personal is a free anti-virus software, but it always displays Ad banner when the virus definition is updating. I’m currently using Windows Vista Business and it works. However, I don’t know whether Windows Vista Home (Basic/Premium) or Windows XP Home Edition can do it by the following method.

  1. Click Windows Icon (or Start) > Control Panel >Administrative Tools >Local Security Policy.
  2. After Local Security Policy MMC has opened, you can click Additional Rules under Software Restriction Policies.
  3. If you cannot find Additional Rules, you can right click Software Restriction Policies and click New Software Restriction Policies.
  4. Then, right click Additional Rules, and select New Path Rule. Then, you will see a new dialog box. Then, click Browse… to select C:\Program Files\Avira\AntiVir PersonalEdition Classic\avnotify.exe.
  5. Make sure the security level is set to Disallowed. Finally, you can click OK button.

Happy Chinese New Year!

January 26th, 2009

祝您身體健樂,心想事成﹗

Useful S.M.A.R.T command usages

January 12th, 2009

I have just checked the hard disk status of my Linux home server. I found that the hard disk has already run for 20845 hours (868 days). Also, it displays there are 94 errors occurred. I guess it may malfunction suddenly. Although S.M.A.R.T is just a reference and it is not 100% accurate, it is better to do a full backup to prevent data loss.

Useful S.M.A.R.T command usages:
Prints all SMART information
smartctl -a /dev/hda
Show device SMART health status
smartctl -H /dev/hda

Postfix relay through Gmail

December 14th, 2008

Since Discuz (a PHP based BBS application) don’t support TLS SMTP (Gmail), I setup a relay SMTP server using Postfix yesterday. Relay SMTP Server is like a middleman. When the site administrator want to send mail notifications to their members, Discuz first connects to the middleman (Relay SMTP Server) instead of Gmail (because Discuz don’t support TLS SMTP), and the middleman will redirect such emails to Gmail SMTP server. Finally, the mails are delivered to recipients by Gmail.

After you have done SMTP relay, not only work in Discuz, other PHP applications that use mail() function should work as well.

I’ve tried below steps in my CentOS 4.5 and Fedora 10 servers, both distributions work and the emails are able to send out via PHP mail() function.

In my scenario, both SMTP Server (Postfix) and Discuz (or other mail PHP applications) are installed on the same server. Otherwise, it is necessary to do some additional configurations on your Postfix and your PHP application must support ESMTP.

 
Before you do:
You must enable Gmail IMAP (with SMTP) function. Details:
http://mail.google.com/support/bin/answer.py?answer=77695

 
Basic commands:
Install postfix and change to appropriate directory:
yum install postfix
mkdir /etc/postfix/certs
cd /etc/postfix/certs

 
Create own certificate authority (CA):
For CentOS4:
/usr/share/ssl/misc/CA -newca
For CentOS 5/Fedora 10:
/etc/pki/tls/misc/CA -newca

Follow the prompts and make intelligent responses.

 
Create the client keys/certs:
Again with intelligent responses and ensuring you use the same common name and country code.
openssl genrsa -out postfixclient.key 1024
openssl req -new -key postfixclient.key -out postfixclient.csr
openssl ca -out ./postfixclient.pem -infiles postfixclient.csr

 
Amend Postfix configuration:
Open /etc/postfix/main.cf:
vim /etc/postfix/main.cf

And add the following lines:
relayhost = [smtp.gmail.com]:587
smtp_connection_cache_destinations = smtp.gmail.com
relay_destination_concurrency_limit = 1
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_note_starttls_offer = yes
tls_random_source = dev:/dev/urandom
smtp_tls_scert_verifydepth = 5
smtp_tls_key_file=/etc/postfix/certs/postfixclient.key
smtp_tls_cert_file=/etc/postfix/certs/postfixclient.pem
smtp_tls_enforce_peername = no
smtpd_tls_req_ccert =no
smtpd_tls_ask_ccert = yes

Create username and password database:
vim /etc/postfix/sasl_passwd

In /etc/postfix/sasl_passwd, add the following lines:
[smtp.gmail.com]:587 username@gmail.com:password
username@gmail.com is your Gmail login account and you must provide the corresponding password.

Enter the following commands and Postfix will parse the password file:
postmap /etc/postfix/sasl_passwd

 
Change appropriate permissions:
Other users cannot see the password files.
chmod 640 /etc/postfix/sasl_passwd*
chgrp postfix /etc/postfix/sasl_passwd*

The configuration is complete! Restart Postfix after you make any change:
/etc/init.d/postfix restart

 
Testing (optional):
This step will send an email to test whether it is configured successfully.
telnet 127.0.0.1 25
EHLO 127.0.0.1
MAIL FROM: username@gmail.com
RCPT TO: receipent@xxx.com
DATA
HIHI
If you can see this email, it means that the SMTP relay is configured successfully.
.

(Don’t forget to enter dot at the end)

 
Discuz configuration:
In mail_config.inc.php under Discuz root directory, change $mailsend option to 1 because your local server has already supported mail sending. For example:
$mailsend = 1;    // sendmail type
               //   0=do not send any mails
               //   1=send via PHP mail() function and UNIX sendmail
               //   2=send via Discuz! SMTP/ESMTP interface
               //   3=send via PHP mail() and SMTP(only for win32, do not support ESMTP)

 
References:
http://souptonuts.sourceforge.net/postfix_tutorial.html
http://www.wormly.com/blog/2008/11/05/relay-gmail-google-smtp-postfix/

Few months ago, I converted my another blog’s database character set from latin1 to utf8. The following is my conversion steps.

Prepared Software

  • MySQL 4.1 or later
  • Unicode Text Editor (eg. Notepad++)
  • phpMyAdmin (Optional)

 
1. Export the database
I used mysqldump command to export the database to SQL file. I am not sure whether it works with phpMyAdmin. Please let me know if this way works. It is very important to set default-character-set to latin1.
mysqldump -h localhost --user=[username] -p --default-character-set=latin1 --insert-ignore --skip-set-charset [database] > dump.sql

 
2. Replace SQL statements
This procedure is replacing the charset keywords from latin1 to utf8 inside a SQL file, so that the collation of tables will be set to utf8. It is recommended to use Notepad++. If the Chinese characters can be shown in the text editor, it mean you have chosen a correct editor and the previous step is right. The replacing strings are the following:

Find:
DEFAULT CHARSET=latin1
Replace:
DEFAULT CHARSET=utf8
Now you can save it as dump_utf8.sql. And do NOT save it directly (file name:dump.sql) becuase this SQL file is for backup.

 
3. Modify the default Collation
When you create the new tables in the future, new tables will be set to the default character set, latin1. Therefore, it is suggested to modify the default Collation to utf8. You could choose either MySQL monitor or phpMyAdmin to modify and the below example is using MySQL monitor.

Login to MySQL:
mysql --user=[username] -p

After logged in, input the following SQL statement:
ALTER DATABASE [database] DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

 
4. Import the modified SQL file
I also selected MySQL monitor to import the modified SQL file. Please make sure that the default-character-set is utf8 in this time.
mysql --user=[username] -p --default-character-set=utf8 [database]< dump_utf8.sql

 
5. Change web applications configuration
The conversion is basically completed. If you find the text of your web application unable to show correctly, you are needed to change the charset setting. For example:

WordPress (wp-config.php)
define( 'DB_CHARSET', 'utf8');
Discuz (config.inc.php)
$dbcharset = 'utf8';

MSN No-Ad patch

November 3rd, 2008

Description: This patch can remove the ad-banner of Live Messenger 8.5.1302.1018
Release date: 07 Sep 2008
Requirement:
Live Messenger 8.5.1302.1018 (Click Help>About to check your installed version)

Screenshot:

Download Here