zoukankan      html  css  js  c++  java
  • discuz formhash

    class.core.php中      

    $this->var['formhash'] = formhash();
    define('FORMHASH', $this->var['formhash']);

    hash值生成方法

     function formhash() {
      return substr(md5(substr($this->time, 0, -4).UC_KEY), 16);
     }

    在表单中使用

    <input type="hidden" name="formhash" value="<?php echo FORMHASH;?>" />function submitcheck($var, $allowget = 0, $seccodecheck = 0, $secqaacheck = 0) {
        if(!getgpc($var)) {
            return FALSE;
        } else {
            global $_G;
            if(!empty($_G['gp_mobiledata'])) {
                require_once libfile('class/mobiledata');
                $mobiledata = new mobiledata();
                if($mobiledata->validator()) {
                    return TRUE;
                }
            }
            if($allowget || ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_G['gp_formhash']) && $_G['gp_formhash'] == formhash() && empty($_SERVER['HTTP_X_FLASH_VERSION']) && (empty($_SERVER['HTTP_REFERER']) ||
            preg_replace("/https?://([^:/]+).*/i", "\1", $_SERVER['HTTP_REFERER']) == preg_replace("/([^:]+).*/", "\1", $_SERVER['HTTP_HOST'])))) {
                if(checkperm('seccode')) {
                    if($secqaacheck && !check_secqaa($_G['gp_secanswer'], $_G['gp_sechash'])) {
                        showmessage('submit_secqaa_invalid');
                    }
                    if($seccodecheck && !check_seccode($_G['gp_seccodeverify'], $_G['gp_sechash'])) {
                        showmessage('submit_seccode_invalid');
                    }
                }
                return TRUE;
            } else {
                showmessage('submit_invalid');
            }
        }
    }

    表单提交验证

  • 相关阅读:
    JEECG 不同(角色的)人对同样的字段数据,使用不同的字段验证规则
    CRM系统设计方案
    MySql concat与字符转义
    MYSQL 三元 函数
    Linux watchdog
    Prometheus & SoundCloud
    Docker存储驱动Device Mapper,Overlay,AUFS
    linux的nohup命令
    Eclipse Todo Tasks 任务试图
    Mysql drop function xxxx ERROR 1305 (42000): FUNCTION (UDF) xxxx does not exist
  • 原文地址:https://www.cnblogs.com/agang-php/p/4235050.html
Copyright © 2011-2022 走看看