Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    56
    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 Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. failvalue

    failvalue Registered

    Joined:
    Sep 7, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    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 Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    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?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Bahram0110

    Bahram0110 Well-Known Member

    Joined:
    Dec 12, 2007
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    56
    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 Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    $res = $cpanel->api2('Email', 'listpopswithdisk');
    print_r($res);
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice