开发者

joomla : authentication

I have made a folder in joomla directory. In this folder I have some file.

I want to authenticate these files from direct access using URL by name?

How can it be achieve开发者_C百科d?


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}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜