Web Development Thread, Joomla login in Coding and Web Development; I am developing a plugin to make inserting media a little easier in joomla.
The plugin loads up a php ...
-
22nd July 2011, 05:25 PM #1 Joomla login
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. 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;
}
-
-
IDG Tech News
-
29th July 2011, 03:20 PM #2
- Rep Power
- 9
What does the above file give you? Any erros or the white screen of death?
With $checkuser if you use PHP Code:
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 to PeteW from:
rocknrollstar (4th August 2011)
-
4th August 2011, 10:55 PM #3 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","r am","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';
}
-
SHARE: 
Similar Threads
-
By Fontayne56 in forum Web Development
Replies: 1
Last Post: 18th February 2010, 01:09 PM
-
By karldenton in forum Web Development
Replies: 3
Last Post: 14th August 2009, 09:08 AM
-
By wesleyw in forum EduGeek Joomla 1.5 Package
Replies: 2
Last Post: 4th June 2009, 05:23 PM
-
By alan-d in forum Web Development
Replies: 4
Last Post: 11th February 2009, 12:45 PM
-
By ict.teacher in forum Virtual Learning Platforms
Replies: 2
Last Post: 13th November 2008, 04:43 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules