visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: Passing functions via PHP


By: MirageSF U.S.A.  Date: 09/11/2004 00:00:00  English  Points: 250 Status: Answered
Quality : Excellent
Hi,

How do I pass the createacct function using the following information, to get it to create an account ?

The Cpanel Accounting php module is designed to give programs that need access to create/remove/modify accounts an easy way to implement this in their php program. The general syntax for calling these functions is:
function_name ($host,$user,$accesshash,$usessl,$args);
Example: createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);



For security reasons if you are connecting to a remote server you should set the usessl argument to 1.

You must have the curl+ssl module installed for this to work.



Cpanel Accounting supports the following methods

showversion

Shows what version of WHM the remote server is running.





listaccts

Lists currently active accounts.





listpkgs

Lists packages avalible for creation.




createacct

Creates a new account on the server.




killacct

Terminates an account on the server.




suspend

Suspends an account on the server.




unsuspend

Unsuspends an account on the server.





Below is a sample php program.

#!/usr/local/cpanel/3rdparty/bin/php

<?php
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
$host = "localhost";
$user = "<USERNAME HERE>";
$accesshash = '<REMOTE ACCESS KEY HERE>';

$accts = listaccts($host,$user,$accesshash,0);
print_r($accts);
$pkgs = listpkgs($host,$user,$accesshash,0);
print_r($pkgs);

?>

Cheers
By: VGR Date: 10/11/2004 05:54:00 English  Type : Answer
understood nothing, but use
echo '<pre>';
print_r();
echo '</pre>';

or it won't work
By: Diggie Date: 10/11/2004 19:27:00 English  Type : Assist
<?php
// cpanel settings
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
$host = "localhost";
$user = "<USERNAME HERE>";
$accesshash = '<REMOTE ACCESS KEY HERE>';

// new account
$acctdomain = 'my_domain';
$acctuser = 'test-user';
$acctpass = 'secret';
$acctplan = 'unknown'; // see Accounting.php.inc what should be in here

// create the account
createacct ($host, $user, $accesshash, $usessl, $acctdomain, $acctuser, $acctpass, $acctplan);

// check accounts
$accts = listaccts($host,$user,$accesshash,0);
var_dump($accts);

?>

By: Diggie Date: 10/11/2004 19:29:00 English  Type : Comment
try to login to the support forum on cpanel.net

there is a topic about new users; maybe interesting
By: sweet_aris08 Date: 06/07/2009 15:25:34 English  Type : Comment
<?php
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
$host = "localhost";
$user = "<USERNAME HERE>";
$accesshash = '<REMOTE ACCESS KEY HERE>';

$accts = listaccts($host,$user,$accesshash,0);
print_r($accts);
$pkgs = listpkgs($host,$user,$accesshash,0);
print_r($pkgs);

?>

Cheers
By: VGR Date: 10/11/2004 06:54:00 English Type : Answer
understood nothing, but use
echo '<pre>';
print_r();
echo '</pre>';

or it won't work
By: Diggie Date: 10/11/2004 20:27:00 English Type : Assist
<?php
// cpanel settings
require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
$host = "localhost";
$user = "<USERNAME HERE>";
$accesshash = '<REMOTE ACCESS KEY HERE>';

// new account
$acctdomain = 'my_domain';
$acctuser = 'test-user';
$acctpass = 'secret';
$acctplan = 'unknown'; // see Accounting.php.inc what should be in here

// create the account
createacct ($host, $user, $accesshash, $usessl, $acctdomain, $acctuser, $acctpass, $acctplan);

// check accounts
$accts = listaccts($host,$user,$accesshash,0);
var_dump($accts);

?>

Do register to be able to answer

EContact
browser fav
page generated in 337.988850 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page