Please, can somebody help me with this script? 🙁
This redirect script takes the number from the end of link and assigns to URL from array.
Number 1 is second element (yahoo), number 2 is third element (google) etc.
I would like to change number at the end of URL with keyword and put pairs in array like:

array (
"yahoo" => "http://yahoo.com",
"google" => "http:// google.com"
);

So, when somebody come on page via URL "domain.com/?mn=yahoo" I would like to redirected him to

http://yahoo.com.

<?php

//Standalone CPA Redirector v2.1 with multioffers

//Settings http://dexony.com/insurance2/?mn=google

//put in your desired offers in the array below , you can add as many as you want , but make sure 

to enclose them with ""
// to match the desired domain you wonna link to , set the magicnumber to the position in the array 

below 
// to use your desired offer use http://www.yourdomain.com/?mn=offernumber


$offers = array ( 
"",                          // must be empty 
"http://www.yahoo.com/",     // ?mn=1
"http://www.google.com/"     // ?mn=2
);


//you can specify a safenumber here, what it does it sets the magicnumber of the offer you would 

like + it's value
//you normally don't need this, but if you don't want your magic numbers to start at 1 you can 

change it here
// example if you set this to 50 and you want to use your first number it would be index.php?mn=51
$safemode = 0;


//Don't edit below this line unless you know what you are doing.
$PHP_SELF = preg_replace( "/index.php/", "", $_SERVER['PHP_SELF'] );


if (isset($_GET['mn'])) {
$magic_number = $_GET['mn'] - $safemode;
$cpa_offer_url = $offers[$magic_number];
setcookie("mnval",$magic_number,time()+10,"/");
setcookie("cpaval",$cpa_offer_url,time()+10,"/");

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']== $_COOKIE['mnval']) && (isset($_COOKIE['mnval'])))  {
$magic_number = $_COOKIE['mnval'];

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']==$_COOKIE['mnval'].$_COOKIE['mnval']) && (isset($_COOKIE['mnval']))){
$cpa_offer_url = $_COOKIE['cpaval'];		
header( 'Location: ' . $cpa_offer_url);
		exit();
setcookie("mnval","",time()-60);
setcookie("cpaval","",time()-60);
	}


?>


<html>
  <head>
    <title>your fake landing page</title>
  </head>
  <body>
	<br><br><br><br>
	 <center><h1>text</h1></center>

  </body>
</html> 

    Are yahoo and google the only options you need, or will there be more later?

    A switch statement may do the job needed...?

    $v = $_REQUEST['mn'];
    
    switch($v)
    {
    Case 'yahoo':
         header('Location: yahoo.com');
         break;
    Case 'google':
         header('Location: google.com');
         break;
    }
      Write a Reply...