Community Forums
Connect with us on LinkedIn
  
+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    5

    Default Questions

    Hello
    Can create a database and add user , Change Permissions to Directories and add Password Protect to Directories by useing php ?

    if yes , how ?
    Note I am not root user
    Last edited by S P E E D; 06-13-2011 at 05:04 AM.

  2. #2
    Member
    Join Date
    Aug 2008
    Location
    Uruguay
    Posts
    55
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Questions

    I do not understand very well what you want. But if you are trying to create a db with users on it change perms and set password protected directories you can do it using you panel.

    Check the documentation here:

    MySQL Databases
    File Manager
    Password Protect Directories

    Hope this info can help you.

    Cya.

  3. #3
    Member
    Join Date
    Jun 2011
    Posts
    5

    Default Re: Questions

    Quote Originally Posted by fi77i View Post
    I do not understand very well what you want. But if you are trying to create a db with users on it change perms and set password protected directories you can do it using you panel.

    Check the documentation here:

    MySQL Databases
    File Manager
    Password Protect Directories

    Hope this info can help you.

    Cya.
    i want do it , by php not cpanel

  4. #4
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: Questions

    Hi SPEED,

    If you're trying to make an application, script, or web application on your site, you should probably use the PHP XML-API client class to make cPanel API calls (documentation for using the XML/JSON-API interface for cPanel APIs).

    If you're writing a cPanel Plugin or an application that lives within a cPanel theme directory, you can use LivePHP to make cPanel API calls

    fi77i is referencing the API calls that you will use when requesting cPanel to perform the manipulations that you mention.

    There should be plenty of forum threads related to using the XML-API client class for MySQL database management. There's also a blog article that discusses using the XML-API client class in a script (note, the article link to the full example is broke, but you can find the full example it here)

    Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  5. #5
    Member
    Join Date
    Jun 2011
    Posts
    5

    Default Re: Questions

    Quote Originally Posted by cPanelDavidN View Post
    Hi SPEED,

    If you're trying to make an application, script, or web application on your site, you should probably use the PHP XML-API client class to make cPanel API calls (documentation for using the XML/JSON-API interface for cPanel APIs).

    If you're writing a cPanel Plugin or an application that lives within a cPanel theme directory, you can use LivePHP to make cPanel API calls

    fi77i is referencing the API calls that you will use when requesting cPanel to perform the manipulations that you mention.

    There should be plenty of forum threads related to using the XML-API client class for MySQL database management. There's also a blog article that discusses using the XML-API client class in a script (note, the article link to the full example is broke, but you can find the full example it here)

    Regards,
    -DavidN
    yes , i trying to make an application php can add db and user
    but Question can use PHP XML-API client class and i don't have root access

  6. #6
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: Questions

    Yes, you can use the cPanel account password. When authenticating as a cPanel user, you need to use port 2083 (ssl) or 2082 (non-ssl).

    PHP Code:
    <?php
    include "xmlapi.php";

    $ip 'my.domain.com';
    $user 'dave';
    $user_pass 'secret!';

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($user,$user_pass);
    $xmlapi->set_port('2083');

    $xmlapi->set_debug(1);  //for debugging

    $cp_account $user;

    $args = array(
        
    'cptest',
    );

    /**
     * This call will create the 'dave_cptest' database because we're working
     * against the 'dave' account.
     */
    $result $xmlapi->api1_query($cp_account'Mysql','adddb',$args);
    ?>
    Regards,
    -DavidN
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  7. #7
    Member
    Join Date
    Jun 2011
    Posts
    5

    Default Re: Questions

    nice , but i want add user to db , and i have another Question

    can change Permissions to file or folder ?

  8. #8
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: Questions

    Yes, you can add a user to a database too. You will first need to create the user with Mysql::adduser. Then you can give that user privileges to the database with Mysql::adduserdb.

    You can change file permission with the API2 Fileman::fileop call. This works for files within your home directory. You cannot change file ownership with an API call.

    -DavidN
    Last edited by cPanelDavidN; 06-16-2011 at 07:13 AM. Reason: typo
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  9. #9
    Member
    Join Date
    Jun 2011
    Posts
    5

    Default Re: Questions

    hi ,
    i used this code but see error apper



    Warning: file_get_contents() [function.file-get-contents]: SSL: The operation completed successfully. in C:\xampp\htdocs\xmlapi.php on line 737

    Warning: file_get_contents() [function.file-get-contents]: SSL: The operation completed successfully. in C:\xampp\htdocs\xmlapi.php on line 737

    Warning: file_get_contents() [function.file-get-contents]: SSL: The operation completed successfully. in C:\xampp\htdocs\xmlapi.php on line 737

    Warning: file_get_contents() [function.file-get-contents]: SSL: The operation completed successfully. in C:\xampp\htdocs\xmlapi.php on line 737

    PHP Code:
    <?php

    /**
     * @author PHPDes7
     * @copyright 2011
     */

    include("xmlapi.php");
    $host "xxx.com";
    $cpuser "cpuser";
    $cppass "cppass";
    $db_name ="dbname";
    $db_user="dbuser";
    $db_pass="dbpassword";

    $xmlapi = new xmlapi($host);
    $xmlapi->set_port(2083);
    $xmlapi->password_auth($cpuser,$cppass);
    $xmlapi->set_debug(1);
    //create database
    print $xmlapi->api1_query($cpuser"Mysql""adddb"$db_name);
    //create user
    print $xmlapi->api1_query($cpuser"Mysql""adduser", array('user' => $db_user,'pass'=> $db_pass));
    //add user to database
    $xmlapi->api1_query($cpuser"Mysql""adduserdb", array(
                        
    'db' => $db_name,
                        
    'user'=> $db_user,
                        
    'SELECT INSERT UPDATE CREATE DELETE ALTER DROP'));  

    ?>

  10. #10
    Member
    Join Date
    Jun 2011
    Location
    Passaic N.J. USA
    Posts
    14
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Questions

    Hello,

    MY Questions Or Request for Advise:

    I am relatively new to using C-panel and WHM (and later soon WHMPHP). I noticed that as a reseller I fet the following warning:
    Warning! You are logged in with the reseller or root password.

    I am basically wondering what I need to be worried about, naturally I have some ideas. I have logged in a "A Reseller" however I do have some of my own domains and websites to migrate over. I currently have access to a standard reseller, a master reseller and an Alpha reseller.

    I imagine that the migration of the websites might be more difficult with the standard reseller, however all the real functions get carried in C-panel it seems. I have set up name servers and and the domains will not be transferred.

    The entire tar archive for about 30 or so domains with about 15 small (mostly WordPress) websites is about 3 Gigabyte and then apparently there is another homedir which is about another GB.

    Just a simple overview of the migration, and can it be done using file manager or is FTP much better. Is there an order to do things, such as mysql databases 1st then files etc.

Similar Threads & Tags
Similar threads

  1. Just A Few Questions! Help Please
    By smoke_kills in forum New User Questions
    Replies: 5
    Last Post: 08-08-2008, 12:29 PM
  2. A few questions
    By peppos in forum New User Questions
    Replies: 0
    Last Post: 06-19-2007, 07:36 AM
  3. Few questions
    By jaymc in forum Data Protection
    Replies: 1
    Last Post: 04-03-2005, 01:12 PM
  4. 2 questions
    By Esr Tek in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 04-11-2003, 08:23 AM
  5. Few questions
    By nkisberg2000 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 03-26-2003, 05:31 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube