[英]access php file only from index.php?p=test
我使用 winwheel.js + custom.js,我也有 test.php,其中文件由 Custom.js 調用以獲取隨機 StopPosition,一切正常,我的問題是如何限制訪問文件 test.php?action=直接嘗試,因為如果我訪問該文件,它會調用 php 函數( payWheel() , getReward() )
test.php生成一個項目,如果有人旋轉輪子將贏得該項目
自定義.js :
function startSpin() {
if (wheelSpinning == false)
{
var jsonData = null;
$.getJSON("wheel-responder.php?action=rotate", function (data)
{
console.log(data);
WheelOfFortune.rotationAngle = 0;
WheelOfFortune.animation.spins = 10;
WheelOfFortune.animation.stopAngle = data["lastPosition"];
WheelOfFortune.startAnimation();
wheelSpinning = true;
});
} }
測試.php
if(isset($_GET['action']))
{
if($mycredit>= 100){
if($_GET['action'] == 'try')
_Spin(rand(1, 10), 100);
}
}
如果您想限制臨時用戶,請使其成為 POST 請求。 這將防止通過地址欄進行隨機訪問。
JS文件
$.post("wheel-responder.php?action=rotate", function (data) {}
PHP文件
if(isset($_POST['action'])) {}
未經測試,但應該是微不足道的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.