+ Post New Thread
Results 1 to 3 of 3
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 ...
  1. #1
    rocknrollstar's Avatar
    Join Date
    Jun 2008
    Location
    Hampshire
    Posts
    435
    Thank Post
    387
    Thanked 28 Times in 24 Posts
    Rep Power
    20

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

  2. #2

    Join Date
    Jun 2010
    Location
    Birmingham, UK
    Posts
    48
    Thank Post
    1
    Thanked 13 Times in 13 Posts
    Rep Power
    11
    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?

  3. Thanks to PeteW from:

    rocknrollstar (4th August 2011)

  4. #3
    rocknrollstar's Avatar
    Join Date
    Jun 2008
    Location
    Hampshire
    Posts
    435
    Thank Post
    387
    Thanked 28 Times in 24 Posts
    Rep Power
    20
    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:
+ Post New Thread

Similar Threads

  1. Auto Ldap Login Joomla 1.5
    By Fontayne56 in forum Web Development
    Replies: 1
    Last Post: 18th February 2010, 01:09 PM
  2. Joomla Login Remove Forgot Password
    By karldenton in forum Web Development
    Replies: 3
    Last Post: 14th August 2009, 09:08 AM
  3. Login problems with joomla
    By wesleyw in forum EduGeek Joomla 1.5 Package
    Replies: 2
    Last Post: 4th June 2009, 05:23 PM
  4. Joomla Login Box
    By alan-d in forum Web Development
    Replies: 4
    Last Post: 11th February 2009, 12:45 PM
  5. Moodle Login Block on Joomla Homepage
    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
  •