Created
May 20, 2014 14:20
-
-
Save mikeemoo/714f39befbeb188dcec9 to your computer and use it in GitHub Desktop.
resolve adfly
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 | |
function resolveAdfly($url) { | |
if (!preg_match("@https?:\/\/adf\.ly\/[a-z0-9]+@i", $url)) { | |
return $url; | |
} | |
$contents = file_get_contents($url); | |
preg_match("@var ysmm = '([^']+)'@", $contents, $match); | |
$ysmm = $match[1]; | |
$a = $t = ''; | |
for ($i = 0; $i < strlen($ysmm); $i++) { | |
if ($i % 2 == 0) { | |
$a .= $ysmm[$i]; | |
} else { | |
$t = $ysmm[$i] . $t; | |
} | |
} | |
$url = base64_decode($a . $t); | |
$url = str_replace(' ', '%20', filter_var(strstr($url, 'http'), FILTER_SANITIZE_URL)); | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment