将变量从客户端计算机发送到服务器并返回

时间:2014-04-12 22:13:05

标签: php

我使用file_get_contents从没有静态IP地址的本地计算机向服务器(域)发送变量,但我不知道如何将另一个变量(从服务器)发送回本地计算机。(所以我可以验证数据并发回确认)。我知道如果我在他们的路由器(本地计算机)中打开端口,这个问题将会解决,但我不能这样做。

我想通过互联网进行许可证激活。

if (isset($_GET['result']) && $_GET['result']) {

if($result === "true"){
         echo "<br/>";
        echo  "<p>Thank you for playing fair";
    }else{
       echo "<br/>";
        echo "<p>This Computer is not Licensed to run this software, please visit bridgesmsrs.com for more informaiton. Thank you "; 

    }
}else{
$result="";
ob_start();
system('ipconfig /all');
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean();
$findme = "Physical";
$pos = strpos($mycom, $findme);
$macp=substr($mycom,($pos+36),17);
//echo "The mac id of this system is :".$macp;
$mac=$macp;
// encrpt the max address
$key_value = pack('H*', "bc"); 
$plain_text = $mac; 
$encrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $plain_text, MCRYPT_ENCRYPT); 
echo ("<p><b> Text after encryption : </b>"); 
echo ( $encrypted_text ); 

// send encrypted mac address to bridge for verification
$response = file_get_contents('http://localhost/scale/check.php?mac='.$mac);
print_r( $response );
}

这是代码域服务器将接收并验证答案:

<?php
// Recived data from Client PC for verfication
$result="";
if (isset($_GET['mac']) && $_GET['mac']) {
    $mac = $_GET['mac'];
    //echo "<br/>";
    //echo $mac;
    //decrypted recieve data 
    // $key_value = pack('H*', "bcb04b7e103a0c"); 
    /* @var $encrypted_text type */
    // $encrypted_text = $mac;
    // $decrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $encrypted_text, MCRYPT_DECRYPT);
    //echo ("<p><b> Text after decryption : </b>");
    //echo ( $decrypted_text );
// check see if clinet mac address verify with our list
    if ($mac === "B8-AC-6F-2D-5C-23") {
        echo "<br/>";
        echo $mac . "<p>Thank you playing fare";
        $result="true";
    } else {
        echo "<br/>";
        echo "<p>This Computer is not Licensed to run this software, please visit bridgesmsrs.com for more informaiton. Thank you ";
        $result="false";
    }
}
?>

实际上有更多的本地主机,因为客户端将数据发送到http://domain.com,但我不知道服务器在哪里发送数据。

0 个答案:

没有答案
相关问题