Tag Archives: wordpress
自动备份mysql数据库并发送到Email方法
Posted on 18. Dec, 2009 by Yao Yuan.
所以写了个自动备份mysql数据库的脚本,再加上gmail这个G级邮箱,备份多少数据都可以了…下面是代码:
mysqldump -uuser -ppassword –databases db1 db2 db3 > /home/website/backups/databackup.sql
tar zcf /home/website/backups/databackup.sql.tar.gz /home/website/backups/
echo “主题:数据库备份” | mutt -a /home/website/backups/databackup.sql.tar.gz -s “内容:数据库备份” www@gmail.com
rm -r /home/website/backups/*
将上面的代码保存为automysqlbackup.sh
然后利用crontab 实现动备份,在ssh下,
crontab -e
输入以下内容:
00 00 * * * /home/website/automysqlbackup.sh
这样就实现了每天00:00自动备份mysql数据库并发送到Email
简单的说明下吧.
第一句是一次性备份多个数据库,这个要你用root权限的用户才可以的..-u后面的是数据库用户名 -p后面的是数据库密码 无需空格 db1 db2 db3为你需要备份的数据库名.
如果你的数据库用户名没有root这个权限,可以改为这样
mysqldump -uuser -ppassword db1 > /home/website/backups/db1.sql
mysqldump -uuser -ppassword db2 > /home/website/backups/db1.sql
mysqldump -uuser -ppassword db3 > /home/website/backups/db1.sql
第二句是将 backups 文件夹里面的数据文件压缩为文件名:databackup.sql.tar.gz
第三句是将压缩了的数据库文件发送到指定的邮箱…..
其中的主题:数据库备份 ,就是邮件的主题, 内容:数据库备份,就是邮件的内用,
/home/website/backups/databackup.sql.tar.gz 为附件
www@gmail.com为要发送的Email
Continue Reading
Fix WordPress automaticlly upgrade wordpress upgrade automatically ‘Could not copy file……’
Posted on 27. Nov, 2009 by Yao Yuan.
I had moved my weblog to a cheapest vps server, it used to on a share hosting. but at the same time, the problem came . i can not use automaticlly upgrade of wordpress. it’s told me that ‘Could not copy file……’, and i need to fill the ftp infomations when i do it.
i found a funcion get_filesystem_method , the explanation of it
(FTP) it only uses this when it detects that files it creates have the wrong owner name
so, it’s clear… the owner of the dir and php process is different.
login ssh, do this
chown -R apache dir
it’s ok now.
Continue Reading
摆脱mySQL,让WordPress投奔SQLite
Posted on 19. May, 2009 by Yao Yuan.
WordPress默认就是与mySQL搭配的,这次要为wordpress换一个数据库搭档,但这并不是说mySQL如何的不优秀,但在10万以下的低并发访问,SQLite这样的单文件轻量级数据库系统性能优异,体积小、读取速度快、容量大,免费、开源,其实更适合像blog、或中小型站点的这种场景的数据库应用。 4 c- g- p! v5 d/ w6 W3 z3 L2 b6 h7 P5 i/ u$ s 如果你需要独立为数据库服务支付购买,或者并不满意主机系统繁杂的mySQL数据服务,倒真的是应该尝试一下SQLite这样的轻量级数据库。6 L, P: b# {% i+ Q! W |
Continue Reading
How to Fix Unexpected WordPress Database Table Error
Posted on 06. Mar, 2009 by Yao Yuan.
Two days ago, out of nowhere, a particular table in the WordPress in hongkiat.com went corrupted. The ‘wp_comments‘ table of the WordPress database just crashed without signs, warnings nor error messages. So how did I came to know? Here are the symptoms:
- If you try to back up your database, you’ll be thrown with this error message – wp_comments is marked as crashed and should be repaired when using LOCK TABLES
- Recent comments widget appears blank.
- Top commenter widget appears blank.
- Comment posted will not be written into DB, therefore will not be shown.
- Comments section in WP Admin appears to have zero records.
After searching the Internet high and low in hoping to find similar cases to help me identify and fix the problem, I end up with nothing. So I tried it my way and luckily enough, I managed to solved it. I thought writing the entry out will not only help those who suffered the same, also keep myself reminded just in case I hit on this error again in the future.
The fix / Solution
To fix this, you must have access to the wordpress database, either via PhpMyAdmin or Secure Shell (SSH). Most shared hosting account comes with phpMyAdmin, but either option you should be extremely careful because you dealing with the database. Any wrong move will cause more data lost.
PhpMyAdmin

In PhpMyadmin, select the WordPress database and look for the error table. In my case, the ‘wp_comments‘ table. Check it, and scroll all the way down and look for ‘With selected‘ drop-down box. Select Repair table and things should be alright.
Secure Shell

- Login to your shell
- Enter ‘mysql -u username -p database_name‘ to access databases
- Enter ’show databases;’ to view all databases
- Enter ‘use database_name;‘ to engage the database
- Enter ‘show tables;‘ to show all tables within the database
- Enter ‘check table wordpress_table_name‘ to verify this is the corrupted table
- Fix it with ‘repair table wordpress_table_name‘
- Enter ‘check table wordpress_table_name‘ again to make sure it’s fixed
Step 3 and 5 are not necessary if you are familiar with your databases and tables. Hope this helps.
Continue Reading
WordPress Theme That Mimics Mac OS X Leopard – Leopress
Posted on 06. Mar, 2009 by Yao Yuan.

here’s the WordPress theme that gets very close to a Mac OS X Leopard – Leopress. Leopress tries to look like the Mac’s Finder, and I think it’s pretty close. One good reason why you will want to use WordPress themes that mimic other interface is – it kinda camouflage your blogging activity, hiding them from bosses or superiors who passes by.
Continue Reading
Widgetize non-widget WordPress theme
Posted on 06. Mar, 2009 by Yao Yuan.

Consider this – If you found a WordPress theme that you like so much but it is not widget-supported, don’t give up just yet. Methods below helps you to widgetize non-widget theme to a drag-drop widget theme. Download Widget plugin from Automattic, upload them accordingly and follow the 2 steps below.
Step 1
Look for functions.php (Create one if you don’t have). Insert the following code into it, save and close. We are done with functions.php. Basically what this codes does is – it register the sidebar as dynamic.
<?php
if ( function_exists(’register_sidebar’) )
register_sidebar();
?>
Step 2
Here’s how a typical sidebar.php will look like.
<div id=”sidebar”>
<h2>Search this site</h2>
<div id=”searchdiv”>
<form id=”searchform” method=”get” action=”<?php echo $_SERVER['PHP_SELF']; ?>”>
<input type=”text” name=”s” id=”s” size=”20″/>
<input name=”sbutt” type=”submit” value=”Go” alt=”Submit” />
</form>
</div>
<h2><?php _e(’Archives’); ?></h2>
<ul><?php wp_get_archives(’type=monthly’); ?></ul>
<h2><?php _e(’Categories’); ?></h2>
<ul><?php list_cats() ?></ul>
<h2><?php _e(’Meta’); ?></h2>
<ul>
<?php wp_register(); ?>
<li><a href=”<?php bloginfo(’rss2_url’); ?>”>RSS</a></li>
<li><?php wp_loginout(); ?></li>
</ul>
<?php wp_meta(); ?>
</div>
What you need to do here is to enclose an an-if statement into sidebar.php. The addition of codes are in bold.
<div id=”sidebar”>
<h2>Search this site</h2>
<div id=”searchdiv”>
<form id=”searchform” method=”get” action=”<?php echo $_SERVER['PHP_SELF']; ?>”>
<input type=”text” name=”s” id=”s” size=”20″/>
<input name=”sbutt” type=”submit” value=”Go” alt=”Submit” />
</form>
</div>
//
<?php if ( !function_exists(’dynamic_sidebar’)
|| !dynamic_sidebar() ) : ?> // added
//
<h2><?php _e(’Archives’); ?></h2>
<ul><?php wp_get_archives(’type=monthly’); ?></ul>
<h2><?php _e(’Categories’); ?></h2>
<ul><?php list_cats() ?></ul>
<h2><?php _e(’Meta’); ?></h2>
<ul>
<?php wp_register(); ?>
<li><a href=”<?php bloginfo(’rss2_url’); ?>”>RSS</a></li>
<li><?php wp_loginout(); ?></li>
</ul>
<?php wp_meta(); ?>
//
<?php endif; ?> // added
//
</div>
That’s it. The theme now is now widgetized. You can now do the drag-drops like the widget themes. Here’s a goodWordPress widget resource.
Continue Reading
Execute PHP in WordPress post, page and Widget Sidebar
Posted on 06. Mar, 2009 by Yao Yuan.

If you are still struggling on how to insert PHP Codes inside particular blog post, page or a widget sidebar for execution; the following tutorial is for you.
Executing PHP codes in WordPress Page/Post
Installation
- Download phpexec.txt
- Rename phpexec.txt to phpexec.php
- Upload to /wp-content/plugins/ directory
- Activate the plug-in from WordPress administration menu
Usage
Anywhere in your post/pages where you want to execute a PHP Codes, insert <phpcode> before your php codes and </phpcode> your php codes.
<phpcode>
<?php
echo "Current date and time: ";
echo date("l dS of F Y h:i:s A");
?>
</phpcode>
Security
If you are running a blog with multiple users, you need to determine who can run this plug-in. Alter the settings in your Administration Menu. Options -> PHPExec
Executing PHP codes in WordPress widget sidebar
Installation
- Download execphp.txt
- Rename execphp.txt to execphp.php
- Upload to /wp-content/plugins/ directory
- Activate the plug-in from WordPress administration menu
Usage
This plug-in work like a normal text widget except that it allows execution of PHP Codes. You can create up to 9 instances of this widget. 
Continue Reading
Something Useful for creating a WordPress theme
Posted on 06. Mar, 2009 by Yao Yuan.
people wanting to know how to create a WordPress theme. Here’s some resources I’ve found useful for putting one together:
- Graphic design:
- Useful to have: Photoshop/Fireworks or the like to create your graphics
- For inspiration: sites like Netdiver, Design Melt Down, CSS Beauty, Unmatched Style etc can help sometimes.
- Color scheme ideas: Colorschemer, Daily Color Scheme and Flickr (photos are a brilliant source for color combinations). Flip through your favourite magazines (I love looking through my How Magazines and books for ideas. Look at how you’ve designed your house/bedroom/office – what color combinations do you like?
- Fonts: DaFont for free fonts and Linotype for purchasing professional fonts.
- Images: SXC for free photos and iStockPhoto for inexpensive illustrations and photos.
- XHTML/CSS templating:
- W3Schools for learning or for quick reference.
- Firefox web developer toolbar – essential for checking and testing your code. Great for live changing of your CSS.
- A text editor like Notepad++ to write your code.
- Browser Shots – for testing your design in different browsers
- For reference: Listamatic, Layoutomatic, Practical CSS and A List Apart in general, CSS Zen Garden for insight into how to achieve different layouts and effects using CSS and Layout Gala
- Understanding how WordPress themes are put together. I can’t emphasise enough how important the WordPress manual is. Don’t miss the Stepping into templates information.
- Understanding “the loop” and various WordPress tags.
- Knowing when and how to install plugins. WP-Plugins.net has many plugins, but doing a Google or delicious search for “WordPress plugin” and then the type of plugin you’re wanting will help you find many others.
- Knowing at least a little bit of PHP if you don’t want to feel so scared by WordPress tags, the loop, plugins and your templates. There’s some tutorials on W3Schools which can help.
Have you found any others which you find essential?
Continue Reading
My wp’s theme “elements-of-seo”
Posted on 07. Oct, 2008 by Yao Yuan.
Elements of SEO WordPress Theme is not designed by me,but Drew Stauffer. i had a little changed. and it passed xthml successfuly.if you like it you can download it for free.
Continue Reading
MY wp need update again (﹁ ﹁)~
Posted on 18. Sep, 2008 by Yao Yuan.
MY wp need update again,and something wrong with this theme.
But i have no time to care about it now.
i think i’ll do it at this weekend ……make a mark here




