diff options
Diffstat (limited to 'p/api')
| -rw-r--r-- | p/api/.htaccess | 11 | ||||
| -rw-r--r-- | p/api/greader.php | 21 | ||||
| -rw-r--r-- | p/api/index.php | 27 |
3 files changed, 33 insertions, 26 deletions
diff --git a/p/api/.htaccess b/p/api/.htaccess index 41b653d96..937983ec9 100644 --- a/p/api/.htaccess +++ b/p/api/.htaccess @@ -1,4 +1,9 @@ -<IfModule mod_rewrite.c> - RewriteEngine on - RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] +<IfModule mod_setenvif.c> + SetEnvIf "^Authorization$" "(.*)" HTTP_AUTHORIZATION=$1 +</IfModule> +<IfModule !mod_setenvif.c> + <IfModule mod_rewrite.c> + RewriteEngine on + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + </IfModule> </IfModule> diff --git a/p/api/greader.php b/p/api/greader.php index 7cd312f2c..d41430d3c 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -143,14 +143,11 @@ function checkCompatibility() { Minz_Log::warning('checkCompatibility() ' . debugInfo(), API_LOG); header('Content-Type: text/plain; charset=UTF-8'); if (PHP_INT_SIZE < 8 && !function_exists('gmp_init')) { - die('FAIL 64-bit or GMP extension!'); + die('FAIL 64-bit or GMP extension! Wrong PHP configuration.'); } - if ((!array_key_exists('HTTP_AUTHORIZATION', $_SERVER)) && //Apache mod_rewrite trick should be fine - (!array_key_exists('REDIRECT_HTTP_AUTHORIZATION', $_SERVER)) && //Apache mod_rewrite with FCGI - (empty($_SERVER['SERVER_SOFTWARE']) || (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') === false)) && //nginx should be fine - (empty($_SERVER['SERVER_SOFTWARE']) || (stripos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') === false)) && //lighttpd should be fine - ((!function_exists('getallheaders')) || (stripos(php_sapi_name(), 'cgi') !== false))) { //Main problem is Apache/CGI mode - die('FAIL getallheaders! (probably)'); + $headerAuth = headerVariable('Authorization', 'GoogleLogin_auth'); + if ($headerAuth == '') { + die('FAIL get HTTP Authorization header! Wrong Web server configuration.'); } echo 'PASS'; exit(); @@ -913,6 +910,10 @@ FreshRSS_Context::$system_conf = Minz_Configuration::get('system'); if (!FreshRSS_Context::$system_conf->api_enabled) { serviceUnavailable(); +} elseif (count($pathInfos) < 3) { + badRequest(); +} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') { + checkCompatibility(); } ini_set('session.use_cookies', '0'); @@ -927,9 +928,7 @@ if ($user !== '') { Minz_Session::_param('currentUser', $user); -if (count($pathInfos) < 3) { - badRequest(); -} elseif ($pathInfos[1] === 'accounts') { +if ($pathInfos[1] === 'accounts') { if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd'])) { clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']); } @@ -1088,8 +1087,6 @@ if (count($pathInfos) < 3) { userInfo(); break; } -} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') { - checkCompatibility(); } badRequest(); diff --git a/p/api/index.php b/p/api/index.php index ee37b794b..d441099d7 100644 --- a/p/api/index.php +++ b/p/api/index.php @@ -5,6 +5,18 @@ <title>FreshRSS API endpoints</title> <meta name="robots" content="noindex" /> <link rel="start" href="../i/" /> +<script src="../scripts/api.js" defer="defer"></script> +<script id="jsonVars" type="application/json"> +<?php +require(__DIR__ . '/../../constants.php'); +require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader +Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php'); +echo json_encode(array( + 'greader' => Minz_Url::display('/api/greader.php', 'php', true), + 'fever' => Minz_Url::display('/api/fever.php', 'php', true), + )); +?> +</script> </head> <body> @@ -14,17 +26,11 @@ <dl> <dt>Your API address:</dt> <dd><?php -require(__DIR__ . '/../../constants.php'); -require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader -Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php'); echo Minz_Url::display('/api/greader.php', 'html', true); ?></dd> +<dt>Google Reader API configuration test:</dt> +<dd id="greaderOutput">?</dd> </dl> -<ul> -<li><a href="greader.php/check%2Fcompatibility" rel="nofollow">Check full server configuration</a></li> -<li><a href="greader.php/check/compatibility" rel="nofollow">Check partial server -configuration (without <code>%2F</code> support)</a></li> -</ul> <h2>Fever compatible API</h2> <dl> @@ -32,10 +38,9 @@ configuration (without <code>%2F</code> support)</a></li> <dd><?php echo Minz_Url::display('/api/fever.php', 'html', true); ?></dd> +<dt>Fever API configuration test:</dt> +<dd id="feverOutput">?</dd> </dl> -<ul> -<li><a href="fever.php?api" rel="nofollow">Test</a></li> -</ul> </body> </html> |
