cPanel plugin with PHP code 500 error
I have followed these instructions here:
and here
I managed to get the .tar.gz file with:
Unique identifier: Wordpress_Staging
Name: Wordpress Staging
Group: Ibertrix (new group)
Priority: 99
URI: ibertrix/wpstaging/index.php
URI target: (empty)
Icon: a 48x48 png file
In index.php I put this code
I get a 500 error. Where I can debug why is not working? /var/log/apache2/error_log doesn"t show anything I forgot! I use version 68
header( "Page Heading" ); // Add the header.
?>
uapi( // Get domain user data.
'DomainInfo', 'domains_data',
array(
'format' => 'hash',
)
);
?>
footer(); // Add the footer.
$cpanel->end(); // Disconnect from cPanel - only do this once.
?>
I get a 500 error. Where I can debug why is not working? /var/log/apache2/error_log doesn"t show anything I forgot! I use version 68
-
Hi @Miguel G Is anything noted regarding the plugin's errors in the cPanel error log? It's located at: /usr/local/cpanel/logs/error_log
0 -
I get this error: PHP Fatal error: Uncaught exception 'RuntimeException' with message 'There was a problem fetching the env variablecontaining the path to the socket' in /usr/local/cpanel/php/cpanel.php:146 Stack trace: #0 /tmp/cpanel_phpengine.1535738975.31783VtVl8U9FBY(3): CPANEL->__construct() #1 {main} thrown in /usr/local/cpanel/php/cpanel.php on line 146
0 -
Hi @Miguel G Based on this [QUOTE]Your backend code should go into /usr/local/cpanel/base/frontend/paper_lantern/
From: And some other threads () this error seems to indicate that your code is in the wrong location. Thanks!0 -
The code is in /usr/local/cpanel/base/frontend/paper_lantern/ibertrix/wpstaging/index.php 0 -
HI @Miguel G How are you testing this? Since it's LiveAPI you'll need to test it through the UI Thanks! 0 -
Through the Cpanel UI, I just click on the plugin 0 -
Hi @Miguel G My only suggestion would be to look at the code used for the plugin. I tested the installation steps which seem to work without issue. What it sounds like may not have been done was the second tar.gz: Per the instructions here: The compressed infection_scanner.tar.gz file should then be included with your backend code (your plugin/app) in another tar file (used for distribution).
0 -
What do you mean with the second .tar.gz? I don"t quite get you. I generate the .tar.gz and install it like this: /usr/local/cpanel/scripts/install_plugin /var/cpanel/cpanel_plugin_generator/wpstaging.tar.gz
Any PHP sample code I can use? I just took a random PHP example I found on the internet. I was just testing how to create a PHP plugin, my idea is to have a form with three fields and pass them to a PHP script as parameters0 -
Hi @Miguel G That guide has a sample though it's written in perl the steps should be the same. If you look at the guide it notes that you need to include your code in another tar. This is detailed in Step 2: Step 2: Create the install.json file. To create the install.json file, we go to WHM => Development => cPanel Plugin File Generator. Documentation on how to use this can be found here: cPanel Plugin File Generator - Documentation - cPanel Documentation You'll need a Unique Identifier (letters, numbers, hyphens and underscores). For the purposes of this tutorial, I used "Infection_Scanner" For the Name I used "Infection Scanner", the Group I selected "Security", for the Priority I chose "99" and for the URI, I entered: "infection_scanner/infection_scanner.live.pl". You'll also need an icon that is 48px by 48px and must be in PNG format. Browse for your icon file and add it to the page. Finally click the Add Item button and for the name (top-right) enter "infection_scanner". This will create a compressed tar.gz file in /var/cpanel/cpanel_plugin_generator directory, called infection_scanner.tar.gz. The UI will also give you a chance to download the file. The contents of the infection_scanner.tar.gz file will be an infection_scanner/ directory and within that directory will be an install.json file, a meta.json file (which only contains a timestamp and cpversion information), and your icon. The meta.json file is not required and if you wish, you can remove it from the archive, but it also does not hurt to leave it in place. The contents of the install.json file will look something like this: [{"icon":"infection_scanner.png","featuremanager":true,"name":"Infection Scanner","uri":"infection_scanner/infection_scanner.live.pl","group_id":"security","order":"99","type":"link","id":"infection_scanner"}] The compressed infection_scanner.tar.gz file should then be included with your backend code (your plugin/app) in another tar file (used for distribution).
As I quoted earlier the full line is:The compressed infection_scanner.tar.gz file should then be included with your backend code (your plugin/app) in another tar file (used for distribution).
0 -
Ok, now I get you. I haven"t included the code but I edited it manually so the index.php is not empty. 0 -
Hi @Miguel G The following may be helpful just for the fact it breaks the process down Guide to cPanel Plugins - Add Plugins to Version 11.44 and Later - Developer Documentation - cPanel Documentation There's also Guide to cPanel Plugins - Developer Documentation - cPanel Documentation that might be useful for you. Otherwise, you may want to try the install with the Perl script noted in the test to see if you get the same results. Thanks! 0 -
I even tried following this blog entry changing /usr/local/cpanel/base/frontend/ibertrix/wpstaging/index.php to exec('') ); print_r ( $cpanel->api1('print','',array('cow')) ); print_r ( $cpanel->exec('') ); print_r ( $cpanel->api('exec',1,'print','',array('cow')) ); print_r ( $cpanel->cpanelprint('$homedir') ); print_r ( $cpanel->cpanelprint('$hasvalidshell') ); print_r ( $cpanel->cpanelprint('$isreseller') ); print_r ( $cpanel->cpanelprint('$isresellerlogin') ); print_r ( $cpanel->exec('') ); print_r ( $cpanel->exec('') ); print_r ( $cpanel->api2('Email','listpopswithdisk',array('api2_paginate' => 1, 'api2_paginate_start' => 1, 'api2_paginate_size' => 10, "acct"=>1) ) ) ; print_r ( $cpanel->fetch('$CPDATA{\'DNS\'}') ); print_r ( $cpanel->api2('Ftp','listftpwithdisk',array("skip_acct_types"=>'sub') ) ); print_r ( $cpanel->uapi('SSL','list_keys', array( 'api.sort_column' => 'friendly_name' ))); print_r ( $cpanel->uapi('non-exist','list_keys', array( 'api.sort_column' => 'friendly_name' ))); print_r ( $cpanel->api3('SSL','list_certs', array( 'api.sort_column' => 'subject.commonName', 'api.filter_column' => 'modulus', 'api.filter_term' => 'mod_goes_here' ,'api.sort_column' => 'friendly_name' )));print_r ( $cpanel->api2(array('Ftp' => 1),'listftpwithdisk',array("skip_acct_types"=>'sub') ) ); // should complain about an untrappable failure if ( $cpanel->cpanelif('$haspostgres') ) { print "Postgres is installed\n"; }if ( $cpanel->cpanelif('!$haspostgres') ) { print "Postgres is not installed\n"; } if ($cpanel->cpanelfeature("fileman")) { print "The file manager feature is enabled\n"; } print "test complete\n"; $cpanel->end(); ?>
but I get a blank page and this error:PHP Fatal error: Uncaught exception 'RuntimeException' with message 'There was a problem fetching the env variablecontaining the path to the socket' in /usr/local/cpanel/php/cpanel.php:146 Stack trace: #0 /tmp/cpanel_phpengine.1535747270.279487IkUoFyQ7o(8): CPANEL->__construct() #1 {main} thrown in /usr/local/cpanel/php/cpanel.php on line 146
0 -
Sorry I forgot to add the source of the blog entry: Developing with LiveAPI | cPanel Blog 0 -
I am wondering what kind of tests you say you made on your systems. As referred here Tutorial - Create a New Paper Lantern Interface in PHP - Developer Documentation - cPanel Documentation (no referenced on your answers) I needed just to use .live.php extension instead of .php only. Now any of the scripts that I was testing, works. You guys definitely need to add more information about developing a plugin with PHP 0 -
Hi @Miguel G Thanks for the information, I'm glad you got it working, despite that hangup. 0 -
A couple of things: 1.- Is it possible while developing the plugin to make it only accessible for one user account for testing? 2.- I am seeing that using PHP could be the worst thing to do since I have disabled exec in PHP. I just want to be able to select in a form as the Wordpress addon you provide in cpaddons the list of domains and subdomains created in the Cpanel account and call an external WP-CLI based bash script to create a site. Maybe is better to use those .tt html language you use? 0 -
Hi @Miguel G .- Is it possible while developing the plugin to make it only accessible for one user account for testing?
If you've added the plugin you should be able to disable it from all users by using the feature manager. Just have it enabled in the featurelist for the user you want to develop with..- I am seeing that using PHP could be the worst thing to do since I have disabled exec in PHP. I just want to be able to select in a form as the Wordpress addon you provide in cpaddons the list of domains and subdomains created in the Cpanel account and call an external WP-CLI based bash script to create a site. Maybe is better to use those .tt html language you use?
Keep in mind cPanel's internal PHP is different than the site's PHP so configurations made to the PHP versions your sites use won't have an effect on the internal PHP. I believe as far as languages to write the plugin, in we recommend LivePHP0
Please sign in to leave a comment.
Comments
17 comments