Bahram0110

Well-Known Member
Dec 12, 2007
45
0
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.
 

MattDees

Well-Known Member
Apr 29, 2005
416
1
243
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
 

failvalue

Registered
Sep 7, 2011
3
0
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
 

Bahram0110

Well-Known Member
Dec 12, 2007
45
0
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
 
Last edited: