Hi,
I am setting up my own affiliate function on my main site. Each affiliate will be able to pick 1 or 20 different templates and they will have their own subdomain off the main site.
My idea is, once the user has finished registering, PHP could ftp to my server and create the directory and upload all the files that are needed for that template. When I say upload I mean copy as they are all on the same physical server.
The scripts I have tried give me errors like
Warning: ftp_mkdir() expects parameter 1 to be resource, null given in /usr/local/home/httpd/vhtdocs/sitename/affiliates.php on line 187
$ftp_server = "ftp.sitename";
$ftp_user = "USER";
$ftp_pass = "PASS";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
// turn on passive mode transfers
ftp_pasv ($conn_id, true) ;
function ftp_putAll($conn_id, $src_dir, $dst_dir) {
$d = dir($src_dir);
while($file = $d->read()) { // do this for each file in the directory
if ($file != "." && $file != "..") { // to prevent an infinite loop
if (is_dir($src_dir."/".$file)) { // do the following if it is a directory
ftp_mkdir($conn_id, $dst_dir."/".$file); // create directories that do not yet exist
ftp_putAll($conn_id, $src_dir."/".$file, $dst_dir."/".$file); // recursive part
} else {
$upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY); // put the files
}
}
}
$d->close();
}
ftp_putAll($login_result, "/usr/local/home/httpd/vhtdocs/template1", "/usr/local/home/httpd/vhtdocs/$username.sitename");
Help is appreciated