"); } if (0 == ($count = count($valueTree))) { fwrite($fp, 'true'); } else { fwrite($fp, "[\n"); for ($keys = array_keys($valueTree), $i = 0; $i < $count; $i++) { writeNode($fp, $valueTree[$keys[$i]], $keys[$i], $indent + 1); if ($i + 1 != $count) { fwrite($fp, ",\n"); } else { fwrite($fp, "\n"); } } fwrite($fp, str_repeat(' ', $indent) . "]"); } } try { $request = new HTTP_Request2(LIST_URL, HTTP_Request2::METHOD_GET, [ // Provide path to your CA file and change 'ssl_verify_peer' to true to enable peer validation // 'ssl_cafile' => '... path to your Certificate Authority file ...', 'ssl_verify_peer' => false ]); $response = $request->send(); if (200 != $response->getStatus()) { throw new Exception("List download URL returned status: " . $response->getStatus() . ' ' . $response->getReasonPhrase()); } $list = $response->getBody(); if (false === strpos($list, '// ===BEGIN ICANN DOMAINS===')) { throw new Exception("List download URL does not contain expected phrase"); } if (!($fp = @fopen(OUTPUT_FILE, 'wb'))) { throw new Exception("Unable to open " . OUTPUT_FILE); } } catch (Exception $e) { die($e->getMessage()); } $tldTree = []; $license = true; fwrite($fp, ""); fclose($fp); ?>