Give Free Domain and WebHosting on cPanel Based Hosting

Well….,Do you already have cPanel Based Hosting? Do you have a lot of unused bandwith by end of the month?or you got unlimited / unmetered bandwith?And still got a lot of web space in your hosting account??

Now, You can share your domain, by giving subdomain for free!i mean your visitor can simply register their desired subdomain under your domain! without hasle for you to login to your cpanel account and register the subdomain for them! Yes correct!you can!!

Here is the interesting part!, There’s Script written by zubrag.com…You may download it here, or visit their web for more and updated information..Or you can simply copy and paste the code below!

<?php

###############################################################
# cPanel Subdomains Creator 1.1
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################
#
# Can be used in 3 ways:
# 1. just open script in browser and fill the form
# 2. pass all info via url and form will not appear
# Sample: cpanel_subdomains.php?cpaneluser=USER&cpanelpass=PASSWORD&domain=DOMAIN&subdomain=SUBDOMAIN
# 3. list subdomains in file. In this case you must provide all the defaults below
#
# Note: you can omit any parameter, except “subdomain”.
# When omitted, default value specified below will be taken
###############################################################

// cpanel user
define(‘CPANELUSER’,'user’);

// cpanel password
define(‘CPANELPASS’,'pass’);

// name of the subdomains list file.
// file format may be 1 column or 2 columns divided with semicilon (;)
// Example for two columns:
//   rootdomain1;subdomain1
//   rootdomain1;subdomain2
// Example for one columns:
//   subdomain1
//   subdomain2
define(‘INPUT_FILE’,'domains.txt’);

// cPanel skin (mainly “x”)
// Check http://www.zubrag.com/articles/determine-cpanel-skin.php
// to know it for sure
define(‘CPANEL_SKIN’,'x’);

// Default domain (subdomains will be created for this domain)
// Will be used if not passed via parameter and not set in subdomains file
define(‘DOMAIN’,”);
/////////////// END OF INITIAL SETTINGS ////////////////////////
////////////////////////////////////////////////////////////////

function getVar($name, $def = ”) {
if (isset($_REQUEST[$name]) && ($_REQUEST[$name] != ”))
return $_REQUEST[$name];
else
return $def;
}

$cpaneluser=getVar(‘cpaneluser’, CPANELUSER);
$cpanelpass=getVar(‘cpanelpass’, CPANELPASS);
$cpanel_skin = getVar(‘cpanelskin’, CPANEL_SKIN);

if (isset($_REQUEST["subdomain"])) {
// get parameters passed via URL or form, emulate string from file
$doms = array( getVar(‘domain’, DOMAIN) . “;” . $_REQUEST["subdomain"]);
if (getVar(‘domain’, DOMAIN) == ”) die(“You must specify domain name”);
}
else {
// open file with domains list
$doms = @file(INPUT_FILE);
if (!$doms) {
// file does not exist, show input form
echo ”
Cannot find input file with subdomains information. It is ok if you are not creating subdomains from file.<br>
Tip: leave field empty to use default value you have specified in the script’s code.<br>
<form method=’post’>
Subdomain:<input name=’subdomain’><br>
Domain:<input name=’domain’><br>
cPanel User:<input name=’cpaneluser’><br>
cPanel Password:<input name=’cpanelpass’><br>
cPanel Skin:<input name=’cpanelskin’><br>
<input type=’submit’ value=’Create Subdomain’ style=’border:1px solid black’>
</form>”;
die();
}
}

// create subdomain
function subd($host,$port,$ownername,$passw,$request) {

$sock = fsockopen(‘localhost’,2082);
if(!$sock) {
print(‘Socket error’);
exit();
}

$authstr = “$ownername:$passw”;
$pass = base64_encode($authstr);
$in = “GET $requestrn”;
$in .= “HTTP/1.0rn”;
$in .= “Host:$hostrn”;
$in .= “Authorization: Basic $passrn”;
$in .= “rn”;

fputs($sock, $in);
while (!feof($sock)) {
$result .= fgets ($sock,128);
}
fclose( $sock );

return $result;
}

foreach($doms as $dom) {
$lines = explode(‘;’,$dom);
if (count($lines) == 2) {
// domain and subdomain passed
$domain = trim($lines[0]);
$subd = trim($lines[1]);
}
else {
// only subdomain passed
$domain = getVar(‘domain’, DOMAIN);
$subd = trim($lines[0]);
}
// http://[domainhere]:2082/frontend/x/subdomain/doadddomain.html?domain=[subdomain here]&rootdomain=[domain here]
$request = “/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd”;
$result = subd(‘localhost’,2082,$cpaneluser,$cpanelpass,$request);
$show = strip_tags($result);
echo $show;
}

?>

I already tried the code, and its does really good job!

But, from my point of view, some changes is needed to re-amend the code, since the visitor who want to register need to fill some information that only you know such..

Input:

Of course you will not give the valuable information to the visitor (your cPanel Username & Password)….

Well, after you downloaded & run the script, you will know what i meant….

But this code is totally awsome!

Thanx to http://www.zubrag.com, its real nice!it has been a long wait till i could find this code..~!

Recent Entries

3 Responses to “Give Free Domain and WebHosting on cPanel Based Hosting”

  1. bantingboy Says:

    erk. not really understand that coding..

  2. CrusheD_LameR Says:

    Hei bantingboy,

    Just download the files, or simply copy and paste the coding, and save it as blabla.php

    Caused the code given above is PHP code.

  3. video hosting Says:

    Enjoying reading your blog. Hard work always pays off.

Leave a Reply