Skip to main content
cPanel Technical Support has been heavily impacted by hurricane Beryl and our ability to respond to tickets has been hindered as a result. We appreciate your understanding and patience as we address these delays.

Cpanel::App - should it be used to check which app user is in?

Comments

2 comments

  • cPRex Jurassic Moderator

    Maybe Andy Baugh has some ideas on this one?

    0
  • Andy Baugh cPanel Staff

    Depends on what you mean by developers. Developers working at cPanel? Yes. Integrators? No.

    This is why we do not mention use of this module in our online documentation (last I checked anyways).

    When you are using Cpanel::App, it is autoritative *if* your code's execution context is already inside of a compiled binary. This is useful if say, your context is a "module" hook, but not if you are a "script" hook. Similarly, custom CGIs in whostmgr (for example) will never have $Cpanel::appname set, so this module will as well be "at a loss" as to what the app actually is (and thus assume the "default" of cpanel), as this CGI is ran via fork+exec, so it retains no prior memory of what was in the compiled binary.

    You might be tempted to reference ENV to see if we put something useful in there for you, but as far as the app goes, you'd be out of luck here too.

    Your best bet is either to:

    a) Check the URL in your code, which usually is different enough to use as a semaphore for "what app am I in"

    b) Already know "what app you'll be" by coding it into your custom CGI script before install. Since the way to install whostmgr, cpanel and webmail plugin CGIs are all slightly different, whatever install script you use to install this CGI to the various cPanel "apps" can always just echo in "what app we are" to a __DATA__ block at the end of the file and then reference it above in your CGI.

    0

Please sign in to leave a comment.