Jump to content

Recommended Posts

Posted

I am developing a plugin to make inserting media a little easier in joomla.

 

The plugin loads up a php file in a browser windows, which simple lists files in a directory. It all works fine!

 

However, I want to add some security to my file listing page, so that you need to be logged in to load it.

 

e.g. http://www.mysite.com/media/filelist.php

 

Is there anything I can put at the top of my filelist.php file, so that checks for a logged in user before running? Note that filelist.php isn't really linked to joomla in anyway, it is simply a php file in a directory.

 

I've tried stuff like the lines below, but I don't really know what I'm doing. Thanks:

 

define( '_JEXEC',0 );

define('JPATH_BASE', dirname("../../") );

define( 'DS', DIRECTORY_SEPARATOR );

/* Required Files */

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );

require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

/* To use Joomla's Database Class */

require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );

 

 

$checkuser = JFactory::getUser();

if (!$checkuser->get('gid')>0){

 

 

echo 'not logged in';

die;

}

Posted

What does the above file give you? Any erros or the white screen of death?

 

With $checkuser if you use

if($checkuser->guest) echo "You are a guest, please login";

it's more easier to read.

 

If you creating an plugin for Joomla, are you using Joomlas standard layout? There is a quick guide here - Joomla Plugin - On how to create a bacis plugin.

 

Have you checked the extension directory to see if there is something already available?

  • Thanks 1
Posted

Thanks, will update my code. The code below works, but it does look very odd. Need to work on the css.

 

I've written plugins before, but the problem is that this file lies outside of the plugin directory. It needs more work to be an official plugin though, struggling for time.

 

The beauty of the plugin is that it is a simple file browser that lets you select a folder or file on your server filesystem, and it will automatically put in the joomla tags for you so that it shows a 'gallery' or media player or picture viewer for that file. VERY WYSIWYG.

 

ie. if it has mp3s in it, it automatically puts in the correct tags so that it shows a gallery/player of mp3s. same for pics or videos. It makes use of several other media plugins, but means that you don't have to remember the tags or path names inside the tages. Something Joomla struggles with, IMHO.

 

Also, if you select a single picture, it lets you put a static thumbnail in or a thumbnail that can be clicked to produce the large version (like lightbox).

 

Makes use of:

AllRideos Reloaded: Introduction - Streaming local content

MP3 Player: Joomla Downloads - MP3 Browser for Joomla 1.5.x | Dotcom Development - Web Design Birmingham

Photo Gallery: Simple Image Gallery Pro (plugin) | JoomlaWorks

 

Works for:

$videoaudiotypes = array("wmv", "flv", "mpg", "mov", "wma","mp3","swf","3gp","m4v","avi","mpeg","rm","ram","rv","divx");

$imagetypes = array("jpg", "jpeg", "gif", "png");

 

 

---------------------------------------

 

define( '_JEXEC', 1 );

define('JPATH_BASE', '../' ); // this varies depending on where this file is...

define( 'DS', DIRECTORY_SEPARATOR );

 

require( JPATH_BASE .DS.'includes'.DS.'defines.php' );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );

require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );

 

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

 

$checkuser = JFactory::getUser();

if ($checkuser->get('gid')>0){

echo 'logged in';

 

}else{

echo 'logged out';

}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 47 When would you like EduGeek EDIT 2025 to be held?

    1. 1. Select a time period you can attend


      • I can make it in June\July
      • I can make it in August\Sept
      • Other time period. Comment below
      • Either time

×
×
  • Create New...