我已经实施了一个我不能拒绝它的解决方案。它仍有改进的余地。我使用控制器来获取 csrf
class Csrf_secure extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->library('user_agent');
}
function get_csrf()
{
$this->fuel->admin->check_login();
if(false)
{}
elseif(trim($this->agent->referrer()) =='' or $this->input->is_ajax_request()== false)
{show_404(); }
else {
echo json_encode(array(
'token'=>$this->security->get_csrf_token_name(),
'hash'=>$this->security->get_csrf_hash()
));
} }}
每次关闭模态 i 帧时获取和更新函数
(如果只有在 from 上发生更新时才可以将其单元格化,则需要对其进行优化)
/fuel/modules/fuel/assets/js/jquery/plugins/jqModal.js
改变
$.fn.jqm隐藏
功能如下。
$.fn.jqmHide=function(t){return this.each(function(){
$.jqm.close(this._jqm,t);
if(typeof window.parent != "undefined" ){
if(typeof window.parent.CallParent == "undefined" ){
window.parent.CallParent = function(context)
{
$.getJSON(jqx_config.basePath+"csrf_secure/get_csrf", function(result){
if(typeof result.token != "undefined"){
document.querySelectorAll('#'+result.token).forEach(function(rf){
rf.value=result.hash;
});
}
});
};
};
window.parent.CallParent(this._jqm,t);
}
});};