define( '_JEXEC', 1 );
define( 'JPATH_BASE',$_SERVER['DOCUMENT_ROOT']);
$mosConfig_absolute_path = dirname( __FILE__ );
define( 'DS', DIRECTORY_SEPARATOR );
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.'methods.php');
require_once ( JPATH_BASE .DS.'configuration.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'base'.DS.'object.php');
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'database.php');
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'database'.DS.'mysql.php');
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'filesystem'.DS.'folder.php');
It worked when the .php file was in the root folder, but when I call it from subdomain I had an error:
XMLHttpRequest cannot load the php <my php file>. Origin <subdomain> is not allowed by Access-Control-Allow-Origin.
Frankly speaking it works(sends me an e-mail), but callback doesn't...
So I moved the php file to subdomain directory. Now I have 500 error. Need help. Thank you!
All Domains:
<?php
header('Access-Control-Allow-Origin: *');
?>
Allowed Domains:
<?php
header('Access-Control-Allow-Origin: http://domain1.com, http://domain2.com');
?>
Related
Hi I'm trying to load a K2 content module in an external php file. I found some info and examples about this but the problem it's that it is only working with some Joomla modules (custom html and others) but not with the k2 modules. This is mi code:
define( '_JEXEC', 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' );
$app = JFactory::getApplication('site');
$app->initialise();
$modules = JModuleHelper::getModules("contenedor-eventos");
$document = JFactory::getDocument();
$attribs = array();
$attribs['style'] = 'xhtml';
foreach ($modules as $mod)
{
echo JModuleHelper::renderModule($mod, $attribs);
}
I have this error message: Fatal error: Class 'K2Model' not found in /home/my_user/my_domain/modules/mod_k2_content/helper.php on line 289
The code in helper.php line 289 is:
$model = K2Model::getInstance('Item', 'K2Model');
Hope someone could help me.
Thanks in advance.
I'm a newbie but trying to learn.
I have a script to read the joomla user details. It's a simple script just to display logged in user name. The script works if I put it in the root directory of my website.
What I want to do is run the script from a folder off the root, /ssscart, for example.
When I put the script in the sub-directory it does not execute.
Here is my script:
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', '/' );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
JFactory::getApplication('site')->initialise();
$user = JFactory::getUser();
$joomla_name = $user->name;
$joomla_email = $user->email;
$joomla_password = $user->password;
$joomla_username = $user->username;
echo 'hello';
echo " - ".$joomla_username;
?>
I believe my problem is in the JPATH_BASE entry but haven't been able to figure it out yet.
Thanks
G
Try this,
The is issue is due to JPATH_BASE path getting wrongly.
when you are in root it will look like.
define('JPATH_BASE', dirname(__FILE__) );
So in your case you are in sub folder so it will be look like.
define('JPATH_BASE', dirname(dirname(__FILE__)) );
so your final code will be look like.
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(dirname(__FILE__)) );
define( 'DS', '/' );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
JFactory::getApplication('site')->initialise();
Hope it works..
I am trying to load a module on an external page from the Joomla core.
I am using the following:
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');
$mainframe->initialise();
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule('xxxx', 'xxxxxxx');
$memberships = JModuleHelper::renderModule($module);
But get the following error
JPath::check Use of relative paths not permitted
Any ideas
i have this code which will check whether (a) the store is online and (b) the directory /store is available:
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(realpath(__FILE__)). '/../store' );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.application.module.helper');
jimport('joomla.application.component.helper');
$mainframe =& JFactory::getApplication('site');
$filename = '../store/';
if (!$mainframe->getCfg('offline') && file_exists($filename))
{
echo "online";
}
else
{
echo "offline";
}
?>
when the i set the store as offline in my control panel it works fine, however when the directory /store has it's name changed or is deleted (becomes unavailable) the page generates a server error whereas it should echo "offline". how can i modify it so that when the directory names changes, it changes it echoes "offline"
You must check the directory prior to the initialization of the application, since the application relies on the directory's existence.
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(realpath(__FILE__)). '/../store' );
if (!file_exists(JPATH_BASE)) {
echo 'Offline due to missing installation';
exit(0);
}
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.application.module.helper');
jimport('joomla.application.component.helper');
$app = JFactory::getApplication('site');
if ($app->getCfg('offline')) {
echo 'Offline due to configuration setting';
$app->close();
}
echo 'Online';
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Accessing session data outside Joomla
I tried to use the below script to retrieve Joomla's Session, but it's not working.
Can anyone help me...
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(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');
$session = &JFactory::getSession();
This is what i use :
//Joomla Stuff
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');
/**
* INITIALISE THE APPLICATION
*
* NOTE :
*/
// set the language
$mainframe->initialise();
JPluginHelper::importPlugin('system');
// trigger the onAfterInitialise events
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
$mainframe->triggerEvent('onAfterInitialise');
// End Joomla Stuff