I try to development my first cPanel plugin, i passed to write live page and install plugin
My only problem at execute bash script with root privilege at this line, it return error message Permission denied
Is there any assist?
PHP:
<?php
ini_set('display_startup_errors', 1);
error_reporting(-1);
include("/usr/local/cpanel/php/cpanel.php"); // Instantiate the CPANEL object.
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
print $cpanel->header( "Purge Web Server cache" );
// Get domain user data.
$get_userdata = $cpanel->uapi(
'DomainInfo', 'domains_data',
array(
'format' => 'hash',
'return_https_redirect_status' => '1',
)
);
$domainListApiCall = $cpanel->api2('DomainLookup', 'getbasedomains', array());
$domainList = $domainListApiCall['cpanelresult']['data'];
echo '<form class="form-horizontal" action = "" method = "POST" role="form">';
echo '<div class="form-group"><label for="domain" class="col-sm-2 control-label">Domain Name</label>';
echo "<div class='col-sm-4'><select name='domainName' class='form-control'>";
foreach ($domainList as $domain) {
echo "<option>" . $domain['domain'] . "</option>";
}
echo "</select></div>";
echo '<div class="col-sm-6">';
echo '<input id="next" class="btn btn-primary" type="submit" value="Purge">';
echo '<div id="status"></div></div>';
echo "</div></form>";
if(isset($_POST['domainName'])) {
echo shell_exec('bash /usr/local/cpanel/base/frontend/paper_lantern/PLUGIN_NAME/BASH_FILE.sh '.htmlspecialchars($_POST['domainName']));
echo '<br /><br /><span style="color:Green;text-align:center;"><strong>Web Cache for domain '.htmlspecialchars($_POST['domainName']).' has been Purged</strong></span>';
}
print $cpanel->footer(); // Add the footer.
$cpanel->end(); // Disconnect from cPanel - only do this once.
?>
Please note that i don't have enough experience with Perl scriptingecho shell_exec('bash /usr/local/cpanel/base/frontend/paper_lantern/PLUGIN_NAME/BASH_FILE.sh '.htmlspecialchars($_POST['domainName']));
Is there any assist?
Last edited by a moderator: