1

素敵なスクリプトをコーディングしましたが、常に取得しています

Error on line 29: Parse error, unexpected T_IF(if)

コードのデバッグを試みましたが、多くの時間を無駄にしました。しかし、何も出ませんでした。

これが私のコードです。

<?php

  include("geoip.inc");
$ip=$_SERVER['REMOTE_ADDR'];
$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);

$country_code = geoip_country_code_by_addr($gi, "$ip");
$referrer=$_SERVER['HTTP_REFERER'];
// Country name is not used so commented
// Get Country Name based on source IP
//$country = geoip_country_name_by_addr($gi, "$ip");
$real=0;
geoip_close($gi);

if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")) {
    $real = 1;  
}
else {
                if ($_COOKIE['iwashere'] != "yes")  {
                setcookie("iwashere", "yes", time()+315360000); 
                            if ($country_code="IN") {
                                    if(preg_match('/google/i', $referrer)) {
                                    $key = "g17x9erm28n7cgifddssfqhgorjf3e"; // Account API Key
                                    $ip = $_SERVER['REMOTE_ADDR']; // IP to Lookup

                                    $result = file_get_contents('http://www.ipqualityscore.com/api/ip_lookup.php?KEY='.$key.'&IP='.$ip);
                                    $real=$result
//$result will be equal to 1 for detected proxies & vpns or equal to 0 for clean IP's
                                            {if($real==0)
                                            {setcookie("testcookie", "testvalue");  
                                                        if( isset( $_COOKIE['testcookie'] ) ) {
                                                                if (isset($_POST['jstest'])) {
                                                                    $nojs = FALSE;
                                                                    } else {
  // create a hidden form and submit it with javascript
                                                                    echo '<form name="jsform" id="jsform" method="post" style="display:none">';
                                                                    echo '<input name="jstest" type="text" value="true" />';
                                                                    echo '<script language="javascript">';
                                                                    echo 'document.jsform.submit();';
                                                                    echo '</script>';
                                                                    echo '</form>';
  // the variable below would be set only if the form wasn't submitted, hence JS is disabled
                                                                    $nojs = TRUE;
    }
                                                                                if ($nojs){
    $real=1;
 }


}
else    
$real=1;        
}
else
$real=1;

        } else 
            $real = 1;

    }
 else {
    $real = 1;
}
          }  }

if ($real==1) {
    include_once('Biggenius1.htm');

}

?>

中にあればです。これらのエラーを回避するにはどうすればよいか、アドバイスをください。また、複数のネストされた if ステートメントを使用してこのような複雑なスクリプトをコーディングする代替手段はありますか?

コード全体を投稿してください:

4

5 に答える 5

0

ここに私が見つけたいくつかのエラーがあります:

  1. if ($country_code="IN"): これは比較ではなく割り当てであり、常に true を返します
  2. $real=$result;:最後にターミネーションがありません
于 2012-05-01T06:30:49.017 に答える
0

29 行$real=$result目はセミコロンで終わり、次の行{if($real==0)if($real==0){.

エラーメッセージはあなたの友人です.29行目を見てください.

于 2012-05-01T06:32:29.797 に答える
0

//$result は、検出されたプロキシと vpn の場合は 1、クリーンな IP の場合は 0 になります {if($real==0)

それを削除すると、エラーが削除されます

于 2012-05-01T06:32:31.140 に答える
0

あなたのコードを読むと、私が見つけることができる唯一のエラーは次のようです:

{if($real==0)

と:

$real=$result

次のように変更する必要があります。

if($real==0){

と:

$real=$result;
于 2012-05-01T06:34:01.013 に答える
0

これを試して

$real = 0;
geoip_close($gi);

if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")) {
    $real = 1;
} else {
    if ($_COOKIE['iwashere'] != "yes") {
        setcookie("iwashere", "yes", time() + 315360000);
        if ($country_code = "IN") {
            if (preg_match('/google/i', $referrer)) {
                $key = "g17x9erm28n7cgifddssfqhgorjf3e"; // Account API Key
                $ip = $_SERVER['REMOTE_ADDR']; // IP to Lookup

                $result = file_get_contents('http://www.ipqualityscore.com/api/ip_lookup.php?KEY=' . $key . '&IP=' . $ip);
                $real = $result;
//$result will be equal to 1 for detected proxies & vpns or equal to 0 for clean IP's {
                    if ($real == 0) {
                        setcookie("testcookie", "testvalue");
                        if (isset($_COOKIE['testcookie'])) {
                            if (isset($_POST['jstest'])) {
                                $nojs = FALSE;
                            } else {

                            }
                            // create a hidden form and submit it with javascript
                            echo '<form name="jsform" id="jsform" method="post" style="display:none">';
                            echo '<input name="jstest" type="text" value="true" />';
                            echo '<script language="javascript">';
                            echo 'document.jsform.submit();';
                            echo '</script>';
                            echo '</form>';
                            // the variable below would be set only if the form wasn't submitted, hence JS is disabled
                            $nojs = TRUE;
                        }
                        if ($nojs) {
                            $real = 1;
                        }
                    }
                    else
                        $real = 1;
                }
                else
                $real = 1;
            } else
                $real = 1;
        }
        else {
            $real = 1;
        }

}

if ($real == 1) {
    include_once('Biggenius1.htm');
}
于 2012-05-01T06:35:25.263 に答える