#16 (permalink)  
Old 01-08-2009, 10:02 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
Ok i got this file test.php and it had these functions:
<cpanel PHP="loadvars()">
<cpanel PHP="loadparkeddomains()">
<cpanel PHP="loadsubdomains()">
<cpanel PHP="loaddocroots()">

What other functions exist ?
I want MySQL info so that I can connect to MySQL

Also will a PHP script be allowed to open external files !
like http://ext-url.com/file.zip

I want to store that file in the frontend/x3/myplugin/
I am not aware of any way of retrieving MySQL information for existing accounts. Typically applications will create the MySQL accounts themselves and keep track of the chosen username/passwords for whatever configuration needs to be done for scripts.

As the PHP will be executing as root, you will be able to access external files as well as store files in frontend/x3/myplugin/

Regarding API1/API2 functions that exist (which would typically be within <cpanel ... > tags), there are very many functions. Take a peak at the source code of the x3 theme for inspiration. If you're looking for a specific API function, please let me know.
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 01-08-2009, 12:01 PM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
Yes I am looking for some API functions:
1) Retrieve MySQL info and
2) Creation of MySQL Databases

I mean creation will be allowed if its a root script or will it not be allowed ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 01-08-2009, 12:41 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
Yes I am looking for some API functions:
...
2) Creation of MySQL Databases

I mean creation will be allowed if its a root script or will it not be allowed ?
PHP executes as root for WHM Plug-ins.

If you are incorporating the creation of MySQL databases into a cPanel Plug-in (or a script that uses the XML API), you can use the following API call:

Code:
<cpanel Mysql="adddb(DBName)">
Where DBName is the name of your database.


To create a database user, you can use this API call:

Code:
<cpanel Mysql="adduser(user,pass)">
To grant a database user access to a database, you would use the following API call:

Code:
<cpanel Mysql="adduserdb(db,user,ALTER, CREATEROUTINE, CREATETEMPORARYTABLES, CREATE, DELETE, DROP, SELECT, INSERT, UPDATE, REFERENCES, INDEX, LOCKTABLES, ALL)">
db = the database

user = the database user to grant access to this database

The upper-case parameters refer to individual permissions to apply, ALL representing all permissions.
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 01-09-2009, 02:51 AM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
Thanks thats really awesome
But I will have to check whether the user has not crossed the DB limit with MAXSQL right

Also I wanted to know how should i store a file in the USERS account
X3 is a theme and I wanted to store a file in /home/user/.userplugindata

I know i have harassed you a lot!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 01-09-2009, 09:21 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
Thanks thats really awesome
But I will have to check whether the user has not crossed the DB limit with MAXSQL right
It may be prudent to catch all errors rather than just that possibility. You can do that by reading the contents of <result>...</result> in the XML that is returned. Details of this are in the documentation at:

http://cpanel.net/plugins/xmlapi/cpanel.html

Quote:
Originally Posted by rongup View Post
Also I wanted to know how should i store a file in the USERS account
X3 is a theme and I wanted to store a file in /home/user/.userplugindata

I know i have harassed you a lot!
That's not something that is handled via the APIs. Typically, one would have a script running with root privileges handling the storing of files into user accounts, being sure to set ownership and permissions as needed.
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #21 (permalink)  
Old 01-09-2009, 09:47 AM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
Sorry I forgot to mention that the FILES will be located at:
/usr/local/cpanel/whostmgr/docroot/cgi/plugin/enduser

The enduser will be redirected VIA a link file for all situations to:
/usr/local/cpanel/whostmgr/docroot/cgi/plugin/enduser

In such a situation also the CPANEL parser works but how should I store the file in /home/user/.plugdata
this is because the CPAnel parser executes it as some RANDOM file!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22 (permalink)  
Old 01-20-2009, 05:59 AM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
How can I get the info on how much is the disk space available!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 01-22-2009, 09:36 AM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
Pleaaaaaaaaaaaase help me,
I am so close to getting my thing done. I want the following INFO:
1) How to find the available disk space remaining and load it in PHP so that I can check that we dont exceed the space remaining
2) How to know the MYSQL server e.g. localhost or as the case may be!

Please help me.
I need this info to complete the PLUGIN I make
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24 (permalink)  
Old 01-22-2009, 11:14 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
Pleaaaaaaaaaaaase help me,
I am so close to getting my thing done. I want the following INFO:
1) How to find the available disk space remaining and load it in PHP so that I can check that we dont exceed the space remaining
2) How to know the MYSQL server e.g. localhost or as the case may be!

Please help me.
I need this info to complete the PLUGIN I make
1. Are you referring to disk space remaining for a cPanel user, Reseller or on the server?

2. Offhand, I'm not aware of how to retrieve the MySQL server's location or if it is using a remote MySQL server. Typically, localhost will work. However, this wouldn't work in a setup utilizing remote MySQL.
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25 (permalink)  
Old 01-23-2009, 01:05 AM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
1) I am referring to disk space remaining for a cPanel user

Also could you give me a link to a list of PHP cPanel functions that load all the USER DATA in PHP variables.
The API and API2 functions need to be called using <?cp ?>.
1) I want a list of functions called via <cpanel PHP="function()"> and if can be called directly via PHP functions then it would be the BEST
2) <cpanel MySQL="adddb('asasaas')"> is not working and no database is created

Thanks for the help

Last edited by rongup; 01-23-2009 at 08:53 AM. Reason: More info
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26 (permalink)  
Old 01-23-2009, 10:39 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
1) I am referring to disk space remaining for a cPanel user
The following URL will provide information about disk space consumed and their allocated disk space. You can write your own code to process this to provide the disk space remaining.

Code:
/xml-api/cpanel?user=username&xmlin=<cpanelaction><module>StatsBar</module><func>stat</func><apiversion>2</apiversion><args><display>diskusage</display></args></cpanelaction>
Where username is the cPanel user.

Quote:
Originally Posted by rongup View Post
Also could you give me a link to a list of PHP cPanel functions that load all the USER DATA in PHP variables.
The API and API2 functions need to be called using <?cp ?>.
1) I want a list of functions called via <cpanel PHP="function()"> and if can be called directly via PHP functions then it would be the BEST
2) <cpanel MySQL="adddb('asasaas')"> is not working and no database is created

Thanks for the help
Are you executing this code as part of the cPanel interface via a custom theme or skin? Or via an external PHP script?

If it is an external PHP script, you will need to use the XML-API to interface with API1 as described at:

http://cpanel.net/plugins/xmlapi/cpanel.html

The <cpanel> and <cp?> tags are for use within the cPanel interface itself. They are not functional outside of the cPanel interface, hence we have the XML API to allow you to work around this limitation of API1 and API2.
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27 (permalink)  
Old 01-23-2009, 12:05 PM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
All scripts are within the CPanel theme frontend/x3/plugin
I want the functions that can give me the required data as I posted:
1) I want a list of functions called via <cpanel PHP="function()"> and if can be called directly via PHP functions then it would be the BEST
2) <cpanel MySQL="adddb('asasaas')"> is not working and no database is created

The file is for e.g.:
http://domain:2082/frontend/x3/plugin/index.php

I want to create a Database and check the available space remaining of a ENDUSER in frontend/x3/plugin/index.php
I did a research and learnt how to call API and API2 functions that need to be called using <?cp ?> from a PHP File within cPanel interface itself.
Using <?cp ?> I get the output in HTML/Text Format.
But I couldnt find any way to store the output in PHP Variables

Also the function <cpanel MySQL="adddb('asasaas')"> is not working within the cPanel interface itself.

Please help.
I hope I have clarified the problem and the environment I am working in!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28 (permalink)  
Old 01-23-2009, 01:54 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
All scripts are within the CPanel theme frontend/x3/plugin
I want the functions that can give me the required data as I posted:
1) I want a list of functions called via <cpanel PHP="function()"> and if can be called directly via PHP functions then it would be the BEST
I spoke to our quality assurance team member who handles API issues about this. In his research he found that the functions you provide is the complete list of functions available for <cpanel PHP="function()">.

Quote:
Originally Posted by rongup View Post
2) <cpanel MySQL="adddb('asasaas')"> is not working and no database is created

The file is for e.g.:
http://domain:2082/frontend/x3/plugin/index.php

I want to create a Database and check the available space remaining of a ENDUSER in frontend/x3/plugin/index.php
I did a research and learnt how to call API and API2 functions that need to be called using <?cp ?> from a PHP File within cPanel interface itself.
Using <?cp ?> I get the output in HTML/Text Format.
But I couldnt find any way to store the output in PHP Variables

Also the function <cpanel MySQL="adddb('asasaas')"> is not working within the cPanel interface itself.

Please help.
I hope I have clarified the problem and the environment I am working in!
As far as your API call goes, case sensitivity is important. It should be Mysql (sic.), not MySQL.

If you're looking to pass the values returned by our APIs to a PHP script, there are various ways of doing so. However, I believe the most elegant way of doing this in PHP would be to use our LivePHP framework, which you can learn about at:

http://httpupdate.cpanel.net/cpanels...php/README.TXT
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #29 (permalink)  
Old 01-23-2009, 11:49 PM
Registered User
 
Join Date: Dec 2008
Posts: 31
rongup is on a distinguished road
The <cpanel Mysql="adddb('test')"> is now working (Thanks for correcting the case sensitive mistake)
1) However <cpanelif $CPERROR{'mysql'}> is not working even if the database is not created e.g. There is already an existing database rongup_test.
Now I create a database using :
<cpanel setvar="dprefix=../">
<cpanel Mysql="adddb('test')">

If there are errors it should be in this variable:
<cpanel print="$CPERROR{'mysql'}">
(I got this from the addb.html page)
But it prints no errors

2) I checked that Live PHP framework you posted above (even before you posted). But I refrained from using it as IT Had comments that it is going to be changed in the future and IT should be used only with the CPANEL VERSION it came with. Here is the Comments:
PHP Code:
# cpanel12 - cpanel.pl             Copyright(c) 1997-2007 cPanel, Inc.
#                                 All rights Reserved.
# copyright@cpanel.net                 http://cpanel.net

#
#  You are free to include this module in your program as long as it is for use with cPanel.
#  This module is only licensed for use with the version of cPanel it is distributed with.
#
#  The backend xml api is going to change.  If you ignore this message you will find
#  that this module will not work in future versions.  This module will be updated
#  if the backend xml api changes.  We will make all efforts to provide backwards
#  compatibility, but if you do not use this module with any version of cpanel other then
#  the one it is distributed with the results could be disasterous.
#  
#  That being said this module should insulate you from those changes if you use its api
#  instead of the cpanel xml api which it translates to. 
#
#  FOR THE AVOIDANCE OF DOUBT: MAKE SURE YOU ONLY USE THIS MODULE WITH THE VERSION OF CPANEL
#  THAT IT CAME WITH
#

So is it going to change every now and then with a new version of Cpanel or the output given by it will remain the same.
Also I will HAVE to RENAME 100's of pages to .LIVE.PHP which will not look so cool! Is there any other way of calling API2 from PHP or LivePHP is the stable one and can be used

3) Also I am having problems that <cpanel Mysql="adddb('.$dbname.')"> is executed before PHP is executed.
So the database user_dbname is created instead of the value in $dbname i.e a PHP variable!

Last edited by rongup; 01-25-2009 at 11:24 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30 (permalink)  
Old 01-26-2009, 10:52 AM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 8,117
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by rongup View Post
The <cpanel Mysql="adddb('test')"> is now working (Thanks for correcting the case sensitive mistake)
1) However <cpanelif $CPERROR{'mysql'}> is not working even if the database is not created e.g. There is already an existing database rongup_test.
Now I create a database using :
<cpanel setvar="dprefix=../">
<cpanel Mysql="adddb('test')">

If there are errors it should be in this variable:
<cpanel print="$CPERROR{'mysql'}">
(I got this from the addb.html page)
But it prints no errors

2) I checked that Live PHP framework you posted above (even before you posted). But I refrained from using it as IT Had comments that it is going to be changed in the future and IT should be used only with the CPANEL VERSION it came with. Here is the Comments:
PHP Code:
# cpanel12 - cpanel.pl             Copyright(c) 1997-2007 cPanel, Inc.
#                                 All rights Reserved.
# copyright@cpanel.net                 http://cpanel.net

#
#  You are free to include this module in your program as long as it is for use with cPanel.
#  This module is only licensed for use with the version of cPanel it is distributed with.
#
#  The backend xml api is going to change.  If you ignore this message you will find
#  that this module will not work in future versions.  This module will be updated
#  if the backend xml api changes.  We will make all efforts to provide backwards
#  compatibility, but if you do not use this module with any version of cpanel other then
#  the one it is distributed with the results could be disasterous.
#  
#  That being said this module should insulate you from those changes if you use its api
#  instead of the cpanel xml api which it translates to. 
#
#  FOR THE AVOIDANCE OF DOUBT: MAKE SURE YOU ONLY USE THIS MODULE WITH THE VERSION OF CPANEL
#  THAT IT CAME WITH
#

So is it going to change every now and then with a new version of Cpanel or the output given by it will remain the same.
Also I will HAVE to RENAME 100's of pages to .LIVE.PHP which will not look so cool! Is there any other way of calling API2 from PHP or LivePHP is the stable one and can be used

3) Also I am having problems that <cpanel Mysql="adddb('.$dbname.')"> is executed before PHP is executed.
So the database user_dbname is created instead of the value in $dbname i.e a PHP variable!
An alternate way of integrating PHP is to use .cpphp or .phpcp extensions on your files. The .cpphp extension means that the file is parsed for API1/API2 first and then PHP is executed. This is useful if you want to only have API1/API2 functions return values to your PHP script. The .phpcp extension means that PHP is executed first before the API1/API2 code is executed. This is useful if you only want to have values from your PHP be used in API1/API2 calls.

The $CPERROR{'mysql'} code you're using, is that within a Live PHP file?

As for the message in the file, many of our newer APIs have comments indicating they are for cPanel 12. However, the intent of the message is to not copy this file to another cPanel/WHM server (e.g. a server still running cPanel 10) and expect it to continue functioning properly.
__________________
Need technical assistance? You can find your best avenue for support at: http://support.cPanel.net
-- cPanel David G., Lead Forum Administrator & cPanel Technical Sales Representative
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:46 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© cPanel Inc