我正在構建一個示例服務器,以便我可以學習PHP並想知道這是否是保護我的數據庫的好方法。基本上我正在發送我自己的API密鑰。這甚至做了什麼有用的事,或者這會很容易克服。保護GET請求的好方法?
如果這太可怕了,那麼採用這種方法的標準方法是什麼?
下面是PHP文件
<?php
//Check if insert function exists
$apiKey = "6dM7V0n5GqYJLTMibQDf2gA2a94h8hbF";
if(function_exists($_GET['insert']) && ($_GET['key'])==$apiKey) {
$id = $_GET['id'];
$first=$_GET['first'];
$last = $_GET['last'];
//If found, call the function inser with value as a parameter
$_GET['insert']($id,$first,$last);
}
?>
web請求看起來像(從iOS應用);
NSURL*url=[NSURL URLWithString:@"http://localhost/Tutorials/index.php?insert=insert&id=9000&first=YOOOO&last=LOOOO&key=6dM7V0n5GqYJLTMibQDf2gA2a94h8hbF"];
//URL request
NSURLRequest*request=[NSURLRequest requestWithURL:url];
//Set the connection
connection = [NSURLConnection connectionWithRequest:request delegate:self];
if (connection) {
webData=[[NSMutableData alloc]init];
}
以上基本上意味着一旦有人嗅探到請求,甚至從瀏覽器的歷史記錄中檢索到它們,它們可能會完全控制。 – PeeHaa