0

社区,我有一个小问题,我不知道如何进行。我想创建一个脚本,检查允许在域上运行的脚本。例如:我正在制作一个独占脚本,它只允许在我在 MySQL-DB 中指定的域上运行。我现在的问题是脚本和服务器之间的通信 - 我没有让它工作。

这是 index.php:

 <?php 
        require_once('includes/callback.php'); 
    ?> 

    <!DOCTYPE html> 
    <html lang="en"> 
        <head> 
            <meta charset="utf-8" /> 
            <title></title> 
        </head> 
        <body> 

        </body> 
    </html>

这是callback.php:

<?php 
$urltopost = "check.php"; 
$datatopost = array ( 
    "url" => $_SERVER['HTTP_HOST'], 
    "request_url" => $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] 
); 

$ch = curl_init ($urltopost); 
curl_setopt ($ch, CURLOPT_POST, true); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
$returndata = curl_exec ($ch); 
while($status='0'){ 
     $status = $_POST['status'];} 
if($status=='2'){ 
    echo 'Success'; 
} 
elseif($status=='1') 
{ 
    echo 'Error!'; 
} 
?>

至少 check.php:

<?php 
    $allowed='dev.pasternt-cms.de'; 
    $url = $_POST['url']; 
    $request = $_POST['request_url']; 
    if($allowed!= $url){ 
        $urltopost = $request; 
        $datatopost = array ( 
        "status" => '1', 
        ); 

        $ch = curl_init ($urltopost); 
        curl_setopt ($ch, CURLOPT_POST, true); 
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost); 
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
        $returndata = curl_exec ($ch); 
    } 
    else 
    { 
        $urltopost = $request; 
        $datatopost = array ( 
              "status" => '2', 
        ); 

        $ch = curl_init ($urltopost); 
        curl_setopt ($ch, CURLOPT_POST, true); 
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost); 
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
        $returndata = curl_exec ($ch) 
    } 
?>

如果您能给我一个小的解决方案或帮助,那就太好了。请帮我 ;)

谢谢

4

0 回答 0