PageRenderTime 204ms CodeModel.GetById 101ms app.highlight 6ms RepoModel.GetById 94ms app.codeStats 0ms

/ext/flashremoting/lib/typo3/includes.php

https://github.com/elhakim22003/TypoFlash
PHP | 207 lines | 125 code | 40 blank | 42 comment | 12 complexity | 30cfd6780effe43b953a3315d38edeb6 MD5 | raw file
  1<?php
  2// *******************************
  3// TYPO3 includes for Flash Remoting
  4// This script is made by A Borg, based on Kasper's index_ts.php.
  5// *******************************
  6
  7
  8// *******************************
  9// Set error reporting
 10// *******************************
 11error_reporting (E_ALL ^ E_NOTICE);
 12
 13// *******************************
 14// Typo3 remoting config
 15// *******************************
 16
 17
 18
 19
 20define('RELAY_HOST','localhost');
 21//define('RELAY_PORT','8801');
 22//define('RELAY_SERVER','http://www.xxx.com/typo3conf/ext/remoting_relay/xxx_8801.php');//Used for restarting server
 23
 24
 25// ******************
 26// Constants defined
 27// ******************
 28
 29//require_once('../typo3_remoting_config.php');	
 30
 31define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME']))));//generates /www/cms.elevated.to/elevated/typo3conf/ext/flashremoting/gateway.php 
 32
 33$ss = split('typo3conf',PATH_thisScript);
 34
 35define('PATH_site',$ss[0]);// '/www/cms.elevated.to/elevated/'
 36
 37//getcwd() //generates /usr/local/home/httpd/cms.elevated.to/elevated/typo3conf/ext/mus/remoting
 38//define('PATH_site', '/www/cms.elevated.to/elevated/');
 39
 40define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
 41define('TYPO3_MODE','FE');
 42
 43
 44
 45
 46//$TYPO3_MISC['microtime_start'] = microtime();
 47define('PATH_t3lib', PATH_site.'t3lib/');
 48define('PATH_tslib', PATH_site.'tslib/');
 49define('PATH_typo3conf', PATH_site.'typo3conf/');
 50define('TYPO3_mainDir', PATH_site.'typo3/');		// This is the directory of the backend administration for the sites of this TYPO3 installation.
 51
 52if (!@is_dir(PATH_typo3conf))	die('Cannot find configuration. You need to set PATH_site relative to your site. And if you are using remoting_relay the port and host.');
 53
 54
 55// *********************
 56// DIV Library included
 57// *********************
 58
 59
 60// *********************
 61// Timetracking started
 62// *********************
 63require_once(PATH_t3lib.'class.t3lib_timetrack.php');
 64$GLOBALS['TT'] = $TT = new t3lib_timeTrack;
 65$TT->start();
 66$TT->push('','Script start');
 67
 68
 69// *********************
 70// DIV Library included
 71// *********************
 72$TT->push('Include class t3lib_db, t3lib_div, t3lib_extmgm','');
 73	require(PATH_t3lib.'class.t3lib_div.php');
 74	require(PATH_t3lib.'class.t3lib_extmgm.php');
 75$TT->pull();
 76
 77
 78//require(PATH_t3lib.'class.t3lib_div.php');
 79//require(PATH_t3lib.'class.t3lib_extmgm.php');
 80
 81//$error = array("errortype"=>2,"errormsg"=>"Flash remoting extension not installed."); 
 82//	return $error; 
 83
 84
 85$CLIENT=t3lib_div::clientInfo();				// Set to the browser: net / msie if 4+ browsers
 86//require_once(PATH_t3lib.'class.t3lib_timetrack.php');
 87//$GLOBALS['TT'] =$TT=  new t3lib_timeTrack;
 88//$TT->start();
 89
 90
 91
 92
 93
 94
 95
 96// **********************
 97// Include configuration
 98// **********************
 99global $TT,$TYPO3_CONF_VARS,$TYPO3_LOADED_EXT,$T3_VAR,$EXEC_TIME,$SIM_EXEC_TIME,$LANG,$LOCAL_LANG,$TYPO3_DB,$TYPO_VERSION;//must define all globals as such here...else they will be lost. Borg
100
101require(PATH_t3lib.'config_default.php');
102
103/*
104Issue here with two sets of cached files and only half of the info in the remoting one!!
105Why? 
106Explains why !t3lib_extMgm::isLoaded('cms')) doesnt work for instance
107
108
109The cache prefix is determined by PATH_site and TYPO_VERSION and in the normal html version 
110define('PATH_site', dirname(PATH_thisScript).'/');
111
112if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1)	$cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']),0,4);
113
114That script didn't have access to the global variable TYPO_VERSION because it wasnt set as global above.
115Careful with that!
116
117*/
118
119global $TT,$TYPO3_CONF_VARS,$TYPO3_LOADED_EXT,$T3_VAR,$EXEC_TIME,$SIM_EXEC_TIME,$LANG,$LOCAL_LANG,$TYPO3_DB;//must define all globals as such here...else they will be lost. Borg
120
121
122
123
124
125
126// the name of the TYPO3 database is stored in this constant. Here the inclusion of the config-file is verified by checking if this var is set.
127//if (!t3lib_extMgm::isLoaded('cms'))	die('<strong>Error:</strong> The main frontend extension "cms" was not loaded. Enable it in the extension manager in the backend.'); //doesnt work with remoting
128
129require(PATH_t3lib.'class.t3lib_db.php');
130$GLOBALS['TYPO3_DB'] = $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
131
132// *******************************
133// Checking environment
134// *******************************
135if (t3lib_div::int_from_ver(phpversion())<4000006)	die ('TYPO3 runs with PHP4.0.6+ only');
136
137if (isset($_POST['GLOBALS']) || isset($_GET['GLOBALS']))	die('You cannot set the GLOBALS-array from outside the script.');
138if (!get_magic_quotes_gpc())	{
139	t3lib_div::addSlashesOnArray($_GET);
140	t3lib_div::addSlashesOnArray($_POST);
141	$HTTP_GET_VARS = $_GET;
142	$HTTP_POST_VARS = $_POST;
143}
144// *********************
145// Libraries included
146// *********************
147
148//require_once(PATH_tslib.'class.tslib_fe.php');
149//require_once(PATH_t3lib.'class.t3lib_page.php');
150//require_once('class.flashremoting_userauth.php');
151
152//require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
153//require_once(PATH_t3lib.'class.t3lib_cs.php');
154require_once('class.flashremoting_base.php');
155
156 //Check if remoting is installed otherwise die
157if(!t3lib_extMgm::isLoaded('flashremoting')){
158	die;
159}
160
161
162// ***********************************
163// Connecting to database
164// ***********************************
165$TYPO3_DB->link = mysql_pconnect(TYPO3_db_host, TYPO3_db_username,TYPO3_db_password);
166mysql_select_db(TYPO3_db);
167
168
169
170$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'] = true;//this is to enable login from different places via remoting
171
172// *********
173// FE_USER
174// *********
175$GLOBALS['R_SQL'] ='';
176if ($_COOKIE['fe_typo_user']) {	
177	require_once('class.flashremoting_feuserauth.php');
178	if($GLOBALS['FE_USER'] == null){
179		$GLOBALS['FE_USER'] = t3lib_div::makeInstance('flashremoting_feuserauth');
180	}
181	flashremoting_base::initFEuser();
182}
183
184
185
186// *********
187// BE_USER
188// *********
189
190if ($_COOKIE['be_typo_user']) {		// If the backend cookie is set, we proceed and checks if a backend user is logged in.
191	
192	require_once (PATH_t3lib.'class.t3lib_befunc.php');
193	require_once ('class.flashremoting_beuserauth.php');
194	if($GLOBALS['BE_USER'] == null){
195		$GLOBALS['BE_USER'] =  t3lib_div::makeInstance('flashremoting_beuserauth');	// New backend user object
196	}
197	flashremoting_base::initBEuser();
198
199}
200
201
202// ********************
203// Finish timetracking
204// ********************
205$TT->pull();
206
207?>