Jump to content

It wont make the ftp account part!!


angelfire

Recommended Posts

THE ISSUE: i found this free sub domain + ftp user creation

script on the internet so i tested it out, It created the sub domain part

then gave me this error when attempting to create the ftp user account

"Subdomain created successfully

There may be some error while creating FTP account."(what does that mean?)

 

THE REASON WHY I WANT THIS SCRIPT FIXED:

I am hosting people and i am so sick and tired of manually creating

the subdomains and ftp accounts for people by hand!

 

Answers To Questions You May Ask:

1. I have Dedicated Hosting

2. I have a cpanel account

3. The scripts is 100% compatible with the domain

4. I want the script fixed so it would work with my cpanel account!

 

here is the code 2 files:

 

code for index.php

 

<?php
/*
This is the example script for cpsubdomain class
*/

?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>cPanel Subdomain Creator</title>
</head>

<body>

<p><b><font size="5">Cpanel Subdomain Creator</font></b></p>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<table border="0" width="52%" style="border-collapse: collapse">
	<tr>
		<td colspan="2">
		<p align="left"><b>Create Sub-domain:</b></td>
	</tr>
	<tr>
		<td style="text-align: right; width: 92px;">
		Sub-domain:</td>
		<td>
		<input type="text" name="subdomain" size="20" style="width: 166px"></td>
	</tr>
	<tr>
		<td style="width: 92px">FTP Password</td>
		<td>
		<input type="text" name="ftppass" size="20" style="width: 166px"></td>
	</tr>
	<tr>
		<td style="width: 92px"></td>
		<td>
		<input type="submit" value="Create New Subdomain" name="create" style="width: 165px"></td>
	</tr>
</table>
</form>
<?php
if(isset($_POST['create'])){
//you can implement some security measure to ensure that the form is submitted from your domain

//include class file
require_once('class.php');

/*
  instanciate class & pass three arguments cpanelusername, cpanelpassword,yourdomainname,cpanelskin
*/


$cpanel=new cpsubdomain("my_user","my_pass","my_site","rvblue"); 

//cpanel username, cpanel password, domain name, cpanel theme
//cpanel theme may be 'x', 'rvblue' etc.
/*
   See following URL to know how to determine your cPanel skin 
  http://www.zubrag.com/articles/determine-cpanel-skin.php 
  if you don't pass cpanelskin argument, default will be x. Thanks to this website.
*/
  
//call create function and you have to pass subdomain parameter

echo $cpanel->createSD($_POST['subdomain']);
echo '<br/>';
//call createFTP method and provide params ftp username,ftp password, quota.
//if quota is not passed or blank, default is 20MB
echo $cpanel->createFTP($_POST['subdomain'],$_POST['ftppass'],"20");
}
?>
</body>

</html>

 

Code for class.php

 

<?php 

//definding main class 
class cpsubdomain{ 
  //declare public variables 
  var $cpuser;    // cPanel username 
  var $cppass;        // cPanel password 
  var $cpdomain;      // cPanel domain or IP 
  var $cpskin;        // cPanel skin. Mostly x or x2. 
   
  //defining constructor 
  function cpsubdomain($cpuser,$cppass,$cpdomain,$cpskin='x'){ 
    $this->cpuser=$cpuser; 
    $this->cppass=$cppass; 
    $this->cpdomain=$cpdomain; 
    $this->cpskin=$cpskin; 

  } 
   

  //function for creating subdomain 
   
  function createSD($esubdomain){ 
      //checking whether the subdomain is exists 
      $subdomain=$esubdomain.".".$this->cpdomain; 
      $path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/subdomain/index.html"; 
    $f = fopen($path,"r"); 
    if (!$f) { 
      return('Can\'t open cPanel'); 
    } 

    //check if the account exists 
    while (!feof ($f)) { 
      $line = fgets ($f, 1024); 
      if (ereg ($subdomain, $line, $out)) { 
        return('Such subdomain already exists. Subdomain Creation aborted.'); 
      } 
    } 
    fclose($f); //close the file resource 
     
     
    //subdomain does not already exist. So proceed to creating it 
    $path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/subdomain/doadddomain.html?domain=".$esubdomain."&rootdomain=".$this->cpdomain; 
    $f = fopen($path,"r"); 
    if (!$f) { 
      return('Can\'t open cPanel.'); 
    } 

    //check if the subdomain added 
    while (!feof ($f)) { 
      $line = fgets ($f, 1024); 
      if (ereg ("has been added.", $line, $out)) { 
        return('Subdomain created successfully'); 
      } 
    } 
    fclose($f); //close the file resource 
    //return success message 
    return "There may be some error while creating subdomain."; 
     
} //end of function

function createFTP($ftpuser,$ftppass,$ftpquota=20)
{
	//login=testing&password=12345&quota=20&homedir=testing
	//for security purpose, I set homedirectory to the same name of ftpuser
	//if you want to provide access to root directory, set $homedir="/"
	$params="login=$ftpuser&password=$ftppass&quota=$ftpquota&homedir=$ftpuser";

	//checking whether the subdomain is exists 
	$ftp=$ftpuser."@".$this->cpdomain; 
	$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/ftp/accounts.html"; 
	$f = fopen($path,"r"); 
	if (!$f) { 
	  return('Can\'t open cPanel'); 
	} 

	//check if the account exists 
	while (!feof ($f)) { 
	  $line = fgets ($f, 1024); 
	  if (ereg ($ftp, $line, $out)) { 
	    return('Such FTP account already exists. FTP Creation aborted.'); 
	  } 
	} 
	fclose($f); //close the file resource 

	//not duplicate FTP account, so proceed to creating it
	$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/ftp/doaddftp.html?$params"; 
    $f = fopen($path,"r"); 
    if (!$f) { 
      return('Can\'t open cPanel.'); 
    } 

    //check if the FTP account added 
    while (!feof ($f)) { 
      $line = fgets ($f, 1024); 
      if (ereg ("was sucessfully created", $line, $out)) { 
        return('The FTP account was created successfully'); 
      } 
    } 
    fclose($f); //close the file resource 
    //return success message 
    return "There may be some error while creating FTP account."; 
}//end of createFTP function

} 

?>

 

If you can help - thank you !

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.