Explorar el Código

rTorrent different endpoints more fixes with api test - Fix #1072

causefx hace 7 años
padre
commit
43891cd65e

+ 3 - 2
api/functions/homepage-connect-functions.php

@@ -793,7 +793,7 @@ function rTorrentConnect()
 	if ($GLOBALS['homepagerTorrentEnabled'] && !empty($GLOBALS['rTorrentURL']) && qualifyRequest($GLOBALS['homepagerTorrentAuth'])) {
 		try {
 			$torrents = array();
-			$digest = qualifyURL($GLOBALS['rTorrentURL'], true);
+			$digest = (empty($GLOBALS['rTorrentURLOverride'])) ? qualifyURL($GLOBALS['rTorrentURL'], true) : qualifyURL(checkOverrideURL($GLOBALS['rTorrentURL'], $GLOBALS['rTorrentURLOverride']), true);
 			$passwordInclude = ($GLOBALS['rTorrentUsername'] != '' && $GLOBALS['rTorrentPassword'] != '') ? $GLOBALS['rTorrentUsername'] . ':' . decrypt($GLOBALS['rTorrentPassword']) . "@" : '';
 			$extraPath = (strpos($GLOBALS['rTorrentURL'], '.php') !== false) ? '' : '/RPC2';
 			$extraPath = (empty($GLOBALS['rTorrentURLOverride'])) ? $extraPath : '';
@@ -2205,9 +2205,10 @@ function testAPIConnection($array)
 		case 'rtorrent':
 			if (!empty($GLOBALS['rTorrentURL'])) {
 				try {
-					$digest = qualifyURL($GLOBALS['rTorrentURL'], true);
+					$digest = (empty($GLOBALS['rTorrentURLOverride'])) ? qualifyURL($GLOBALS['rTorrentURL'], true) : qualifyURL(checkOverrideURL($GLOBALS['rTorrentURL'], $GLOBALS['rTorrentURLOverride']), true);
 					$passwordInclude = ($GLOBALS['rTorrentUsername'] != '' && $GLOBALS['rTorrentPassword'] != '') ? $GLOBALS['rTorrentUsername'] . ':' . decrypt($GLOBALS['rTorrentPassword']) . "@" : '';
 					$extraPath = (strpos($GLOBALS['rTorrentURL'], '.php') !== false) ? '' : '/RPC2';
+					$extraPath = (empty($GLOBALS['rTorrentURLOverride'])) ? $extraPath : '';
 					$url = $digest['scheme'] . '://' . $passwordInclude . $digest['host'] . $digest['port'] . $digest['path'] . $extraPath;
 					$options = (localURL($url)) ? array('verify' => false) : array();
 					$data = xmlrpc_encode_request("system.listMethods", null);

+ 9 - 0
api/functions/normal-functions.php

@@ -620,4 +620,13 @@ function isLocal($checkIP = null)
 		}
 	}
 	return $isLocal;
+}
+
+function checkOverrideURL($url, $override)
+{
+	if (strpos($override, $url) !== false) {
+		return $override;
+	} else {
+		return $url . $override;
+	}
 }