2009年7月22日 星期三

How to solve ‘You do not have sufficient permissions to access this page.’ in WordPress

I have been running into troubles logging in to WordPress and was kinda frustrated all morning.

Basically each time I use tried to log in, I get:

You do not have sufficient permissions to access this page.

I could not edit the blog, nothing works except the front page. I did a couple of searches at Google but the solutions didn’t seem to work for me.

In the end, I did a new installation of WordPress and scrutinized every damn thing in the users and usermeta table between a database that worked and a database that doesn’t.
Did you change the prefix of your table names in WordPress after the migration?

In my old database, I used ‘wp_’ as my prefix. As I migrated, I decide to use ‘wp3_’ instead of ‘wp_’. Unfortunately, the meta_key values are tied down to:

* wp_user_level
* wp_capabilities
* wp_autosave_draft_ids

I need to update it to

* wp3_user_level
* wp3_capabilities
* wp3_autosave_draft_ids

I wrote an SQL statement to share, just replace ‘prefix_’ with your new WordPress prefix. The following statements go to ‘meta_key’ and does a string replace from ‘wp_’ to ‘prefix_’.

UPDATE `prefix_usermeta` SET `meta_key` = REPLACE( `meta_key` , 'wp_', 'prefix_' );

(Make sure you do backups first! Note that the quotes used for string and field name are different.)

In the options table, there is ‘wp_user_roles’, make sure you get that changed into ‘prefix_user_roles’.

UPDATE `prefix_options` SET `option_name` = 'prefix_user_roles' WHERE `option_name` ='wp_user_roles' AND `blog_id` =0;

(Make sure you do backups first! Note that the quotes used for string and field name are different.)

With everything set, I tried logging in again and it worked. A happy WordPress user once again. I am using WordPress 2.2.2 before the migration and I did not upgrade WordPress during the migration. Hope it helps. (Applies to WordPress 2.3.3 also.)

2009年7月21日 星期二

How can I find out what is generating iowait on my server?

A question I’m asked daily is “How can I find out what is generating iowait on my server?” Sure, you can dig through pages of lsof output, restart services, or run strace, but it can be a frustrating process. I saw a process on this blog post, and I changed the regexes to fit Red Hat and CentOS systems a bit better:

# /etc/init.d/syslog stop
# echo 1 > /proc/sys/vm/block_dump
# dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)’ | sort | uniq -c | sort -rn | head
1526 mysqld
819 httpd
429 kjournald
35 qmail
27 in
7 imapd
6 irqbalance
5 pop
4 pdflush
3 spamc

In my specific situation, it looks like MySQL is the biggest abuser of my disk, followed by Apache and the filesystem journaling. As expected, qmail is a large contender, too.

Don’t forget to set things back to their normal state when you’re done!

# echo 0 > /proc/sys/vm/block_dump
# /etc/init.d/syslog start

2009年7月15日 星期三

[Apache] 防盜連,抓圖

« SSH SCP 速度
[apache] mod cband 頻寬限制 »
[Apache] 防盜連,抓圖

Jan 18th, 2007 by appleboy 參觀者:3,109Views 機器人:1,128Views

目前管理 國史館-台灣文獻館,幾台檔案伺服器

裝了 快 1000萬的數位話檔案,如果將來對外開放,將會造成大量被下載

所以我列了下面幾個保護裝置,目前用在館內,我弄了幾個軟體去下載,果然已經被阻擋了

網頁伺服器要支援REWRITE功能

1.直接不給連
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

2.給你其他小檔案
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/badimage.gif [R,L]

3.擋離線瀏覽器
RewriteEngine on
# (testing purposes) RewriteCond %{HTTP_USER_AGENT} ^Mozilla* [OR]
RewriteCond %{HTTP_USER_AGENT} ^FAST\-WebCrawler* [OR]
RewriteCond %{HTTP_USER_AGENT} ^ia_archiver* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Dart* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Pockey* [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetMechanic* [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot* [OR]
RewriteCond %{HTTP_USER_AGENT} ^QRVA* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebMiner* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebDownloader* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Downloader* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebMirror* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Anarchie* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Down* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Slurp* [OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget* [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebHook* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Scooter* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport*
RewriteRule ^.*$ /pbourke/errors/robots.html [L]

4.不過我不想用這個,因為離線瀏覽器的名稱可以隨便給

還是擋離線軟體,不知道有沒有重複
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Siphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.*$ /error.php [L]
RewriteRule ^.*$ http://www.site-where-you-want-to-send-the-bot [L,R]

另外一種方法
SetEnvIfNoCase Referer "^http://220\.134\.208\.55/" local_ref=1
SetEnvIfNoCase Referer "^http://hi17168\.calling\.com\.tw/" local_ref=1

Order Allow,Deny
Allow from env=local_ref
Allow from 127.0.0.1



http://www.webmasterworld.com/forum13/687-4-10.htm
Alias /old_image "D:\Big_img"

Options -Indexes
SetEnvIfNoCase Referer "^http://192\.168\.100\.244/old_dar/" local_ref=1
SetEnvIfNoCase Referer "^http://163\.29\.208\.22/old_dar/" local_ref=1

Order Allow,Deny
Allow from env=local_ref
Allow from 127.0.0.1
Allow from 192.168.100.244
Allow from 163.29.208.22



參考:

網站一
網站二

摘自:http://blog.wu-boy.com/2007/01/18/63/

2009年7月13日 星期一

2009年7月9日 星期四

Linux 系統時間自動校正

系統時間不一致的問題一直困擾著我

趁著暑假有時間查一查時間校正

鳥哥的確解說詳盡

不過看了一大堆NTPD伺服器的安裝文件後

也試著跟著做

看到後面

......



才發現其實跟本不必大費週章去安裝

國家時間與頻率標準實驗室 提供了Ntp讓server請求

只要ntpdate 指到台灣的 time.stdtime.gov.tw

並使用hwclock -w 指令寫入Bios 就好了

以下排程指令

10 5 * * * root /usr/sbin/ntpdate time.stdtime.gov.tw ; /sbin/hwclock -w

真是 @)X%$#......

摘自:http://school.jfps.tcc.edu.tw/plog2/post/8/30

要如何檢查網域名稱是那里申請的

http://whois.domaintools.com/

Registration Service Provider

2009年7月2日 星期四

ZRM for MySQL 即時備份的新選擇

備份機制對於 MySQL 來說是最弱的一環,當中最難處理的就是 InnoDB 備份,除了透過 mysqldump 這種原始的方式之外,還有 MySQL 官方提供的手動備份資檔案的方式。然而唯一可以即時備份 InnoDB 的軟體又只有 InnoDB Hot Backup 壟斷整個市場。(諷刺的是,現在已經是 Oracle 的公司了)


所以只要談到 InnoDB 的即時備份,也只能乖乖的每年繳保護費給 InnoDB Hot Backup 了。

然而,在 2007 年初 Zmanda 在 MySQL 發佈了MySQL Backup & Recovery for the Enterprise,也正式宣告這些令人困擾的備份方式將有所改變。

Zmanda Recovery Manager for MySQL (以下簡稱為 ZRM for MySQL) 不但有 InnoDB 的即時備份、定時自動備份功能,還有 Incremental backup 以及 Granular recovery、Selective recovery。


(ZRM for MySQL 與 MySQL 常見的備份方式比較)

ZRM for MySQL 不但功能強大,而且還是 OpenSource 的軟體,想要了解 ZRM for MySQL 其它強大的功能,可以從下列的網址下載簡報:
http://downloads.mysql.com/webinars/pdf/Zmanda_Jan_17.pdf

ZRM for MySQL –Downloads
http://www.zmanda.com/download-zrm.php

ZRM for MySQL –Wiki
http://mysqlbackup.zmanda.com/

ZRM for MySQL –Forums
http://forums.zmanda.com/

延伸閱讀:
MySQL AB: Backing Up and Recovering an InnoDB Database
Jeremy Zawodny: MySQL Backup & Recovery


摘自:http://www.neo.com.tw/archives/1093

wibiya widget