Page 1 of 1

Defining _VALID_MOS to access files from "outside" Joomla

Posted: Wed Apr 12, 2006 1:25 pm
by rowanseymour
I've written an AJAX Who's Online module http://forge.joomla.org/sf/sfmain/do/vi ... nline_ajax

The module has a php file which is the AJAX server, which responds to the AJAX requests for updates. When this is happening, _VALID_MOS is not defined because the file isn't being accessed as part of the Joomla application, and this limits what I can access in the way of other Joomla files.

Is it ok to define _VALID_MOS myself and access these files or would that be bad practice? Can I use the Joomla classes such as the database class?

Thanks

Re: Defining _VALID_MOS to access files from "outside" Joomla

Posted: Fri Apr 14, 2006 9:06 pm
by lordsiris
I am wondering the same thing...

Anyone have any information?

Thanks...

chris

Re: Defining _VALID_MOS to access files from "outside" Joomla

Posted: Wed Apr 26, 2006 1:14 am
by danuel
I am wondering the same thing also.  I will try to help figure it out!

Re: Defining _VALID_MOS to access files from "outside" Joomla

Posted: Wed May 31, 2006 10:37 am
by Scarpantibus
I'm having the same problem. I tried to define it myself (using define( '_VALID_MOS', 1 ); at the beginning of the php file), but I still can't use any joomla classes.

any help would be very appreciated.

Scarpantibus.

Re: Defining _VALID_MOS to access files from "outside" Joomla

Posted: Sun Jun 25, 2006 12:59 am
by lordsiris
I have done it using the function below... Is there a better way to do this?

Code: Select all

<?php

function getDatabase()
{
	$basePath = dirname( __FILE__ );
	include $basePath . '/../../configuration.php';
	define('_VALID_MOS', '_VALID_MOS');
	include $basePath . '/../../includes/database.php';
	global $database;
	$database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix );
}

getDatabase();
?>
lordsiris

Re: Defining _VALID_MOS to access files from

Posted: Sat Oct 05, 2013 6:39 am
by atpatil11
I know its very old thread but hope will help to other guys so posting my answer.

define( '_JEXEC', 1) or die( 'Restricted access' ); // This will allow to access file outside of joomla.
//defined( '_JEXEC') // Use this if you wanna access file only in Joomla.
define( '_VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

Just put above lines into your php file & you will be able to access any Joomla classes like database, session n all.