Inject code to all websites?
Hello,
I would like to write a plugin which allows me to inject a small part of code to all my websites in cPanel. I believe it is possible to Apache, I don't know how to communicate with it via the custom plugin.
Did anyone try something similar?
Any comments could be helpful.
I don't know how to via plugin (PHP file) edit httpd.conf file (root permission). Any help?
-
What kind of code are you looking to include? If you don't want to break the sites of your customers you'll need to inject the code in a specific part of their pages (in the HEAD or BODY, but not AFTER the closing HTML statement). 0 -
You might look at mod_layout. Although I suspect it is no longer being developed, but there may be a successor to it. Or at least give you a starting point to look for something. 0 -
I would like to inject some JS script in the HEAD section. For now it would be some statistics code. Maybe another one in the future. I am thinking about using ext_filter_module of Apache. I would need to edit httpd.conf file. I need to be root to do that. I wrote a cPanel plugin, but there I exec scripts as cPanel user. If I create a WHM plugin, will I run script as root? Is this the best solution? This is only part of information I would like to get. I will also use an API to get another information. That's why I would like to use plugin. 0 -
Have you considered using htaccess to prepend your JS as a php file? 0 -
I wrote a cPanel plugin, but there I exec scripts as cPanel user. If I create a WHM plugin, will I run script as root? Is this the best solution?
Hello, Are you sure a WHM plugin is necessary for this script as opposed to writing a custom bash script that runs from the command line? Generally, a WHM plugin is utilized if you want to allow a WHM user to perform certain actions from the UI. In the scenario you described, it seems like the server administrator could simply run the script via the command line. Thank you.0
Please sign in to leave a comment.
Comments
6 comments