Hola. Tengo un sistema automatizado para crear subdominios por medio de un registro de usuarios con PHP y mySQL. Todo marcha bien, pero solo por un detalle que todas las carpeta se crean en la raíz:
Código:
/home/userhost/public_html/$id_usuario_subdominio
y lo que deseo es personalizar osea que la carpeta del subdonio vaya en otra carpeta, así de esta manera:
Código:
/home/userhost/public_html/$carpeta_categoria/$id_usuario_subdominio
Mi sistema se basa en este script:
Código PHP:
Ver originaldefine('INPUT_FILE','domains.txt'); // domain;sd 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"])) { $doms = array( getVar
('domain', DOMAIN
) . ";" . $_REQUEST["subdomain"]); if (getVar
('domain', DOMAIN
) == '') die("You must specify domain name"); }
else {
$doms = @file(INPUT_FILE
); if (!$doms) {
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>";
}
}
// create subdomain
function subd($host,$port,$ownername,$passw,$request) {
if(!$sock) {
print('Socket error');
}
$authstr = "$ownername:$passw";
$in = "GET $request\r\n";
$in .= "HTTP/1.0\r\n";
$in .= "Host:$host\r\n";
$in .= "Authorization: Basic $pass\r\n";
$in .= "\r\n";
$result .= fgets ($sock,128); }
return $result;
}
foreach($doms as $dom) {
if (count($lines) == 2) { $domain = trim($lines[0]); }
else {
$domain = getVar('domain', DOMAIN);
}
$request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd";
$result = subd('localhost',2082,$cpaneluser,$cpanelpass,$request);
echo $show;
}
Gracias por todo.