[英]PHP script not getting executed
我已經使用cURL解決方案來解決XSS,但是它存在問題。 我的proxy.php文件內容是: -
<?php
$url = "http://www.yahoo.com";
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>
這就是我試圖執行PHP腳本的方式
$("#tempButton").click(function(){
$("#pageContent").load('http://localhost:8080/proof/proxy.php',function() {
var t = $("#pageContent").html();
alert(t);
});
});
但是變量t顯示了proxy.php文件的內容,而期望它顯示在proxy.php文件中設置的yahoo.com的內容。 我做的事情很傻。 #FirstTimePHP
由於變量t顯示文件的內容,服務器軟件不得將腳本識別為PHP。
有幾個原因可能會發生這種情況。 沒有開放標簽將是1但你當然有這些。
另一個潛在的原因是php沒有作為模塊加載到服務器軟件中。
另一個可能的原因是服務器不解析擴展名為php的文件(這是可配置的)。
你應該從基礎開始。 忽略javascript,而是手動調用url,看看你得到了什么。 您可能會看到代碼。
如果發生這種情況,請確保將服務器軟件(通常是apache)設置為識別擴展php與php模塊相關聯。 最后確保PHP實際上已正確安裝。
讓你的proxy.php像這樣。
<?php
if(in_array('curl', get_loaded_extensions())) {
$url = "http://www.yahoo.com";
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
}
else {
echo 'No cUrl here';
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.