00001 <?php
00002 SetCookie("test_script_cookie", "Cookie Value!", 0, "/");
00003
00004
00005 class t3lib_div {
00006 function trimExplode($delim, $string, $onlyNonEmptyValues=0) {
00007
00008 $temp = explode($delim,$string);
00009 $newtemp=array();
00010 while(list($key,$val)=each($temp)) {
00011 if (!$onlyNonEmptyValues || strcmp("",trim($val))) {
00012 $newtemp[]=trim($val);
00013 }
00014 }
00015 reset($newtemp);
00016 return $newtemp;
00017 }
00018 function dirname($path) {
00019 $p=t3lib_div::revExplode("/",$path,2);
00020 return count($p)==2?$p[0]:"";
00021 }
00022 function revExplode($delim, $string, $count=0) {
00023 $temp = explode($delim,strrev($string),$count);
00024 while(list($key,$val)=each($temp)) {
00025 $temp[$key]=strrev($val);
00026 }
00027 $temp=array_reverse($temp);
00028 reset($temp);
00029 return $temp;
00030 }
00031
00041 function getIndpEnv($getEnvName) {
00042 global $HTTP_SERVER_VARS;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 # if ($getEnvName=='HTTP_REFERER') return '';
00103 switch((string)$getEnvName) {
00104 case 'SCRIPT_NAME':
00105 return php_sapi_name()=='cgi' ? $HTTP_SERVER_VARS['PATH_INFO'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
00106 break;
00107 case 'SCRIPT_FILENAME':
00108 return str_replace('
00109 break;
00110 case 'REQUEST_URI':
00111
00112 if (!$HTTP_SERVER_VARS['REQUEST_URI']) {
00113 return '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')).
00114 ($HTTP_SERVER_VARS['QUERY_STRING']?'?'.$HTTP_SERVER_VARS['QUERY_STRING']:'');
00115 } else return $HTTP_SERVER_VARS['REQUEST_URI'];
00116 break;
00117 case 'PATH_INFO':
00118
00119
00120
00121
00122 if (php_sapi_name()!='cgi') {
00123 return $HTTP_SERVER_VARS['PATH_INFO'];
00124 } else return '';
00125 break;
00126
00127 case 'REMOTE_ADDR':
00128 case 'REMOTE_HOST':
00129 case 'HTTP_REFERER':
00130 case 'HTTP_HOST':
00131 case 'HTTP_USER_AGENT':
00132 case 'HTTP_ACCEPT_LANGUAGE':
00133 case 'QUERY_STRING':
00134 return $HTTP_SERVER_VARS[$getEnvName];
00135 break;
00136 case 'TYPO3_DOCUMENT_ROOT':
00137
00138
00139 $SFN = t3lib_div::getIndpEnv('SCRIPT_FILENAME');
00140 $SN_A = explode('/',strrev(t3lib_div::getIndpEnv('SCRIPT_NAME')));
00141 $SFN_A = explode('/',strrev($SFN));
00142 $acc=array();
00143 while(list($kk,$vv)=each($SN_A)) {
00144 if (!strcmp($SFN_A[$kk],$vv)) {
00145 $acc[]=$vv;
00146 } else break;
00147 }
00148 $commonEnd=strrev(implode('/',$acc));
00149 if (strcmp($commonEnd,'')) $DR = substr($SFN,0,-(strlen($commonEnd)+1));
00150 return $DR;
00151 break;
00152 case 'TYPO3_HOST_ONLY':
00153 $p=explode(':',$HTTP_SERVER_VARS['HTTP_HOST']);
00154 return $p[0];
00155 break;
00156 case 'TYPO3_PORT':
00157 $p=explode(':',$HTTP_SERVER_VARS['HTTP_HOST']);
00158 return $p[1];
00159 break;
00160 case 'TYPO3_REQUEST_HOST':
00161 return 'http'.($HTTP_SERVER_VARS['SSL_SESSION_ID']?'s':'').':
00162 $HTTP_SERVER_VARS['HTTP_HOST'];
00163 break;
00164 case 'TYPO3_REQUEST_URL':
00165 return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('REQUEST_URI');
00166 break;
00167 case 'TYPO3_REQUEST_SCRIPT':
00168 return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('SCRIPT_NAME');
00169 break;
00170 case 'TYPO3_REQUEST_DIR':
00171 return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
00172 break;
00173 case 'TYPO3_SITE_URL':
00174 if (defined('PATH_thisScript') && defined('PATH_site')) {
00175 $lPath = substr(dirname(PATH_thisScript),strlen(PATH_site)).'/';
00176 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR');
00177 $siteUrl = substr($url,0,-strlen($lPath));
00178 if (substr($siteUrl,-1)!='/') $siteUrl.='/';
00179 return $siteUrl;
00180 } else return '';
00181
00182 break;
00183 case '_ARRAY':
00184 $out=array();
00185
00186 $envTestVars = t3lib_div::trimExplode(',','
00187 HTTP_HOST,
00188 TYPO3_HOST_ONLY,
00189 TYPO3_PORT,
00190 PATH_INFO,
00191 QUERY_STRING,
00192 REQUEST_URI,
00193 HTTP_REFERER,
00194 TYPO3_REQUEST_HOST,
00195 TYPO3_REQUEST_URL,
00196 TYPO3_REQUEST_SCRIPT,
00197 TYPO3_REQUEST_DIR,
00198 TYPO3_SITE_URL,
00199 SCRIPT_NAME,
00200 TYPO3_DOCUMENT_ROOT,
00201 SCRIPT_FILENAME,
00202 REMOTE_ADDR,
00203 REMOTE_HOST,
00204 HTTP_USER_AGENT,
00205 HTTP_ACCEPT_LANGUAGE',1);
00206 reset($envTestVars);
00207 while(list(,$v)=each($envTestVars)) {
00208 $out[$v]=t3lib_div::getIndpEnv($v);
00209 }
00210 reset($out);
00211 return $out;
00212 break;
00213 }
00214 }
00215
00216 }
00217
00218 function view_array($array_in) {
00219
00220
00221
00222 if (is_array($array_in)) {
00223 $result='<table border=1 cellpadding=1 cellspacing=0 bgcolor=white>';
00224 if (!count($array_in)) {$result.= '<tr><td><font face="Verdana,Arial" size="1"><b>'.HTMLSpecialChars("EMPTY!").'</b></font></td></tr>';}
00225 while (list($key,$val)=each($array_in)) {
00226 $result.= '<tr><td><font face="Verdana,Arial" size="1">'.HTMLSpecialChars($key).'</font></td><td>';
00227 if (is_array($array_in[$key])) {
00228 $result.=t3lib_div::view_array($array_in[$key]);
00229 } else
00230 $result.= '<font face="Verdana,Arial" size="1" color=red>'.nl2br(HTMLSpecialChars($val)).'<BR></font>';
00231 $result.= '</td></tr>';
00232 }
00233 $result.= '</table>';
00234 } else {
00235 $result = false;
00236 }
00237 return $result;
00238 }
00239 function debug($array_in) {
00240
00241 echo view_array($array_in);
00242 }
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 error_reporting (E_ALL ^ E_NOTICE);
00260
00261 define("TYPO3_OS", stristr(PHP_OS,"win")&&!stristr(PHP_OS,"darwin")?"WIN":"");
00262
00263
00264
00265
00266
00267
00268
00269
00270 define("PATH_thisScript",str_replace('
00271 define('PATH_site', dirname(PATH_thisScript).'/');
00272
00273
00274 if (count($_GET) || $_SERVER["HTTP_REFERER"]) {
00275 # KOMPENSATED:
00276 echo "<H3>t3lib_div::getIndpEnv()</H3><p>These are 'system variables' returned from t3lib_div::getIndpEnv() and should be universal for any server configuration:</p>";
00277 debug(t3lib_div::getIndpEnv("_ARRAY"));
00278
00279 debug(array(
00280 "PHP_OS"=>PHP_OS,
00281 "TYPO3_OS"=>TYPO3_OS,
00282 "PATH_thisScript"=>PATH_thisScript,
00283 "php_sapi_name()" => php_sapi_name()
00284 ));
00285
00286
00287
00288
00289 ##debug(parse_url("http://admin:palindrom@192.168.1.4:8080/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/index.php?arg1,arg2,arg3&p1=parameter1&p2[key]=value#link1"));
00290
00291
00292 echo "<H3>Raw values</H3><p>These are the raw 'system variables' returned from getenv(), HTTP_SERVER_VARS, HTTP_ENV_VARS etc. These are displayed here so we can find the right values via this testscript to map to with t3lib_div::getIndpEnv()</p>";
00293 $envTestVars = explode(",","REQUEST_URI,REMOTE_ADDR,REMOTE_HOST,PATH_INFO,SCRIPT_NAME,SCRIPT_FILENAME,HTTP_HOST,HTTP_USER_AGENT,HTTP_ACCEPT_ENCODING,HTTP_REFERER,QUERY_STRING");
00294 $lines=array();
00295 $lines[] = '<tr bgcolor="#eeeeee">
00296 <td>Key</td>
00297 <td nowrap>getenv()</td>
00298 <td nowrap>HTTP_SERVER_VARS</td>
00299 <td nowrap>_SERVER</td>
00300 <td nowrap>HTTP_ENV_VARS</td>
00301 <td nowrap>_ENV</td>
00302 </tr>';
00303 while(list(,$v)=each($envTestVars)) {
00304 $lines[] = '<tr>
00305 <td bgcolor="#eeeeee">'.htmlspecialchars($v).'</td>
00306 <td nowrap>'.htmlspecialchars(getenv($v)).' </td>
00307 <td nowrap>'.htmlspecialchars($GLOBALS["HTTP_SERVER_VARS"][$v]).' </td>
00308 <td nowrap>'.htmlspecialchars($GLOBALS["_SERVER"][$v]).' </td>
00309 <td nowrap>'.htmlspecialchars($GLOBALS["HTTP_ENV_VARS"][$v]).' </td>
00310 <td nowrap>'.htmlspecialchars($GLOBALS["_ENV"][$v]).' </td>
00311 </tr>';
00312 }
00313 echo '<table border=1 style="font-family:verdana; font-size:10px;">'.implode("",$lines).'</table>';
00314
00315 echo '<table border=1 style="font-family:verdana; font-size:10px;">
00316 <tr><td>'.htmlspecialchars('$GLOBALS["HTTP_SERVER_VARS"]["DOCUMENT_ROOT"]').'</td><td>'.htmlspecialchars($GLOBALS["HTTP_SERVER_VARS"]["DOCUMENT_ROOT"]).'</td></tr>
00317 <tr><td>'.htmlspecialchars('$HTTP_SERVER_VARS["PATH_TRANSLATED"]').'</td><td>'.htmlspecialchars($HTTP_SERVER_VARS["PATH_TRANSLATED"]).'</td></tr>
00318 <tr><td>'.htmlspecialchars('$GLOBALS["HTTP_SERVER_VARS"]["REDIRECT_URL"]').'</td><td>'.htmlspecialchars($GLOBALS["HTTP_SERVER_VARS"]["REDIRECT_URL"]).'</td></tr>
00319 <tr><td>'.htmlspecialchars('$GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"]').'</td><td>'.htmlspecialchars($GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"]).'</td></tr>
00320 </table>';
00321
00322
00323
00324 echo "Cookie 'test_script_cookie': '<strong>".$HTTP_COOKIE_VARS["test_script_cookie"]."</strong>'<BR>";
00325
00326
00327 echo '<HR><a name="link1"></a>';
00328 echo '<div style="border: 1px solid black; padding: 10px 10px 10px 10px;"><h3>What to do now?</h3>
00329 <p>1) Click this link above once more: <a href="index.php?arg1,arg2,arg3&p1=parameter1&p2[key]='.substr(md5(time()),0,4).'#link1">Go to this page again.</a><BR>
00330 2) Then save this HTML-page and send it to kasperYYYY@typo3.com with information about 1) which webserver (Apache/ISS), 2) Unix/Windows, 3) CGI or module (ISAPI)<br>
00331 2a) You might help us find any differences in your values to this <a href="reference.html" target="_blank">reference example</a> by comparing the values before you send the result (thanks).
00332 <br>
00333 3) If you are really advanced you try and click the link below here. With CGI-versions of servers it will most likely give an error page. If it does not, please send the output to me as well (save HTML-page and send to kasperYYYY@typo3.com). If you do this PATH_INFO test, please let me know.<br><br>
00334
00335 4) For the really, really advanced folks, it might be interesting to see the output if you could place this link in the root of a domain. That means the index.php script will be executed from eg. "http:
00336 <br>
00337 <br>
00338 I am operating with these categories of servers. <strong>Please identify your configuration and label your email with that "type":</strong><br><br>
00339
00340 <table border=1>
00341 <tr bgcolor="#eeeeee">
00342 <td><em>TYPE:</em></td>
00343 <td><em>Description:</em></td>
00344 </tr>
00345 <tr>
00346 <td>WA13CGI</td>
00347 <td>Windows / Apache 1.3.x / CGI</td>
00348 </tr>
00349 <tr>
00350 <td>WA2CGI</td>
00351 <td>Windows / Apache 2.x / CGI</td>
00352 </tr>
00353 <tr>
00354 <td>WA13ISAPI</td>
00355 <td>Windows / Apache 1.3.x / ISAPI-module</td>
00356 </tr>
00357 <tr>
00358 <td>WA2ISAPI</td>
00359 <td>Windows / Apache 2.x / ISAPI-module</td>
00360 </tr>
00361 <tr>
00362 <td>WISS_CGI</td>
00363 <td>Windows / ISS / CGI</td>
00364 </tr>
00365 <tr>
00366 <td>WISS_ISAPI</td>
00367 <td>Windows / ISS / ISAPI-module</td>
00368 </tr>
00369 <tr>
00370 <td>MA13MOD</td>
00371 <td>Mac (Darwin) / Apache 1.3.x / Module</td>
00372 </tr>
00373 <tr>
00374 <td>LA13CGI</td>
00375 <td>Linux / Apache 1.3.x / CGI</td>
00376 </tr>
00377 <tr>
00378 <td>LA2CGI</td>
00379 <td>Linux / Apache 2.x / CGI</td>
00380 </tr>
00381 <tr>
00382 <td>LA13MOD</td>
00383 <td>Linux / Apache 1.3.x / Module</td>
00384 </tr>
00385 <tr>
00386 <td>LA2MOD</td>
00387 <td>Linux / Apache 2.x / Module</td>
00388 </tr>
00389 </table>
00390
00391
00392 </p></div>';
00393 echo '<a href="index.php/arg1/arg2/arg3/#link2" name="link2">Go to this page again (PATH_INFO).</a><BR>';
00394
00395 phpinfo();
00396 } else {
00397 echo '<a href="index.php?arg1,arg2,arg3&p1=parameter1&p2[key]=value#link1" name="link1">Click this link to start the test.</a><BR>';
00398 }
00399 ?>