• 23
  • Jul

近几天,我的某篇文章下每天都会出现40+的spam,来源遍布世界各地,即使我一次可以删上几百条也是很烦,对spam过滤又没什么经验便只能听之任之,索性都懒的删了。看来,事后过滤对人为的还可以,对付bot就太力不从心了。

今天得Dongsheng 的指点,加了几行js代码到页面中,不支持js的 client 发出的留言已经可以全部过滤了。原来还打算把这些东西先放到数据库中,以便手动筛选不是spam的信息。后来想想那样工作量太大,而且浪费资源没有必要,便干脆直接过滤了。

此方法的原理

自己写了个插件,原理是用 js 在留言表单中动态插入一个域,当留言表单提交到服务端后检查一下是否存在这个域即可,99% 的 spam bot 不能执行 js,所以用这个办法干掉 spam 的成功率接近 100%,相对于用验证码,这样的好处是不需要用户额外输入,缺点是如果用户用 non-javascript 的浏览器就没法留言了

代码很简单,只有几行

<script type="text/javascript">
window.onload = function(){
  var validate = document.createElement("input");
  validate.name="val";
  validate.value="true";
  validate.type="hidden";
  Tem=document.getElementById("commentform");
  Tem.appendChild(validate);
}
<script>

下面的,就是看看效果如何了

  • 22
  • Jul

排名分先后

  • javascript基础, ajax, jquery, prototype
  • ejb, spring, hibernate
  • python
  • ruby
  • algorithm
  • gtk

这些大概够做了吧


Continue reading...

  • 21
  • Jul

应该没得罪人吧

刚刚开机发现某篇日志下突然多了144条垃圾信息,发布源遍布世界各地,没有2个一样的IP。这东西有些难弄啊,看来过些日子还得琢磨一下防止垃圾信息的办法了。

当初做后台时没考虑到会有这种情况,只能到数据库操作一下了。一条sql即可。

附部分截图(p低i俗s的ca, 能看的就看,看不着的就不要看):

  • 05
  • Jul

Just found PDO was not supported by bluehost. After searching on google, I noticed that PDO module was installed, just was not active by default.

Here is the official solution: http://helpdesk.bluehost.com/index.php/kb/article/000445

A more specific instruction ( I couldn't find the "PHP CONFIG icon" suggested by official anyway.)

First, create yourself a php.ini file. The php.ini file can be set up under cPanel -> Software/Services -> PHP Config (click on the "INSTALL PHP.INI MASTER FILE" button). While you have this screen up, I would also change the PHP configuration to use "PHP5 (single php.ini)".

After you have installed the "php.ini.default" file, rename it to "php.ini" using FTP or the File Manager (found under cPanel -> Files). To enable PDO, you will need to add the following lines to your php.ini file (I usually paste it at the very bottom):

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

http://forum.bluehost.com/showthread.php?t=17116

Continue reading...

  • 05
  • Jul

网站早就弄的差不多了,前两天打算租个虚拟主机,转账时发现必须要立即到账的付款,而paypal里是分文没有,又不想使用信用卡,没办法,只能等paypal从银行账号上转账了。

paypal的钱前两天就到账了,因为网站还有点细节没最后搞定就又拖了两天。今天到bluehost和hostmonster的主页上一看,两个竟然同时打出了限时特价,$3.95/M

二话不说赶紧交易,省了一半的钱。心情不错