2015-04-05 54 views
0
<html> 
<head> 
    <title>Online Verification</title> 
    <style> 
     body { 
      font-family: "trebuchet ms", arial, verdana; 
     } 
    </style> 
</head> 
<body> 
<?php 

# Key array 
$lks = array("0c8d3290675d6cf652ef70486d707090", "5eb059442ee03e9721ef3bb00d670020" , "a3d96258be778b21558b5c2222accea2", "3af88a65b1326db94fad0e4b66f7b556"); 

# Log file 
$log = 'log.txt'; 

# Get IP 
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { 
    $ip = $_SERVER['HTTP_CLIENT_IP']; 
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; 
} else { 
    $ip = $_SERVER['REMOTE_ADDR']; 
} 

# Set missing vars 
if(!isset($_GET["key"])) {$_GET["key"] = "248f824yf";} 
if($_GET["key"] == "") {$_GET["key"] = "482fh3748fh";} 
if(!isset($_GET["vn"])) {$_GET["vn"] = "";} 
if(!isset($_GET["psh"])) {$_GET["psh"] = "";} 
if(!isset($_GET["a"])) {$_GET["a"] = "";} 

# Shorten GET vars 
$lk = $_GET["key"]; 
$vn = $_GET["vn"]; 
$cb = $_GET["psh"]; 
$a = $_GET["a"]; 

# Check key to see if it is blank, correct or wrong. 
if(in_array(md5($lk), $lks)) { 
    $lko = TRUE; 
} else { 
    $lko = FALSE; 
} 

# Correct 
if($lko = TRUE) { 
    die("<span style='color: green;'><b>Your license key is correct! Well done.</b></span>"); 
} 
# Incorrect 
if($lko = FALSE) { 
    echo "<span style='color: red;'><b>Your license key was invalid or you have not yet purchased this product. Please do so for more features!</b></span>"; 
    if(!file_exists($log)) { 
     # Create file if it doesn't exist 
     $handle = fopen($log, 'w') or die('Cannot open file: '.$log); //implicitly creates file 
     fclose($handle); 
    } 
    # Add key, version number, IP and website address to file 
    file_put_contents($log, "Key: ".$lk." | User IP: ".$ip." | Version: ".$vn." | Website Addr: ".$a."\n"); 
    die(); 
} 
?> 
</body> 
</html> 

由於某種原因,此腳本將始終輸出「您的許可證密鑰正確無誤!幹得好」。即使許可證密鑰錯誤。我沒有看到我在這裏做錯了什麼;它應該工作。基本上我試圖讓一個PHP腳本在iframe中運行這個腳本,並帶有適當的參數。 psh並不重要,但key是用戶在通過IFrame等發送請求的PHP腳本的配置中輸入的許可證密鑰。看起來完全正確的腳本總是輸出相同的東西

包含IFRAME的PHP腳本看起來像這樣...

echo "<iframe height='70px' width='700px' src='http://marksrtz.site50.net/prl/main.php?key=".urlencode($license_key)."&vn=".urlencode($version)."&a=".urlencode($_SERVER['HTTP_HOST)."'></iframe>"; 

我敢肯定,這一切是正確的,它只是不會輸出正確的事情。

回答

2

if($lko = TRUE) {如果條件評估爲true,則進行分配。 改爲使用比較:if($lko == TRUE) {

+0

YAAAAH!這就是我玩遊戲幾天,然後做PHP的。我現在必須重新學習PHP。感謝您發現錯誤。 – unknownA 2015-04-05 17:15:24

相關問題