找回密码
 立即注册

QQ登录

只需一步,快速开始

Discuz!x3.2新版本在后台选择Flash 验证码、语音验证码无效解决方案之一


Discuz!新版本在后台选择Flash 验证码、语音验证码无效。
导致部分站点选择使用语音验证码进行防灌水策略无效。
打上以下补丁后即可正常使用。
补丁上传位置source/module/misc/
misc_seccode.php
  1. <?php

  2. /**
  3. *      [Discuz!] (C)2001-2099 Comsenz Inc.
  4. *      This is NOT a freeware, use is subject to license terms
  5. *
  6. *      $Id: misc_seccode.php 33997 2013-09-17 06:46:37Z nemohou $
  7. */

  8. if(!defined('IN_DISCUZ')) {
  9.         exit('Access Denied');
  10. }

  11. $idhash = isset($_GET['idhash']) && preg_match('/^\w+$/', $_GET['idhash']) ? $_GET['idhash'] : '';
  12. $modid = isset($_GET['modid']) && preg_match('/^[\w:]+$/', $_GET['modid']) ? $_GET['modid'] : '';

  13. if($_GET['action'] == 'update') {

  14.         $message = '';
  15.         $showid = 'seccode_'.$idhash;
  16.         $rand = random(5, 1);
  17.         $htmlcode = '';
  18.         $ani = $_G['setting']['seccodedata']['animator'] ? '_ani' : '';
  19.         if($_G['setting']['seccodedata']['type'] == 2) {
  20.                 $htmlcode = extension_loaded('ming') ?
  21.                         "$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent('width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', 'misc.php?mod=seccode&update=$rand&idhash=$idhash','quality', 'high', 'wmode', 'transparent', 'bgcolor', '#ffffff','align', 'middle', 'menu', 'false', 'allowScriptAccess', 'sameDomain');" :
  22.                         "$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent('width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', '$_G[siteurl]static/image/seccode/flash/flash2.swf', 'FlashVars', 'sFile=".rawurlencode("$_G[siteurl]misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent');";
  23.                 $message = '<span id="seccodeswf_'.$idhash.'"></span>';
  24.         } elseif($_G['setting']['seccodedata']['type'] == 3) {
  25.                 $htmlcode = "$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_sound_tips')."' + AC_FL_RunContent('id', 'seccodeplayer_$idhash', 'name', 'seccodeplayer_$idhash', 'width', '0', 'height', '0', 'src', '$_G[siteurl]static/image/seccode/flash/flash1.swf', 'FlashVars', 'sFile=".rawurlencode("$_G[siteurl]misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent');";
  26.                 $message = '<span id="seccodeswf_'.$idhash.'"></span>'.lang('forum/misc', 'seccode_player', array('idhash' => $idhash));
  27.         } else {
  28.                 if(!is_numeric($_G['setting']['seccodedata']['type'])) {
  29.                         $etype = explode(':', $_G['setting']['seccodedata']['type']);
  30.                         if(count($etype) > 1) {
  31.                                 $codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
  32.                                 $class = $etype[1];
  33.                         } else {
  34.                                 $codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
  35.                                 $class = $_G['setting']['seccodedata']['type'];
  36.                         }
  37.                         if(file_exists($codefile)) {
  38.                                 @include_once $codefile;
  39.                                 $class = 'seccode_'.$class;
  40.                                 if(class_exists($class)) {
  41.                                         $code = new $class();
  42.                                         if(method_exists($code, 'make')) {
  43.                                                 ob_start();
  44.                                                 $seccode = $code->make($idhash, $modid);
  45.                                                 make_seccode($seccode);
  46.                                                 $message = preg_replace("/\r|\n/", '', ob_get_contents());
  47.                                                 ob_end_clean();
  48.                                         }
  49.                                 }
  50.                         }
  51.                 } else {
  52.                         $message = lang('core', 'seccode_image'.$ani.'_tips').'<img onclick="updateseccode(\''.$idhash.'\')" width="'.$_G['setting']['seccodedata']['width'].'" height="'.$_G['setting']['seccodedata']['height'].'" src="misc.php?mod=seccode&update='.$rand.'&idhash='.$idhash.'" class="vm" alt="" />';
  53.                 }
  54.         }
  55.         $imemode = $_G['setting']['seccodedata']['type'] != 1 ? 'ime-mode:disabled;' : '';
  56.         $message = str_replace("'", "\'", $message);
  57.         $seclang = lang('forum/misc');
  58. echo <<<EOF
  59. if($('$showid')) {
  60.         if(!$('v$showid')) {
  61.                 var sectpl = seccheck_tpl['$idhash'] != '' ? seccheck_tpl['$idhash'].replace(/<hash>/g, 'code$idhash') : '';
  62.                 var sectplcode = sectpl != '' ? sectpl.split('<sec>') : Array('<br />',': ','<br />','');
  63.                 var string = '<input name="seccodehash" type="hidden" value="$idhash" /><input name="seccodemodid" type="hidden" value="$modid" />' + sectplcode[0] + '$seclang[seccode]' + sectplcode[1] + '<input name="seccodeverify" id="seccodeverify_$idhash" type="text" autocomplete="off" style="{$imemode}width:100px" class="txt px vm" onblur="checksec(\'code\', \'$idhash\', 0, null, \'$modid\')" />' +
  64.                         ' <a href="javascript:;" onclick="updateseccode(\'$idhash\');doane(event);" class="xi2">$seclang[seccode_update]</a>' +
  65.                         '<span id="checkseccodeverify_$idhash"><img src="' + STATICURL + 'image/common/none.gif" width="16" height="16" class="vm" /></span>' +
  66.                         sectplcode[2] + '<span id="v$showid">$message</span>' + sectplcode[3];
  67.                 evalscript(string);
  68.                 $('$showid').innerHTML = string;
  69.         } else {
  70.                 var string = '$message';
  71.                 evalscript(string);
  72.                 $('v$showid').innerHTML = string;
  73.         }
  74.         $htmlcode
  75. }
  76. EOF;

  77. } elseif($_GET['action'] == 'check') {

  78.         include template('common/header_ajax');
  79.         echo check_seccode($_GET['secverify'], $_GET['idhash'], 1, $modid) ? 'succeed' : 'invalid';
  80.         include template('common/footer_ajax');

  81. } else {

  82.         $refererhost = parse_url($_SERVER['HTTP_REFERER']);
  83.         $refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';

  84.         if($_G['setting']['seccodedata']['type'] < 2 && ($refererhost['host'] != $_SERVER['HTTP_HOST']) || $_G['setting']['seccodedata']['type'] == 2 && !extension_loaded('ming') && $_POST['fromFlash'] != 1 || $_G['setting']['seccodedata']['type'] == 3 && $_GET['fromFlash'] != 1) {
  85.                 exit('Access Denied');
  86.         }

  87.         $seccode = make_seccode();

  88.         if(!$_G['setting']['nocacheheaders']) {
  89.                 @header("Expires: -1");
  90.                 @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  91.                 @header("Pragma: no-cache");
  92.         }

  93.         require_once libfile('class/seccode');

  94.         $code = new seccode();
  95.         $code->code = $seccode;
  96.         $code->type = $_G['setting']['seccodedata']['type'];
  97.         $code->width = $_G['setting']['seccodedata']['width'];
  98.         $code->height = $_G['setting']['seccodedata']['height'];
  99.         $code->background = $_G['setting']['seccodedata']['background'];
  100.         $code->adulterate = $_G['setting']['seccodedata']['adulterate'];
  101.         $code->ttf = $_G['setting']['seccodedata']['ttf'];
  102.         $code->angle = $_G['setting']['seccodedata']['angle'];
  103.         $code->warping = $_G['setting']['seccodedata']['warping'];
  104.         $code->scatter = $_G['setting']['seccodedata']['scatter'];
  105.         $code->color = $_G['setting']['seccodedata']['color'];
  106.         $code->size = $_G['setting']['seccodedata']['size'];
  107.         $code->shadow = $_G['setting']['seccodedata']['shadow'];
  108.         $code->animator = $_G['setting']['seccodedata']['animator'];
  109.         $code->fontpath = DISCUZ_ROOT.'./static/image/seccode/font/';
  110.         $code->datapath = DISCUZ_ROOT.'./static/image/seccode/';
  111.         $code->includepath = DISCUZ_ROOT.'./source/class/';

  112.         $code->display();

  113. }

  114. ?>
复制代码

本教程由无限星辰工作室CRX349独家整理和提供,转载请注明地址,谢谢。本文地址:https://www.xmspace.net/thread-225-1-1.html
无限星辰工作室  好集导航 Discuz全集下载  星辰站长网  集热爱361  一品文学  手机小游戏合集   海外空间网 星辰api  星辰支付二维码管理平台 阿里云服务器 腾讯云服务器
服务Discuz!建站|DiscuzQ配置|二开|小程序|APP|搬家|挂马清理|防护|Win/Linux环境搭建|优化|运维|
服务理念:专业 诚信 友好QQ842062626 服务项目 Q群315524225

发表于 2014-8-29 15:49:46 | 显示全部楼层 |阅读模式

回复 | 使用道具 举报

该帖共收到 0 条回复!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

美图秀

    • fastadmin 后台界面使用字段数组类型
    • Discuz!x3.5 修改标题高亮颜色
    • Discuz!x3.5 应用中心 下载应用一直下载中
    • 帖子定时显示
    • 论坛辅助审核
拖动客服框
Online Service
点击这里给我发消息
点击这里联系我们
微信扫一扫
在线客服
快速回复 返回顶部 返回列表