Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Sunday, July 5, 2009

Top Ten Open Source PHP Apps

Open-source PHP applications that changed the world. From managing databases to shopping, writing blogs to sending emails. Ten years of passion, great software architectures, team work and revolutionary ideas. Here are the most influential open-source PHP applications.

Blog

Wordpress - is a state-of-the-art semantic personal publishing platform with a focus on aesthetics, web standards, and usability.

BBS

phpBB -is a high powered, fully scalable, and highly customizable open-source bulletin board package. phpBB has a user-friendly interface, simple and straightforward administration panel, and helpful FAQ. Based on the powerful PHP server language and your choice of MySQL, MS-SQL, PostgreSQL or Access/ODBC database servers, phpBB is the ideal free community solution for all web sites. Features include: Unlimited forums and posts; Multiple language interface; Private or public forums; Powerful search utility; Private messaging system; Templates.

CMS

Drupal - an open source content management platform. Equipped with a powerful blend of features, Drupal supports a variety of websites ranging from personal weblogs to large community-driven websites.

Wikis

MediaWiki - is a free software wiki package originally written for Wikipedia. It allows collaborative editing on documents within a familiar interface. It was designed to be run on a large server farm and requires Apache, PHP, and MySQL.

Database Tools

phpMyAdmin - handles the administration of MySQL over the Web. phpMyAdmin performs many database administration tasks like running SQL statements, adding and dropping databases, and adding, editing or deleting tables or fields.

Photo Tools

Gallery - is an open source project with the goal to develop and support leading photo sharing web application solutions. It allow some basic photo manipulation, such as resizing, rotating, and altering image quality, but does not include advanced photo editing.

Advertising Tools

OpenX - OpenX is a hugely popular, free ad server for web publishers. Take control, manage your advertising and make more money from online advertising today.

DIGG

Pligg - Pligg CMS provides free software to create your own social networking website. Start a site in minutes using Pligg Content Management System and save time and money on your next website.

RSS

Gregarius–Gregarius is a web-based RSS/RDF/ATOM feed aggregator, designed to run on your web server, allowing you to access your news sources from wherever you want.

E-Commerce

osCommerce  - osCommerce("open source Commerce") is an e-commerce and online store-management software program. It can be used on any web server that has PHP and MySQL installed. osCommerce provides a basic set of functionality that meets the common needs of online businesses.

Saturday, November 29, 2008

Top Ten Wordpress Security Tips

Below are 10 security tips that you can easily implement on your WordPress blog. Please share one or more life-savers you use permanently to help protect yourself from WordPress security issues.

1. Upgrade Wordpress - In general, keeping your Wordpress installation up to date is a great way to avoid known problems. Do note that the lastest version, especially in the case of major upgrades, may cause more problems then it resolves.

2. WordPress Version - The tag in your header.php that displays your current version of wordpress. Since everyone knows your wordpress version this way, your blog is prone to hackers if you have not upgraded to the new version.

3. WordPress Username - Every hacker knows Wordpress has a user “admin” with god-like administration privileges. Slow the hackers down by removing the “admin” user. Create a Wordpress user with admin privileges using the administration interface. Log out of Wordpress and log back in with the new user. Delete the admin user. The new admin user should be different than your normal post author.

4. WordPress Password - Are you still logging into your wp-admin page with the same default password that was emailed to you? If so, CHANGE IT! That password is only 6 characters and just numbers and letters. Make it complex and more than 10 characters if you can. Also, try not to use words, make it a nice jumble of letters, numbers, and symbols.

5. Prevent Directory Listing - In many Wordpress installations it is possible to view a list of installed plugins by navigating to the /wp-content/plugins/ directory. This is not a good idea as known plugin vulnerabilities can than be easily exploited. Add an empty default index file, such as index.html, to the directory. You can also protect it using an .htaccess file assuming you're using Apache.

6. Protect Your WP-Admin Folder - You can protect your Wordpress admin folder by allowing access to it from a defined set of IP addresses. Everything else will bring up a Forbidden error message. So if you only access your blog from one or two places routinely, it’s worth implementing. Also, you’re supposed to create a new .htaccess file inside your wp-admin folder, not replace the one at the root of your blog.

7. Protect From Search Engines - There is no need to have all of your filesWordpress files indexed by Google, so it’s best to block them in your robots.txt file. Add the following line to your list:Disallow: /wp-*

8. Install Login Lockdown WordPress Plugin - This plugin records the IP address and timestamp of every failed WordPress login attempt. If more than a certain number of attempts are detected within a short period of time from the same IP range, then the login function is disabled for all requests from that range.

9. Install WordPress Database Backup Plugin - You always have to take regular backups of your file directories as well as the database. WordPress Database Backup plugin creates backups of your core WordPress tables as well as other tables of your choice in the same database.

10. Install Wordpress Security Scan Plugin - The WP Security Scan plugin attempts to both to audit your blog security and to implement many of the suggestions mentioned above.

Tuesday, November 25, 2008

Disable WordPress Autosave Plugin

WordPress autosave is the best features which I hate in WordPress. AutoSave will auto save a copy of edited post or page every 60 seconds provided there is a change on the content in the editor. However, there is only ever a maximum of one AutoSave version for any given post. New AutoSaves created will overwrite old AutoSaves. Beside, AutoSaves are stored as a special type of revision so that the auto saved with a more recent version of data does not overwrite actual published content, and is used to restore unsaved work only when necessary.

While each Post Revisions is stored in its own database table, the auto-save is only stored once with previous versions being overwritten by the new auto-saved content. So, if you’re worried about your database growing to massive proportions because of auto-save, you can stop worrying.

These are methods that disable or delay the WordPress autosave functions.  The Most easy way is using plugin. The disabling plugin works with versions 2.3 through 2.7  while the delay configuration works with 2.5 and later.

Copy this text to a text file, name it whatever you want (using the .php extension, of course) and upload it to your WordPress plugin directory. Activate it and it works immediately, but you need to clear your browser cache:

<?php
/*
Plugin Name: Disable autosave
*/
add_action('admin_print_scripts', 'plugin_deregister_autosave');
function plugin_deregister_autosave() {
 wp_deregister_script('autosave');
}
define('WP_POST_REVISIONS',false);
?>

Tuesday, July 15, 2008

Disable Wordpress 2.6 Post Revisions

Post Revisions Tracking is a new features of Wordpress 2.6, Which makes it a lot easier to share writing between people. Since you can save your copy, and the other person can see what you changed. Also you can revert to previous revisions of posts you've made.

But if there is only one author of WordPress blog, Post Revisions will taking too much space as every revision is a new row in wp_post table. It creates a alot of useless database-entries.

To disable Post Revisions, Add:

define('WP_POST_REVISIONS', false);

into wp-config.php, the wordpress 2.6 Post Revisions now disabled.

In my little opinion, there should be an option in general or writing settings to enable/disable the post revision feature.

Monday, June 23, 2008

DB2ASP - Free Access Database to ASP Converter

DB2ASP generates an Active Server Page framework from an Access database. The framework contains Script subroutines to display and validate html forms and update the selected table or query. This won't do everything for you but it will jumpstart your development process by automatically generating tedious code.

Overview



So many of the applications I create involve using web-based html forms to update Access databases that one day I just got tired of doing the same stuff over and over and came up with the idea for this program. The framework created by the program will display a blank form and data view, you can enter data into the form and write the form data back to the database. The wizard eliminates about 80% of the redundant coding associated with these types of applications. You'll still have to make modifications to the resulting code to fit your specific situations.

You need VB6 with service pack 5 and DAO 3.6 on your machine for the db2asp to run.

UI Details



DB2ASP

Run db2asp.exe.

In the Register Form, if you don't have a register code, Click Cancel.

Click Select.

Select an existing Access database.

Select a table.

Select the fields you want to appear on the html form.

Select the filter method and search field.

Verify your selections.

Click Start.

Some ASP file which containing the JavaScript code will be generated on the output path. Copy this file and database to your Inetput/wwwroot path and run it. You can also edit it with your editor.

Code Details



The prgoram creates a Dim statement for each database field you selected. It also dims several other variables used throughout the framework.

Verify that sDBName points to a valid path on your server.

db.asp :

You can change your database connect string here. You can also change your database to another database system, such as SQL Server.

If you use SQLServer, change your connstr as below.
connstr="driver={SQL Server};server=localhost;uid=sa;pwd=;database=DatabaseName"

fileedit.asp :

This file is your data edit form. You can change your edit form interface here.

filelist.asp :

This file is your data listview interface.

filefilter.asp :

This file is your data data filter form.

Hints



Your Access database must have a field named "ID", and it should auto increase.

Your Access database must writeble. check the property of the database file.

Requirements



At least 32 MB RAM

MS Access 7.0 or higher (ODBC is not required)

Necessary privileges to write into the destination database

Price



DB2ASP Converter is totally free with no limited features.

Downloads



Click here to download totally free version of DB2ASP converter.

Installation



After downloading the zip program you should simply unzip it and run the db2asp program.

Contact



William Long
e-mail: williamlone(at)gmail.com
website:http://www.moon-blog.com

Saturday, May 24, 2008

Install WordPress MU On IIS With Url Rewrite

I have successfully installed WordPress MU on my Windows Server 2003 running IIS 6. To be honest, I know that WPMU is not full compatible with IIS right out of the box. It relies heavily on apaches mod_rewrite, which IIS isn't capable of. The only IIS fix for permalinks I've seen have either been via a special filter named ISAPI_Rewrite.

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS server. It is compatible with Apache mod_rewrite making it possible to move configurations from Apache to IIS and vice versa just by copying .htaccess files. I have tested with Wordpress 2.x or Wordpress MU 1.3.x, it's work. This is also works in IIS Mod-Rewrite Pro, but IIS Mod-Rewrite Pro have no free version.

To enable Clean Permalinks on Wordpress MU on IIS, follow these steps:

  • Install PHP and MySQL following the vendor's instructions.

  • Install ISAPI_Rewrite.

  • Install Wordpress according to the vendor's instructions.

  • Open with a text editor the file wp-settings.php, located in Wordpress root directory. Add the code line



$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];

  • Log on to Wordpress as administrator, go to admin panel, open the "Permalinks" settings page, and set the permalink structure of your choice. Apply your changes.

  • Wordpress is supposed to automatically create a file with name ".htaccess" in its root directory. Open with a text editor the file .htaccess, copy it and paste into httpd.conf in ISAPI_Rewrite directory.


Now we have a WordPress MU with clean permalinks on Windows Server 2003 running IIS 6.

Monday, April 14, 2008

WordPress 2.5 Widescreen Version

I have discussed in an article under WordPress 2.5 in widescreen display abnormal. Almost all of the interface of WordPress 2.5 are directed at the design of the 1024 × 768. When I use my 1440 × 900 widescreen monitor will show only the left side of the body. I've finally managed to get my 1440×900 widescreen monitor working with the WordPress 2.5.

Open file wordpress\wp-admin\css\global.css, in line 159, replace:

max-width: 980px;

to:

max-width: 1400px;

In line 166, replace:

max-width: 950px;

to:

max-width: 1400px;

That's it. Before the modification, we can see that the interface of WordPress 2.5 in 1440 × 900 like this:

WordPress 2.5 Widescreen Version

After the modification, we can see that the interface of WordPress 2.5 in 1440 × 900 like that. It's so cool, isn't it.

WordPress 2.5 Widescreen Version

If you are using the 1440 × 900 display resolution, you can changes the code and make a better look in WordPress 2.5 Widescreen Version.

Saturday, March 29, 2008

Wordpress 2.5 Released

WordPress 2.5 has been released and includes a huge number of changes over the WordPress 2.3 series. Rather than list the changes in detail which would probably take me some days to write out I offer the following statistics and information about the WordPress 2.5 release:

  • In development for 185 days (6 months 3 days to be precise).

  • Changes to 364 files with 54008 insertions, and 29136 deletions for more detail you can view the diffstat output.

  • Patches committed from over 110 different contributors.

  • Over 1300 individual changes made for more detail you can view a complete changelog.


As usual you can download wordpress at their site, http://wordpress.org/download/. Btw, check out their new interface. They also changed how the wordpress.org site works.

Sunday, March 9, 2008

WordPress Excerpt Seo Tips

Wordpress blogs have duplicate content issues, and one of them is allowing reading the same content on both the posts, index page, archives and categories pages. To avoid search engine penalty it is important to optimize your Wordpress using Wordpress excerpt so that duplication will be avoided.

Instead of duplicating the whole content, you may use just an excerpt in the index, archives and categories pages. The WordPress displays the excerpt of the current post with [...] at the end, which is not a "read more" link. If you do not provide an explicit excerpt to a post (in the post editor's optional excerpt field), the first 55 words of the post's content are used.

To use Wordpress excerpt function, you may replace the_content() tag with the_excerpt() when on archive (tested by is_archive()) and category (is_category()) pages and index (is_home()) page in WordPress themes.

Now that you are in the correct section, locate the following piece of code:

<div class="entry">
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>


You are going to replace that entire piece of code with the following:

<div class="entry">
 <?php if(is_category() || is_archive() || is_home() ) {
  the_excerpt();
 } else {
  the_content('Read the rest of this entry &raquo;');
 } ?>
</div>


Of course, this example uses the WordPress default template, but the same code can be used on most any template if you find the index.php or main index page and the spot where <?php the_content(); ?> is in the code.

Thursday, February 14, 2008

WordPress Mod Rewrite Make Subdirectory 404 Error

Last night, I getting lots of 404 error while using Google to search my own blog index page, I realized there is something wrong about my blog.

My user-created-outside-of-WP folder is throwing a 404 when trying to access it. Now for some details:

Blog www.moon-blog.com : normal WP blog. Permalinks "/%year%/%monthnum%/%postname%.html" through mod_rewrite in the default .htaccess file WP created.

Subdirectory www.moon-blog.com/MySubdirectory/): normal PHP application. User defind permalinks. Located at directory "/MySubdirectory/".

The problem is that the WordPress thinks My Subdirectory is 404, and do not allow Google to index my files.

I Try add some of php code into my php application to resolve this problem:

header("Status: 200 OK");

After adding that code, my PHP application in the subdirectory do not return 404 error again.

Wednesday, January 16, 2008

WordPress MU Optimization Script

WordPress MU will be automatically established more than 10 tables when a new user register, so when a large number of users register will caused a lot of problem. Then I write some performance scripts can delete the WordPress MU inactive users.

The PHP source code as follows:


  $mysql_host = "localhost";
  $mysql_user = "root";
  $mysql_pass = "";
  $mysql_db = "wordpress";
  $mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass)
  or die ("Cannot make the connection");
  mysql_select_db($mysql_db, $mysql_mylink)
  or die ("Cannot connect to the database");
  $strsql="select * from wp_blogs where blog_id>2 ";
  $rs_query = mysql_query($strsql);
  $alls=mysql_num_rows($rs_query);
  while (($RS = mysql_fetch_array($rs_query))) {
  extract($RS);
  $blogid=$RS["blog_id"];
  $query2 = "select * from wp_".$blogid."_posts ";
  $result = mysql_query($query2);
  $num= mysql_num_rows($result);
  //print $num;
  if ($num<=2) {
  print "DROP TABLE IF EXISTS wp_".$blogid."_comments;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_links ;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_options ;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_postmeta ;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_posts ;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_terms ;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_term_relationships ;";
  print "DROP TABLE IF EXISTS wp_".$blogid."_term_taxonomy ;";
  print "DELETE from wp_blogs where blog_id=".$blogid.";";
  }
  }
  mysql_close ();

Wednesday, January 9, 2008

Custom WordPress Database Error Page

From what i have mentioned before, we can use a program to monitor the WordPress MySQL server, when the server is down, WordPress will auto send an e-mail and write to a text log file in a recorded. Now, WordPress 2.3.2, the latest version of the popular blogging platform allows you to define a custom database error page.

It is very simple. Just follow the following steps and within a few minutes your custom database error page is ready!

First, upload a file named log.txt to the WordPress root directory, chmod it to 666.

Second, Download the file db-error.php and upload it to WordPress content directory(wp-content/db-error.php).

Finally, replace the e-mail address of the code to your own e-mail.

That's it! From now on this error file will be report the error whenever your WordPress blog has encountered some trouble connecting to the database server.

Saturday, December 29, 2007

WordPress Plugin: Yearly Blog Stats

Yearly Blog Stats is the easy way to display the total year number of blog posts, comments and other stats from anywhere within your blog. One file, easy to use.

With Yearly Blog Stats, you display only the information you want, where you want. This plugin is highly flexible, simple to use, and completely free.

Display any or all of the provided site statistics — customize your own set to provide only the statistics you want.

Features:

1. Total number of posts in this year
2. Total number of comments in this year
3. Most views post each month in this year

Installation and Usage

Unzip wp-stats.zip and copy wp-stats.php to your WordPress root directory.

Download Latest:

Click here to download the latest version of WordPress Yearly Blog Stats Plugin.

Wednesday, December 26, 2007

WordPress Plugin: SimpleTags Modification

WordPress SimpleTags is a WordPress plugin that will allow you to easily manage tags of your blog. However, I found some of bugs of WordPress SimpleTags, here is my modification.

1. Search terms problem:

SimpleTags use of the full text of the search, as long as the article contains the keyword matching, which can lead to large errors match, I modify it only match of the headlines.

Open file simple-tags\inc\simple-tags.admin.php, in line 1466, replace:

$search_sql = "AND ( (post_title LIKE '%{$search}%') OR (post_content LIKE '%{$search}%') )";

to:

$search_sql = "AND ( (post_title LIKE '%{$search}%') OR (post_title LIKE '%{$search}%') )";

2. Untagged only problem:

When blog have large numbers of the article, the untagged only function will return errors, I change some of original code in the SQL statement , greatly improving the efficiency of search and speed.

Open file simple-tags\inc\simple-tags.admin.php, in line 1475, replace:

$p_id_used = $wpdb->get_col("
SELECT DISTINCT term_relationships.object_id
FROM {$wpdb->term_taxonomy} term_taxonomy, {$wpdb->term_relationships} term_relationships, {$wpdb->posts} posts
WHERE term_taxonomy.taxonomy = 'post_tag'
AND term_taxonomy.term_taxonomy_id = term_relationships.term_taxonomy_id
AND term_relationships.object_id = posts.ID
AND posts.post_type = '{$type}'");
$filter_sql = 'AND ID NOT IN ("'.implode( '", "', $p_id_used ).'")';


to:

$p_id_used = "SELECT DISTINCT term_relationships.object_id
FROM {$wpdb->term_taxonomy} term_taxonomy, {$wpdb->term_relationships} term_relationships, {$wpdb->posts} posts
WHERE term_taxonomy.taxonomy = 'post_tag'
AND term_taxonomy.term_taxonomy_id = term_relationships.term_taxonomy_id
AND term_relationships.object_id = posts.ID
AND posts.post_type = '{$type}'";
$filter_sql = 'AND ID NOT IN ('.$p_id_used.')';

Saturday, December 22, 2007

WordPress Plugin: Post2Mail, Send Post to Email

Some of WordPress user needed a plugin to send an e-mail to a mailing list whenever a post was published to the blog. Here is a modified version of the "Post2Mail" plugin which can email the post to a mailing list or email address.

WordPress Post2Mail plugin allows you to automatically e-mail selected people when a post is published on your blog. Also useful for alerting an administrator when a post has been published on the blog. Configuration is done in the post2mail.config.php file which has comments to get you started.

This modified plugin have the following Features:

1. Support Far East Characters (such as Chinese Characters). Use base64 to encode email title to support Chinese Characters.

2. Fix some Security bug.

Installation / Configuration Instructions:

1. Edit post2mail.config.php to add the email address or mailing list address.

2. Upload post2mail.php and post2mail.config.php to your WordPress plugin directory.

3. Activate the plugin.

Download Latest:

Click here to download the latest version of WordPress Post2Mail Plugin.

Monday, December 17, 2007

WordPress Plugin: WP-PostViews JavaScript Edition

Lester Chan develop a greate WordPress plugin - WP-PostViews, can enable user to display how many times a post/page had been viewed. It's base on PHP. But if you active WP-Cache plugin, you will found that  WP-PostViews not working. So I develop a new javascript version of WP-PostViews, that can work fine with WP-Cache or WP Super Cache plugin.

Installation / Configuration Instructions:

1. Install normal version of WP-PostViews 1.20.

2. Upload postviews.php to your WordPress plugin directory(wp-content\plugins\postviews).

3. Upload wp-counter.php to your WordPress root directory.

4. Activate the WP-PostViews plugin.

Download Latest:

Click here to download the latest version of WP-PostViews JavaScript Version plugin.

Saturday, December 15, 2007

How To Turning Off WordPress Autosave

WordPress autosave is the best features which I hate in WordPress. My WordPress hosting is very slow, when I post new article, sometimes I got two saved post. The autosave features almost make me crazy. How can I turn off the autosave?

I finally patched core program post_new.php to disable autosave for a "new" post and the problem went away. Do not know if this will help you or not. My patch for v.2.3.1 follows. Newer versions might be around the same location.

Edit the file wp-admin/post_new.php WP v2.3.1 and insert "//" (without the quotes) at the beginning of this line (currently line 8):

wp_enqueue_script('autosave');

Save and upload the file post_new.php, and the WordPress autosave features is now disable.

Sunday, December 9, 2007

WordPress Robots.txt For SEO

The robots.txt file is used to instruct search engine robots about what pages on your website should be crawled and consequently indexed. Most websites have files and folders that are not relevant for search engines (like images or admin files) therefore creating a robots.txt file can actually improve your website indexation.

Implementing an effective SEO robots.txt file for WordPress will help your blog to rank higher in Search Engines, receive higher paying relevant Ads, and increase your blog traffic.

Here is my robots.txt files, which can further protect WordPress from this duplicate content issue.

User-agent: *
Disallow: /wp-
Disallow: /feed/
Disallow: /trackback/
Disallow: /comments/feed/
Disallow: /page/
Disallow: /comments/


After you created the robots.txt file just upload it to your root directory and you are done!

Friday, December 7, 2007

WordPress MU AdSense Plugin

WordPress MU AdSense Plugin is an easy-to-use plugin for WordPress MU 1.3+ (also including WordPress 2.3+) for quickly inserting Google or Yahoo! ads into all of the WordPress multi-user's blog posts. Wordpress MU allows webmasters to easily integrate Google Adsense inside wordpress using this plugins. Google Adsense has become the most popular online contextual advertising program and proper custom integration with Wordpress can help to increase Adsense earnings.

Installation / Configuration Instructions:

1. Edit wp-adsense.php, replace the Google AdSense code in the plugin with your own customized Google Adsense code.

2. Upload wp-adsense.php to your WordPress plugin directory(not the mu-plugins directory).

3. Download and install a WordPress MU Plugin - Plugin Commander, upload Plugin Commander to mu-plugins directory.

4. Login WordPress MU's Site Admin, click Plugin Commander, find WordPress Adsense plugin and click "Activate all" to mass activate the wordpress adsense plugin.

Download Latest:

Click here to download the latest version of WordPress MU AdSense plugin.

WordPress MU AdSense plugin can display AdSense ads inline with blog posts. Wish you would like this plugin.

Monday, December 3, 2007

WordPress Plugin: MySQL Server Crash Monitor

Since end of October our MySQL Server crashed on or two times a day. We don't no exactly why. Maybe the Databases are to big. We run several WordPress system on this MySQL Server. but the MySQL services often crashed, then my WordPress can't connect to MySQL server and show the error. So I develop this program to monitor the WordPress MySQL server, when the server is down, WordPress will auto send me an e-mail and write to a text log file in a recorded. We can look trough the log file to analysis the MySQL server databse, in order to cantact the host administrators to fix the error.

Here is the source code of the MySQL Server Crash Monitor.


// Change the e-mail address below .
$from = "[email protected]";
$to = "[email protected]";
$subject = "MySQL Crashed!";
$body = date("Y-m-d H:i:s");
$headers = 'From: '.$from . "\r\n"
.'Reply-To: '.$from . "\r\n"
.'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $body, $headers);
// Log to file
$filename = 'log.txt';
$somecontent = date("Y-m-d H:i:s");
$somecontent = $somecontent . "\r\n";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
exit;
}
if (!fwrite($handle, $somecontent)) {
exit;
}
fclose($handle);
}


First, upload a file named log.txt to the WordPress root directory, chmod it to 666.

Second, replace the e-mail address of the code to your own e-mail.

Then,opening wp-includes/wp-db.php, find "if (! $ This-> dbh)", 66 lines in WordPress 2.3.1, paste the code after that. Save and upload the file.

Now, When the database lost connection or get problems, WordPress will automatically mail the error message to your mailbox, at the same time the message will be recorded in log.txt document.