Skip to content

Instantly share code, notes, and snippets.

@mikeemoo
Created May 20, 2014 14:20
Show Gist options
  • Save mikeemoo/714f39befbeb188dcec9 to your computer and use it in GitHub Desktop.
Save mikeemoo/714f39befbeb188dcec9 to your computer and use it in GitHub Desktop.
resolve adfly
<?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