william321

Member
Jan 2, 2004
16
0
151
New Zealand
Hi all

i have developing a custom billing system but a problerm has a rose that i cant seem to fix which one is the creation of the accounts for some reason the createactt functions disaplys a login form and an error about cpanelerror function not being valid and this is my code.

PHP:
$status = createacct($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
print $status;
Not sure why its asking me to login but it does for some reason displays a form for some reason anyone can help me here i here is the rest of my code i have

PHP:
if(isset($_POST['GetAccount']))
				{
					//
					$cpuser=$_POST['cpuser'];
					$cppass=$_POST['cppass'];
					if($cpuser || $cppass)
					{
						//
						$message = "Somone has Ordered Hosting from you.";
				//
						mail("$owneremail", "Thank you!", $message, "From: $from");
						echo "Thanks for Ordering your Hosting Account will be created shortly";
						$acctuser=$cpuser;
						$acctpass=$cppass;
						//Get Package Data
						$acctplan=get_hpid_by_id($hpid);
						$acctdomain=getplanoninvoice($invoice);		
						//
						$host = "localhost";
						$user = "root";
						$usessl = 0;
						$acctdomain = "demonichosting.com";
						$accesshash = 'accesshash here';
						require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
						$status = createacct($host,$user,$pass,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
						print $status;
						echo "Result is";
						echo $result;
						//
					}
					//
				}
				else
				{
					?>
					<fieldset>
					<legend>Before You Continue with your Order please Enter your Cpanel Login Information below.</legend>
					<table>
					<form method="post" action="">
							<tr>
								<th>Cpanel username</th>
								<th><input type="text" name="cpuser" maxlength="8" /></th>
							</tr>
							<tr>
								<th>Cpanel Password:</th>
								<th><input type="password" name="cppass" /></th>
							</tr>
							<tr>
								<th><input type="submit" value="Generate Account" name="GetAccount" /></th>
							</tr>
							</table></form>	
					</fieldset>				
				<?
				}
			}
What am i doing wrong anything else i can do to make it autoamtically create the account?
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
You may want to use the more robust XML-API in favor of the old WHM API. However, typically a login form means that the script is not properly authenticating. That cpanelerror message goes beyond my technical knowledge though.
 
Last edited:

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
79
458
cPanel Access Level
Root Administrator
Hi all

i have developing a custom billing system but a problerm has a rose that i cant seem to fix which one is the creation of the accounts for some reason the createactt functions disaplys a login form and an error about cpanelerror function not being valid and this is my code.

Please post the exact error message being returned. Also, what is your full cPanel version number?
 

kalipiev

Member
Feb 12, 2008
21
0
51
Hello all,

I have problem with account creation too. It's not same with this one but I don't want to open another thread. I have some problems with scripts account creation. When I use root password I succeed to create the account but I don't get response from server that the account has been made.(result, ip & response are empty). Also the account is created with package 'default' but not with that I put in the script URL?
I am not very sure but I think that root can create accounts only with default package and cannot do it with reseller_whatever.

Please assist me.

Cheers!
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Hello all,

I have problem with account creation too. It's not same with this one but I don't want to open another thread. I have some problems with scripts account creation. When I use root password I succeed to create the account but I don't get response from server that the account has been made.(result, ip & response are empty). Also the account is created with package 'default' but not with that I put in the script URL?
I am not very sure but I think that root can create accounts only with default package and cannot do it with reseller_whatever.

Please assist me.

Cheers!
Does the same thing happen you try to create an account using a package owned by root?
 

kalipiev

Member
Feb 12, 2008
21
0
51
Yes, same thing with package owned by root. This time I get another error:
0 Sorry that username (XXXXXX) is taken. Check /etc/passwd

But the account is created with default package.

Please help.

Cheers!
 

kalipiev

Member
Feb 12, 2008
21
0
51
Thanks. That seems to work.

Would you please give me a link where I can find information for all the arguments?

Cheers
 

kalipiev

Member
Feb 12, 2008
21
0
51
Just last question:

I am very sure that it works before with msel? Why it's not working now? Due to upgrade reasons or anything else?

Will plan argument work with older cpanel/WHM versions?

Best regards.
 

kalipiev

Member
Feb 12, 2008
21
0
51
Is there anybody who can answer my questions?

I am very sure that it works before with msel? Why it's not working now? Due to upgrade reasons or anything else?

Will plan argument work with older cpanel/WHM versions?

Cheers
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Calling :2086/scripts and :2086/scripts2 are not recommended and are subject to breaking as these are not APIs.

If you wish to create accounts programmatically, please use the XML-API as Kenneth suggested.
 

kalipiev

Member
Feb 12, 2008
21
0
51
Hello again,

I have another issue with account creation. I am using this code
PHP:
$whm_url  = $this->proto . $this->whm_user . ":" . $this->whm_password . "@" . $this->whm_server . ":" . $this->whm_port . "/scripts/wwwacct?" . $string;
ob_start();
$response = join("", file($whm_url));
ob_end_clean();
$whm_url is the correct URL. I tried to run it in my browser and it works fine, but through PHP I can't get server response.
I mean var_dump($response); returns bool(false).

Any suggestions?

Cheers,
 

kalipiev

Member
Feb 12, 2008
21
0
51
Hello again,

I have another issue with account creation. I am using this code
PHP:
$whm_url  = $this->proto . $this->whm_user . ":" . $this->whm_password . "@" . $this->whm_server . ":" . $this->whm_port . "/scripts/wwwacct?" . $string;
ob_start();
$response = join("", file($whm_url));
ob_end_clean();
$whm_url is the correct URL. I tried to run it in my browser and it works fine, but through PHP I can't get server response.
I mean var_dump($response); returns bool(false).

Any suggestions?

Cheers,

Did you read this post?