Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict use of jdump to IP-Address #5

Open
tkahl opened this issue Mar 31, 2011 · 0 comments
Open

Restrict use of jdump to IP-Address #5

tkahl opened this issue Mar 31, 2011 · 0 comments

Comments

@tkahl
Copy link

tkahl commented Mar 31, 2011

I have added a configuration setting to configure a list of allowed IP-Addresses. All other IPs won't see a jdump output. But there will be no error when dc_dump is used in the code.

In the plugin constructor, i have added the following code:
$com_params = JComponentHelper::getParams('com_dump');
$checkforIP=$com_params->get('dump_ip');
$userIP=$_SERVER['REMOTE_ADDR'];
$checkforIP=$checkforIP ? explode(',',$checkforIP) : false;
if (!$checkforIP || in_array($userIP,$checkforIP) ) {
define("DUMP_ALLOWED",true);
} else {
define("DUMP_ALLOWED",false);
}

The whole code in the onAfterRender-function is in this if-clause:
if(defined('DUMP_ALLOWED') && DUMP_ALLOWED) { ... }

The same if-clause wraps the code in the dump-function from the fourth line of code:
if(defined('DUMP_ALLOWED') && DUMP_ALLOWED) {
if (function_exists('debug_backtrace')) {
....

In the components config.xml, i have added an additional parameter to store the IP-Addresses (and a helper element to show me the current ip):

    <param name="dump_ip" type="textarea" cols="30" rows="5" label="IP-Address" description="Set the IP-Address(es) for which the JDump should be active. Separate multiple addresses with comma, leave empty for every user." default="" />
    <param name="@currentip" label="Your current IP-Address" type="currentip" extension="com_dump" ptype="system" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant