1801ed459c
Imported from https://unit-tests.svn.wordpress.org/trunk@1337 see #24976. git-svn-id: https://develop.svn.wordpress.org/trunk@25002 602fd350-edb4-49c9-b593-d223f7449a82
113 lines
2.9 KiB
PHP
113 lines
2.9 KiB
PHP
<?php
|
|
|
|
// Thanks WordPress..
|
|
function is_ssl() {
|
|
if ( isset($_SERVER['HTTPS']) ) {
|
|
if ( 'on' == strtolower($_SERVER['HTTPS']) )
|
|
return true;
|
|
if ( '1' == $_SERVER['HTTPS'] )
|
|
return true;
|
|
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . (!empty($_SERVER['HTTP_POST']) && 80 != $_SERVER['HTTP_POST'] ? ':' . $_SERVER['HTTP_POST'] : '');
|
|
if ( strpos($_SERVER['REQUEST_URI'], '?') )
|
|
$url .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
|
|
else
|
|
$url .= $_SERVER['REQUEST_URI'];
|
|
|
|
if ( isset($_GET['source']) ) {
|
|
highlight_file(__FILE__ );
|
|
exit;
|
|
}
|
|
|
|
if ( isset($_GET['201-location']) ) {
|
|
header("HTTP/1.1 201 OK");
|
|
if ( isset($_GET['fail']) ) {
|
|
echo "FAIL";
|
|
} else {
|
|
header("Location: $url?201-location&fail=true", true, 201);
|
|
echo "PASS";
|
|
}
|
|
exit;
|
|
}
|
|
if ( isset($_GET['header-check']) ) {
|
|
$out = array();
|
|
header("Content-type: text/plain");
|
|
foreach ( $_SERVER as $key => $value ) {
|
|
if ( stripos($key, 'http') === 0 ) {
|
|
$key = strtolower(substr($key, 5));
|
|
echo "$key:$value\n";
|
|
}
|
|
}
|
|
exit;
|
|
}
|
|
if ( isset($_GET['multiple-headers']) ) {
|
|
header("HeaderName: One", false);
|
|
header("HeaderName: Two", false);
|
|
header("HeaderName: Three", false);
|
|
exit;
|
|
}
|
|
|
|
if ( isset( $_GET['post-redirect-to-method'] ) ) {
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
$response_code = isset( $_GET['response_code'] ) ? $_GET['response_code'] : 301;
|
|
|
|
if ( 'POST' == $method && ! isset( $_GET['redirection-performed'] ) ) {
|
|
header( "Location: $url?post-redirect-to-method=1&redirection-performed=1", true, $response_code );
|
|
exit;
|
|
}
|
|
|
|
echo $method;
|
|
exit;
|
|
|
|
}
|
|
|
|
if ( isset( $_GET['location-with-200'] ) ) {
|
|
if ( ! isset( $_GET['redirection-performed'] ) ) {
|
|
header( "HTTP/1.1 200 OK" );
|
|
header( "Location: $url?location-with-200=1&redirection-performed", true, 200 );
|
|
echo 'PASS';
|
|
exit;
|
|
}
|
|
// Redirection was followed
|
|
echo 'FAIL';
|
|
exit;
|
|
}
|
|
|
|
if ( isset( $_GET['print-pass'] ) ) {
|
|
echo 'PASS';
|
|
exit;
|
|
}
|
|
|
|
if ( isset( $_GET['multiple-location-headers'] ) ) {
|
|
if ( ! isset( $_GET['redirected'] ) ) {
|
|
header( "Location: $url?multiple-location-headers=1&redirected=one", false );
|
|
header( "Location: $url?multiple-location-headers=1&redirected=two", false );
|
|
exit;
|
|
}
|
|
if ( 'two' != $_GET['redirected'] )
|
|
echo 'FAIL';
|
|
else
|
|
echo 'PASS';
|
|
exit;
|
|
}
|
|
|
|
$rt = isset($_GET['rt']) ? $_GET['rt'] : 5;
|
|
$r = isset($_GET['r']) ? $_GET['r'] : 0;
|
|
|
|
if ( $r < $rt ) {
|
|
$code = isset($_GET['code']) ? (int)$_GET['code'] : 302;
|
|
header("Location: $url?rt=" . $rt . "&r=" . ($r+1), true, $code);
|
|
echo "Redirect $r of $rt";
|
|
exit;
|
|
}
|
|
echo "Redirect $r of $rt is FINAL.<br/>";
|
|
echo "GET['rt'] = Total times to redirect. Defaults to 5.<br />";
|
|
echo "GET['r'] = Current redirection. Defaults to 0.<br />";
|
|
echo "<a href='$url?source=true'>View Source</a>";
|
|
|