Example #1
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$sld = 'nabi.ir';
try {
    $domain = new Phois\Whois\Whois($sld);
} catch (InvalidArgumentException $e) {
    die($e->getMessage() . "\n");
}
if ($domain->isAvailable()) {
    echo "Domain is available\n";
} else {
    echo "Domain is registered\n";
}
<?php

$sld = 'reg.ru';
$domain = new Phois\Whois\Whois($sld);
$whois_answer = $domain->info();
echo $whois_answer;
if ($domain->isAvailable()) {
    echo "Domain is available\n";
} else {
    echo "Domain is registered\n";
}
 /**
  * @inheritdoc
  */
 public function validateAttribute($model, $attribute)
 {
     $value = $model->{$attribute};
     if (is_array($value)) {
         $this->addError($model, $attribute, Yii::t('yii', '{attribute} is invalid.'));
         return;
     }
     if ($this->compareValue !== null) {
         $compareLabel = $compareValue = $this->compareValue;
     } else {
         $compareAttribute = $this->compareAttribute === null ? $attribute . '_repeat' : $this->compareAttribute;
         $compareValue = $model->{$compareAttribute};
         $compareLabel = $model->getAttributeLabel($compareAttribute);
     }
     if ($compareValue) {
         $domain = new \Phois\Whois\Whois($compareValue . "." . $value);
         $whois_answer = $domain->info();
         if (!$domain->isAvailable()) {
             $this->addError($model, $attribute, 'Домен занят');
         }
     }
     // if (!$this->compareValues($this->operator, $this->type, $value, $compareValue)) {
     //    $this->addError($model, $attribute, $this->message, [
     //        'compareAttribute' => $compareLabel,
     //       'compareValue' => $compareValue,
     //     ]);
     // }
 }