If you’re familiar with Directadmin panel, you should know that there is no way to add multiple domain names to an account at once. So, if a customer has 100 domains, he needs to add them one by one. That takes lots of time and is quite a stupid job. I would like to tell you about several methods that will allow you to add multiple domains at once.
First of all is an intelligent soultion that is named DirectAdmin Bulk Domain and Subdomain Plugin. It is really a great tool if you own a hosting service and need to use this function day by day. The price… hmm… not quite affordable, but for a hosting company I don’t think it is too big. You’re getting an interface and the ability to add as many domains and subdomains as you wish.
If you need to add a list of domains just once, a simple script written in PHP will help you to do this. I will post the code here (it’s not mine, but I consider it to be great)
We need to have a list of domains, PHP with cURL support and a valid login information.
<?
set_time_limit(0);
function get_page ($url,$var,$proxy,$ref)
{
$ch = curl_init();
if(isset($proxy))
curl_setopt ($ch, CURLOPT_PROXY, $proxy);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, “Mozilla/4.0”);
curl_setopt ($ch, CURLOPT_COOKIEJAR, “cookie.txt”);
curl_setopt($ch, CURLOPT_COOKIEFILE,”cookie.txt”);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 400);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $var);
curl_setopt($ch, CURLOPT_REFERER, $ref);
$result = curl_exec ($ch);
curl_close($ch);
return $result;
}$ip=”IP”;
$username=”USERNAME”;
$password=”PASSWORD”;$result=get_page (“http://”.$ip.”:2222/CMD_LOGIN”,”referer=%2FCMD_ADDITIONAL_DOMAINS%3F&username=”.$username.”&password=”.$password,””,”http://”.$ip.”:2222/CMD_ADDITIONAL_DOMAINS?”);
$bufer=””;
$file=fopen(“dom.txt”,”r”); //domains are located here
while(!feof($file))
{
$bufer=fgets($file,100);
$bufer=ereg_replace(“n”, “”, $bufer);
$bufer=ereg_replace(“r”, “”, $bufer);
$result=get_page (“http://”.$ip.”:2222/CMD_DOMAIN”,”action=create&domain=”. $bufer.”&ubandwidth=unlimited&uquota=unlimited&cgi=ON&php=ON”,””,””);
print $bufer.” – “.$result;
}
fclose ($file);?>
What are we doing here? We’re logging into your Directadmin account and adding our domain names one by one. dom.txt is the file that contains the list of domains, and cookie.txt is the file for cookies; it should be writable.
This script really saves lots of time if you need to add more than one domain to an existing account.
Pingback: fix phpscript - ScriptLance Programming Project