Skip to content

Instantly share code, notes, and snippets.

@caseyw
Created August 4, 2015 15:29
Show Gist options
  • Select an option

  • Save caseyw/2be360e61ef781902eab to your computer and use it in GitHub Desktop.

Select an option

Save caseyw/2be360e61ef781902eab to your computer and use it in GitHub Desktop.
Look through list of domains to see if PageSpeed service is enabled
#!/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