按月存档: 2012/02

wordpress文章评论后可见

分类:折腾日期:2012-02-27 - 18:15:33评论:27条作者:老谢

function reply_to_read($atts,$content=null){
    extract(shortcode_atts(array("notice"=>'<span class="reply-to-read">此處內容需要
<a href="'. get_permalink().'#respond" title="評論本文">評論本文</a>後
<a href="javascript:window.location.reload();" 
title="刷新">刷新本頁</a>才能查看.</span>'),$atts));
    $email=null;
    $user_ID=(int)wp_get_current_user()->ID;
    if($user_ID>0){
        $email =  get_userdata($user_ID)->user_email; //如果用戶已登錄,從登錄信息中獲取email
    }else if(isset($_COOKIE['comment_author_email_'.COOKIEHASH])){
        $email=str_replace('%40','@',$_COOKIE['comment_author_email_'.COOKIEHASH]); 
//如果用戶未登錄但電腦上有本站的Cookie信息,從Cookie裏讀取email
    }else{
        return $notice; //無法獲取email,直接返回提示信息
    }
    if(empty($email)){
        return $notice;
    }
    global $wpdb;
    $post_id=get_the_ID(); //文章的ID
    $query="SELECT `comment_ID` 
FROM {$wpdb->comments} WHERE `comment_post_ID`={$post_id} 
and `comment_approved`='1' and `comment_author_email`='{$email}' LIMIT 1";
    if($wpdb->get_results($query)){
        return $content; //查詢到對應的已經審核通過的評論則返回內容
    }else{
        return $notice; //否則返回提示信息
    }
}
 
add_shortcode('reply', 'reply_to_read');

以上代码复制到function.php即可,用法如下:

[reply]评论可见内容[/reply]

原文传送门:http://zuidongting.com/non-plug-ins-to-achieve-the-contents-of-the-article-shows-the-code-reply-share.html

Mysql清理日志文件

分类:运维技术日期:2012-02-25 - 23:12:45评论:16条作者:老谢

Mysql运行中,默认会生成日志,这是众所周知的,而且网上很多网友反映硬盘空间不足了,最后检查都是被mysql的日志占掉了大量的空间,对于这些日志文件,我们应该如何清理呢?

Putty
[root@xj123 data]# ls
micro mysql-bin.000002 mysql-bin.000005 wp
mysql mysql-bin.000003 mysql-bin.index xj123.info.err
mysql-bin.000001 mysql-bin.000004 mysql-bin.000005 xj123.info.pi

[root@xj123 data]# du ./ -h
18M ./wp
168K ./micro
988K ./mysql
120M ./

继续阅读…

Nginx打开目录浏览功能

分类:运维技术日期:2012-02-25 - 11:07:36评论:2条作者:老谢

Apache的目录浏览默认是打开的,而Nginx的目录浏览默认是关闭的,演示传送门 ==> VPS软件下载

要打开该功能,非常简单,只需要添加autoindex on;参数即可,下面是vps.xj123.info的例子:

nginx.conf
server {
listen 80;
server_name vps.xj123.info;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;

location / {
root html/vps;
index index.html index.htm;
}
}

autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间

Nginx的启动、停止、平滑重启

分类:运维技术日期:2012-02-24 - 22:42:34评论:4条作者:老谢

启动Nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止Nginx

可以发送向通信号给Nginx主进程的方式来停止Nginx,操作如下:

CentOS release 5.7 (Final)
[root@vps ~]# ps -ef | grep nginx #查询master process主进程号
root 3266 1 0 Feb20 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 3267 3266 0 Feb20 ? 00:00:01 nginx: worker process
root 9282 9239 0 20:51 pts/0 00:00:00 grep nginx
[root@vps ~]# kill -QUIT 3266 #从容停止Nginx

继续阅读…

(D)DoS Deflate 防御简单DDOS攻击

分类:运维技术日期:2012-02-23 - 11:03:23评论:17条作者:老谢

前言:

互联网如同现实社会一样充满钩心斗角,网站被DDOS也成为站长最头疼的事。在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables,但是iptables不能在自动屏蔽,只能手动屏蔽。今天要说的就是一款能够自动屏蔽DDOS攻击者IP的软件:DDoS Deflate。

(D)Dos官方地址:http://deflate.medialayer.com/

(D)DoS Deflate is a lightweight bash shell script designed to assist in the process of blocking a denial of service attack. It utilizes the command below to create a list of IP addresses connected to the server, along with their total number of connections. It is one of the simplest and easiest to install solutions at the software level.

Installation

wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 0700 install.sh
./install.sh

安装完以后,你会看到一大篇协议,按q退出即可 :)
继续阅读…

让cmd也能查询whois和ip信息

分类:乱七八糟日期:2012-02-22 - 20:43:27评论:9条作者:老谢

WhosIP下载地址:http://www.nirsoft.net/utils/whosip.html
WhoisCL下载地址:http://www.nirsoft.net/utils/whoiscl.html

更详细的参数,请参考下载页面:)

程序下载后解压,分别命名为:whois.exe、ip.exe,然后放到C:\Windows\System32目录,

好了,然后打开cmd,就可以分别使用whois、ip这两个命令了,ps:如果想放到其他地方,则需要增加PATH,

让cmd也能查询whois和ip信息

Tags: ,

HDWIKI 安装提示Access Denied解决方案

分类:网站技术日期:2012-02-22 - 15:03:58评论:3条作者:老谢

今天一位朋友安装HDWIFI配置到数据库的时候,出现access denied!的提示,解决方案如下:

进入HDWIKI根目录,编辑install/install.php,找到:

$db_config = get_db_config();

改成

//$db_config = get_db_config();
                    if(empty($db_config)) {
                        $db_config['dbhost'] = 'localhost:3306';
                        $db_config['dbuser'] = '';
                        $db_config['dbpassword'] = '';
                        $db_config['dbname'] = 'wiki';
                        $db_config['table_prefix'] = 'wiki_';
                    }

再安装试试看吧 :)

谁偷走了我的密码?

分类:运维技术日期:2012-02-20 - 18:26:11评论:39条作者:老谢

本文核心:强烈建议vpser们修改自己的ssh端口以及设置更复杂的密码,甚至禁止root远程登录

一直听朋友说,网上很多无聊的人扫服务器密码,老谢不以为然,以为不会有那么多无聊的人,虽然老谢早就修改了ssh端口以及使用了随机生成的复杂密码,但是为了验证是否真的有那么无聊的人存在,老谢把一台闲置的vps端口改成了默认的22,一周后查看日志,震精了

Shell
[root@test ~]# cat /var/log/secure|awk ‘/Failed/{print $(NF-3)}’|sort|uniq -c|awk ‘{print $2″=”$1;}’
112.216.140.51=129
122.227.232.158=246
125.211.221.117=15
128.46.93.59=15
180.151.96.175=1713
211.144.37.41=458
219.140.165.85=18
223.165.6.67=1
61.253.249.157=54

继续阅读…

Tags: , ,

吐槽の超淫乱!(重口、慎入)

分类:吐槽日期:2012-02-19 - 22:16:36评论:34条作者:老谢

生命的意义在于:坚持

全文内容有重口味图片,请慎入!

继续阅读…

Tags: ,

css自定义滑块样式

分类:折腾日期:2012-02-18 - 14:01:03评论:15条作者:老谢

作为一个爱折腾的博主,怎么能让自己的博客大众呢?windows默认的滑块太丑了,让我们用css自定义一个与众不同的样式吧!

/* webkit scroller */
::-webkit-scrollbar-thumb:vertical{height:10px;background-color:#ccc;}
::-webkit-scrollbar{width:14px;height:5px;background:#FFF;margin-right:15px;}

以上css扒自林木木童鞋的博客
以上样式加到主题所在目录的style.css即可,仅支持chrome浏览器!演示见老谢博客 :)

Tags: ,