Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/03/2005, 21:06
kez0
 
Fecha de Ingreso: enero-2004
Mensajes: 431
Antigüedad: 22 años, 9 meses
Puntos: 6
Subdominios desde PHP

Veran tengo el siguiente script el cual si crea la carpeta y el subdominio pero no crea el archivo index.php

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

$host = "miwebsite.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($fp, 4096); }
//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']."/", 0777);  // took me forever to figure out the chmod line
$fp = fopen("/".$_POST['subdomain']."/index.php","a");
if(!
$fp) {
   exit;
}
$url = $_POST['redsite'];
$html = "<? Header'Location: ".$url."'); ?>";
$stringtowrite = $html;
fwrite($fp, $stringtowrite);
fclose($fp);

?>
Error que muestra:

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

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