@No4NaMe

Как сделать валидацию в форме?

Есть скрипт проверки доменных имен, но здесь проблема нету проверки на валидацию уже все перепробовал как добавить в подобный скрипт проверку?

<?php
/*************************************************
 * Max's Whois
 *
 * Version: 1.0
 * Date: 2007-11-28
 *
 ****************************************************/

class maxWhois{

    var $serverList;
    var $tr = 0;
    
function maxWhois(){  
  
        $this->serverList[0]['top']      = 'ru';
	$this->serverList[0]['server']   = 'whois.ripn.net';
	$this->serverList[0]['response'] = 'No entries found';
	$this->serverList[0]['check']    = false;

        $this->serverList[1]['top']      = 'com';
	$this->serverList[1]['server']   = 'whois.crsnic.net';
	$this->serverList[1]['response'] = 'No match for';
	$this->serverList[1]['check']    = false;
	
	$this->serverList[2]['top']      = 'net';
	$this->serverList[2]['server']   = 'whois.crsnic.net';
	$this->serverList[2]['response'] = 'No match for';
	$this->serverList[2]['check']    = false;

	$this->serverList[3]['top']      = 'org';
	$this->serverList[3]['server']   = 'whois.publicinterestregistry.net';
	$this->serverList[3]['response'] = 'NOT FOUND';
	$this->serverList[3]['check']    = false;
	
	$this->serverList[4]['top']      = 'info';
	$this->serverList[4]['server']   = 'whois.afilias.net';
	$this->serverList[4]['response'] = 'NOT FOUND';
	$this->serverList[4]['check']    = false;
	
	$this->serverList[5]['top']      = 'name';
	$this->serverList[5]['server']   = 'whois.nic.name';
	$this->serverList[5]['response'] = 'No match';
	$this->serverList[5]['check']    = false;

	$this->serverList[6]['top']      = 'biz';
	$this->serverList[6]['server']   = 'whois.nic.biz';
	$this->serverList[6]['response'] = 'Not found';
	$this->serverList[6]['check']    = false;

	$this->serverList[7]['top']      = 'tv';
	$this->serverList[7]['server']   = 'whois.internic.net';
	$this->serverList[7]['response'] = 'No match for';
	$this->serverList[7]['check']    = false;
}

function showHeader(){
?>
<?php
}

function showWhoisForm(){
?>
                        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" class="form-search-2 with-dropdown clearfix">
	    <input type="text" autocomplete="off" placeholder="ВВЕДРРўР• РџР РћРЎРўРћ РРњРЇ, БЕЗ ДОМЕННОЙ Р—РћРќР«" />
            <div><button class="custom-btn big invers" name="submitBtn" type="submit">ПРОВЕРРРўР¬</button></div>
				<table class="hidden-xs">
				<tr>
            <?php
            	$i = 0;
                foreach ($this->serverList as $value) {
                    if ($value['check'] == false) $checked=" checked ";
            		else $checked = " ";
            		
            		echo '<td colspan="5"><div style="display: none;"><input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'].'</div></td>';
                    $i++;            		
            		if ($i > 4) {
            		    $i = 0;
            		    echo '</tr><tr>';
            		}
            	}
            	
            ?>				
				</tr>
				</table>
            </form>
<?php
}

function showFooter(){
?>

<?php
}

function processWhois(){
    $this->showHeader();

    if (!isset($_POST['submitBtn'])){
        $this->showWhoisForm();
    } else {

        $domainName = (isset($_POST['domain'])) ? $_POST['domain'] : '';
        
       	for ($i = 0; $i < sizeof($this->serverList); $i++) {
       		$actTop = "top_".$this->serverList[$i]['top'];
       		$this->serverList[$i]['check'] = isset($_POST[$actTop]) ? true : false;
       	}

        // Check domains only if the base name is big enough
        if (strlen($domainName)>2){
            echo '<div class="pricing-table pricing-table-5"><table class="hidden-xs">';
            echo '<thead><tr><td colspan="2"><span class="border-color_blue"><b>РЕЗУЛЬТАТ ПРОВЕРКРДОМЕННЫХ РМЕН</b></span></td></tr></thead>';
		
           	for ($i = 0; $i < sizeof($this->serverList); $i++) {
	       		if ($this->serverList[$i]['check']){
			     	$this->showDomainResult($domainName.".".$this->serverList[$i]['top'],
			     	                        $this->serverList[$i]['server'],
			     	                        $this->serverList[$i]['response']);
			    }
		    }
        
		    echo '</table></div><br>';
        }
        $this->showWhoisForm();
        
    }
    $this->showFooter();

}

function showDomainResult($domain,$server,$findText){
   if ($this->tr == 0){
       $this->tr = 1;
       $class = " class='tr2'";
   } else {
       $this->tr = 0;
       $class = "";
   }
   if ($this->checkDomain($domain,$server,$findText)){
      echo "<tr $class><td>$domain</td><td style='color:green;'><a href='https://my.hostuner.ru/billmgr?startpage=domain' class='custom-btn small blue-btn'>ЗАРЕГРРЎРўР РР РћР’РђРўР¬</a></td></tr>";
   }
   else echo "<tr $class><td>$domain</td><td style='color:red;'>Р—РђРќРЇРў</td></tr>";
}
function checkDomain($domain,$server,$findText){
    $con = fsockopen($server, 43);
    if (!$con) return false;
        
    // Send the requested doman name
    fputs($con, $domain."\r\n");
        
    // Read and store the server response
    $response = ' :';
    while(!feof($con))
  • Вопрос задан
  • 141 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы