dousha1873 2015-04-05 17:11
浏览 15
已采纳

看起来完全正常的脚本总是输出相同的东西

<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."
");
    die();
}
?>
</body>
</html>

For some reason, this script will always output "Your license key is correct! Well done." even if the license key is wrong. I don't see what I'm doing wrong here; it should work. Basically I'm trying to make a PHP script run this script in an Iframe, with proper arguments. psh isn't really important but key is the License Key the user inputted in the configurations of the PHP script that sends the request through the IFrame and so on.

The PHP script containing the IFrame looks like this...

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>";

I'm pretty sure all of this is correct, it just won't output the right thing.

  • 写回答

1条回答 默认 最新

  • doulao1966 2015-04-05 17:13
    关注

    if($lko = TRUE) { makes an assignment with if condition evaluation to true. Use comparison instead: if($lko == TRUE) {

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题