Nabble\SemaltBlocker\Updater::getNewDomainList PHP Method

getNewDomainList() public static method

public static getNewDomainList ( ) : string
return string
    public static function getNewDomainList()
    {
        if (function_exists('curl_init')) {
            $curl = curl_init();
            curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => self::$updateUrl]);
            $domains = curl_exec($curl);
            curl_close($curl);
        } else {
            $domains = @file_get_contents(self::$updateUrl);
        }
        return $domains;
    }

Usage Example

コード例 #1
0
 /**
  * @depends testDomainsRetrieval
  */
 public function testForcedDomainsUpdate()
 {
     $domainList = \Nabble\SemaltBlocker\Updater::getNewDomainList();
     file_put_contents($this->blockFile, '');
     \Nabble\SemaltBlocker\Updater::$ttl = 60 * 60 * 24 * 9999;
     // = 9999 days;
     \Nabble\SemaltBlocker\Updater::update(true);
     $this->assertStringEqualsFile($this->blockFile, $domainList, 'Blocked file should match online domain list');
 }
All Usage Examples Of Nabble\SemaltBlocker\Updater::getNewDomainList