由于Fenng说他的站点,
就算有SCode插件也收到不少垃圾留言, 说是有些发垃圾留言的机器人可以认识到图片中的数字了.
图片验证码在很多地方都被使用, 但由于SCode默认生成的图片太有规律, 因此可能比较容易识别吧.
我在这儿主要作了两个改进:

  1. 将四个数据用不同的色彩打印出来.
  2. 在每个字符中间画一条和背景色相同的竖线,这样数字就被折成两半了

    当然我的一切修改还只是在理想化的阶段, 可惜我自已的访问量不够, 不能吸引垃圾留言.
还是来看一下我所作的修改吧. 这次只改mt-scode.cgi中的代码, 如下所示:

  # define the color we going to use
  $c_background = $im->colorAllocate(224,224,224);
  $c_border = $im->colorAllocate(0,0,0);
  $c_line = $im->colorAllocate(224,224,224);

  # color of first character
  $c_code1 = $im->colorAllocate(###,###,###);

  # color of second character
  $c_code2 = $im->colorAllocate(###,###,###);

  # color of third character
  $c_code3 = $im->colorAllocate(###,###,###);

  # color of forth character
  $c_code4 = $im->colorAllocate(###,###,###);
 
  # Fill in the background
  $im->fill(50,50,$c_background);
   
  # Write the code
  $im->string(gdGiantFont,10,1,substr($scode,0,1),$c_code1);
  $im->string(gdGiantFont,18,3,substr($scode,1,1),$c_code2);
  $im->string(gdGiantFont,26,2,substr($scode,2,1),$c_code3);
  $im->string(gdGiantFont,34,4,substr($scode,3,1),$c_code4);
 
  $im->line( 5,0, 5,19,$c_line);
  $im->line(13,0,13,19,$c_line);
  $im->line(21,0,21,19,$c_line);
  $im->line(29,0,29,19,$c_line);
  $im->line(37,0,37,19,$c_line);
  $im->line(45,0,45,19,$c_line);

  $im->rectangle(0,0,$im_length-1,19,$c_border);

    验证码图片的例了就看下面的好了.