Jump to content

Recommended Posts

Posted

Olá Galera,

 

Embora o whmcs já faça isso, no momento estou testando o gerenciador de hospedagem "Isistem" e infelizmente não é tão bom como whmcs por exemplo não faz registro de domínio separado da hospedagem, traduzindo o cliente é obrigado a contratar a hospedagem se quiser comprar o Domínio.

 

Pensando nisso eu precisava de uma pesquisa de domínios direta pelo Reseller Club, só funciona para quem tem revenda Reseller Club fuçando na net consegui esse scrip que funciona muito bem

 

Parte Html ´responsável por enviar os dados para consulta de domínios .com, .net, .in, .biz, .org, e .asia podendo ser adicionado mais como quiser 

<html>
<head>
</head>
<body>
<form method="post" action="test.php">
    <input type="text" name="domain" value="<?php echo $domainname; ?>"/>

    <input type="checkbox" name="tld[]" value="com"  <?php  if(!isset($_POST['check'])){  ?> checked="checked" <?php } elseif (in_array("com", $tldarray)) {  ?> checked="checked" <?php  } ?> />com
    <input type="checkbox" name="tld[]" value="net" <?php if (in_array("net", $tldarray)) {  ?> checked="checked" <?php  } ?> />net
    <input type="checkbox" name="tld[]" value="in" <?php if (in_array("in", $tldarray)) {  ?> checked="checked" <?php  } ?> />in
    <input type="checkbox" name="tld[]" value="biz" <?php if (in_array("biz", $tldarray)) {  ?> checked="checked" <?php  } ?> />biz
    <input type="checkbox" name="tld[]" value="org" <?php if (in_array("org", $tldarray)) {  ?> checked="checked" <?php  } ?> />org
    <input type="checkbox" name="tld[]" value="asia" <?php if (in_array("asia", $tldarray)) {  ?> checked="checked" <?php  } ?> />asia


    <input type="submit" name="check" value="Check"/>
</form> 
</body>
</html> 

parte php responsável por fazer a pesquisa direto com seu api do reseller club

<?php

$api_user_id="seuid";
$api_key="sua chave ou sua senha";


function domainCallAPI($method, $url, $data = false) {
    $curl = curl_init();

    switch ($method) {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);

            if ($data)
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data)
                $url = sprintf("%s?%s", $url, http_build_query($data));
    }

    // Optional Authentication: - Need not touch this
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "username:password");
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    return curl_exec($curl);
}
?>

<?php
//Example Call to see available domains and suggestions
$url = '';
$tldarray[] = "";
$domainname="";
if (isset($_POST['check']) && isset($_POST['domain']) && $_POST['domain'] != "" && isset($_POST['tld']) && $_POST['tld'] != "") {

    $domainname = $_POST['domain'];
    $tld = "";
    $i = 0;
    foreach ($_POST['tld'] as $arrayitem) {
        $tld.='&tlds=' . $arrayitem;
        $tldarray[$i] = $arrayitem;
        $i++;
    }

    $url = 'https://test.httpapi.com/api/domains/available.json?auth-userid=' . $api_user_id . '&auth-password=' . $api_key . '&domain-name=' . $domainname . $tld . '&suggest-alternative=true';
    $data = "";
    $data = domainCallAPI('GET', $url, $data);
    $datajson = json_decode($data, TRUE);
    $fulldomainname = "";
    //  $flag=0;
    foreach ($tldarray as $arrayitem) {

        $fulldomainname = $domainname . "." . $arrayitem;
        echo '<br/>' . $fulldomainname;
        if ($datajson[$fulldomainname]["status"] == "available") {
            echo '    Available';
            // $flag=1;
        } else {
            echo '    Not Available <br/>';
        }
    }
    // Domain Suggestions
    $stack = array("");
    $i = 0;
    foreach ($datajson[$domainname] as $sugdomain => $sugtld) {
        // echo $sugdomain.'.'.$tld;

        $stack[$i] = $sugdomain;
        $i++;
    }
    echo '<br/>Sugg names : <br/>';
    $i = 0;
    foreach ($stack as $value) {
        foreach ($datajson[$domainname][$value] as $sugdomain => $sugtld) {
            if ($datajson[$domainname][$value][$sugdomain] == "available") {
                echo $value . '.' . $sugdomain;
                echo '<br/>';
                $i++;
                if ($i == 7) {

                    break;
                }
            }
        }

        if ($i == 7) {

            break;
        }
    }
    // domain suggestions end
}
 elseif (isset($_POST['check'])){

    if(!isset($_POST['tld'])){
      echo '<br/> Tick Your Domain';

    }
     if( !isset($_POST['domain']) || $_POST['domain'] =="" ){
        echo '<br/> Type Domain Name';     
    }else{
        $domainname=$_POST['domain'];
    }
}
?>

faz a pesquisa normalmente e ainda da sugestões 

lembrando para funcionar é necessário adicionar o ip do site para uso do Api na sua conta Reseller Club que atualiza o ip a em torno de 30 minutos.

espero que sirva para outras pessoas assim como serviu muito bem pra mim.

 

Ricardo


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Do you agree with our terms?