Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/03/2005, 15:37
kez0
 
Fecha de Ingreso: enero-2004
Mensajes: 431
Antigüedad: 20 años, 3 meses
Puntos: 6
Subdominios desde php

Bueno veran tengo el siguiente script para krear subdominios:


Código PHP:
<?php
ini_set
('display_errors'1);

$host "algo.com"// domain name
$port 2082//cpanel port (always 2082)
$path "/frontend/rvblue/subdomain/doadddomain.html?domain=".$_POST['subdomain']."&rootdomain=".$host// cpanel subd action

// cpanel login info
$cpaneluser "*****";
$cpanelpass "******";
$authstr "$cpaneluser:$cpanelpass";
//****************************

// Set auth str
$pass base64_encode($authstr);

$fp fsockopen($host$port$errno$errstr$timeout 30);

if(!
$fp){
// error tell us
echo "$errstr ($errno)\n";

}else{

// server request

fputs($fp"POST $path HTTP/1.1\r\n");
fputs($fp"Host: $host\r\n");
fputs($fp"Authorization: Basic $pass \r\n");
fputs($fp"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp"Content-length: ".strlen($poststring)."\r\n");
fputs($fp"Connection: close\r\n\r\n");
fputs($fp$poststring "\r\n\r\n");

while(!
feof($fp)) { fgets($fp4096); }
//close fp - we are done with it
fclose($fp);
}
print 
"Your subdomain ".$_POST['subdomain'].' was created. URL : <a href="http://'.$_POST['subdomain'].'.'.$host.'/">http://'.$_POST['subdomain'].'.'.$host.'</a>';

// The following is the start of the creation of the index.php, it will chmod the directory,
// then create the redirection php file, once done it will have a subdomain and a redirection script

// I finally got this code to work! (below code)
// Note to self - Do not touch this part.
$subdomain $_POST['subdomain'];
chmod("/".$_POST['subdomain']."/"777);  // took me forever to figure out the chmod line
$fp fopen("/".$_POST['subdomain']."/index.php","a");
if(!
$fp) {
  print 
"Error.";
  exit;
}
$url $_POST['redsite'];
$html "<? Header'Location: ".$url."'); ?>";
$stringtowrite $html;
fwrite($fp$stringtowrite);
fclose($fp);

?>

este si krea los subdominios en el CPANEL osea si krea la karpeta y en el cpanel aparece el subdominio pero no krea el archivo index.php ke se supone ke va a redirekcionar al website


El error ke muestra es este:

Warning: chmod(): No such file or directory in /home/usuario/public_html/subdomain.php on line 47

Warning: fopen(/test/index.php): failed to open stream: No such file or directory in /home/usuario/public_html/subdomain.php on line 48
Error
__________________
El que teme preguntar, se averguenza de aprender.

Última edición por kez0; 14/03/2005 a las 13:31