dongxiegao3071 2011-10-20 14:15
浏览 30
已采纳

仅显示某些国家/地区的代码

So I have an affiliate program that's lately been getting a lot of bad leads from countries we don't service, which we tell affiliates will be voided. Anyways, this is going to cause our reversal rate to be through the roof. So I want to do something about it.

So I want to use geoip, which gets me the stuff as a 2 letter country code.

<?php
    $output = shell_exec('geoip-lookup '.$_SERVER['REMOTE_ADDR']);
?>

So how do I put that together?

Would this be correct?

<?php
$output = shell_exec('geoip-lookup '.$_SERVER['REMOTE_ADDR']);
if($_SESSION['check']!=1) && ($output=='US' || $output=='AU' || $output=='GB' || $output=='CA')
{
    $submission = $_POST['submission_id'];
    $_SESSION['check']=1;
    echo 'insert pixel';
}
?>
  • 写回答

3条回答 默认 最新

  • dqr3883 2011-10-20 14:18
    关注

    You'll want to verify $output is what you expect (i.e. a string - var_dump($output)).

    However, provided it is, you'll need to quote your country codes to do a string comparison. Also, as noted by heximal, be sure to use == for comparison. Otherwise, it's an assignment.

    if ($_SESSION['check'] != 1 && ($output == 'US' || $output == 'AU' ...)) {
    

    Otherwise, the rest of you code appears correct (without knowing your exact logic).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置