views:

47

answers:

1

hi i am new to joomla .

i have made a folder in joomla directory and in this folder i have a some file .

i want to authenticate these files from direct access using in url by name?

how it is possible?

help

+1  A: 

I'm not sure if this is the best way, but you can create a PHP script (let's call it joomla-auth.php) containing this:

<?php

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');

if (JFactory::getUser()->id == 0)
   die("Access denied: login required.");

?>

Then, at the top of PHP scripts that need Joomla authentication, do:

<?php
include 'joomla-auth.php';
?>

If you have a PHP script, and you need to get information about the authenticated user, use JFactory::getUser() . If you have an .html file, you can change the extension to .php and add the 3 lines above to the top.

Chances are, creating a component or module is the "right way" to do what you're trying to do. However, I can't advise you on that because this is a lesson I still need to learn myself. You should also look into Jumi, which lets you embed PHP, HTML, JavaScript, etc. files directly into articles using a syntax like this:

{jumi myfile.html}{/jumi}
Joey Adams
good it work fine
tom