Execute PHP code inside a new cPanel template?
How do I execute PHP code inside a new cPanel template?
I tried some and it does not work. Is there something special I have to do in order to execute regular PHP code inside a template?
-
Hi, What exactly you mean by inside the template. Can you elaborate more on what issue you are facing and what error does occur when you actually perform the stuff that you mentioned? 0 -
I mean a HTML page inside a cPanel theme. You can edit HTML files inside the default theme or another one you created. But I also need to execute some PHP code inside. 0 -
Hello @nibb, Are you familiar with the LiveAPI system? We document it at: Guide to the LiveAPI System - Developer Documentation - cPanel Documentation For PHP applications in-particular, we offer a PHP class: Guide to the LiveAPI System - PHP Class - Developer Documentation - cPanel Documentation Thank you. 0 -
But it does not work. My problem is that it execute basic things like echo or a redirect but even if I use the example from here: Guide to the LiveAPI System - PHP Class - Developer Documentation - cPanel Documentation I get a blank page the second I put the code in the file: // Instantiate the CPANEL object. require_once "/usr/local/cpanel/php/cpanel.php"; // Connect to cPanel - only do this once. $cpanel = new CPANEL(); // Get domain user data. $get_userdata = $cpanel->uapi( 'DomainInfo', 'domains_data', array( 'format' => 'hash', ) ); // Perform the desired actions. So while PHP code works in the php file, no real complex code actually works unless its very simple. 0 -
Hello, Here's an example that I've verified functions on a test system: header( "Page Heading" ); // Add the header. ?> uapi( 'SSL', 'list_certs' ); var_dump($SSL_list_certs); ?> footer(); // Add the footer. $cpanel->end(); // Disconnect from cPanel - only do this once. ?>
Can you check and verify if this example works as expected and is a better reflection of what you are attempting to do? Thank you.0
Please sign in to leave a comment.
Comments
5 comments