2

Someone built a site using joomla and third party plugin RS Forms Pro and created a page where a client could configure and purchase a product (via stripe). But they have asked me to write some scripts that allows them to create a basket system so clients can buy multiple products at once without entering their card details each time.

I have years of php/js experience but have never worked with a system like joomla. RSForms Pro allows me to attach javascripts and attributes to form items so this looked very easy and the JS part has indeed been simple. However, I wrote a small PHP shopping cart designed to be interfaced via GET url params and there is no where on the webserver I can place it where attempting an ajax request does not cause a 403 forbidden error.

What is the path of least resistance is to get the php api I've written into the joomla ecosystem in a way that will allow me to talk with it properly from within RSForms pages? Many thanks.

EDIT for functional details: The php script I wrote stores item data (class objects in this case) in a php session, it's essentially a simple session cart. The script itself expects to find instructions passed via URL, such as script.php?additem&itemdata=foobar which the script reads from the standard $_GET array. The script echo's a result which can either be some requested data, a confirmation or an error string - in all cases designed to be processed by the calling javascript.

1
  • If your php endpoint is standalone then can you access it with a regular request or is the 403 only via js? On a side note, would it not be better to replace the rsforms with a shopping cart extension (eg J2Store)? Feb 4, 2018 at 23:21

1 Answer 1

1

We have minimum information about how you have implemented all the above, however, I guess that you have created a php script somewhere that won't be executed/accessed from within Joomla's execution flow, but you are calling it directly. Right? In this case, you skip Joomla, the 403 error you get isn't coming from Joomla. Most likely this is a security restriction (access forbidden error) from your server.

Usually this comes either from directives in the .htaccess file - e.g. restricting the direct access/execution of php files, or by other security mechanisms/firewalls e.g. mod_security - which has become a standard in many hosting environments.

As for if you wanted to go fully the Joomla way, you would want to write a Joomla extension for your application.

2
  • There is indeed a htaccess file but I was under the impression when last looking that it was generated by the joomla install - I will have to double check this. But if it IS generated by the joomla install then my concern is that if the owner installed a future joomla update it might overwrite any changes I make and break the script again. RE: joomla extensions, there seems to be different types (extension? module?) some made within the joomla environment themselves even? I am uncertain which is the "correct" type for this task - I will edit original post with more functional details. Feb 4, 2018 at 22:54
  • @DavidBurford, Joomla does not install an .htaccess file. It only ships a sample htaccess.txt file containing basic directives, that needs to be renamed to.htaccess if you use Joomla's rewrite mode. You can do whatever you want with it - as far as you use it properly. You don't have to worry for future updates.
    – FFrewin
    Feb 5, 2018 at 1:43

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.