Advertisement
Guest User

TransIP DropCatcher

a guest
Dec 20th, 2016
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('Transip/DomainService.php');
  4.  
  5. echo "Loading file..." . "<br/>";
  6.  
  7. $filename = "domains.txt";
  8. $filehandle = fopen($filename, "r");
  9. $domains = explode(PHP_EOL, fread($filehandle, filesize($filename)));
  10. $domains = array_map('trim', $domains);
  11. $domains = array_filter($domains, function($value) { return $value !== ''; });
  12.  
  13. echo "Found domains: " . count($domains) . "<br/>";
  14.  
  15. try {
  16.     $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains);
  17.     foreach($domainCheckResults as $domainCheckResult) {
  18.         switch($domainCheckResult->status) {
  19.             case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
  20.                 echo "Removing: " . $domainCheckResult->domainName . "<br/>";
  21.                
  22.                 $index = array_search($domainCheckResult->domainName, $domains);
  23.                 if($index !== FALSE){
  24.                     unset($domains[$index]);
  25.                 }
  26.             break;
  27.            
  28.             case Transip_DomainService::AVAILABILITY_FREE:
  29.                 echo "Registering: " . $domainCheckResult->domainName . "<br/>";
  30.            
  31.                 Transip_DomainService::register($domainCheckResult->domainName);
  32.             break;
  33.            
  34.             default:
  35.                 echo "No action for: " . $domainCheckResult->domainName . "<br/>";
  36.             break;
  37.         }
  38.     }
  39. } catch(SoapFault $e) {
  40.     echo "An error occurred: " . htmlspecialchars($e->getMessage()) . "<br/>";
  41. }
  42.    
  43. echo "Saving file..." . "<br/>";
  44.  
  45. file_put_contents($filename, implode(PHP_EOL, $domains));
  46. fclose($filehandle);
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement