Solved

Restricting access to PHP/CGI scripts to only registered users in Joomla

Posted on 2009-07-04
2
485 Views
Last Modified: 2012-05-07
I run Joomla CMS on my Apache server (WAMP) with User Registration feature enabled. This means visitors can register and have accounts on the web site. I can restrict access to specific articles/sections from Joomla itself. Using the "Custom HTML" module, I added an HTML form to the web site; this HTML form sends its parameters to a PHP file (I created) located in the server.

The customized HTML form is restricted to only registered users. However, that does not prevent non-registered users from running my PHP file (If they knew its name).

How can I restrict access to my own PHP/CGI files to only registered users? Does Joomla provide such feature?
0
Comment
Question by:ISDCCC
2 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 24778044
I am not sure if Joomla can do what you want all by itself, but it should be fairly easy to protect your action script.  Use a CAPTCHA image.  That way you will be able to know that anyone who access your PHP file came through your form and was human-enough to enter the CAPTCHA information correctly.

A good place to start is with ReCaptcha:
http://lmgtfy.com?q=ReCaptcha

Best regards, ~Ray
0
 
LVL 4

Accepted Solution

by:
stevepicks earned 500 total points
ID: 24778237

<body>
<?php //cortecy of lleo for joomla 1.5
$user =& JFactory::getUser();?>
<?php if ($user->id > 1) : ?>

<!-- user IS logged in so deliver normal template
     Your normal template HTML here -->

<?php else : ?>
<!--  Visitor is NOT logged in so deliver the login page -->

<jdoc:include type="modules" name="user9" />

    <?php if ($option == 'com_user') : ?>
         <jdoc:include type="component" />
    <?php endif; ?>
<?php endif; ?>

</body>
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Knowledge base software has turned out to be a quite reliable method for storing information, promoting collaborative work and for sharing valuable input and solutions.However, some organizations are trying to develop a knowledge base that works wit…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question