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!

WHM Plugin PHP Wrapper

Discussion in 'cPanel Developers' started by KMyers, Oct 15, 2010.

  1. KMyers

    KMyers Member

    Joined:
    May 20, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    151
    Location:
    Miami, Florida
    cPanel Access Level:
    Root Administrator
    Twitter:
    Greetings,
    Is there any way someone can post a simple template to create a WHM plugin using PHP. I am looking for a simple "Hello World" style script?
     
  2. 9xlinux

    9xlinux Well-Known Member

    Joined:
    Dec 20, 2009
    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    66
    cPanel Access Level:
    Root Administrator
    Code:
    #!/usr/bin/perl
    #WHMADDON:HelloWorld:Hello World
    
    use lib '/usr/local/cpanel';
    use Cpanel::cPanelFunctions ();
    use Cpanel::Form            ();
    use Cpanel::Config          ();
    use Whostmgr::HTMLInterface ();
    use Whostmgr::ACLS          ();
    
    print "Content-type: text/html\r\n\r\n";
    
    Whostmgr::ACLS::init_acls();
    if ( !Whostmgr::ACLS::hasroot() ) {
    print "You need to be root...\n";
    exit();
    }
    print "<meta http-equiv=\"refresh\" content=\"0;url=hello.php\">";
    1;
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. d_t

    d_t Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    242
    Likes Received:
    1
    Trophy Points:
    168
    Location:
    Bucharest
    file: /usr/local/cpanel/whostmgr/docroot/cgi/addon_test.php
    Code:
    #!/usr/bin/php -q
    <?
    #WHMADDON:addonupdates:Test php
    echo "Hello World!";
    
    (you shoul chmod +x addon_test.php)

    See also CreatingWhmPlugins < AllDocumentation/AutomationIntegration < TWiki

    @9xlinux that is very unsecure, anyone can access php script directly without any check.
     
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