Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

【向暴力群发(搜客,利剑)说不For Disciz 5.0 GBK!】2007/01/03更新

[复制链接]
gqg7902 发表于 2006-11-29 13:22:15 | 显示全部楼层
那位老大把删除好的给我发一份怎么样?估计我的是没删完,对代码不了解,所以没办法了。我邮箱lxshd@126.com,谢谢了。
回复

使用道具 举报

gqg7902 发表于 2006-11-29 16:22:03 | 显示全部楼层
  1. <?php

  2. $secnum['num_list'] = "1~1,2~2,3~3,4~4,5~5,6~6,7~7,8~8,9~9,10~10";
  3. $secnum['hashname'] = 'kengni';
  4. $secnum['fieldname_useranswer'] = "$mcspvalue";
  5. $secnum['fieldname_mathresult'] = "$mcspinfo";

  6. function math_comment_spam_protection() {
  7.         global $secnum;
  8.         $num_array = mcsp_aux_numbers_to_array($secnum['num_list']);
  9.         $rand_keys = array_rand($num_array, 2);
  10.         $mcsp_info['operand1'] = $num_array[$rand_keys[0]];
  11.         $mcsp_info['operand2'] = $num_array[$rand_keys[1]];
  12.         $result = $rand_keys[0] + $rand_keys[1];
  13.         $mcsp_info['result'] = mcsp_aux_generate_hash($result, date(j));
  14.         return $mcsp_info;
  15. }

  16. function mcsp_check_input($answer,$result) {
  17.         global $secnum;
  18.         $value_result = $result;
  19.         $value_entered = preg_replace('/[^0-9]/','',$answer);       
  20.         if ($value_entered == '') {
  21.                                 $checkresult='no_answer';
  22.         } elseif ( $value_result != mcsp_aux_generate_hash($value_entered, date(j)) ) {
  23.                 if ( ( date('G') <= 1 ) AND ( $value_result == mcsp_aux_generate_hash($value_entered, (intval(date(j))-1) ) )  ) {

  24.                 } else {
  25.                                                 $checkresult='wrong_answer';
  26.                 }
  27.         }
  28.         return $checkresult;
  29. }

  30. function mcsp_aux_generate_hash($inputstring, $day) {
  31.         global $secnum;
  32. $inputstring .= getenv('REMOTE_ADDR');
  33.         $inputstring .= $secnum['hashname'];
  34.         $inputstring .= $day . date('ny');
  35.         $enc = strrev(md5($inputstring));
  36.         $enc = substr($enc, 26, 1) . substr($enc, 10, 1) . substr($enc, 23, 1) . substr($enc, 3, 1) . substr($enc, 19, 1);
  37.         return $enc;
  38. }
  39. function mcsp_aux_numbers_to_array($input) {

  40.         $input = str_replace(' ', '', $input);       
  41.         $sourcearray = explode(',', $input);       
  42.         foreach ($sourcearray as $loopval) {
  43.                 $temparr = explode('~', $loopval);
  44.                 $targetarray[$temparr[0]] = $temparr[1];
  45.         }
  46.         return $targetarray;
  47. }
  48. function mcsp_aux_fieldname_formatting($input) {
  49.        
  50.         $return = preg_replace('/[^a-zA-Z0-9_\-]/', '', $input);
  51.         return $return;
  52. }
  53. ?>
复制代码

这是我删除注释后的代码,那位帮看一下那里删错了
回复

使用道具 举报

 楼主| xuesharp 发表于 2006-11-29 17:49:05 | 显示全部楼层
这个我就不太清楚了,我碰到一个有类似情况的,只要把注释删除,就OK了~~~!
回复

使用道具 举报

gqg7902 发表于 2006-11-29 17:52:21 | 显示全部楼层
能不能把你删除注释的代码发一份?我可能给删除的多了,对有些代码不认识。
回复

使用道具 举报

 楼主| xuesharp 发表于 2006-11-29 18:16:24 | 显示全部楼层
这个就是删除注释后的了~~!
  1. <?php
  2. $secnum['num_list'] = "1~1,2~2,3~3,4~4,5~5,6~6,7~7,8~8,9~9,10~10";
  3. $secnum['hashname'] = 'kengni';
  4. $secnum['fieldname_useranswer'] = "$mcspvalue";
  5. $secnum['fieldname_mathresult'] = "$mcspinfo";
  6. function math_comment_spam_protection() {
  7.         global $secnum;
  8.         // Get numbers in array
  9.         $num_array = mcsp_aux_numbers_to_array($secnum['num_list']);
  10.         // Get random keys
  11.         $rand_keys = array_rand($num_array, 2);
  12.         // Operands for displaying...
  13.         $mcsp_info['operand1'] = $num_array[$rand_keys[0]];
  14.         $mcsp_info['operand2'] = $num_array[$rand_keys[1]];
  15.         // Calculate result
  16.         $result = $rand_keys[0] + $rand_keys[1];
  17.         $mcsp_info['result'] = mcsp_aux_generate_hash($result, date(j));
  18.         return $mcsp_info;
  19. }
  20. function mcsp_check_input($answer,$result) {
  21.         global $secnum;
  22.         // Get result
  23.         $value_result = $result;
  24.         // Get value user has entered
  25.         $value_entered = preg_replace('/[^0-9]/','',$answer);        // Remove everything except numbers
  26.         if ($value_entered == '') {
  27.                 // Case 1: User has not entered an answer at all:
  28.                 $checkresult='no_answer';
  29.         } elseif ( $value_result != mcsp_aux_generate_hash($value_entered, date(j)) ) {
  30.                 if ( ( date('G') <= 1 ) AND ( $value_result == mcsp_aux_generate_hash($value_entered, (intval(date(j))-1) ) )  ) {
  31.                         // User has just passed midnight while writing the comment. We consider
  32.                         // the time between 0:00 and 1:59 still as the day before to avoid
  33.                         // error messages if user visited page on 23:50 but pressed the "Submit Comment"
  34.                         // button on 0:15.
  35.                 } else {
  36.                         // Case 2: User has entered a wrong answer:
  37.                         $checkresult='wrong_answer';
  38.                 }
  39.         }
  40.         return $checkresult;
  41. }
  42. function mcsp_aux_generate_hash($inputstring, $day) {
  43.         global $secnum;
  44.         // Add IP address:
  45.         //          [ not use for now... if users using dial-up connections, disconnect when writing
  46.         //                    the comment and re-connect again, they will get a new IP address. ]
  47.         // $inputstring .= getenv('REMOTE_ADDR');
  48.         // Add name of the weblog:
  49.         $inputstring .= $secnum['hashname'];
  50.         // Add date:
  51.         $inputstring .= $day . date('ny');
  52.         // Get MD5 and reverse it
  53.         $enc = strrev(md5($inputstring));
  54.         // Get only a few chars out of the string
  55.         $enc = substr($enc, 26, 1) . substr($enc, 10, 1) . substr($enc, 23, 1) . substr($enc, 3, 1) . substr($enc, 19, 1);
  56.         // Return result
  57.         return $enc;
  58. }
  59. function mcsp_aux_numbers_to_array($input) {
  60.         // Converts the input string, e.g. "1~one, 2~two, 3~three, 4~four, ..."
  61.         // into an array, e.g.: Array([1] => one, [2] => two, [3] => three, ...)
  62.         $input = str_replace(' ', '', $input);        // Strip whitespace
  63.         $sourcearray = explode(',', $input);        // Create array
  64.         foreach ($sourcearray as $loopval) {
  65.                 $temparr = explode('~', $loopval);
  66.                 $targetarray[$temparr[0]] = $temparr[1];
  67.         }
  68.         return $targetarray;
  69. }
  70. function mcsp_aux_fieldname_formatting($input) {
  71.         // Clean the input values for the field names...
  72.         $return = preg_replace('/[^a-zA-Z0-9_\-]/', '', $input);
  73.         return $return;
  74. }
  75. ?>
复制代码
回复

使用道具 举报

gqg7902 发表于 2006-11-29 18:23:21 | 显示全部楼层
非常感谢,我试一下。
回复

使用道具 举报

gqg7902 发表于 2006-11-29 21:24:55 | 显示全部楼层
非常感谢搂住,终于安装成功了,按照你删除注释后的上传的,看来我删除的注释删除的太多了。
回复

使用道具 举报

dawiye 发表于 2006-12-1 21:33:30 | 显示全部楼层

我按你的方法修改后注册页面显示空白

我按你的方法修改后注册页面显示空白,请楼主教下我。谢谢
回复

使用道具 举报

ywxs 发表于 2006-12-3 22:44:08 | 显示全部楼层
这帖子怎么跑这里来了???
回复

使用道具 举报

chen1mao 发表于 2006-12-6 16:09:13 | 显示全部楼层
注册页的提示有点往上了。改为

  1. <tr>
  2.         <td class="altbg1"><span class="bold">防止暴力注册</span></td>
  3.         <td class="altbg2"><div class="input"><input type="text" name="mcspvalue" size="25" maxlength="15" id="mcspvalue"></div>
  4.         <div id="mcsp" class="notice">&nbsp; <span class="smalltxt">请计算一个简单的加法 $mcsp_info[operand1] + $mcsp_info[operand2] ,将结果填写至左边.</span></div>
  5.         <input type="hidden" name="mcspinfo" value="$mcsp_info['result']">
  6.         </td>
  7.         </tr>
复制代码

能好看一点~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-26 15:04 , Processed in 0.099858 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表