说明:仅在 emlog5.3.1 版本测试通过,另外,emlog 基本停止更新了,大家换 wordpress 吧。
若要给 emlog 验证码添加点击刷新功能,还是很简单的,因为 emlog 的验证码也是 img 形式存在的,所以和其它类似的验证码一样,为 img 标签添加 onclick 属性就行了。
Emlog 有用到验证码的源代码有如下文件:
Emlog 碎语:/t/index.php
Emlog 评论:/include/controller/log_controller.php
Emlog 管理后台登录:include\lib\loginauth.php
一、修改内核法
将以上文件的验证码位置的 img 标签添加以下语句即可实现点击刷新验证码功能:
style=\"cursor:pointer;\" alt=\"未显示? 请点击刷新\" title=\"看不清楚?请点击刷新\" onclick=\"this.src=this.src+'?'\"
如 Emlog 评论:/include/controller/log_controller.php, 有以下验证码源码:
<img src=\"".BLOG_URL."include/lib/checkcode.php\" align=\"absmiddle\" /><input name=\"imgcode\" type=\"text\" class=\"input\" size=\"5\" tabindex=\"5\" />
改成如下代码即可添加上点击刷新验证码功能:
<img src=\"".BLOG_URL."include/lib/checkcode.php\" align=\"absmiddle\" style=\"cursor:pointer;\" alt=\"未显示? 请点击刷新\" title=\"看不清楚?请点击刷新\" onclick=\"this.src=this.src+'?'\" /><input name=\"imgcode\" type=\"text\" class=\"input\" size=\"5\" tabindex=\"5\" />
其它几个页面中添加验证码刷新功能方法类似,此略,注:此方法在 em5.3.1 正常使用,其他版本未测试。
二、直接修改法
在模板文件 module.php 中找到<?php echo $verifyCode; ?> 用下面代码替换即可
<?php if(Option::get('comment_code') == 'y'){?><img src="<?php echo BLOG_URL;?>include/lib/checkcode.php" align="absmiddle" style="cursor:pointer;" alt="未显示? 请点击刷新" title="看不清楚?请点击刷新" onclick="this.src=this.src+'?'" /><input name="imgcode" type="text" class="input" size="5" tabindex="5" /><?php }?>
========举例===


如 Emlog 评论:/include/controller/log_controller.php, 有以下验证码源码:
改为:
此验证在 https 模式下会失效。建议这样做
Emlog 评论:/include/controller/log_controller.php
Emlog 管理后台登录:include\lib\loginauth.php
将以上文件的验证码位置的 img 标签添加以下语句即可实现点击刷新验证码功能:
style=\"cursor:pointer;\" alt=\"未显示? 请点击刷新\" title=\"看不清楚?请点击刷新\" onclick=\"this.src=this.src+'?'\"
如此,甚好!
@ACG 资源:O(∩_∩)O 哈哈~ [F7]