0

I would like to call a PHP helper file (helper_ppal.php) included in a custom module (mod_ms_lib). Accessing the helper file would simplify processing PayPal IPN (Instant Paypal Notifications) requests. (For info, PayPal posts data to a custom url after a transaction has occurred. I would like to process these data.)

Currently, with the DirectPHP plugin, I am able to access the helper file by redirecting the request to the url of the ipn article that contains include and processing statements.

Question: Is it possible to directly access helper file methods from the outside w/o transitioning through a menu/article?

I have a working PHP demo, which senses IPN requests and redirects them to the ppal handler. I understand that for security reasons, access rights to Joomla files are restricted. How can I address this situation?


Thanks for your answer.

Question: Does this mean for example that I could add some php code in 'index.php' to instruct Joomla to check url's? If a specific url is detected, say 'http://...//ppal.php&action=ipn', the app would then take action?

TIA.

2
  • I've seen that you asked this question on stackoverflow and the Joomla! forums too. For the next time I would ask you to ask the question only on one forum.
    – fruppel
    Sep 10, 2015 at 19:27
  • In regard to postings, you are right: I should'nt. Quite often, however, questions remain unanswered; this tempts me in joining different fori to hopefully get an answer when time pressure builds up. Sep 11, 2015 at 9:53

1 Answer 1

1

You can include PHP scripts in other PHP scripts easily with the help of PHP's functions require or include (resp. require_once/include_once to make sure you only include the file once). The difference between require and include is that when the file can not be included with require it will throw an fatal error and abort your script and with include it will just throw a warning.

Example:

<?php
require_once "/path/to/joomla/modules/mod_ms_lib/helper_ppal.php";

After that you can use functions defined in that helper_ppal.php or you can use the class methods if this file defines a class. Be aware that if it's not a static class you have to make a new object of it first.

If you include files in other Joomla files (e.g. another module) you can use Joomla's file path constants, for example:

require_once JPATH_ROOT . "/modules/mod_example/helper.php";

Update:

Yes you can add PHP code to index.php and detect GET parameters and execute specific functions then. But if you call the URL in your example, index.php will not be called but ppal.php so this wouldn't work. And it wouldn't be the nice way. In Joomla we build/install extensions like components, modules or plugins for such purposes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.