Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('Transip/DomainService.php');
- echo "Loading file..." . "<br/>";
- $filename = "domains.txt";
- $filehandle = fopen($filename, "r");
- $domains = explode(PHP_EOL, fread($filehandle, filesize($filename)));
- $domains = array_map('trim', $domains);
- $domains = array_filter($domains, function($value) { return $value !== ''; });
- echo "Found domains: " . count($domains) . "<br/>";
- try {
- $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains);
- foreach($domainCheckResults as $domainCheckResult) {
- switch($domainCheckResult->status) {
- case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
- echo "Removing: " . $domainCheckResult->domainName . "<br/>";
- $index = array_search($domainCheckResult->domainName, $domains);
- if($index !== FALSE){
- unset($domains[$index]);
- }
- break;
- case Transip_DomainService::AVAILABILITY_FREE:
- echo "Registering: " . $domainCheckResult->domainName . "<br/>";
- Transip_DomainService::register($domainCheckResult->domainName);
- break;
- default:
- echo "No action for: " . $domainCheckResult->domainName . "<br/>";
- break;
- }
- }
- } catch(SoapFault $e) {
- echo "An error occurred: " . htmlspecialchars($e->getMessage()) . "<br/>";
- }
- echo "Saving file..." . "<br/>";
- file_put_contents($filename, implode(PHP_EOL, $domains));
- fclose($filehandle);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement