Skip to content

Instantly share code, notes, and snippets.

@nch7
Created May 9, 2015 20:35
Show Gist options
  • Save nch7/e7eb90010fbc89ff621e to your computer and use it in GitHub Desktop.
Save nch7/e7eb90010fbc89ff621e to your computer and use it in GitHub Desktop.
$anchors = $domain->ahrefs_data['anchors'];
$anchorsCombined = implode('|',$anchors);
$anchor_words = explode(' ',str_replace('|', ' ', $anchorsCombined));
if(preg_match('/(*UTF8)[\p{Han}\p{Hiragana}\p{Katakana}\p{Thai}]+/',$anchorsCombined)!==0){
$badDomainIds[] = $domain->id;
echo sprintf('Domain "%s" has bad character in anchors'.PHP_EOL,$domain->domain);
Log::info(sprintf('Domain "%s" has bad character in anchors'.PHP_EOL,$domain->domain));
} else {
foreach ($blStrs as $key => $blStr) {
if((strpos($blStr,' ')===false AND in_array($blStr,$anchor_words)>0) OR // Blacklisted string is a one-word only and such string exists as a word in anchors
(strpos($blStr,' ')!==false AND strpos($anchorsCombined,$blStr)!==false) OR // Blacklisted string is a multi-word phrase and it exists in (substring of) any of the anchors
(strpos($blStr,'*')!==false AND fnmatch_in_array($blStr,$anchors)==true)){ // Blacklisted Wildcard pattern matches in any of the anchors
$badDomainIds[] = $domain->id;
echo sprintf('Domain "%s" has bad anchor "%s"'.PHP_EOL,$domain->domain,$blStr);
Log::info(sprintf('Domain "%s" has bad anchor "%s"'.PHP_EOL,$domain->domain,$blStr));
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment