我正在使用此代码来隐藏我的流量来源,它运行良好,但它只有1个值,如何编辑代码以支持多值?
E.g:
index.php?mn = 1 => affiliateurl-1.com
index.php?mn = 2 => affiliateurl-2.com
index.php?mn = 3 => affiliateurl-3.com
index.php?mn = 4 => affiliateurl-4.com
<?php
$magic_number = 1; // Any number you choose except ZERO!
$affiliate_url = 'http://www.affiliateurl.com/';
$PHP_SELF = preg_replace( "/index.php/", "", $_SERVER['PHP_SELF'] );
if (isset($_GET['mn']) && $_GET['mn']==$magic_number){
echo '<html><head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><form action="' . 'http://'.$_SERVER['HTTP_HOST'].$PHP_SELF. '" method="post" id="form1">
<input type="hidden" name="mn" value="' . $magic_number . '" /></form>
<script language="JavaScript">
document.getElementById(\'form1\').submit();</script></body></html>';
return true;
exit();
}
if ($_POST['mn']==$magic_number){
echo '<html><head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><form action="' . 'http://'.$_SERVER['HTTP_HOST'].$PHP_SELF. '" method="post" id="form1">
<input type="hidden" name="mn" value="' . $magic_number . $magic_number . '" /></form>
<script language="JavaScript">
document.getElementById(\'form1\').submit();</script></body></html>';
return true;
exit();
}
$dom = preg_replace( "/^www\./", "", $_SERVER[ 'HTTP_HOST' ] ) ;
$ref= $_SERVER['HTTP_REFERER'];
if (((strpos($ref, $dom)!=FALSE) || (trim($ref)=="" ) ) && (!isset($_GET['mn'])) && ($_POST['mn']==$magic_number.$magic_number)){
header( 'Location: ' . $affiliate_url);
exit();
}
?>
答案 0 :(得分:0)
您可以使用此代码
if (isset($_GET['mn']) && $_GET['mn']==0){
// some code here
}elseif(isset($_GET['mn']) && $_GET['mn']==1){
//some code here
}else{
//default action here
}
您可以使用任何您需要的 elseif