duangu8264 2019-03-18 01:06
浏览 31

将captcha添加到formmail pro core.cgi中

I am a bit confused about adding captcha into form mail.. I am trying to not break anything in the main script. That's why i have a couple of question. I have this mailform pro main script, which is right below...

sub _MAIN {
    &_ModuleLoadConfigs;
    if($ENV{'REQUEST_METHOD'} eq "POST" && $_GET{'module'} eq $null){
        $_ENV{'mode'} = 1;
        &mailformpro;
    }
    elsif($_GET{'module'} ne $null){
        $_ENV{'mode'} = 0;
        &_ModuleMode;
    }
    else {
        &mfpjs;
    }
}

sub mailformpro {
    &_RunModule('extend');
    &_COOKIE;
    &_POST;
    #@AttachedFiles = ();
    #@ResAttachedFiles = ();
    ($Serial,$InputTime,$ConfirmTime,$_ENV{'mfp_uniqueuser'}) = split(/\,/,&_LOAD($config{'file.data'}));
    &_RunModule('check');
    &_ErrorCheck;
    if(!$Error){
        &_RunModule('initialize');
        if(!$config{'disabled'}){
            &_MAINPROCESS;
        }
        &_RESULT;
    }
    else {
        &_RunModule('error');
        if($_POST{'mfp_jssemantics'}){
            &_REDIRECT("$ENV{'HTTP_REFERER'}#WarningCode${Error}");
        }
        else {
            &_Error($Error);
        }
    }
}
sub _MAINPROCESS {
    &_SETENV;
    &_RunModule('startup');
    &_MAILTEXT;
    &_RunModule('run');

    if($_POST{'mfp_testmode'}){
        @mailto = @testmailto;
        if($config{'bcc'}){
            $config{'bcc'} = $mailto[0];
        }
    }

    if($config{'mailto'} eq $null){
        $config{'mailto'} = $mailto[0];
        $config{'mailtoName'} = $mailto[0];
    }
    elsif($config{"ReturnSubject"} ne $null && $_TEXT{'responder'} ne $null){
        &_SENDMAIL($config{'mailto'},$config{'mailfrom'},$config{'fromname'},$config{"ReturnSubject"},$_TEXT{'responder'},join('',@ResAttachedFiles),$_HTML{'HTMLMail'});
    }
    if($config{'fixed'}){
        $replyTo = $config{'mailto'};
        $config{'mailto'} = $config{'mailfrom'};
        $config{'mailtoName'} = $config{'mailfrom'};
    }
    if(!$config{'mailtoName'}){
        $config{'mailtoName'} = $config{'mailto'};
    }
    for(my $cnt=0;$cnt<@mailto;$cnt++){
        &_SENDMAIL($mailto[$cnt],$config{'mailto'},$config{'mailtoName'},$config{'subject'},$_TEXT{'posted'},join('',@AttachedFiles),$_HTML{'HTMLMailAdmin'});
    }
    &_RunModule('finish');
}

sub _RESULT {
    if($_RESULT{'error'}){
        &_Error(500);
    }
    elsif($_RESULT{'html'}){
        print "Content-type: text/html;charset=UTF-8
";
        &_SET_COOKIE;
        print $_RESULT{'html'};
    }
    elsif($_RESULT{'uri'}){
        &_REDIRECT($_RESULT{'uri'});
    }
    else {
        &_REDIRECT($config{'ThanksPage'});
    }
}

sub _ErrorCheck {
    ## Error Chec
    if(!$_POST{'mfp_jssemantics'} && $config{'DisabledJs'}){
        ## Error Code 1 / Disabled Javascript
        $Error = 1;
    }
    elsif($config{"EnglishSpamBlock"}){
        ## Error Code 2 / All English
        $Error = 2;
    }

And this is my captcha.php But the problem here, how to connect main script and captcha php. I mean where should add these lines in main script

$captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';
$img_session = isset($_SESSION['img_session']) ? $_SESSION['img_session'] : '';

Then I can use captcha in the contact form. Really, need help about this issue...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了