Skip to main content

Inject code to all websites?

Comments

6 comments

  • CloudNexus
    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
  • sparek-3
    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
  • cPanelMichael
    Hello @Pawel Lorenc, You can find some solutions discussed on the following StackOverflow thread:
    0
  • Pawel Lorenc
    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
  • rpvw
    Have you considered using htaccess to prepend your JS as a php file?
    0
  • cPanelMichael
    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.