<?php

/**
* @version 2.6.4
* @package Joomla 1.5
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

session_start();

ob_start();

define( '_JEXEC', 1 );

$_SESSION['old_path'] = getcwd();

chdir('../../');

define('JPATH_BASE', getcwd() );

define( 'DS', DIRECTORY_SEPARATOR );

require_once("configuration.php");

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

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

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

// set the language
$mainframe->initialise();
JPluginHelper::importPlugin('system');
jimport( 'joomla.error.profiler' );
global $p ;
$p = JProfiler::getInstance('Application');
$p->mark('StartIPN');

$mainframe->triggerEvent('onAfterInitialise');
$mainframe->route();
$mainframe->triggerEvent('onAfterRoute');
$mainframe->triggerEvent('onAfterDispatch');
$database = &JFactory::getDBO();
 $data = explode('|',$_REQUEST['custom']);

			foreach($data as $key=>$value){

				if(substr($value,0,7)=='session'){

					$arr = explode("=",$value);

					$paypal_session_id = $arr[1];

					break;

				}

			}

			 $sql  = "select * from #__dtregister_session where id=$paypal_session_id";

			 $database->setQuery($sql);

			 $database->query();

			 $row = $database->loadObjectList();

			 $data = unserialize($row[0]->data);

			 $_SESSION = $data;
			
			   if(isset($_SESSION['__default']['registry']->_registry['application']['data']->lang) && $_SESSION['__default']['registry']->_registry['application']['data']->lang !=""){
			     $lang_code =  $_SESSION['__default']['registry']->_registry['application']['data']->lang;
				   $query = "select * from #__languages where code='".$lang_code."' and active=1";
				   $database->setQuery($query);
           $database->query();
			     $row = $database->loadObject();
				   $_REQUEST['lang'] = $row->shortcode;	   
			   }
			
			 $lang =& JFactory::getLanguage();



$lang->load('com_dtregister');

include(JPATH_SITE."/components/com_dtregister/dtregister.php");

ob_clean();

ob_start();

if(isset($_GET['type']) && $_GET['type']=='paymentchange'){

  paypal_chg_notify('Paypal');
}else{
 paypal_notify('Paypal');
}
$p->mark('ENDIPN');

chdir($_SESSION['old_path']);

?>