소스 검색

Add support for running rss-bridge from the CLI

Teromene 6 년 전
부모
커밋
e30ad3feb4
1개의 변경된 파일12개의 추가작업 그리고 6개의 파일을 삭제
  1. 12 6
      index.php

+ 12 - 6
index.php

@@ -28,6 +28,14 @@ define('CACHE_DIR', __DIR__ . '/cache');
 // Specify path for whitelist file
 // Specify path for whitelist file
 define('WHITELIST_FILE', __DIR__ . '/whitelist.txt');
 define('WHITELIST_FILE', __DIR__ . '/whitelist.txt');
 
 
+
+/*
+Move the CLI arguments to the $_GET array, in order to be able to use
+rss-bridge from the command line
+*/
+parse_str(implode('&', array_slice($argv, 1)), $cliArgs);
+$params = array_merge($_GET, $cliArgs);
+
 /*
 /*
   Create a file named 'DEBUG' for enabling debug mode.
   Create a file named 'DEBUG' for enabling debug mode.
   For further security, you may put whitelisted IP addresses in the file,
   For further security, you may put whitelisted IP addresses in the file,
@@ -124,8 +132,8 @@ try {
 		$whitelist_selection = array_map('strtolower', $whitelist_selection);
 		$whitelist_selection = array_map('strtolower', $whitelist_selection);
 	}
 	}
 
 
-	$action = filter_input(INPUT_GET, 'action');
-	$bridge = filter_input(INPUT_GET, 'bridge');
+	$action = $params['action'];
+	$bridge = $params['bridge'];
 
 
 	if($action === 'display' && !empty($bridge)) {
 	if($action === 'display' && !empty($bridge)) {
 		// DEPRECATED: 'nameBridge' scheme is replaced by 'name' in bridge parameter values
 		// DEPRECATED: 'nameBridge' scheme is replaced by 'name' in bridge parameter values
@@ -134,7 +142,7 @@ try {
 			$bridge = substr($bridge, 0, $pos);
 			$bridge = substr($bridge, 0, $pos);
 		}
 		}
 
 
-		$format = filter_input(INPUT_GET, 'format')
+		$format = $params['format']
 			or returnClientError('You must specify a format!');
 			or returnClientError('You must specify a format!');
 
 
 		// DEPRECATED: 'nameFormat' scheme is replaced by 'name' in format parameter values
 		// DEPRECATED: 'nameFormat' scheme is replaced by 'name' in format parameter values
@@ -152,13 +160,11 @@ try {
 		// Data retrieval
 		// Data retrieval
 		$bridge = Bridge::create($bridge);
 		$bridge = Bridge::create($bridge);
 
 
-		$noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN);
+		$noproxy = filter_var($params['_noproxy'], FILTER_VALIDATE_BOOLEAN);
 		if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy) {
 		if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy) {
 			define('NOPROXY', true);
 			define('NOPROXY', true);
 		}
 		}
 
 
-		$params = $_GET;
-
 		// Initialize cache
 		// Initialize cache
 		$cache = Cache::create('FileCache');
 		$cache = Cache::create('FileCache');
 		$cache->setPath(CACHE_DIR);
 		$cache->setPath(CACHE_DIR);