Created
August 4, 2015 15:29
-
-
Save caseyw/2be360e61ef781902eab to your computer and use it in GitHub Desktop.
Look through list of domains to see if PageSpeed service is enabled
This file contains hidden or 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
| #!/usr/bin/env php | |
| <?php | |
| /** | |
| * List of domains on the level where your CNAME would exist | |
| */ | |
| $domains = [ | |
| ]; | |
| echo PHP_EOL; | |
| /** | |
| * Cycle through domains and output those who have PageSpeed installed | |
| */ | |
| foreach ($domains as $domain) { | |
| if (hasPageSpeedEnabled($domain)) { | |
| echo 'PageSpeed Installed: ' . $domain . PHP_EOL; | |
| } | |
| } | |
| /** | |
| * See if the CNAME for PageSpeed is setup on $domain | |
| * | |
| * @param string $domain | |
| * | |
| * @return bool | |
| */ | |
| function hasPageSpeedEnabled($domain) | |
| { | |
| $resp = dns_get_record($domain, DNS_CNAME); | |
| if (!count($resp)) { | |
| return false; | |
| } | |
| foreach ($resp as $cname) { | |
| if (strpos($cname['target'], 'pagespeed') !== false) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment