Follow-up to bug #13428: pi1/captcha.php: PHP Fatal Error when called directly
[TYPO3CMS/Extensions/sr_freecap.git] / pi1 / captcha.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2005-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
6 * All rights reserved
7 *
8 * This script is part of the Typo3 project. The Typo3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24 /**
25 * This script invokes the freecap CAPTCHA image generation
26 *
27 */
28 // Exit, if script is called directly (must be included via eID in index_ts.php)
29 if (!defined('TYPO3_MODE') || TYPO3_MODE !== 'FE') {
30 die('Could not access this script directly!');
31 }
32 require_once(t3lib_extMgm::extPath('sr_freecap').'pi1/class.tx_srfreecap_pi1.php');
33 if (t3lib_div::int_from_ver($GLOBALS['TYPO_VERSION']) < 4003000) {
34 require_once(PATH_tslib.'class.tslib_fe.php');
35 require_once(PATH_t3lib.'class.t3lib_userauth.php');
36 require_once(PATH_tslib.'class.tslib_feuserauth.php');
37 require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
38 require_once(PATH_t3lib.'class.t3lib_page.php');
39 require_once(PATH_tslib.'class.tslib_content.php');
40 }
41
42 // ***********************************
43 // Creating a $TSFE object
44 // ***********************************
45 $id = t3lib_div::_GET('id');
46 if (!isset($id)) {
47 $id = 0;
48 }
49 $id = htmlspecialchars($id);
50 $MP = htmlspecialchars(t3lib_div::_GET('MP'));
51 $GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], $id, '0', 1, '', '', $MP, '');
52 $GLOBALS['TSFE']->connectToDB();
53 $GLOBALS['TSFE']->initFEuser();
54 $GLOBALS['TSFE']->determineId();
55 // *******************************************
56 // Get compressed $TCA-Array();
57 // After this, we should now have a valid $TCA, though minimized
58 // *******************************************
59 $GLOBALS['TSFE']->getCompressedTCarray();
60 $GLOBALS['TSFE']->initTemplate();
61 $GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
62
63 // ******************************************************
64 // Get config if not already gotten
65 // After this, we should have a valid config-array ready
66 // ******************************************************
67 $GLOBALS['TSFE']->getConfigArray();
68
69 // *******************************************
70 // Setting language and locale
71 // *******************************************
72 $GLOBALS['TT']->push('Setting language and locale','');
73 $GLOBALS['TSFE']->settingLanguage();
74 $GLOBALS['TSFE']->settingLocale();
75 $GLOBALS['TT']->pull();
76
77 // *******************************************
78 // Invoke the freecap plugin
79 // *******************************************
80 $freecap = t3lib_div::makeInstance('tx_srfreecap_pi1');
81 $freecap->cObj = t3lib_div::makeInstance('tslib_cObj');
82 $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$freecap->prefixId.'.'];
83 $freecap->main($conf);
84 ?>