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.

cPanel Plugin ==> Hello World?

Discussion in 'cPanel Developers' started by Bahram0110, Aug 16, 2011.

  1. Bahram0110

    Bahram0110 Well-Known Member

    Joined:
    Dec 12, 2007
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Hello guys
    Is there any hello world plugin for cPanel (Not whm)?
    I want to make a php plugin for cPanel but documentation is not so clear.
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    For this sort of thing, I recommend using the LiveAPI, a basic branded example can be seen below.

    docs: LivePHP - PHP Class for cPanel
    PHP:
    <?php

    include("/usr/local/cpanel/php/cpanel.php");


    $cpanel = &new CPANEL();

    $res $cpanel->api1('Branding''include', array('stdheader.html') );
    print 
    $res['cpanelresult']['data']['result'];
    ?>
    <div class="body-content">
    Hello World!
    </div>
    <?php
    $res 
    $cpanel->api1('Branding''include', array('stdfooter.html') );
    print 
    $res['cpanelresult']['data']['result'];
    $cpanel->end();
    place contents into /usr/local/cpanel/base/frontend/x3/MyApp/branded.live.php
    then visit $yourserversip:2083/frontend/x3/MyApp/branded.live.php

    and you will see the page.

    Now if you want to add an icon, you visit cPanel Plugins - Developer and use /MyApp/branded.live.php as your access URL.

    If you have more questions, please let me know
     
  3. failvalue

    failvalue Registered

    Joined:
    Sep 7, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello Matt,

    I found your above post very helpful. I have a small problem though, the first time I click on the related icon once im logged in to cpanel the error below is displayed. If I press back on the browser and click the icon again everything works and stays working until I log out.

    Hope you can point me in the right direction.

    Regards,
    Colin

    Warning: fsockopen() [function.fsockopen]: unable to connect to unix:///home/ctest1/.cpanel/php-connector-rCpavdsTD_.sock:-1 (Connection refused) in /usr/local/cpanel/php/cpanel.php on line 75

    Fatal error: Uncaught exception 'Exception' with message 'There was a problem connecting back to the cPanel engine. Make sure your script ends with .live.php or .livephp' in /usr/local/cpanel/php/cpanel.php:78 Stack trace: #0 /usr/local/cpanel/base/frontend/x3/MyApp/lhtutorials.live.php(3): CPANEL->__construct() #1 {main} thrown in /usr/local/cpanel/php/cpanel.php on line 78
     
  4. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    That's.. very unusual, was there anything in the error_log when this happens?

    is it a consistent problem?
     
  5. Bahram0110

    Bahram0110 Well-Known Member

    Joined:
    Dec 12, 2007
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Hello,
    Thank you dear cPanelMatt for your reply.

    Can you send a simple api2 example too?
    I can not find any way to use api2 with php

    Regards
     
    #5 Bahram0110, Sep 16, 2011
    Last edited: Sep 16, 2011
  6. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    $res = $cpanel->api2('Email', 'listpopswithdisk');
    print_r($res);
     
Loading...

Share This Page