Initial upload to TYPO3 Forge
[TYPO3CMS/Extensions/sr_freecap.git] / pi1 / captcha.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2005-2008 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 error_reporting (E_ALL ^ E_NOTICE);
29 define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='xcgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&((!empty($_SERVER['ORIG_PATH_TRANSLATED'])&&isset($_SERVER['ORIG_PATH_TRANSLATED']))?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ((!empty($_SERVER['ORIG_PATH_TRANSLATED'])&&isset($_SERVER['ORIG_PATH_TRANSLATED']))?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):((!empty($_SERVER['ORIG_SCRIPT_FILENAME'])&&isset($_SERVER['ORIG_SCRIPT_FILENAME']))?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME']))));
30 if (!defined('PATH_site')) define('PATH_site', dirname(dirname(dirname(dirname(dirname(PATH_thisScript))))).'/');
31 if (!defined('PATH_t3lib')) define('PATH_t3lib', PATH_site.'t3lib/');
32 define('PATH_typo3conf', PATH_site.'typo3conf/');
33 define('TYPO3_mainDir', 'typo3/');
34 if (!defined('PATH_typo3')) define('PATH_typo3', PATH_site.TYPO3_mainDir);
35 if (!defined('PATH_tslib')) {
36 if (@is_dir(PATH_site.'typo3/sysext/cms/tslib/')) {
37 define('PATH_tslib', PATH_site.'typo3/sysext/cms/tslib/');
38 } elseif (@is_dir(PATH_site.'tslib/')) {
39 define('PATH_tslib', PATH_site.'tslib/');
40 }
41 }
42 define('TYPO3_MODE','FE');
43 define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
44
45 require_once(PATH_t3lib.'class.t3lib_div.php');
46 require_once(PATH_t3lib.'class.t3lib_extmgm.php');
47 require_once(PATH_t3lib.'config_default.php');
48 require_once(PATH_typo3conf.'localconf.php');
49 require_once(PATH_tslib.'class.tslib_fe.php');
50 require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
51 require_once(PATH_t3lib.'class.t3lib_page.php');
52 require_once(PATH_tslib.'class.tslib_content.php');
53 require_once(t3lib_extMgm::extPath('sr_freecap').'pi1/class.tx_srfreecap_pi1.php');
54 require_once(PATH_t3lib.'class.t3lib_userauth.php');
55 require_once(PATH_tslib.'class.tslib_feuserauth.php');
56 require_once(PATH_t3lib.'class.t3lib_cs.php');
57
58 if (!defined ('TYPO3_db')) die ('The configuration file was not included.');
59 if (isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_COOKIE['GLOBALS'])) die('You cannot set the GLOBALS-array from outside this script.');
60
61 require_once(PATH_t3lib.'class.t3lib_db.php');
62 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
63
64 require_once(PATH_t3lib.'class.t3lib_timetrack.php');
65 $GLOBALS['TT'] = new t3lib_timeTrack;
66
67 if (t3lib_div::int_from_ver( TYPO3_version ) >= 4003000) {
68 // ***********************************
69 // Initializing the Caching System
70 // ***********************************
71 $GLOBALS['TT']->push('Initializing the Caching System','');
72 require_once(PATH_t3lib . 'class.t3lib_cache.php');
73
74 require_once(PATH_t3lib . 'cache/class.t3lib_cache_abstractbackend.php');
75 require_once(PATH_t3lib . 'cache/class.t3lib_cache_abstractcache.php');
76 require_once(PATH_t3lib . 'cache/class.t3lib_cache_exception.php');
77 require_once(PATH_t3lib . 'cache/class.t3lib_cache_factory.php');
78 require_once(PATH_t3lib . 'cache/class.t3lib_cache_manager.php');
79 require_once(PATH_t3lib . 'cache/class.t3lib_cache_variablecache.php');
80
81 require_once(PATH_t3lib . 'cache/exception/class.t3lib_cache_exception_classalreadyloaded.php');
82 require_once(PATH_t3lib . 'cache/exception/class.t3lib_cache_exception_duplicateidentifier.php');
83 require_once(PATH_t3lib . 'cache/exception/class.t3lib_cache_exception_invalidbackend.php');
84 require_once(PATH_t3lib . 'cache/exception/class.t3lib_cache_exception_invalidcache.php');
85 require_once(PATH_t3lib . 'cache/exception/class.t3lib_cache_exception_invaliddata.php');
86 require_once(PATH_t3lib . 'cache/exception/class.t3lib_cache_exception_nosuchcache.php');
87
88 $typo3CacheManager = t3lib_div::makeInstance('t3lib_cache_Manager');
89 $cacheFactoryClass = t3lib_div::makeInstanceClassName('t3lib_cache_Factory');
90 $typo3CacheFactory = new $cacheFactoryClass($typo3CacheManager);
91
92 unset($cacheFactoryClass);
93 $GLOBALS['TT']->pull();
94 }
95
96 // ***********************************
97 // Creating a $TSFE object
98 // ***********************************
99 $TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
100 $id = t3lib_div::_GET('id');
101 if (!isset($id)) $id = 0;
102 $id = htmlspecialchars($id);
103 $TSFE = new $TSFEclassName($TYPO3_CONF_VARS, $id, '0', 1, '', '','','');
104 if (t3lib_div::int_from_ver( TYPO3_version ) >= 4003000) {
105 $TSFE->initCaches();
106 }
107 $TSFE->set_no_cache();
108 $TSFE->connectToDB();
109 $TSFE->initFEuser();
110 $TSFE->determineId();
111 $TSFE->initTemplate();
112 $TSFE->tmpl->getFileName_backPath = PATH_site;
113
114 // ******************************************************
115 // Get config if not already gotten
116 // After this, we should have a valid config-array ready
117 // ******************************************************
118 $TSFE->getConfigArray();
119
120 // *******************************************
121 // Setting language and locale
122 // *******************************************
123 $GLOBALS['TT']->push('Setting language and locale','');
124 $TSFE->settingLanguage();
125 $TSFE->settingLocale();
126 $GLOBALS['TT']->pull();
127
128 // *******************************************
129 // Invoke the freecap plugin
130 // *******************************************
131 $freecap = t3lib_div::makeInstance('tx_srfreecap_pi1');
132 $freecap->cObj = t3lib_div::makeInstance('tslib_cObj');
133 $conf = $TSFE->tmpl->setup['plugin.'][$freecap->prefixId.'.'];
134 $freecap->main($conf);
135 ?>