PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms 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
Possible License(s): GPL-2.0
  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. // Set error reporting
  8. // *******************************
  9. error_reporting (E_ALL ^ E_NOTICE);
  10. // *******************************
  11. // Typo3 remoting config
  12. // *******************************
  13. define('RELAY_HOST','localhost');
  14. //define('RELAY_PORT','8801');
  15. //define('RELAY_SERVER','http://www.xxx.com/typo3conf/ext/remoting_relay/xxx_8801.php');//Used for restarting server
  16. // ******************
  17. // Constants defined
  18. // ******************
  19. //require_once('../typo3_remoting_config.php');
  20. define('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
  21. $ss = split('typo3conf',PATH_thisScript);
  22. define('PATH_site',$ss[0]);// '/www/cms.elevated.to/elevated/'
  23. //getcwd() //generates /usr/local/home/httpd/cms.elevated.to/elevated/typo3conf/ext/mus/remoting
  24. //define('PATH_site', '/www/cms.elevated.to/elevated/');
  25. define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
  26. define('TYPO3_MODE','FE');
  27. //$TYPO3_MISC['microtime_start'] = microtime();
  28. define('PATH_t3lib', PATH_site.'t3lib/');
  29. define('PATH_tslib', PATH_site.'tslib/');
  30. define('PATH_typo3conf', PATH_site.'typo3conf/');
  31. define('TYPO3_mainDir', PATH_site.'typo3/'); // This is the directory of the backend administration for the sites of this TYPO3 installation.
  32. if (!@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.');
  33. // *********************
  34. // DIV Library included
  35. // *********************
  36. // *********************
  37. // Timetracking started
  38. // *********************
  39. require_once(PATH_t3lib.'class.t3lib_timetrack.php');
  40. $GLOBALS['TT'] = $TT = new t3lib_timeTrack;
  41. $TT->start();
  42. $TT->push('','Script start');
  43. // *********************
  44. // DIV Library included
  45. // *********************
  46. $TT->push('Include class t3lib_db, t3lib_div, t3lib_extmgm','');
  47. require(PATH_t3lib.'class.t3lib_div.php');
  48. require(PATH_t3lib.'class.t3lib_extmgm.php');
  49. $TT->pull();
  50. //require(PATH_t3lib.'class.t3lib_div.php');
  51. //require(PATH_t3lib.'class.t3lib_extmgm.php');
  52. //$error = array("errortype"=>2,"errormsg"=>"Flash remoting extension not installed.");
  53. // return $error;
  54. $CLIENT=t3lib_div::clientInfo(); // Set to the browser: net / msie if 4+ browsers
  55. //require_once(PATH_t3lib.'class.t3lib_timetrack.php');
  56. //$GLOBALS['TT'] =$TT= new t3lib_timeTrack;
  57. //$TT->start();
  58. // **********************
  59. // Include configuration
  60. // **********************
  61. global $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
  62. require(PATH_t3lib.'config_default.php');
  63. /*
  64. Issue here with two sets of cached files and only half of the info in the remoting one!!
  65. Why?
  66. Explains why !t3lib_extMgm::isLoaded('cms')) doesnt work for instance
  67. The cache prefix is determined by PATH_site and TYPO_VERSION and in the normal html version
  68. define('PATH_site', dirname(PATH_thisScript).'/');
  69. if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1) $cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']),0,4);
  70. That script didn't have access to the global variable TYPO_VERSION because it wasnt set as global above.
  71. Careful with that!
  72. */
  73. global $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
  74. // 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.
  75. //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
  76. require(PATH_t3lib.'class.t3lib_db.php');
  77. $GLOBALS['TYPO3_DB'] = $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
  78. // *******************************
  79. // Checking environment
  80. // *******************************
  81. if (t3lib_div::int_from_ver(phpversion())<4000006) die ('TYPO3 runs with PHP4.0.6+ only');
  82. if (isset($_POST['GLOBALS']) || isset($_GET['GLOBALS'])) die('You cannot set the GLOBALS-array from outside the script.');
  83. if (!get_magic_quotes_gpc()) {
  84. t3lib_div::addSlashesOnArray($_GET);
  85. t3lib_div::addSlashesOnArray($_POST);
  86. $HTTP_GET_VARS = $_GET;
  87. $HTTP_POST_VARS = $_POST;
  88. }
  89. // *********************
  90. // Libraries included
  91. // *********************
  92. //require_once(PATH_tslib.'class.tslib_fe.php');
  93. //require_once(PATH_t3lib.'class.t3lib_page.php');
  94. //require_once('class.flashremoting_userauth.php');
  95. //require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
  96. //require_once(PATH_t3lib.'class.t3lib_cs.php');
  97. require_once('class.flashremoting_base.php');
  98. //Check if remoting is installed otherwise die
  99. if(!t3lib_extMgm::isLoaded('flashremoting')){
  100. die;
  101. }
  102. // ***********************************
  103. // Connecting to database
  104. // ***********************************
  105. $TYPO3_DB->link = mysql_pconnect(TYPO3_db_host, TYPO3_db_username,TYPO3_db_password);
  106. mysql_select_db(TYPO3_db);
  107. $GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'] = true;//this is to enable login from different places via remoting
  108. // *********
  109. // FE_USER
  110. // *********
  111. $GLOBALS['R_SQL'] ='';
  112. if ($_COOKIE['fe_typo_user']) {
  113. require_once('class.flashremoting_feuserauth.php');
  114. if($GLOBALS['FE_USER'] == null){
  115. $GLOBALS['FE_USER'] = t3lib_div::makeInstance('flashremoting_feuserauth');
  116. }
  117. flashremoting_base::initFEuser();
  118. }
  119. // *********
  120. // BE_USER
  121. // *********
  122. if ($_COOKIE['be_typo_user']) { // If the backend cookie is set, we proceed and checks if a backend user is logged in.
  123. require_once (PATH_t3lib.'class.t3lib_befunc.php');
  124. require_once ('class.flashremoting_beuserauth.php');
  125. if($GLOBALS['BE_USER'] == null){
  126. $GLOBALS['BE_USER'] = t3lib_div::makeInstance('flashremoting_beuserauth'); // New backend user object
  127. }
  128. flashremoting_base::initBEuser();
  129. }
  130. // ********************
  131. // Finish timetracking
  132. // ********************
  133. $TT->pull();
  134. ?>