Knowledgebase
Portal Home > Knowledgebase > Hosting Billing Software > AccountLab Plus > ALP - How to add domain search form in your home page
ALP - How to add domain search form in your home page
| Adding Domain Search function (Accountlab Plus)
Below is a script that shows how to use ALP's API to add whois domain search form in your home page. Just copy paste this code and configure the variables, thats all you need to do.
$ALP_URL this should be your alp url. $LIST_OF_TLDS this is the list of tlds that you offer to user.
Code:
<?php /***************************Configure here***********************************/ ////////////////////////////////////////////////////////////////////////////// ///////Usage: Just configure and place this file anywhere in a webserver////// ////////////////////////////////////////////////////////////////////////////// $ALP_URL = 'http://yourdomain.com/alp/'; $LIST_OF_TLDS = array('com','net','org'); $FORCE_ONLY_DOMAIN = true; $lang = array(); $lang['available'] = "<font color=\\'blue\\'>Domain is available for registration.</font>"; $lang["invalid"] = "<font color=\\'red\\'>Domain is invalid.</font>"; $lang["notavailable"] = "<font color=\\'red\\'>Domain is not available.</font>"; $lang["Check"] = "Check"; $lang["Please_wait"] = "Please wait..."; $lang['Continue'] = "Continue..."; $lang['Domain'] = "Domain : "; $lang['Quering'] = "Quering whois servers..."; $lang['only_domain'] = "Register domain only"; $lang['with_hosting'] = "New domain with hosting"; ////////////////////////////////////////////////////////////////////////////// ////////////////////////No need to edit below this line/////////////////////// ////////////////////////////////////////////////////////////////////////////// /****************************************************************************/ ?> <script type="text/javascript" language="javascript"> <!-- var http_request = false; function makeRequest(u) { url = '<?php echo $ALP_URL; ?>info.php?'+u; http_request = false; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } }
if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } http_request.onreadystatechange = makeSelect; http_request.open('GET', url, true); http_request.send(null); }
function makeSelect() { if (http_request.readyState == 4) { if (http_request.status == 200) { s = Trim(http_request.responseText); if(s=='1') { getObj('btn').value = '<?php echo $lang['Continue']; ?>'; document.getElementById('whoisresult').innerHTML = '<?php echo $lang['available']; ?>'; } else if(s=='-1') { getObj('btn').value = '<?php echo $lang['Check']; ?>'; document.getElementById('whoisresult').innerHTML = '<?php echo $lang['invalid']; ?>'; } else { getObj('btn').value = '<?php echo $lang['Check']; ?>'; document.getElementById('whoisresult').innerHTML = '<?php echo $lang['notavailable']; ?>'; } } else { alert('There was a problem with the request.'); getObj('btn').value = '<?php echo $lang['Check']; ?>'; } } else if(http_request.readyState != 0) { document.getElementById('whoisresult').innerHTML = '<?php echo $lang['Quering']; ?>'; getObj('btn').value = '<?php echo $lang['Please_wait']; ?>'; } }
function getObj(objname) { form = document.getElementById('domainCheck'); for(i=0; i<form.length; i++) { if(form[i].name==objname) return form[i]; } return null; }
function tocart() { var EXT; var SLD; var CAT EXT = getObj('ext').value; SLD = getObj('sld').value; <?php if(!$FORCE_ONLY_DOMAIN) { ?> CAT = getObj('cat').options[getObj('cat').selectedIndex].value; <?php } else { ?> CAT = 0; <?php } ?>
if(CAT == 0) var loc=("<?php echo $ALP_URL; ?>index.php?category=0&tld=" + EXT + "&sld=" + SLD); else var loc=("<?php echo $ALP_URL; ?>index.php?tld=" + EXT + "&sld=" + SLD);
this.location.href = loc; } function Trim(STRING){ STRING = LTrim(STRING); return RTrim(STRING); }
function RTrim(STRING){ while(STRING.charAt((STRING.length -1))==" "){ STRING = STRING.substring(0,STRING.length-1); } return STRING; }
function LTrim(STRING){ while(STRING.charAt(0)==" "){ STRING = STRING.replace(STRING.charAt(0),""); } return STRING; } --> </script> <form name="domainCheck" id='domainCheck' style="margin:0; padding:0;" action=""> <?php echo $lang['Domain']; ?> <input name='sld' type='text' id='sld' size='20' value='' /> <select name='ext' id='ext'> <?php foreach($LIST_OF_TLDS as $tld){ ?> <option value='<?php echo $tld; ?>'>.<?php echo $tld; ?></option> <?php } ?> </select> <?php if(!$FORCE_ONLY_DOMAIN){ ?> <select name='cat' id='cat'> <option value='0'><?php echo $lang['only_domain']; ?></option> <option value='1'><?php echo $lang['with_hosting']; ?></option> </select> <?php } ?> <input type="button" name="btn" id='btn' value="<?php echo $lang['Check']; ?>" onclick="javascript:if(this.value!='<?php echo $lang['Please_wait']; ?>')if(this.value=='<?php echo $lang['Check']; ?>')makeRequest('whois=true&bool=1&tld='+getObj('ext').options[getObj('ext').selectedIndex].value+'&sld='+getObj('sld').value);else tocart();" /> <div id="whoisresult"> </div> </form>
Link: http://www.netenberg.com/forum/index.php?topic=5070.0
|
Add to Favourites
Print this Article
|
Also Read