The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP script to change users email passwords without logging into cPanel

Discussion in 'cPanel Developers' started by pinepapplepete, Jun 17, 2008.

  1. pinepapplepete

    pinepapplepete Registered

    Joined:
    Jun 16, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hey Guys...

    I am trying to write a HTML and PHP script so that I can change users email passwords with out logging into cpanel. This is what my PHP looks like so far.

    <?php

    $username = ($_POST['username']);
    $password = ($_POST['password']);
    $cpaneldomain = ($_POST['cpaneldomain']);
    $email = ($_POST['email']);
    $emaildomain = ($_POST['emaildomain']);
    $newpass = ($_POST['newpass']);
    $quota = ($_POST['quota]);
    file("http://$username:$password@$cpaneldomain:2082/frontend/x3/mail/dopasswdpop.html?email=$email&domain=$emaildomain&quota=$quota&password=$newpass");

    ?>

    This works great. However I would like to make it so that I don't have to enter
    the users quota. What function / how could I call upon the original email quota that is already set? If I do not enter a quota amount it sets the users quota to nill.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    First, it's a bad idea to call URLs directly to achieve functionality available via the APIs.

    Here's the API1 function you're ultimately calling:

    Code:
    <cpanel Email="passwdpop($FORM{'email'},$FORM{'password'},$FORM{'quota'},$FORM{'domain'})">
    Just call this API1 function via the XML-API and your script will work regardless of what theme is set for the cPanel interface.

    Note, as you are creating an email address - cPanel/WHM expects a quota. If you do not want to do this manually, simply program your script to automatically pass a pre-determined quota to the API if you do not explicitly state one when calling the script.

    If you need any help with programming this to work with our APIs, please let me know and I'll help you with that :).
     
  3. SIFE

    SIFE Registered

    Joined:
    Jun 21, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    is there any documentation for APIs Cpanel ?
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    We have some documentation on our website at http://www.cPanel.net/plugins/devel

    However, if you ever need help with anything related to APIs (learning if an API exists etc.) - just drop me an email to sales@cpanel.net
     
  5. SIFE

    SIFE Registered

    Joined:
    Jun 21, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    first thx for tending ,i see the link above but he doesn't show example in php , can you pls show me how to use it in php (one ex is enough )or guide me to subject talking about .
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Basically there's 2 components. First, hooking your script up to the XML API to which there are many PHP code samples up on this forum. Just do a search.

    - This thread references several other threads for using the XML-API from PHP
    - One individual wrote a PHP wrapper for the XML API.
    - Someone wrote some sample code calling curl

    Second, calling API1 from the XML API, a sample of which is at:

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

    As this is an XML API, we abstract many of our examples to XML in the official documentation.
     
Loading...

Share This Page