Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 16 to 30 of 39
  1. #16
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

  2. #17
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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 ?

  3. #18
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

  4. #19
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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!

  5. #20
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

  6. #21
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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!

  7. #22
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    How can I get the info on how much is the disk space available!

  8. #23
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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

  9. #24
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

  10. #25
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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

  11. #26
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

  12. #27
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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!

  13. #28
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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

  14. #29
    Member
    Join Date
    Dec 2008
    Posts
    31

    Default

    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.

  15. #30
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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.

Similar Threads & Tags
Similar threads

  1. Delete Files/Dirs - API1 and/or API2
    By adelin.feraru in forum cPanel Developers
    Replies: 2
    Last Post: 11-17-2010, 11:00 AM
  2. addforward aPI1 bad args in documentation
    By jcorreia in forum cPanel Developers
    Replies: 2
    Last Post: 03-02-2010, 04:26 AM
  3. XML-API issues with API1 and API2 commands
    By XenomediaBV in forum cPanel Developers
    Replies: 7
    Last Post: 09-14-2009, 11:34 AM
  4. API1 doc?
    By takabanana in forum cPanel Developers
    Replies: 1
    Last Post: 05-20-2009, 04:23 PM
  5. List of all available API1 and API2 modules
    By ck in forum cPanel Developers
    Replies: 1
    Last Post: 04-27-2009, 10:43 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube