Last active
November 23, 2022 17:18
-
-
Save bobbydeveaux/9696655 to your computer and use it in GitHub Desktop.
Redirector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* File to handle redirection and cloak links. | |
* | |
* @version 0.0.1 | |
* @author Bobby DeVeaux (me@bobbyjason.co.uk) | |
**/ | |
class Redirector | |
{ | |
/** | |
* Affiliate IDs | |
* Change this to your IDs! | |
*/ | |
CONST MN_ID = 113104; | |
CONST I5_ID = 113106; | |
CONST PD_ID = 100006; | |
/** | |
* Do you want to hide your referring URL? | |
*/ | |
CONST CLOAK = false; | |
/** | |
* Your links. | |
* Change this to any link you wish to redirect. | |
* use %moreniche% for moreniche links | |
* use %impactfive% for impactfive links | |
* use %paydot% for paydot links | |
*/ | |
protected $_links = array( | |
'phen375' => 'http://track.moreniche.com/hit.php?w=%moreniche%&s=157', | |
'brestrogen' => 'http://track.impactfive.com/hit.php?w=%impactfive%&s=217', | |
// add another link here | |
'namelink' => 'http://some.url', | |
); | |
/* YOU DO NOT NEED TO EDIT ANYTHING BELOW THIS LINE */ | |
public $_redirectUrl; | |
public function __construct($linkName) { | |
if (false === in_array($linkName, array_keys($this->_links))) { | |
return false; | |
} | |
$this->_redirectUrl = str_replace( | |
array( | |
'%moreniche%', | |
'%impactfive%', | |
'%paydot%', | |
), | |
array( | |
self::MN_ID, | |
self::I5_ID, | |
self::PD_ID | |
), | |
$this->_links[$linkName] | |
); | |
$this->go(); | |
} | |
public function go() { | |
if (false === self::CLOAK) { | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: " . $this->_redirectUrl); | |
} | |
$output = "<meta http-equiv=\"refresh\" content=\"0;URL='" . $this->_redirectUrl . "'\">"; | |
$output .= "<script type=\"text/javascript\">"; | |
$output .= "<!--"; | |
$output .= 'location.replace("' . $this->_redirectUrl . '");'; | |
$output .= "//-->"; | |
$output .= "</script>"; | |
print $output; | |
exit; | |
} | |
} | |
$r = new Redirector($_GET['r']); | |
// If the above function fails, the below will happen. | |
header("HTTP/1.1 402 No Content"); | |
print 'Sorry, there was a problem loading the requested URL'; | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment